/** * Display the block. * * @param array $blockinfo the blockinfo structure * * @return string output of the rendered block */ public function display($blockinfo) { // only show block content if the user has the required permissions if (!SecurityUtil::checkPermission('Reviews:ModerationBlock:', "{$blockinfo['title']}::", ACCESS_OVERVIEW)) { return false; } // check if the module is available at all if (!ModUtil::available('Reviews')) { return false; } if (!UserUtil::isLoggedIn()) { return false; } ModUtil::initOOModule('Reviews'); $this->view->setCaching(Zikula_View::CACHE_DISABLED); $template = $this->getDisplayTemplate($vars); $workflowHelper = new Reviews_Util_Workflow($this->serviceManager); $amounts = $workflowHelper->collectAmountOfModerationItems(); // assign block vars and fetched data $this->view->assign('moderationObjects', $amounts); // set a block title if (empty($blockinfo['title'])) { $blockinfo['title'] = $this->__('Moderation'); } $blockinfo['content'] = $this->view->fetch($template); // return the block to the theme return BlockUtil::themeBlock($blockinfo); }
/** * The reviewsModerationObjects plugin determines the amount of unapproved objects. * It uses the same logic as the moderation block and the pending content listener. * * @param array $params All attributes passed to this function from the template. * @param Zikula_View $view Reference to the view object. */ function smarty_function_reviewsModerationObjects($params, $view) { if (!isset($params['assign']) || empty($params['assign'])) { $view->trigger_error(__f('Error! in %1$s: the %2$s parameter must be specified.', array('reviewsModerationObjects', 'assign'))); return false; } $serviceManager = $view->getServiceManager(); $workflowHelper = new Reviews_Util_Workflow($serviceManager); $result = $workflowHelper->collectAmountOfModerationItems(); $view->assign($params['assign'], $result); }
/** * Listener for the 'get.pending_content' event with registration requests and * other submitted data pending approval. * * When a 'get.pending_content' event is fired, the Users module will respond with the * number of registration requests that are pending administrator approval. The number * pending may not equal the total number of outstanding registration requests, depending * on how the 'moderation_order' module configuration variable is set, and whether e-mail * address verification is required. * If the 'moderation_order' variable is set to require approval after e-mail verification * (and e-mail verification is also required) then the number of pending registration * requests will equal the number of registration requested that have completed the * verification process but have not yet been approved. For other values of * 'moderation_order', the number should equal the number of registration requests that * have not yet been approved, without regard to their current e-mail verification state. * If moderation of registrations is not enabled, then the value will always be 0. * In accordance with the 'get_pending_content' conventions, the count of pending * registrations, along with information necessary to access the detailed list, is * assemped as a {@link Zikula_Provider_AggregateItem} and added to the event * subject's collection. * * @param Zikula_Event $event The event instance. */ public static function pendingContentListener(Zikula_Event $event) { $serviceManager = ServiceUtil::getManager(); $workflowHelper = new Reviews_Util_Workflow($serviceManager); $modname = 'Reviews'; $useJoins = false; $collection = new Zikula_Collection_Container($modname); $amounts = $workflowHelper->collectAmountOfModerationItems(); if (count($amounts) > 0) { foreach ($amounts as $amountInfo) { $aggregateType = $amountInfo['aggregateType']; $description = $amountInfo['description']; $amount = $amountInfo['amount']; $viewArgs = array('ot' => $amountInfo['objectType'], 'workflowState' => $amountInfo['state']); $aggregateItem = new Zikula_Provider_AggregateItem($aggregateType, $description, $amount, 'admin', 'view', $viewArgs); $collection->add($aggregateItem); } // add collected items for pending content if ($collection->count() > 0) { $event->getSubject()->add($collection); } } }