<commit_before><?php

/**
 * This class registers some handlers for blog settings
 *
 * @package     Nails
 * @subpackage  module-blog
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Admin\Blog;

use Nails\Factory;
use Nails\Admin\Helper;
use Nails\Blog\Controller\BaseAdmin;

class Settings extends BaseAdmin
{
    /**
     * Announces this controller's navGroups
     * @return stdClass
     */
    public static function announce()
    {
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        if (!empty($blogs)) {

            $oNavGroup = Factory::factory('Nav', 'nailsapp/module-admin');
            $oNavGroup->setLabel('Settings');
            $oNavGroup->setIcon('fa-wrench');

            if (userHasPermission('admin:blog:settings:\d+:update')) {

                $oNavGroup->addAction('Blog');
            }

            return $oNavGroup;
        }
    }

    // --------------------------------------------------------------------------

    /**
     * Returns an array of permissions which can be configured for the user
     * @return array
     */
    public static function permissions()
    {
        $permissions = parent::permissions();

        //  Fetch the blogs, each blog should have its own permission
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        $out = array();

        if (!empty($blogs)) {
            foreach ($blogs as $blog) {
                $permissions[$blog->id . ':update']  = $blog->label . ': Can update settings';
            }
        }

        return $permissions;
    }

    // --------------------------------------------------------------------------

    /**
     * Manage Blog settings
     * @return void
     */
    public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nailsapp/module-blog');

        // --------------------------------------------------------------------------

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nailsapp/module-auth');
                $oSession->set_flashdata($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show_404();
            }
        }
<commit_msg>Updated method name<commit_after><?php

/**
 * This class registers some handlers for blog settings
 *
 * @package     Nails
 * @subpackage  module-blog
 * @category    Controller
 * @author      Nails Dev Team
 * @link
 */

namespace Nails\Admin\Blog;

use Nails\Factory;
use Nails\Admin\Helper;
use Nails\Blog\Controller\BaseAdmin;

class Settings extends BaseAdmin
{
    /**
     * Announces this controller's navGroups
     * @return stdClass
     */
    public static function announce()
    {
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        if (!empty($blogs)) {

            $oNavGroup = Factory::factory('Nav', 'nailsapp/module-admin');
            $oNavGroup->setLabel('Settings');
            $oNavGroup->setIcon('fa-wrench');

            if (userHasPermission('admin:blog:settings:\d+:update')) {

                $oNavGroup->addAction('Blog');
            }

            return $oNavGroup;
        }
    }

    // --------------------------------------------------------------------------

    /**
     * Returns an array of permissions which can be configured for the user
     * @return array
     */
    public static function permissions()
    {
        $permissions = parent::permissions();

        //  Fetch the blogs, each blog should have its own permission
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        $out = array();

        if (!empty($blogs)) {
            foreach ($blogs as $blog) {
                $permissions[$blog->id . ':update']  = $blog->label . ': Can update settings';
            }
        }

        return $permissions;
    }

    // --------------------------------------------------------------------------

    /**
     * Manage Blog settings
     * @return void
     */
    public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nailsapp/module-blog');

        // --------------------------------------------------------------------------

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nailsapp/module-auth');
                $oSession->setFlashData($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show_404();
            }
        }

{'fraction_non_alphanumeric': 0.23163556900319382, 'fraction_numerical': 0.0010085728693898135, 'mean_word_length': 1.4196827978853193, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3602626', 'n_tokens_mistral': 1593, 'n_tokens_neox': 1487, 'n_words': 322}