/** * This function removes an nlpg upload entry **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); if (LibertyContent::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * Remove gedcom record from database */ function expunge() { $ret = FALSE; if ($this->isValid()) { $dbged = $this->mGEDCOMId; if (expungeGedcom($dbged)) { $this->mDb->StartTrans(); $sql = "DELETE FROM " . PHPGEDVIEW_DB_PREFIX . "gedcom WHERE g_id=?"; $res = $this->mDb->query($sql, array($dbged)); if (LibertyContent::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } } return $ret; }
function removeStructureNode($structure_id, $delete = FALSE) { // Now recursively remove if (@$this->verifyId($structure_id)) { $query = "SELECT *\n\t\t\t\t\t FROM `" . BIT_DB_PREFIX . "liberty_structures`\n\t\t\t\t\t WHERE `parent_id`=?"; $result = $this->mDb->query($query, array((int) $structure_id)); // Iterate down through the child nodes while ($res = $result->fetchRow()) { $this->removeStructureNode($res["structure_id"], $delete); } // Only delete a page if other structures arent referencing it if ($delete) { $page_info = $this->getNode($structure_id); $query = "SELECT COUNT(*) FROM `" . BIT_DB_PREFIX . "liberty_structures` WHERE `content_id`=?"; $count = $this->mDb->getOne($query, array((int) $page_info["page_id"])); if ($count = 1) { $this->remove_all_versions($page_info["page_id"]); } } // If we are removing the root node, remove the entry in liberty_content as well $query = "SELECT `content_id`\n\t\t\t\t\t FROM `" . BIT_DB_PREFIX . "liberty_structures`\n\t\t\t\t\t WHERE `structure_id`=? AND `structure_id`=`root_structure_id`"; $content_id = $this->mDb->getOne($query, array((int) $structure_id)); // Delete the liberty_content stuff $lc = new LibertyContent($content_id); $lc->expunge(); // Remove the structure node $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_structures` WHERE `structure_id`=?"; $result = $this->mDb->query($query, array((int) $structure_id)); return true; } }
/** * Delete content object and all related records */ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "citizen` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "citizen_type_map` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyContent::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "newsletters` where `nl_id`=?"; $result = $this->mDb->query($query, array($this->mNewsletterId)); // Clear out all individual subscriptions/unsubscriptions, but preserve the unsubscribe_all's $query = "DELETE FROM `" . BIT_DB_PREFIX . "mail_subscriptions` WHERE `content_id`=? AND `unsubscribe_all` IS NOT NULL"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "UPDATE `" . BIT_DB_PREFIX . "mail_subscriptions` SET `content_id`=NULL WHERE `content_id`=? AND `unsubscribe_all` IS NOT NULL"; $result = $this->mDb->query($query, array($this->mContentId)); if (parent::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * Expunges the content deleting attached attachments */ function expunge() { if (!empty($this->mStorage) && count($this->mStorage)) { foreach (array_keys($this->mStorage) as $i) { $this->expungeAttachment($this->mStorage[$i]['attachment_id']); } } return LibertyContent::expunge(); }
/** * expunge a gallery * * @param array $pParamHash * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pForceDeleteItems = FALSE) { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // get all items that are part of the sub tree require_once LIBERTY_PKG_PATH . 'LibertyStructure.php'; $struct = new LibertyStructure(); $tree = $struct->getSubTree($this->mStructureId); // include the current id as well - needed when there are no sub-galleries $galleryContentIds[] = $this->mContentId; foreach ($tree as $node) { $galleryContentIds[] = $node['content_id']; } $galleryContentIds = array_unique($galleryContentIds); // Create Item Object require_once TREASURY_PKG_PATH . 'TreasuryItem.php'; $itemObject = new TreasuryItem(); // Go through all galleries we want to remove foreach ($galleryContentIds as $gid) { // make sure the gallery is fully loaded $this->mContentId = $gid; $this->load(); $itemContentIds = $this->mDb->getCol("SELECT `item_content_id` FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?", array($gid)); $itemContentIds = array_unique($itemContentIds); // Delete items in galleries foreach ($itemContentIds as $iid) { if ($pForceDeleteItems) { // Remove item even if it exists in other galleries $count = 1; } else { // Only delete item if it doesn't exist in other galleries $count = $this->mDb->getOne("SELECT COUNT( `item_content_id` ) FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `item_content_id`=?", array($iid)); } // Only delete item if it doesn't exist in other galleries if ($count == 1) { $itemObject->mContentId = $iid; $itemObject->load(); if (!$itemObject->expunge()) { $this->mErrors['expunge'][] = $itemObject->mErrors; } } } // Next, we remove any icons if they exist if ($thumbdir = $this->getGalleryThumbBaseUrl()) { @unlink_r(BIT_ROOT_PATH . $thumbdir); } // Now that all the items are gone, we can start nuking gallery entries // remove gallery preferences $query = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_content_prefs` WHERE `content_id`=?"; $result = $this->mDb->query($query, array($this->mContentId)); // Remove map entries $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_map` WHERE `gallery_content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Remove gallery entry $sql = "DELETE FROM `" . BIT_DB_PREFIX . "treasury_gallery` WHERE `content_id`=?"; $rs = $this->mDb->query($sql, array($gid)); // Let liberty remove all the content entries for this gallery if (!LibertyContent::expunge()) { $errors = TRUE; } // Finally nuke the structure in liberty_structures $struct->removeStructureNode($this->mStructureId, FALSE); } if (empty($errors)) { $this->mDb->CompleteTrans(); $ret = TRUE; } else { $this->mDb->RollbackTrans(); $ret = FALSE; } } return $ret; }
function expunge($pRecursiveDelete = FALSE) { if ($this->isValid()) { $this->StartTrans(); if ($this->loadImages()) { foreach (array_keys($this->mItems) as $key) { if ($pRecursiveDelete) { $this->mItems[$key]->expunge($pRecursiveDelete); } elseif (is_a($this->mItems[$key], 'FisheyeImage')) { // make sure we have a valid content_id before we exec if (is_numeric($this->mItems[$key]->mContentId)) { $query = "SELECT COUNT(`item_content_id`) AS `other_gallery`\n\t\t\t\t\t\t\t\t\t FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map`\n\t\t\t\t\t\t\t\t\t WHERE `item_content_id`=? AND `gallery_content_id`!=?"; if (!($inOtherGallery = $this->mDb->getOne($query, array($this->mItems[$key]->mContentId, $this->mContentId)))) { $this->mItems[$key]->expunge(); } } } } } $query = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` WHERE `gallery_content_id`=?"; $rs = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` WHERE `item_content_id`=?"; $rs = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery` WHERE `content_id`=?"; $rs = $this->mDb->query($query, array($this->mContentId)); if (LibertyContent::expunge()) { $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); error_log("Error expunging fisheye gallery: " . vc($this->mErrors)); } } return count($this->mErrors) == 0; }