Changeset 502 for trunk/lib/ACL.inc.php


Ignore:
Timestamp:
Dec 30, 2014 10:24:51 PM (9 years ago)
Author:
anonymous
Message:

Many minor fixes during pulso development

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/ACL.inc.php

    r484 r502  
    3737require_once dirname(__FILE__) . '/Cache.inc.php';
    3838
    39 class ACL {
     39class ACL
     40{
    4041
    4142    // A place to keep an object instance for the singleton pattern.
     
    4950        // Automatically create table and verify columns. Better set to false after site launch.
    5051        'create_table' => false,
     52
     53        // Maximum allowed length of names.
     54        // This value can be increased only if {aro,aco,axo}_tbl.name VARCHAR length is increased.
     55        'name_max_length' => 32.
    5156    );
    5257
     
    149154            $db->query("
    150155                CREATE TABLE IF NOT EXISTS acl_tbl (
    151                     aro_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
    152                     aco_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
    153                     axo_id SMALLINT(11) UNSIGNED NOT NULL DEFAULT '0',
     156                    aro_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
     157                    aco_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
     158                    axo_id SMALLINT UNSIGNED NOT NULL DEFAULT '0',
    154159                    access ENUM('allow', 'deny') DEFAULT NULL,
    155160                    added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
     
    180185                    CREATE TABLE IF NOT EXISTS {$a_o}_tbl (
    181186                        {$a_o}_id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
    182                         name VARCHAR(32) NOT NULL DEFAULT '',
    183                         lft MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
    184                         rgt MEDIUMINT(9) UNSIGNED NOT NULL DEFAULT '0',
     187                        name VARCHAR(" . $this->getParam('name_max_length') . ") NOT NULL DEFAULT '',
     188                        lft MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
     189                        rgt MEDIUMINT UNSIGNED NOT NULL DEFAULT '0',
    185190                        added_datetime DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
    186191                        UNIQUE KEY name (name(15)),
     
    255260        if ('' == trim($name) || '' == trim($parent)) {
    256261            $app->logMsg(sprintf('Cannot add node, parent (%s) or name (%s) missing.', $name, $parent), LOG_WARNING, __FILE__, __LINE__);
     262            return false;
     263        }
     264
     265        // Ensure node node name fits in the column size.
     266        // This value can be increased if {aro,aco.axo}_tbl.name VARCHAR length is increased.
     267        if (strlen(trim($name)) > $this->getParam('name_max_length')) {
     268            $app->logMsg(sprintf('Cannot add node, %s character limit exceeded for name "%s"', $this->getParam('name_max_length'), $name, $parent), LOG_WARNING, __FILE__, __LINE__);
    257269            return false;
    258270        }
     
    718730
    719731        if (!$this->check($aro, $aco, $axo)) {
    720             $message = '' == trim($message) ? sprintf(_("You have insufficient privileges to view <em>%s %s</em>"), $aco, $axo) : $message;
     732            $message = '' == trim($message) ? sprintf(_("Sorry, you have insufficient privileges for <em>%s %s</em>."), $aco, $axo) : $message;
    721733            $app->raiseMsg($message, $type, $file, $line);
    722734            $app->dieBoomerangURL();
Note: See TracChangeset for help on using the changeset viewer.