/** * Expunge currently loaded pigeonhole * @return bool TRUE on success, FALSE if store could not occur. * @access public **/ function expunge($pStructureId = NULL) { $ret = FALSE; // if we have a custom structure id we want to remove, load it if (@BitBase::verifyId($pStructureId)) { $this->mStructureId = $pStructureId; $this->load(); } 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(); // include the current structure id as well $structureIds[] = $this->mStructureId; $tree = $struct->getSubTree($this->mStructureId); foreach ($tree as $node) { $structureIds[] = $node['structure_id']; } $structureIds = array_unique($structureIds); $where = ''; foreach ($structureIds as $structureId) { $where .= (empty($where) ? " WHERE " : " OR ") . "`structure_id`=?"; } $result = $this->mDb->query("SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_structures` {$where}", $structureIds); $contentIds = $result->getRows(); foreach ($contentIds as $id) { // now we have the content ids - let the nuking begin $query = "DELETE FROM `" . BIT_DB_PREFIX . "pigeonholes` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($id['content_id'])); $query = "DELETE FROM `" . BIT_DB_PREFIX . "pigeonhole_members` WHERE `parent_id` = ?"; $result = $this->mDb->query($query, array($id['content_id'])); // remove all entries from content tables $this->mContentId = $id['content_id']; if (LibertyMime::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } // finally nuke the structure in liberty_structures $struct->removeStructureNode($this->mStructureId, FALSE); } return $ret; }
/** * This function removes a map entry **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "gmaps` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * This function removes an overlay **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $overlayKey = $this->mOverlayType . '_id'; $this->mDb->StartTrans(); // delete all references to the overlay from the overlay keychain $query = "DELETE FROM `" . BIT_DB_PREFIX . $this->mOverlayKeychainTable . "` WHERE `" . $overlayKey . "` =?"; $result = $this->mDb->query($query, array($this->mOverlayId)); // delete the overlay record $query = "DELETE FROM `" . BIT_DB_PREFIX . $this->mOverlayTable . "` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); // delete the overlay liberty content object if ($ret = LibertyMime::expunge()) { $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * Remove complete blog post set and any comments */ function expunge() { $ret = FALSE; // let's force a full load to make sure everything is loaded. // lets not -wjames5 //$this->load(); if ($this->isValid()) { $this->StartTrans(); // remove all references in blogs_posts_map where post_content_id = content_id $query_map = "DELETE FROM `" . BIT_DB_PREFIX . "blogs_posts_map` WHERE `post_content_id` = ?"; $result = $this->mDb->query($query_map, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "blog_posts` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); // Do this last so foreign keys won't complain (not the we have them... yet ;-) if (LibertyMime::expunge()) { $ret = TRUE; $this->CompleteTrans(); } else { $this->RollbackTrans(); } } return $ret; }
function expunge() { $ret = FALSE; if ($this->isValid()) { $this->StartTrans(); // remove all references in blogs_posts_map where post_content_id = content_id $query_map = "DELETE FROM `" . BIT_DB_PREFIX . "blogs_posts_map` WHERE `blog_content_id` = ?"; $result = $this->mDb->query($query_map, array($this->mContentId)); $query = "DELETE from `" . BIT_DB_PREFIX . "blogs` where `content_id`=?"; $result = $this->mDb->query($query, array((int) $this->mContentId)); if (parent::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } $this->CompleteTrans(); } return $ret; }
function expunge() { global $gBitSystem; $ret = FALSE; if ($this->isValid()) { $this->StartTrans(); $sql = "SELECT `comment_id` FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `parent_id` = ?"; $rows = $this->mDb->getAll($sql, array($this->mContentId)); foreach ($rows as $row) { $comment = new LibertyComment($row['comment_id']); $comment->expunge(); } if ($gBitSystem->isPackageActive('boards')) { // due to foreign key constraints, this has to go in the base class of BitBoardPost $sql = "DELETE FROM `" . BIT_DB_PREFIX . "boards_posts` WHERE `comment_id` = ?"; $rs = $this->mDb->query($sql, array($this->mCommentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "boards_topics` WHERE `parent_id` = ?"; $result = $this->mDb->query($query, array($this->getField('content_id'))); } $sql = "DELETE FROM `" . BIT_DB_PREFIX . "liberty_comments` WHERE `comment_id` = ?"; $rs = $this->mDb->query($sql, array($this->mCommentId)); /* * TODO: figureout why this is even here. Mime should handle this and it needs to pass in mandatory attachmentId * Slated to delete for now - wjames5 */ /* if (method_exists($this,'expungeMetaData')) { $this->expungeMetaData(); } */ if (LibertyMime::expunge()) { $ret = TRUE; $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * expunge * * @access public * @return boolean TRUE on success, FALSE on failure */ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $attrQuery = "DELETE FROM `" . BIT_DB_PREFIX . "ticket_attributes` WHERE `ticket_id` = ?"; $query = "DELETE FROM `" . BIT_DB_PREFIX . "tickets` WHERE `content_id` = ?"; // first delete attributes not to violate constraints $attrResult = $this->mDb->query($attrQuery, array($this->mTicketId)); $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge()) { $ret = TRUE; $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
function expunge() { global $gBitSystem; if ($this->isValid()) { $this->StartTrans(); /* Skip deleting of images for now if( !empty( $this->mInfo['products_image'] ) ) { $duplicate_image = $this->mDb->GetOne("SELECT count(*) as `total` FROM " . TABLE_PRODUCTS . " WHERE `products_image` = ?", array( $this->mInfo['products_image'] ) ); if ($duplicate_image < 2 ) { $products_image = $product_image->fields['products_image']; $products_image_extention = substr($products_image, strrpos($products_image, '.')); $products_image_base = str_replace($products_image_extention, '', $products_image); $filename_medium = 'medium/' . $products_image_base . IMAGE_SUFFIX_MEDIUM . $products_image_extention; $filename_large = 'large/' . $products_image_base . IMAGE_SUFFIX_LARGE . $products_image_extention; if (file_exists(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image'])) { @unlink(DIR_FS_CATALOG_IMAGES . $product_image->fields['products_image']); } if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_medium)) { @unlink(DIR_FS_CATALOG_IMAGES . $filename_medium); } if (file_exists(DIR_FS_CATALOG_IMAGES . $filename_large)) { @unlink(DIR_FS_CATALOG_IMAGES . $filename_large); } } */ $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_NOTIFICATIONS . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_TO_CATEGORIES . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_META_TAGS_PRODUCTS_DESCRIPTION . " WHERE `products_id` = ?", array($this->mProductsId)); // remove downloads if they exist $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_ATTRIBUTES_DOWNLOAD . " WHERE `products_attributes_id` IN (SELECT pa.`products_attributes_id` FROM " . TABLE_PRODUCTS_ATTRIBUTES . " pa INNER JOIN " . TABLE_PRODUCTS_OPTIONS_MAP . " pom ON( pa.`products_options_values_id`=pom.`products_options_values_id` )\tWHERE pom.`products_id` = ?)", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_OPTIONS_MAP . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_CUSTOMERS_BASKET_ATTRIBUTES . " WHERE `customers_basket_id` IN (SELECT `customers_basket_id` FROM " . TABLE_CUSTOMERS_BASKET . " WHERE `products_id` = ?)", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_CUSTOMERS_BASKET . " WHERE `products_id` = ?", array($this->mProductsId)); if ($productReviews = $this->mDb->getCol("SELECT `reviews_id` FROM " . TABLE_REVIEWS . " WHERE `products_id` = ?", array($this->mProductsId))) { foreach ($productReviews as $reviewId) { $this->mDb->query("DELETE FROM " . TABLE_REVIEWS_DESCRIPTION . " WHERE `reviews_id` = ?", array($reviewId)); } } $this->mDb->query("DELETE FROM " . TABLE_REVIEWS . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_FEATURED . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_SPECIALS . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_DISCOUNT_QUANTITY . " WHERE `products_id` = ?", array($this->mProductsId)); if (!$this->isPurchased()) { $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS_DESCRIPTION . " WHERE `products_id` = ?", array($this->mProductsId)); $this->mDb->query("DELETE FROM " . TABLE_PRODUCTS . " WHERE `products_id` = ?", array($this->mProductsId)); LibertyMime::expunge(); } else { $this->update(array('related_content_id' => NULL)); $this->storeStatus($gBitSystem->getConfig('liberty_status_deleted', -999)); } $this->mInfo = array(); $this->mProductsId = NULL; $this->CompleteTrans(); } return count($this->mErrors) == 0; }
/** * This function removes a bitboard entry **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->StartTrans(); $mailingList = $this->getPreference('boards_mailing_list'); $query = "DELETE FROM `" . BIT_DB_PREFIX . "boards_map` WHERE `board_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "boards` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge()) { if ($mailingList) { require_once UTIL_PKG_PATH . 'mailman_lib.php'; if ($error = mailman_rmlist($mailingList)) { $this->mErrors['mailing_list'] = $error; } } $ret = TRUE; $this->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * @return boolean TRUE on success, FALSE on failure */ public function expunge() { global $gBitSystem; $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $query = "DELETE FROM `" . $this->mFormTbl . "` WHERE (`content_id` = ?) "; $result = $this->mDb->query($query, array($this->mContentId)); if (parent::expunge()) { $ret = TRUE; } $this->mDb->CompleteTrans(); } return $ret; }
/** * Remove action */ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // remove all references in diasalsa_track $query_track = "DELETE FROM `" . BIT_DB_PREFIX . "diasalsa_track` WHERE `action_id` = ?"; $result = $this->mDb->query($query_track, array($this->mActionId)); // remove the action content detial record $query_detail = "DELETE FROM `" . BIT_DB_PREFIX . "diasalsa_action_content_map` WHERE `content_id` = ?"; $result = $this->mDb->query($query_detail, array($this->mContentId)); // remove the action content links $query_link = "DELETE FROM `" . BIT_DB_PREFIX . "diasalsa_action_cnxn_map` WHERE `action_content_id` = ?"; $result = $this->mDb->query($query_link, array($this->mContentId)); // remove the action record $query = "DELETE FROM `" . BIT_DB_PREFIX . "diasalsa_actions` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge()) { if ($this->expungeSalsaAction()) { $ret = TRUE; $this->mDb->CompleteTrans(); } } else { $this->mDb->RollbackTrans(); } } return $ret; }
/** * expunge removes user and associated private data * * @access public * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure */ function expunge($pExpungeContent = NULL) { global $gBitSystem; $this->StartTrans(); if (!empty($pExpungeContent)) { if ($pExpungeContent == 'all') { if ($userContent = $this->mDb->getAssoc("SELECT content_id, content_type_guid FROM `" . BIT_DB_PREFIX . "liberty_content` WHERE `user_id`=? AND `content_type_guid` != 'bituser'", array($this->mUserId))) { foreach ($userContent as $contentId => $contentTypeGuid) { if ($delContent = LibertyBase::getLibertyObject($contentId, $contentTypeGuid)) { $delContent->expunge(); } } } } } if ($this->mUserId != ANONYMOUS_USER_ID) { $this->purgeImage('avatar'); $this->purgeImage('portrait'); $this->purgeImage('logo'); $this->invokeServices('users_expunge_function'); $userTables = array('users_cnxn', 'users_watches', 'users_favorites_map', 'users_users'); foreach ($userTables as $table) { $query = "DELETE FROM `" . BIT_DB_PREFIX . $table . "` WHERE `user_id` = ?"; $result = $this->mDb->query($query, array($this->mUserId)); } parent::expunge(); $logHash['action_log']['title'] = $this->mInfo['login']; $this->mLogs['user_del'] = 'User deleted'; $this->storeActionLog($logHash); $this->CompleteTrans(); return TRUE; } else { $this->mDb->RollbackTrans(); $gBitSystem->fatalError(tra('The anonymous user cannot be deleted')); } }
function expunge($pExpungeAttachment = TRUE) { if ($this->isValid()) { $this->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_gallery_image_map` WHERE `item_content_id` = ?"; $rs = $this->mDb->query($query, array($this->mContentId)); $query = "UPDATE `" . BIT_DB_PREFIX . "fisheye_gallery` SET `preview_content_id`=NULL WHERE `preview_content_id` = ?"; $rs = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "fisheye_image` WHERE `content_id` = ?"; $rs = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge($pExpungeAttachment)) { $this->CompleteTrans(); $this->mImageId = NULL; $this->mContentId = NULL; } else { $this->mDb->RollbackTrans(); } } return count($this->mErrors) == 0; }
/** * Expunge data associated with an uploaded file * * @access public * @param should the attachment be expunged. Defaults to true. * @return TRUE on success, FALSE on failure - mErrors will contain reason for failure * TODO: make it possible to remove only items when they are not part of other galleries */ function expunge() { if ($this->isValid()) { $this->mDb->StartTrans(); // Remove map entries $this->expungeItemMap(); // now we can deal with the entry in liberty_content if (LibertyMime::expunge()) { $this->mDb->CompleteTrans(); } else { $this->mErrors['expunge'] = tra('The item could not be completely removed.'); $this->mDb->RollbackTrans(); } } if (count($this->mErrors) != 0) { error_log("Error deleting treasury item: " . vc($this->mErrors)); } return count($this->mErrors) == 0; }
/** * This function removes a group entry **/ function expunge() { global $gBitSystem, $gBitUser; if ($this->isValid()) { // before we clear out the group we need to know its board so we can clear it out too $board =& $this->getBoard(); // before we clear out a a group we may need to nuke all its related content as well /* Note: this is probably not perfect - we're assuming there are custom content perms if one of these is active * which is the source of the issue. A more robust solution might allow content to be freed from its group * something someone more ambitous and with that need can explore */ if ($gBitSystem->isFeatureActive('group_admin_content') || $gBitSystem->isFeatureActive('group_map_required')) { // get all mapped content ids $query = "SELECT `to_content_id` as `content_id` FROM `" . BIT_DB_PREFIX . "groups_content_cnxn_map` WHERE `group_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId), 9999999); while ($res = $result->fetchRow()) { $groupContent[] = $res; } } // delete the group and its related group pkg settings - order matters to respect constraints $this->mDb->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups_invitations` WHERE `group_id` = ?"; $result = $this->mDb->query($query, array($this->mGroupId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups_roles_perms_map` WHERE `group_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups_roles_users_map` WHERE `group_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups_content_cnxn_map` WHERE `group_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups_content_types` WHERE `group_content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); $query = "DELETE FROM `" . BIT_DB_PREFIX . "groups` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); // now we can expunge related content if (!empty($board)) { // delete the associated board $board->expunge(); } // delete related content if (!empty($groupContent)) { foreach ($groupContent as $item) { $obj = LibertyBase::getLibertyObject($item['content_id']); // make sure the object loaded if (is_object($obj)) { $obj->expunge(); } } } // expunge the parent objects if (LibertyMime::expunge()) { if ($gBitUser->expungeGroup($this->mGroupId)) { $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); $this->mErrors['group_expunge'] = 'Users group expunge failed'; } } else { $this->mDb->RollbackTrans(); $this->mErrors['group_expunge'] = 'Parent Liberty class expunge failed'; } } return count($this->mErrors) == 0; }
/** * expunge * * @access public * @return boolean TRUE on success, FALSE on failure */ function expunge() { global $gBitSystem; $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); $query = "DELETE FROM `" . BIT_DB_PREFIX . "sample_data` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if (LibertyMime::expunge()) { $ret = TRUE; } $this->mDb->CompleteTrans(); // If deleting the default/home sample record then unset this. if ($ret && $gBitSystem->getConfig('sample_home_id') == $this->mSampleId) { $gBitSystem->storeConfig('sample_home_id', 0, SAMPLE_PKG_NAME); } } return $ret; }
/** * This function deletes a set **/ function expunge() { $ret = FALSE; if ($this->isValid()) { $this->mDb->StartTrans(); // delete all references to the set from the map sets keychain $query = "DELETE FROM `" . BIT_DB_PREFIX . "gmaps_sets_keychain` WHERE `set_id` =? AND `set_type` = ?"; $result = $this->mDb->query($query, array($this->mOverlaySetId, $this->mOverlaySetType)); // delete all references to the set from the set keychain $query = "DELETE FROM `" . BIT_DB_PREFIX . $this->mOverlaySetKeychainTable . "` WHERE `set_id` =?"; $result = $this->mDb->query($query, array($this->mOverlaySetId)); // delete the overlay set $query = "DELETE FROM `" . BIT_DB_PREFIX . $this->mOverlaySetTable . "` WHERE `content_id` = ?"; $result = $this->mDb->query($query, array($this->mContentId)); if ($ret = LibertyMime::expunge()) { $this->mDb->CompleteTrans(); } else { $this->mDb->RollbackTrans(); } } return $ret; }