/** * Toggle featured bloggers. * * @since 3.5 * @access public */ public function toggleFeatured() { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); // @task: Check for acl rules. $this->checkAccess('user'); $mainframe = JFactory::getApplication(); $records = JRequest::getVar('cid', ''); $message = ''; $task = JRequest::getVar('task'); if (empty($records)) { $mainframe->enqueueMessage(JText::_('COM_EASYBLOG_INVALID_BLOGGER_ID'), 'error'); $mainframe->redirect('index.php?option=com_easyblog&view=users'); $mainframe->close(); } foreach ($records as $record) { if ($task == 'unfeature') { EasyBlogHelper::removeFeatured(EBLOG_FEATURED_BLOGGER, $record); $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED_SUCCESSFULLY'); } else { EasyBlogHelper::makeFeatured(EBLOG_FEATURED_BLOGGER, $record); $message = JText::_('COM_EASYBLOG_BLOGGER_FEATURED_SUCCESSFULLY'); } } $mainframe->enqueueMessage($message, 'message'); $mainframe->redirect('index.php?option=com_easyblog&view=users'); $mainframe->close(); }
/** * Remove an item as featured * * @param string $type The type of this item * @param int $postId The unique id of the item * * @return string Json string **/ function removeFeaturedx($type, $postId) { $ajax = new Ejax(); $acl = EB::acl(); EasyBlogHelper::removeFeatured($type, $postId); $idName = ''; $message = ''; switch ($type) { case 'blogger': $idName = '#blogger_title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED'); break; case 'teamblog': $idName = '#teamblog_title_' . $postId; $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED'); break; case 'post': default: $idName = '#title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED'); break; } $ajax->script('$("' . $idName . '").removeClass("featured-item");'); $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ajax->send(); return; }
/** * Remove an item as featured * * @param string $type The type of this item * @param int $postId The unique id of the item * * @return string Json string **/ function removeFeatured($type, $postId) { $ajax = new Ejax(); $acl = EasyBlogACLHelper::getRuleset(); // Only super admins can feature items if (!EasyBlogHelper::isSiteAdmin() && !$acl->rules->feature_entry) { $ajax->alert(JText::_('COM_EASYBLOG_NOT_ALLOWED'), '', '450'); $ajax->send(); return; } EasyBlogHelper::removeFeatured($type, $postId); $idName = ''; $message = ''; switch ($type) { case 'blogger': $idName = '#blogger_title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOGGER_UNFEATURED'); break; case 'teamblog': $idName = '#teamblog_title_' . $postId; $message = JText::_('COM_EASYBLOG_TEAMBLOG_UNFEATURED'); break; case 'post': default: $idName = '#title_' . $postId; $message = JText::_('COM_EASYBLOG_BLOG_UNFEATURED'); break; } $ajax->script('$("' . $idName . '").removeClass("featured-item");'); $ajax->alert($message, JText::_('COM_EASYBLOG_INFO'), '450', 'auto'); $ajax->send(); return; }