/**
  * Find and delete a resource by ID.
  *
  * @param  int  $id
  * @return bool
  */
 public function delete($id)
 {
     $this->fireEvent('deleting', [$id]);
     $deleted = $this->model->destroy($id);
     $this->fireEvent('deleted', [$id, $deleted]);
     return $deleted;
 }
Example #2
0
 public static function destroy($params)
 {
     // Get delete position
     $deletePosition = $params["data"][0]["stepNumber"];
     // Destroy recipe step
     $returnArray = parent::destroy($params);
     // Check if we need to re-order existing steps
     if (isset($params["reorder"]) && $params["reorder"] == TRUE) {
         // Connect to database
         $mysqli = FoodAppDatabase::connect();
         // Update current data - decrement step numbers above insert position
         $queryString = "SELECT * FROM recipe_step WHERE food_id='" . $params["data"][0]["foodId"] . "' " . "ORDER BY step_number ASC";
         if ($result = $mysqli->query($queryString)) {
             while ($row = $result->fetch_assoc()) {
                 // Update current data
                 if ($row["step_number"] > $deletePosition) {
                     $queryStringUpdate = "UPDATE recipe_step SET step_number='" . ($row["step_number"] - 1) . "' WHERE id='" . $row["id"] . "'";
                     if (!$mysqli->query($queryStringUpdate)) {
                         throw new Exception($mysqli->error);
                     }
                 }
             }
         }
     }
     return $returnArray;
 }
Example #3
0
 static function delete($attachment_id, $file = true)
 {
     if ($file) {
         $attachment = new self($attachment_id);
         @unlink(uploaded($attachment->path, true));
     }
     parent::destroy(get_class(), $attachment_id);
 }
Example #4
0
 /**
  * Function: delete
  * See Also:
  *     <Model::destroy>
  */
 static function delete($id)
 {
     parent::destroy(get_class(), $id);
     SQL::current()->delete("post_attributes", array("post_id" => $id));
 }
Example #5
0
 /**
  * Function: delete
  * Deletes the given milestone. Calls the "delete_milestone" trigger and passes the <Milestone> as an argument.
  *
  * Parameters:
  *     $id - The milestone to delete.
  */
 static function delete($id)
 {
     parent::destroy(get_class(), $id);
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
Example #6
0
 /**
  * Function: delete
  * Deletes the given page.
  * 
  * Calls the @delete_page@ trigger with the <Page> to delete.
  *
  * Parameters:
  *     $page_id - The page to delete.
  *     $recursive - Should the page's children be deleted? (default: false)
  */
 static function delete($page_id, $recursive = false)
 {
     if ($recursive) {
         $page = new self($page_id);
         foreach ($page->children as $child) {
             self::delete($child->id);
         }
     }
     parent::destroy(get_class(), $page_id);
 }
Example #7
0
 /**
  * Function: delete
  * Deletes the given topic. Calls the "delete_topic" trigger and passes the <Topic> as an argument.
  *
  * Parameters:
  *     $id - The topic to delete.
  */
 static function delete($id)
 {
     $topic = new self($id);
     foreach ($topic->message as $message) {
         Message::delete($message->id);
     }
     parent::destroy(get_class(), $id);
     foreach ($topic->attachments as $attachment) {
         unlink(uploaded($attachment->path, false));
     }
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
Example #8
0
 public static function create($params)
 {
     // Check if item is already in the list
     if (self::checkRecentItemPresent($params)) {
         return array();
     }
     // Add row to table
     $returnArray = parent::create($params);
     if (!isset($returnArray) || count($returnArray) < 1) {
         return $returnArray;
     }
     // Check if old row needs to be purged
     $itemCount = self::getRecentItemCount($params);
     if ($itemCount >= self::$maxItemsPerUser) {
         // Get oldest row for user
         $id = self::getOldestItem($params);
         // Delete oldest row for user
         $paramsT = array("data" => array(array("id" => $id)));
         parent::destroy($paramsT);
     }
     return $returnArray;
 }
Example #9
0
 /**
  * Function: delete
  * Deletes a given user. Calls the @delete_user@ trigger and passes the <User> as an argument.
  *
  * Parameters:
  *     $id - The user to delete.
  */
 static function delete($id)
 {
     parent::destroy(get_class(), $id);
 }
Example #10
0
 /**
  * Function: delete
  * Deletes the given extension, including its notes. Calls the "delete_extension" trigger and passes the <Extension> as an argument.
  *
  * Parameters:
  *     $id - The extension to delete.
  */
 static function delete($id)
 {
     $extension = new self($id);
     foreach ($extension->versions as $version) {
         Version::delete($version->id);
     }
     parent::destroy(get_class(), $id);
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
Example #11
0
 function destroy()
 {
     foreach ($this->dsql as $k => $q) {
         unset($q);
     }
     foreach ($this->fields as $k => $f) {
         unset($this->fields[$k]);
     }
     return parent::destroy();
 }
Example #12
0
 /**
  * Function: delete
  * Deletes the given version, including its notes. Calls the "delete_version" trigger and passes the <Version> as an argument.
  *
  * Parameters:
  *     $id - The version to delete.
  */
 static function delete($id)
 {
     $version = new self($id);
     foreach ($version->notes as $note) {
         Note::delete($note->id);
     }
     foreach ($version->attachments as $attachment) {
         Attachment::delete($attachment->id);
     }
     @unlink(uploaded($version->filename, false));
     @unlink(uploaded($version->preview, false));
     parent::destroy(get_class(), $id);
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }
Example #13
0
 /**
  * @param $id
  *
  * @return int
  */
 public function delete($id)
 {
     return $this->model->destroy($id);
 }
Example #14
0
 /**
  * Function: delete
  * Deletes the given ticket, including its revisions and attachment. Calls the "delete_ticket" trigger and passes the <Ticket> as an argument.
  *
  * Parameters:
  *     $id - The ticket to delete.
  */
 static function delete($id)
 {
     $ticket = new self($id);
     foreach ($ticket->revisions as $revision) {
         Revision::delete($revision->id);
     }
     parent::destroy(get_class(), $id);
     foreach ($ticket->attachments as $attachment) {
         unlink(uploaded($attachment->path, false));
     }
     if (module_enabled("cacher")) {
         Modules::$instances["cacher"]->regenerate();
     }
 }