- md5
- 51bad2fdc4a0add7ff7450e086c5f11b
- sha1
- 2f0414306bf6a67865a96cb6c6a374d02613adf6
- sha256
- db5f67ca9ff31a4bdc0a30904d6d9b967197897acfce17ecdafa27326426d5e1
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
<?php
/**
* @version $Id: article.php 21766 2011-07-08 12:20:23Z eddieajau $
* @package Joomla.Administrator
* @subpackage com_content
* @copyright Copyright (C) 2005 - 2011 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controllerform');
/**
* @package Joomla.Administrator
* @subpackage com_content
* @since 1.6
*/
class ContentControllerArticle extends JControllerForm
{
/**
* Class constructor.
*
* @param array $config A named array of configuration variables.
*
* @return JControllerForm
* @since 1.6
*/
function __construct($config = array())
{
// An article edit form can come from the articles or featured view.
// Adjust the redirect view on the value of 'return' in the request.
if (JRequest::getCmd('return') == 'featured') {
$this->view_list = 'featured';
$this->view_item = 'article&return=featured';
}
parent::__construct($config);
}
/**
* Method override to check if you can add a new record.
*
* @param array An array of input data.
*
* @return boolean
* @since 1.6
*/
protected function allowAdd($data = array())
{
// Initialise variables.
$user = JFactory::getUser();
$categoryId = JArrayHelper::getValue($data, 'catid', JRequest::getInt('filter_category_id'), 'int');
$allow = null;
if ($categoryId) {
// If the category has been passed in the data or URL check it.
$allow = $user->authorise('core.create', 'com_content.category.'.$categoryId);
}
if ($allow === null) {
// In the absense of better information, revert to the component permissions.
return parent::allowAdd();
}
else {
return $allow;
}
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
// Initialise variables.
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$user = JFactory::getUser();
$userId = $user->get('id');
// Check general edit permission first.
if ($user->authorise('core.edit', 'com_content.article.'.$recordId)) {
return true;
}
// Fallback on edit.own.
// First test if the permission is available.
if ($user->authorise('core.edit.own', 'com_content.article.'.$recordId)) {
// Now test the owner is the user.
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
if (empty($ownerId) && $recordId) {
// Need to do a lookup from the model.
$record = $this->getModel()->getItem($recordId);
if (empty($record)) {
return false;
}
$ownerId = $record->created_by;
}
// If the owner matches 'me' then do the test.
if ($ownerId == $userId) {
return true;
}
}
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
/**
* Method to run batch operations.
*
* @return void
* @since 1.6
*/
public function batch($model)
{
JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Article', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_content&view=articles'.$this->getRedirectToListAppend(), false));
return parent::batch($model);
}
}
The same content is in 6 releases, Joomla 1.7.0 to 1.7.5. See them all, or every version of this file.