function execute($request) { // Ticket Check if (!$GLOBALS['xoopsGTicket']->check(true, 'pico')) { redirect_header(XOOPS_URL . '/', 3, $GLOBALS['xoopsGTicket']->getErrors()); } parent::execute($request); // initialize $cat_data = $this->currentCategoryObj->getData(); $picoPermission =& PicoPermission::getInstance(); // permission check if (empty($cat_data['can_post'])) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_MAKECONTENT); } // insert a content $content_id = pico_makecontent($this->mydirname); $content_uri4html = XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $content_id, $this->mydirname); // get contentObj $this->contentObj =& new PicoContent($this->mydirname, $content_id, $this->currentCategoryObj); $content_data = $this->contentObj->getData(); // return uri if (!empty($_GET['ret']) && ($ret_uri = pico_main_parse_ret2uri($this->mydirname, $_GET['ret']))) { $ret_uri4html = htmlspecialchars($ret_uri, ENT_QUOTES); } else { $ret_uri4html = $content_uri4html; } // calling a delegate if (class_exists('XCube_DelegateUtils')) { XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Contentman.InsertSuccess', $this->mydirname, $content_id, $cat_data, $ret_uri4html); } // create extra_tags for notifications $extra_tags = array('CONTENT_URL' => pico_common_unhtmlspecialchars($content_uri4html), 'APPROVAL_URL' => XOOPS_URL . "/modules/{$this->mydirname}/index.php?page=contentmanager&content_id={$content_id}", 'CAT_TITLE' => $cat_data['cat_title'], 'CONTENT_SUBJECT' => $content_data['subject_raw']); // users2notify (can_readfull only) $users2notify = $picoPermission->getUidsFromCatid($this->mydirname, $cat_data['id'], 'can_readfull'); if ($cat_data['post_auto_approved']) { // Notify for new content 'global' pico_main_trigger_event($this->mydirname, 'global', 0, 'newcontent', $extra_tags, $users2notify, 0); // Notify for new content 'category' of all parental categories foreach (array_keys($cat_data['paths_raw']) as $cat_id) { pico_main_trigger_event($this->mydirname, 'category', $cat_id, 'newcontent', $extra_tags, $users2notify, 0); } // message "registered" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTMADE); } else { // Notify for new waiting content (only for admin or mod) $users2notify = pico_main_get_moderators($this->mydirname, $cat_data['id']); if (empty($users2notify)) { $users2notify = array(0); } pico_main_trigger_event($this->mydirname, 'global', 0, 'waitingcontent', $extra_tags, $users2notify); // message "waiting approval" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTWAITINGREGISTER); } // view $this->is_need_header_footer = false; }
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 if (empty($content_data['can_edit'])) { if ($content_data['locked']) { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_LOCKEDCONTENT); exit; } else { redirect_header(XOOPS_URL . '/', 2, _MD_PICO_ERR_EDITCONTENT); exit; } } // update the content pico_updatecontent($this->mydirname, $request['content_id'], $cat_data['post_auto_approved'], $cat_data['isadminormod']); $content_uri4html = XOOPS_URL . "/modules/{$this->mydirname}/" . pico_common_make_content_link4html($this->mod_config, $request['content_id'], $this->mydirname); // return uri if (!empty($_GET['ret']) && ($ret_uri = pico_main_parse_ret2uri($this->mydirname, $_GET['ret']))) { $ret_uri4html = htmlspecialchars($ret_uri, ENT_QUOTES); } else { $ret_uri4html = $content_uri4html; } // calling a delegate if (class_exists('XCube_DelegateUtils')) { XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Contentman.UpdateSuccess', $this->mydirname, $request['content_id'], $cat_data, $ret_uri4html); } if ($cat_data['post_auto_approved']) { // message "modified" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTUPDATED); } else { // Notify for new waiting content (only for admin or mod) $users2notify = pico_main_get_moderators($this->mydirname, $cat_data['id']); if (empty($users2notify)) { $users2notify = array(0); } pico_main_trigger_event($this->mydirname, 'global', 0, 'waitingcontent', array('CONTENT_URL' => XOOPS_URL . "/modules/{$this->mydirname}/index.php?page=contentmanager&content_id=" . $request['content_id']), $users2notify); // message "waiting approval" redirect_header($ret_uri4html, 2, _MD_PICO_MSG_CONTENTWAITINGUPDATE); } // view $this->is_need_header_footer = false; }