cvs: pear /Perm_LiveUser/Perm DefineGenerator

From: Date: Mon, 17 Feb 2003 19:21:50 +0000
Subject: cvs: pear /Perm_LiveUser/Perm DefineGenerator
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8916@lists.php.net to get a copy of this message
arnaud Mon Feb 17 14:21:50 2003 EDT Modified files: /pear/Perm_LiveUser/Perm DefineGenerator Log: * fix shebang for unix-like OS ;)) Index: pear/Perm_LiveUser/Perm/DefineGenerator diff -u pear/Perm_LiveUser/Perm/DefineGenerator:1.3 pear/Perm_LiveUser/Perm/DefineGenerator:1.4 --- pear/Perm_LiveUser/Perm/DefineGenerator:1.3 Sun Feb 16 16:54:39 2003 +++ pear/Perm_LiveUser/Perm/DefineGenerator Mon Feb 17 14:21:50 2003 @@ -1,4 +1,4 @@ -#!G:/php/php423/php-cli.exe -q +#!/usr/local/bin/php -q <?php /** * DefineGenerator.php @@ -9,10 +9,10 @@ * and authrights that your application needs. That´s where this script comes * in handy. Currently, you can only call it from the commandline. * Once the GUI is ready, you´ll be able to generate define() files from there. - * - * Syntax: + * + * Syntax: * DefineGenerator [options] - * + * * ...where [options] can be: * -help : Shows this list of options * -dsn : Defines the PEAR::DB DSN to connect to the database. @@ -27,7 +27,7 @@ * -prefix : Prefix to use for naming the constants. * Example: -prefix=LIVEUSER (prefixes all constant names with * LIVEUSER_, i.e. LIVEUSER_ADMINAREA_ADMINRIGHT) - * Defaults to none. + * Defaults to none. * -naming : Defines the way how the constants are being named. Can be a * number between 1 and 3. Examples for naming schemes: * -naming=1 : PREFIX_RIGHTNAME @@ -36,11 +36,11 @@ * Defaults to 1. * * @author Markus Wolff <wolff@21st.de> - * @version $Id: DefineGenerator,v 1.3 2003/02/16 21:54:39 mw21st Exp $ + * @version $Id: DefineGenerator,v 1.4 2003/02/17 19:21:50 arnaud Exp $ */ - + /** * printHelp() * @@ -50,36 +50,36 @@ function printHelp() { echo (' -Syntax: +Syntax: DefineGenerator [options] ...where [options] can be: -help : Shows this list of options - + -dsn : Defines the PEAR::DB DSN to connect to the database. Example: -dsn=mysql://user:passwd@hostname/databasename - --app : Defines the name of the application for which to generate the + +-app : Defines the name of the application for which to generate the constant definitions. Example: -app=MyApplication - --area : Defines the AuthArea to be used. If not set, this script will - generate constants for all AuthAreas within the chosen + +-area : Defines the AuthArea to be used. If not set, this script will + generate constants for all AuthAreas within the chosen application. Example: -area=MyArea - + -file : Defines the output file. Example: -file=/path/to/output/file - + -prefix : Prefix to use for naming the constants. Example: -prefix=LIVEUSER (prefixes all constant names with LIVEUSER_, i.e. LIVEUSER_ADMINAREA_ADMINRIGHT) Defaults to none. - + -naming : Defines the way how the constants are being named. Can be a number between 1 and 3. Examples for naming schemes: -naming=1 : PREFIX_RIGHTNAME -naming=2 : PREFIX_AREANAME_RIGHTNAME -naming=3 : PREFIX_APPLICATIONNAME_AREANAME_RIGHTNAME Defaults to 1. - + '); } @@ -93,10 +93,10 @@ function parseArgs() { global $argv, $argc; - + $args = array(); $ret = null; - + for ($i = 1; $i < $argc; $i++) { $argStruct = array(); $argStruct = explode('=', $argv[$i]); @@ -104,16 +104,16 @@ if ($name == 'help') { $args[$name] = ''; } else { - $args[$name] = $argStruct[1]; + $args[$name] = $argStruct[1]; } - + } - + if (!isset($args['naming'])) { $args['naming'] = 1; } - return $args; + return $args; } @@ -154,7 +154,7 @@ $sql = "SELECT * FROM liveuser_rights R, liveuser_areas A WHERE R.area_id=A.area_id"; if (isset($args['area'])) { - $sql .= " AND A.area_define_name='$args[area]'"; + $sql .= " AND A.area_define_name='$args[area]'"; } $res = $db->query($sql); @@ -168,27 +168,27 @@ while($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) { switch($args['naming']) { case 2: - $strDef .= sprintf("define('%s_%s', %s);\n", + $strDef .= sprintf("define('%s_%s', %s);\n", $prefix.strtoupper($row['area_define_name']), - strtoupper($row['right_define_name']), + strtoupper($row['right_define_name']), $row['right_id'] ); - break; + break; case 3: - $strDef .= sprintf("define('%s_%s_%s', %s);\n", + $strDef .= sprintf("define('%s_%s_%s', %s);\n", $prefix.strtoupper($args['app']), strtoupper($row['area_define_name']), - strtoupper($row['right_define_name']), + strtoupper($row['right_define_name']), $row['right_id'] ); break; default: - $strDef .= sprintf("define('%s', %s);\n", - $prefix.strtoupper($row['right_define_name']), + $strDef .= sprintf("define('%s', %s);\n", + $prefix.strtoupper($row['right_define_name']), $row['right_id'] - ); + ); } - + }

« previous php.pear.cvs (#8916) next »