<commit_before><?php
/**
 * @version        $Id$
 * @category       Nooku
 * @package        Nooku_Server
 * @subpackage     Articles
 * @copyright      Copyright (C) 2009 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link           http://www.nooku.org
 */

/**
 * Article executable controller behavior class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @category   Nooku
 * @package    Nooku_Server
 * @subpackage Articles
 */
class ComArticlesControllerBehaviorArticleExecutable extends ComDefaultControllerBehaviorExecutable
{
    public function canRead() {

        $result = false;

        $article = $this->getModel()->getItem();

        $user = JFactory::getUser();

        // Users can see their own articles regardless of the access settings.
        if ($article->created_by == $user->id) {
            $result = true;
        }

        if ($article->access <= $user->get('aid', 0)) {
            $result = true;
        }

        return $result;
    }

    public function canEdit(KDatabaseRowAbstract $article = null) {

        if (is_null($article)) {
            $article = $this->getModel()->getItem();
        }

        $user = JFactory::getUser();

        // Users can edit their own articles.
        if ($article->created_by == $user->id) {
            $result = true;
        } else {
            $result = parent::canEdit();
        }

        return $result;
    }

    public function canBrowse() {
        return parent::canBrowse();
    }
}<commit_msg>Went back to basics. Only authors can add, editors can edit and publishers can delete.<commit_after><?php
/**
 * @version        $Id$
 * @category       Nooku
 * @package        Nooku_Server
 * @subpackage     Articles
 * @copyright      Copyright (C) 2009 - 2012 Timble CVBA and Contributors. (http://www.timble.net)
 * @license        GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link           http://www.nooku.org
 */

/**
 * Article executable controller behavior class.
 *
 * @author     <NAME> <http://nooku.assembla.com/profile/arunasmazeika>
 * @category   Nooku
 * @package    Nooku_Server
 * @subpackage Articles
 */
class ComArticlesControllerBehaviorArticleExecutable extends ComDefaultControllerBehaviorExecutable
{
    public function canRead() {

        $result = false;

        $article = $this->getModel()->getItem();

        $user = JFactory::getUser();

        if ($article->access <= $user->get('aid', 0)) {
            $result = true;
        }

        return $result;
    }
}
{'fraction_non_alphanumeric': 0.13320610687022902, 'fraction_numerical': 0.007633587786259542, 'mean_word_length': 2.301007556675063, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2894889', 'n_tokens_mistral': 805, 'n_tokens_neox': 762, 'n_words': 182}