function getTemplateName() { $template_name = $this->template_name; // calling a delegate for replacing the main template if (class_exists('XCube_DelegateUtils')) { XCube_DelegateUtils::raiseEvent('ModuleClass.Pico.Controller.GetTemplateName', $this->mydirname, new XCube_Ref($template_name)); } return $template_name; }
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; }
/** * Add OGP tags to theme * @param Legacy_XoopsTpl $xoopsTpl * @return void */ public function addOGPTagsToTheme(Legacy_XoopsTpl $xoopsTpl) { if ($this->_isBeginRenderTheme() === false) { return; } $ogpData = array(); XCube_DelegateUtils::raiseEvent('OGP.SetUp', new XCube_Ref($ogpData), new XCube_Ref($xoopsTpl)); $ogpTags = $this->_renderOGPTags($ogpData); $this->_prependToXoopsModuleHeader($xoopsTpl, $ogpTags); }
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; }
function triggerEvent($mydirname, $mytrustdirname, $category, $item_id, $event, $extra_tags = array(), $user_list = array(), $omit_user_id = null) { $module_hanlder =& xoops_gethandler('module'); $module =& $module_hanlder->getByDirname($mydirname); $notification_handler =& xoops_gethandler('notification'); $mail_template_dir = $this->getMailTemplateDir($mydirname, $mytrustdirname); // calling a delegate before if (class_exists('XCube_DelegateUtils')) { $force_return = false; XCube_DelegateUtils::raiseEvent('D3NotificationHandler.Trigger', new XCube_Ref($category), new XCube_Ref($event), new XCube_Ref($item_id), new XCube_Ref($extra_tags), new XCube_Ref($module), new XCube_Ref($user_list), new XCube_Ref($omit_user_id), $module->getInfo('notification'), new XCube_Ref($force_return), new XCube_Ref($mail_template_dir), $mydirname, $mytrustdirname); if ($force_return) { return; } } $mid = $module->getVar('mid'); // Check if event is enabled $config_handler =& xoops_gethandler('config'); $mod_config =& $config_handler->getConfigsByCat(0, $mid); if (empty($mod_config['notification_enabled'])) { return false; } $category_info =& notificationCategoryInfo($category, $mid); $event_info =& notificationEventInfo($category, $event, $mid); if (!in_array(notificationGenerateConfig($category_info, $event_info, 'option_name'), $mod_config['notification_events']) && empty($event_info['invisible'])) { return false; } if (!isset($omit_user_id)) { global $xoopsUser; if (!empty($xoopsUser)) { $omit_user_id = $xoopsUser->getVar('uid'); } else { $omit_user_id = 0; } } $criteria = new CriteriaCompo(); $criteria->add(new Criteria('not_modid', intval($mid))); $criteria->add(new Criteria('not_category', $category)); $criteria->add(new Criteria('not_itemid', intval($item_id))); $criteria->add(new Criteria('not_event', $event)); $mode_criteria = new CriteriaCompo(); $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDALWAYS), 'OR'); $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENDELETE), 'OR'); $mode_criteria->add(new Criteria('not_mode', XOOPS_NOTIFICATION_MODE_SENDONCETHENWAIT), 'OR'); $criteria->add($mode_criteria); if (!empty($user_list)) { $user_criteria = new CriteriaCompo(); foreach ($user_list as $user) { $user_criteria->add(new Criteria('not_uid', $user), 'OR'); } $criteria->add($user_criteria); } $notifications =& $notification_handler->getObjects($criteria); if (empty($notifications)) { return; } // Add some tag substitutions here $tags = array(); // {X_ITEM_NAME} {X_ITEM_URL} {X_ITEM_TYPE} from lookup_func are disabled $tags['X_MODULE'] = $module->getVar('name', 'n'); $tags['X_MODULE_URL'] = XOOPS_URL . '/modules/' . $module->getVar('dirname') . '/'; $tags['X_NOTIFY_CATEGORY'] = $category; $tags['X_NOTIFY_EVENT'] = $event; $template = $event_info['mail_template'] . '.tpl'; $subject = $event_info['mail_subject']; foreach ($notifications as $notification) { if (empty($omit_user_id) || $notification->getVar('not_uid') != $omit_user_id) { // user-specific tags //$tags['X_UNSUBSCRIBE_URL'] = 'TODO'; // TODO: don't show unsubscribe link if it is 'one-time' ?? $tags['X_UNSUBSCRIBE_URL'] = XOOPS_URL . '/notifications.php'; $tags = array_merge($tags, $extra_tags); $notification->notifyUser($mail_template_dir, $template, $subject, $tags); } } }