english/administrator/components/com_content/controllers/articles.php
/**
	 * Method to toggle the featured setting of a list of articles.
	 *
	 * @return	void
	 * @since	1.6
	 */
Method to toggle the featured setting of a list of articles.
Method to toggle the featured setting of a list of articles .
function featured()
	{
		JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
		$user	= JFactory::getUser();
		$ids	= JRequest::getVar('cid', array(), '', 'array');
		$values	= array('featured' => 1, 'unfeatured' => 0);
		$task	= $this->getTask();
		$value	= JArrayHelper::getValue($values, $task, 0, 'int');
		foreach ($ids as $i => $id)
		{
			if (!$user->authorise('core.edit.state', 'com_content.article.'.(int) $id)) {
				unset($ids[$i]);
				JError::raiseNotice(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
			}
		}
		if (empty($ids)) {
			JError::raiseWarning(500, JText::_('JERROR_NO_ITEMS_SELECTED'));
		}
		else {
			$model = $this->getModel();
			if (!$model->featured($ids, $value)) {
				JError::raiseWarning(500, $model->getError());
			}
		}
		$this->setRedirect('index.php?option=com_content&view=articles');
	}
function featured ( ) { JRequest :: checkToken ( ) or jexit ( JText :: _ ( 'JINVALID_TOKEN' ) ) ; $ user = JFactory :: getUser ( ) ; $ ids = JRequest :: getVar ( 'cid' , array ( ) , '' , 'array' ) ; $ values = array ( 'featured' => 1 , 'unfeatured' => 0 ) ; $ task = $ this -> getTask ( ) ; $ value = JArrayHelper :: getValue ( $ values , $ task , 0 , 'int' ) ; foreach ( $ ids as $ i => $ id ) { if ( ! $ user -> authorise ( 'core.edit.state' , 'com_content.article.' . ( int ) $ id ) ) { unset ( $ ids [ $ i ] ) ; JError :: raiseNotice ( 403 , JText :: _ ( 'JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED' ) ) ; } } if ( empty ( $ ids ) ) { JError :: raiseWarning ( 500 , JText :: _ ( 'JERROR_NO_ITEMS_SELECTED' ) ) ; } else { $ model = $ this -> getModel ( ) ; if ( ! $ model -> featured ( $ ids , $ value ) ) { JError :: raiseWarning ( 500 , $ model -> getError ( ) ) ; } } $ this -> setRedirect ( 'index.php?option=com_content&view=articles' ) ; }
Method to toggle the featured setting of a list of articles.
Method to toggle the featured setting of a list of articles .
// Check for request forgeries // Initialise variables. // Access checks. // Prune items that you can't change. // Get the model. // Publish the items.