- Timestamp:
- Jul 27, 2015 7:56:08 AM (9 years ago)
- Location:
- trunk/bin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/acl.cli.php
r533 r534 44 44 require_once CODEBASE_PATH . '/lib/ACL.inc.php'; 45 45 $acl =& ACL::getInstance(); 46 $acl->setParam(array('create_table' => false)); 46 $acl->setParam(array( 47 'create_table' => false, 48 'enable_cache' => false, 49 )); 47 50 48 51 … … 65 68 case 'aco' : 66 69 case 'axo' : 67 listObjects( 'root',$type);70 listObjects($type); 68 71 break; 69 72 case 'all' : 70 listObjects(' root', 'aro');71 listObjects(' root', 'aco');72 listObjects(' root', 'axo');73 listObjects('aro'); 74 listObjects('aco'); 75 listObjects('axo'); 73 76 break; 74 77 case 'perms' : … … 244 247 * 245 248 * @access public 249 * @param string $type Table to call, one of: aro, aco, or axo. 246 250 * @param string $root Root node from which to begin calculating. 247 * @param string $type Table to call, one of: aro, aco, or axo.248 251 * @return bool Returns false on error. 249 252 * @author Quinn Comendant <quinn@strangecode.com> … … 251 254 * @since 17 Jun 2006 23:41:22 252 255 */ 253 function listObjects($ root, $type)256 function listObjects($type, $root=null) 254 257 { 258 global $acl; 259 255 260 $app =& App::getInstance(); 256 261 $db =& DB::getInstance(); 257 262 258 echo "\n";259 260 263 switch ($type) { 261 264 case 'aro' : 262 $tbl = 'aro_tbl'; 263 printf("%-45s %s\n", 'Request objects', 'Added'); 265 printf("\n%-45s %s\n", 'Request objects', 'Added'); 264 266 break; 265 267 case 'aco' : 266 $tbl = 'aco_tbl'; 267 printf("%-45s %s\n", 'Control objects', 'Added'); 268 printf("\n%-45s %s\n", 'Control objects', 'Added'); 268 269 break; 269 270 case 'axo' : 270 $tbl = 'axo_tbl'; 271 printf("%-45s %s\n", 'Xtra objects', 'Added'); 271 printf("\n%-45s %s\n", 'Xtra objects', 'Added'); 272 272 break; 273 273 default : 274 274 $app->logMsg(sprintf('Invalid access object type: %s', $type), LOG_ERR, __FILE__, __LINE__); 275 275 return false; 276 break;277 276 } 278 277 279 278 echo "---------------------------------------------------------------------\n"; 280 279 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) { 295 281 // 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"; 301 286 } 302 287 -
trunk/bin/module_maker/validation.cli.php
r533 r534 73 73 $field = $col[0]; 74 74 $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]); 76 78 $is_primary_key = ('PRI' == $col[3]); 77 79 $unsigned = preg_match('/\s+unsigned\s*$/i', $col[1]); … … 110 112 case 'varchar' : 111 113 $len_type = 'string'; 112 $max_length = 255;114 $max_length = '' != $max_dig ? $max_dig : 255; 113 115 break; 114 116 … … 131 133 break; 132 134 135 case 'bit' : 136 $len_type = 'num'; 137 $min = 0; 138 $max = '' != $max_dig ? $max_dig : 64; 139 break; 140 133 141 case 'tinyint' : 134 case 'bit' :135 142 case 'bool' : 136 143 $len_type = 'num'; … … 191 198 case 'float' : 192 199 $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 } 195 207 break; 196 208 197 209 case 'double' : 198 210 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 199 221 case 'real' : 200 222 case 'decimal' : 201 223 case 'dec' : 202 224 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. 206 227 break; 207 228 … … 255 276 256 277 case 'float' : 257 case 'float' :258 278 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 260 283 case 'real' : 261 284 case 'decimal' : 262 285 case 'dec' : 263 286 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);"; 266 301 break; 267 302
Note: See TracChangeset
for help on using the changeset viewer.