Changeset 534 for trunk/bin


Ignore:
Timestamp:
Jul 27, 2015 7:56:08 AM (9 years ago)
Author:
anonymous
Message:

Improved module maker validation output. Allow disabling cache at run time for ACL. Added ACL getList() method. Improved ACL CLI listing. Fixed app boomerang array initialization. Now retaining identical boomerang URLs if the key is different. Added a maximum boomerang time. Added a way to disable cache per request through a query string. Added validator isDecimal() method. Added disableSelectOptions() HTML method. Added getGravatarURL() method. Change how navigation page array is managed. Updated navigation currentPage() method to test an array of URLs.

Location:
trunk/bin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/acl.cli.php

    r533 r534  
    4444require_once CODEBASE_PATH . '/lib/ACL.inc.php';
    4545$acl =& ACL::getInstance();
    46 $acl->setParam(array('create_table' => false));
     46$acl->setParam(array(
     47    'create_table' => false,
     48    'enable_cache' => false,
     49));
    4750
    4851
     
    6568    case 'aco' :
    6669    case 'axo' :
    67         listObjects('root', $type);
     70        listObjects($type);
    6871        break;
    6972    case 'all' :
    70         listObjects('root', 'aro');
    71         listObjects('root', 'aco');
    72         listObjects('root', 'axo');
     73        listObjects('aro');
     74        listObjects('aco');
     75        listObjects('axo');
    7376        break;
    7477    case 'perms' :
     
    244247*
    245248* @access   public
     249* @param    string $type Table to call, one of: aro, aco, or axo.
    246250* @param    string $root Root node from which to begin calculating.
    247 * @param    string $type Table to call, one of: aro, aco, or axo.
    248251* @return   bool Returns false on error.
    249252* @author   Quinn Comendant <quinn@strangecode.com>
     
    251254* @since    17 Jun 2006 23:41:22
    252255*/
    253 function listObjects($root, $type)
     256function listObjects($type, $root=null)
    254257{
     258    global $acl;
     259
    255260    $app =& App::getInstance();
    256261    $db =& DB::getInstance();
    257262
    258     echo "\n";
    259 
    260263    switch ($type) {
    261264    case 'aro' :
    262         $tbl = 'aro_tbl';
    263         printf("%-45s %s\n", 'Request objects', 'Added');
     265        printf("\n%-45s %s\n", 'Request objects', 'Added');
    264266        break;
    265267    case 'aco' :
    266         $tbl = 'aco_tbl';
    267         printf("%-45s %s\n", 'Control objects', 'Added');
     268        printf("\n%-45s %s\n", 'Control objects', 'Added');
    268269        break;
    269270    case 'axo' :
    270         $tbl = 'axo_tbl';
    271         printf("%-45s %s\n", 'Xtra objects', 'Added');
     271        printf("\n%-45s %s\n", 'Xtra objects', 'Added');
    272272        break;
    273273    default :
    274274        $app->logMsg(sprintf('Invalid access object type: %s', $type), LOG_ERR, __FILE__, __LINE__);
    275275        return false;
    276         break;
    277276    }
    278277
    279278    echo "---------------------------------------------------------------------\n";
    280279
    281     // Retrieve the left and right value of the $root node.
    282     $qid = $db->query("SELECT lft, rgt FROM $tbl WHERE name = '" . $db->escapeString($root) . "'");
    283     list($lft, $rgt) = mysql_fetch_row($qid);
    284 
    285     $depth = array();
    286 
    287     // Retrieve all descendants of the root node
    288     $qid = $db->query("SELECT name, lft, rgt, added_datetime FROM $tbl WHERE lft BETWEEN $lft AND $rgt ORDER BY lft ASC");
    289     while (list($name, $lft, $rgt, $added_datetime) = mysql_fetch_row($qid)) {
    290         // If the last element of $depth is less than the current rgt it means we finished with a set of children nodes.
    291         while (sizeof($depth) > 0 && end($depth) < $rgt) {
    292             array_pop($depth);
    293         }
    294 
     280    foreach ($acl->getList($type, $root) as $o) {
    295281        // Display indented node title.
    296         printf("%-45s %s\n", str_repeat('    ', sizeof($depth)) . $name, date($app->getParam('date_format') . ' ' . $app->getParam('time_format'), strtotime($added_datetime)));
    297 
    298         // Add this node to the stack.
    299         $depth[] = $rgt;
    300     }
     282        printf("%-45s %s\n", str_repeat('    ', $o['depth']) . $o['name'], date($app->getParam('date_format') . ' ' . $app->getParam('time_format'), strtotime($o['added_datetime'])));
     283    }
     284
     285    echo "\n";
    301286}
    302287
  • trunk/bin/module_maker/validation.cli.php

    r533 r534  
    7373        $field = $col[0];
    7474        $title = ucfirst(str_replace('_', ' ', $field));
    75         $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
     75        $type = preg_replace('/^(\w+).*$/', '$1', $col[1]);
     76        $max_dig = preg_replace('/^\w+\((\d+)(?:,\d+)?\).*$/', '$1', $col[1]);
     77        $max_dec = preg_replace('/^\w+\((?:\d+)(?:,(\d+))?\).*$/', '$1', $col[1]);
    7678        $is_primary_key = ('PRI' == $col[3]);
    7779        $unsigned = preg_match('/\s+unsigned\s*$/i', $col[1]);
     
    110112        case 'varchar' :
    111113            $len_type = 'string';
    112             $max_length = 255;
     114            $max_length = '' != $max_dig ? $max_dig : 255;
    113115            break;
    114116
     
    131133            break;
    132134
     135        case 'bit' :
     136            $len_type = 'num';
     137            $min = 0;
     138            $max = '' != $max_dig ? $max_dig : 64;
     139            break;
     140
    133141        case 'tinyint' :
    134         case 'bit' :
    135142        case 'bool' :
    136143            $len_type = 'num';
     
    191198        case 'float' :
    192199            $len_type = 'num';
    193             $min = -3.40282E+38;
    194             $max = 3.40282E+38;
     200            if ($unsigned) {
     201                $min = 0;
     202                $max = 3.40282E+38;
     203            } else {
     204                $min = -3.40282E+38;
     205                $max = 3.40282E+38;
     206            }
    195207            break;
    196208
    197209        case 'double' :
    198210        case 'double precision' :
     211            $len_type = 'num';
     212            if ($unsigned) {
     213                $min = 0;
     214                $max = 1.7976931348623157E+308;
     215            } else {
     216                $min = -1.7976931348623157E+308;
     217                $max = 1.7976931348623157E+308;
     218            }
     219            break;
     220
    199221        case 'real' :
    200222        case 'decimal' :
    201223        case 'dec' :
    202224        case 'numeric' :
    203             $len_type = 'num';
    204             $min = -1.79769E+308;
    205             $max = 1.79769E+308;
     225        case 'fixed' :
     226            $len_type = 'decimal'; // This doesn't match anything, on purpose.
    206227            break;
    207228
     
    255276
    256277        case 'float' :
    257         case 'float' :
    258278        case 'double' :
    259         case 'double' :
     279            $negative_ok = $unsigned ? '' : ', true';
     280            $o[] = "\$fv->isFloat('$field', sprintf(_(\"%s must be a valid number.\"), _(\"$title\"))$negative_ok);";
     281            break;
     282
    260283        case 'real' :
    261284        case 'decimal' :
    262285        case 'dec' :
    263286        case 'numeric' :
    264             $negative_ok = $unsigned ? '' : ', true';
    265             $o[] = "\$fv->isFloat('$field', sprintf(_(\"%s must be a valid number.\"), _(\"$title\"))$negative_ok);";
     287        case 'float' :
     288            $max = str_repeat('9', $max_dig - $max_dec);
     289            if ($max_dec > 0) {
     290                $max .= '.' . str_repeat('9', $max_dec);
     291            }
     292            if ($unsigned) {
     293                $negative_ok = 'false';
     294                $min = 0;
     295            } else {
     296                $negative_ok = 'true';
     297                $min = -$max;
     298            }
     299            $negative_ok = $unsigned ? 'false' : 'true';
     300            $o[] = "\$fv->isDecimal('$field', sprintf(_(\"%s must be a number between %d and %d.\"), _(\"$title\"), $min, $max), $negative_ok, $max_dig, $max_dec);";
    266301            break;
    267302
Note: See TracChangeset for help on using the changeset viewer.