/** * Delete custom fields for content item. * * @param ID_TEXT Award hook codename * @param ID_TEXT Content entry ID */ function delete_form_custom_fields($content_type, $id) { require_code('catalogues2'); $existing = get_bound_content_entry($content_type, $id); if (!is_null($existing)) { actual_delete_catalogue_entry($existing); $GLOBALS['SITE_DB']->query_delete('catalogue_entry_linkage', array('catalogue_entry_id' => $existing)); } }
/** * Standard aed_module delete actualiser. * * @param ID_TEXT The entry being deleted */ function delete_actualisation($_id) { require_code('catalogues2'); $id = intval($_id); $category_id = $GLOBALS['SITE_DB']->query_value_null_ok('catalogue_entries', 'cc_id', array('id' => $id)); if (is_null($category_id)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } actual_delete_catalogue_entry($id); $catalogue_name = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'c_name', array('id' => $category_id)); $this->donext_category_id = $category_id; $this->donext_catalogue_name = $catalogue_name; }
/** * Delete a catalogue category. * * @param AUTO_LINK The ID of the category * @param boolean Whether we're deleting everything under the category; if FALSE we will actively reassign child categories to be directly under the root */ function actual_delete_catalogue_category($id, $deleting_all = false) { // Info about our category $rows = $GLOBALS['SITE_DB']->query_select('catalogue_categories c LEFT JOIN ' . $GLOBALS['SITE_DB']->get_table_prefix() . 'catalogues x ON c.c_name=x.c_name', array('c_is_tree', 'c.c_name', 'cc_description', 'cc_title', 'cc_parent_id'), array('id' => $id), '', 1); if (!array_key_exists(0, $rows)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } $myrow = $rows[0]; // If we aren't deleting the entire catalogue, make sure we don't delete the root category if (!$deleting_all && $myrow['c_is_tree'] == 1) { $root_category = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'MIN(id)', array('c_name' => $myrow['c_name'], 'cc_parent_id' => NULL)); if ($id == $root_category) { warn_exit(do_lang_tempcode('CATALOGUE_NO_DELETE_ROOT')); } } $GLOBALS['SITE_DB']->query_delete('catalogue_cat_treecache', array('cc_id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_childcountcache', array('cc_id' => $id)); require_code('files2'); delete_upload('uploads/grepimages', 'catalogue_categories', 'rep_image', 'id', $id); if (!$deleting_all) { if (function_exists('set_time_limit')) { @set_time_limit(0); } // If we're in a tree if ($myrow['c_is_tree'] == 1) { $GLOBALS['SITE_DB']->query_update('catalogue_categories', array('cc_parent_id' => $myrow['cc_parent_id']), array('cc_parent_id' => $id)); $GLOBALS['SITE_DB']->query_update('catalogue_entries', array('cc_id' => $myrow['cc_parent_id']), array('cc_id' => $id)); } else { if (function_exists('set_time_limit')) { @set_time_limit(0); } $GLOBALS['SITE_DB']->query_delete('catalogue_categories', array('cc_parent_id' => $id)); // Does nothing, in theory $start = 0; do { $entries = $GLOBALS['SITE_DB']->query_select('catalogue_entries', array('id'), array('cc_id' => $id), '', 500, $start); foreach ($entries as $entry) { actual_delete_catalogue_entry($entry['id']); } $start += 500; } while (count($entries) == 500); } $GLOBALS['SITE_DB']->query_update('catalogue_categories', array('cc_move_target' => NULL), array('cc_move_target' => $id)); } require_code('seo2'); seo_meta_erase_storage('catalogue_category', strval($id)); log_it('DELETE_CATALOGUE_CATEGORY', strval($id), get_translated_text($myrow['cc_title'])); // Delete lang delete_lang($myrow['cc_title']); delete_lang($myrow['cc_description']); /*$entries=collapse_1d_complexity('id',$GLOBALS['SITE_DB']->query_select('catalogue_entries',array('id'),array('cc_id'=>$id))); foreach ($entries as $entry) { actual_delete_catalogue_entry($entry); }*/ $old_parent_id = $GLOBALS['SITE_DB']->query_value('catalogue_categories', 'cc_parent_id', array('id' => $id)); $GLOBALS['SITE_DB']->query_delete('catalogue_categories', array('id' => $id), '', 1); $GLOBALS['SITE_DB']->query_delete('group_category_access', array('module_the_name' => 'catalogues_category', 'category_name' => strval($id))); $GLOBALS['SITE_DB']->query_delete('gsp', array('module_the_name' => 'catalogues_category', 'category_name' => strval($id))); calculate_category_child_count_cache($old_parent_id); }