function execute($request) { // Ticket Check if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) { redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors()); } parent::execute($request); // contentObj $cat_data = $this->currentCategoryObj->getData(); $this->contentObj = new PicoContent($this->mydirname, $request['content_id'], $this->currentCategoryObj); // check existence if ($this->contentObj->isError()) { redirect_header(XOOPS_URL . "/modules/{$this->mydirname}/index.php", 2, _MD_PICO_ERR_READCONTENT); exit; } $content_data = $this->contentObj->getData(); // permission check (can_delete) if (empty($content_data['can_delete'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_DELETECONTENT); exit; } // delete transaction pico_delete_content($this->mydirname, $request['content_id']); // view $this->is_need_header_footer = false; }
function pico_delete_category($mydirname, $cat_id, $delete_also_contents = true) { global $xoopsModule; $db =& Database::getInstance(); $cat_id = intval($cat_id); if ($cat_id <= 0) { return false; } // delete contents if ($delete_also_contents) { $sql = "SELECT content_id FROM " . $db->prefix($mydirname . "_contents") . " WHERE cat_id={$cat_id}"; if (!($result = $db->query($sql))) { die(_MD_PICO_ERR_SQL . __LINE__ . __FUNCTION__); } while (list($content_id) = $db->fetchRow($result)) { pico_delete_content($mydirname, $content_id); } } // delete notifications about this category $notification_handler =& xoops_gethandler('notification'); $notification_handler->unsubscribeByItem($xoopsModule->getVar('mid'), 'category', $cat_id); // delete category if (!$db->queryF("DELETE FROM " . $db->prefix($mydirname . "_categories") . " WHERE cat_id={$cat_id}")) { die(_MD_PICO_ERR_SQL . __LINE__ . __FUNCTION__); } // delete category_permissions if (!$db->queryF("DELETE FROM " . $db->prefix($mydirname . "_category_permissions") . " WHERE cat_id={$cat_id}")) { die(_MD_PICO_ERR_SQL . __LINE__ . __FUNCTION__); } // rebuild category tree pico_sync_cattree($mydirname); return true; }
} pico_sync_all($mydirname); redirect_header(XOOPS_URL . "/modules/{$mydirname}/admin/index.php?page=contents&cat_id={$cat_id}", 3, _MD_A_PICO_MSG_CONTENTSMOVED); exit; } // contents delete if (!empty($_POST['contents_delete']) && !empty($_POST['action_selects'])) { if (!$xoopsGTicket->check(true, 'pico_admin')) { redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); } foreach ($_POST['action_selects'] as $content_id => $value) { if (empty($value)) { continue; } $content_id = intval($content_id); pico_delete_content($mydirname, $content_id, true); /* $db->query( "DELETE FROM ".$db->prefix($mydirname."_contents")." WHERE content_id=$content_id" ) ; $db->query( "DELETE FROM ".$db->prefix($mydirname."_content_votes")." WHERE content_id=$content_id" ) ; */ } pico_sync_all($mydirname); redirect_header(XOOPS_URL . "/modules/{$mydirname}/admin/index.php?page=contents&cat_id={$cat_id}", 3, _MD_A_PICO_MSG_CONTENTSDELETED); exit; } // contents export if (!empty($_POST['contents_export']) && !empty($_POST['action_selects']) && !empty($_POST['export_mid'])) { if (!$xoopsGTicket->check(true, 'pico_admin')) { redirect_header(XOOPS_URL . '/', 3, $xoopsGTicket->getErrors()); } $export_mid = intval(@$_POST['export_mid']); if (empty($exportable_modules[$export_mid])) { die(_MD_A_PICO_ERR_INVALIDMID);
function removeContent($content_id) { // delete transaction require_once dirname(dirname(__FILE__)) . '/include/transact_functions.php'; pico_delete_content($this->mydirname, $content_id); }