<commit_before><?php
/**
 * Default access control list for application.
 *
 * @package Core
 * @author <NAME>
 * @copyright (c) 2009 CultSoft
 * @license http://cultsoft.org.ua/platform/license.html
 */
class App_Acl extends Zend_Acl
{
    // ACL singleton
    private static $instance = null;

    /**
     * Constructor
     */
    public function __construct ()
    {
        if (App_Acl::$instance === null) {
            $acl = App_Cache::getInstance()->getAclRoles();
            $res = current($acl);
            $resources = array();
            foreach ($res as $key => $value) {
                if ((strlen($key) > 4) and (substr($key, 0, 4) == 'res_')) {
                    $resources[substr($key, 4)] = (bool) $value;
                    $this->add(new Zend_Acl_Resource(substr($key, 4)));
                }
            }
            foreach ($acl as $role) {
                $this->addRole(new Zend_Acl_Role($role['role']));
                foreach ($resources as $key => $value) {
                    if ($role['role'] == 'guest') {
                        $value = false;
                    }
                    if ($role['role'] == 'administrator') {
                        $value = true;
                    }
                    if ($value) {
                        $this->allow($role['role'], $key);
                    } else {
                        $acl->deny($role['role'], $key);
                    }
                }
            }
        }
        App_Acl::$instance = $this;
    }

    public static function getInstance ()
    {
        if (App_Acl::$instance == null) {
            // Create a new instance
            new App_Acl();
        }
        return App_Acl::$instance;
    }
}<commit_msg>Fix acl roles fetching from db<commit_after><?php
/**
 * Default access control list for application.
 *
 * @package Core
 * @author <NAME>
 * @copyright (c) 2009 CultSoft
 * @license http://cultsoft.org.ua/platform/license.html
 */
class App_Acl extends Zend_Acl {
	// ACL singleton
	private static $instance = null;
	
	/**
	 * Constructor
	 */
	public function __construct() {
		if (App_Acl::$instance === null) {
			$acl = App_Cache::getInstance ()->getAclRoles ();
			$res = current ( $acl );
			$resources = array ();
			if ($res) {
				foreach ( $res as $key => $value ) {
					if ((strlen ( $key ) > 4) and (substr ( $key, 0, 4 ) == 'res_')) {
						$resources [substr ( $key, 4 )] = ( bool ) $value;
						$this->add ( new Zend_Acl_Resource ( substr ( $key, 4 ) ) );
					}
				}
			}
			foreach ( $acl as $role ) {
				$this->addRole ( new Zend_Acl_Role ( $role ['role'] ) );
				foreach ( $resources as $key => $value ) {
					if ($role ['role'] == 'guest') {
						$value = false;
					}
					if ($role ['role'] == 'administrator') {
						$value = true;
					}
					if ($value) {
						$this->allow ( $role ['role'], $key );
					} else {
						$acl->deny ( $role ['role'], $key );
					}
				}
			}
		}
		App_Acl::$instance = $this;
	}
	
	public static function getInstance() {
		if (App_Acl::$instance == null) {
			// Create a new instance
			new App_Acl ( );
		}
		return App_Acl::$instance;
	}
}
{'fraction_non_alphanumeric': 0.16486658195679796, 'fraction_numerical': 0.005717916137229987, 'mean_word_length': 1.7311361665221163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, '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': '5157247', 'n_tokens_mistral': 1115, 'n_tokens_neox': 962, 'n_words': 235}