diff --git a/include/appData.php b/include/appData.php index f64eeb9..1140588 100644 --- a/include/appData.php +++ b/include/appData.php @@ -37,6 +37,21 @@ class appData } } + function delete() + { + if(!$this->canEdit()) + return FALSE; + + $sQuery = "DELETE FROM appData WHERE id = '?'"; + + $hResult = query_parameters($sQuery, $this->iId); + + if(!$hResult) + return FALSE; + + return $hResult; + } + function listSubmittedBy($iUserId, $bQueued = true) { $hResult = query_parameters("SELECT * FROM appData WHERE diff --git a/include/screenshot.php b/include/screenshot.php index f0ebf9d..b84a377 100644 --- a/include/screenshot.php +++ b/include/screenshot.php @@ -128,9 +128,9 @@ class Screenshot { */ function delete($bSilent=false) { - /* the user object should delete the app data entry */ - /* we can perform better permissions checking there */ - if($_SESSION['current']->deleteAppData($this->iScreenshotId)) + /* appData has a universal function for removing database entries */ + $oAppData = new appData($this->iScreenshotId); + if($oAppData->delete()) { /* make sure the screenshot and thumbnail is loaded */ /* up before we try to delete them */ diff --git a/include/user.php b/include/user.php index 04aa6d3..84ab6b0 100644 --- a/include/user.php +++ b/include/user.php @@ -316,23 +316,6 @@ class User { return ($this->isLoggedIn() && $this->getPref("send_email","yes")=="yes"); } - - /** - * Delete appData - */ - function deleteAppData($iAppDataId) - { - if(!$_SESSION['current']->canDeleteAppDataId($iAppDataId)) - return false; - - $hResult = query_parameters("DELETE from appData where id = '?' LIMIT 1", - $iAppDataId); - if($hResult) - return true; - - return false; - } - function getAppRejectQueueQuery($queryAppFamily) { /* escape input as we can't easily use query_parameters() */