From c47b942008a20196a5bb01f72164e9e63019ec2c Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 19 Jan 2010 18:53:32 -0700 Subject: [PATCH] Add 'cli' option to Horde_Registry_Application::appInit() --- ansel/scripts/all_images_exif_to_tags.php | 12 ++--------- ansel/scripts/ansel.php | 14 +----------- ansel/scripts/garbage_collection.php | 16 ++------------ ansel/scripts/recursive_import.php | 13 +---------- ansel/scripts/remote_import.php | 10 ++------- ansel/scripts/upgrades/1.0_to_1.1.php | 12 +---------- .../2008-09-16_add_original_date_values.php | 12 +---------- .../upgrades/2009-06-14_fix_geolocation_values.php | 12 +---------- .../2009-06-22_move_geolocation_values.php | 12 +---------- framework/Core/lib/Horde/Registry.php | 25 ++++++++++++++++++++-- horde/bin/alarms | 16 ++------------ horde/bin/db_migrate | 16 ++------------ horde/scripts/import_squirrelmail_file_prefs.php | 19 +++------------- horde/scripts/import_squirrelmail_prefs.php | 2 +- horde/scripts/import_squirrelmail_sql_prefs.php | 17 +++------------ .../upgrades/2008-04-09_horde_syncml_map.php | 15 ++----------- .../upgrades/2008-08-29_fix_mdb2_sequences.php | 9 ++------ .../upgrades/convert_datatree_groups_to_sql.php | 15 ++----------- .../upgrades/convert_datatree_perms_to_sql.php | 15 ++----------- horde/scripts/upgrades/migrate_user_categories.php | 15 ++----------- .../upgrades/move_history_out_of_datatree.php | 15 ++----------- hylax/scripts/fax_create.php | 12 +---------- hylax/scripts/fax_create_recv.php | 13 ++--------- hylax/scripts/fax_save_data.php | 13 ++--------- hylax/scripts/fax_save_recv_data.php | 13 ++--------- hylax/scripts/install_cups_drivers.php | 9 +------- imp/scripts/bounce_spam.php | 18 +++++----------- kronolith/scripts/agenda.php | 13 +---------- kronolith/scripts/import_icals.php | 21 +++--------------- kronolith/scripts/import_squirrelmail_calendar.php | 15 ++----------- .../upgrades/convert_datatree_shares_to_sql.php | 12 +++-------- kronolith/scripts/upgrades/convert_to_utc.php | 10 ++------- nag/scripts/import_vtodos.php | 16 ++------------ .../2006-04-18_add_creator_and_assignee_fields.php | 19 ++++------------ .../upgrades/convert_datatree_shares_to_sql.php | 5 +---- .../upgrades/create_missing_add_histories_sql.php | 16 +++----------- turba/scripts/import_squirrelmail_file_abook.php | 17 +++------------ turba/scripts/import_squirrelmail_sql_abook.php | 16 +++----------- turba/scripts/import_vcards.php | 15 ++----------- turba/scripts/upgrades/2.1_to_2.2_sql_schema.php | 6 ++---- .../scripts/upgrades/2005-09-23_flat_comments.php | 12 +---------- .../upgrades/2007-06-17_delete_old_vbooks.php | 15 +------------ .../scripts/upgrades/2007-06-17_flatten_shares.php | 12 +---------- .../upgrades/convert_datatree_shares_to_sql.php | 5 +---- turba/scripts/upgrades/public_to_horde_share.php | 10 +-------- 45 files changed, 107 insertions(+), 498 deletions(-) diff --git a/ansel/scripts/all_images_exif_to_tags.php b/ansel/scripts/all_images_exif_to_tags.php index 51a031509..747f76761 100755 --- a/ansel/scripts/all_images_exif_to_tags.php +++ b/ansel/scripts/all_images_exif_to_tags.php @@ -9,22 +9,14 @@ * @author Michael J. Rubinsky */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); -$cli = Horde_Cli::singleton(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); /* Command line options */ $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:f:', array('help', 'username=', 'password=', 'fields=')); +$cli = Horde_Cli::singleton(); if (is_a($ret, 'PEAR_Error')) { $cli->fatal($ret->getMessage()); } diff --git a/ansel/scripts/ansel.php b/ansel/scripts/ansel.php index e97c16ea5..291f1922c 100755 --- a/ansel/scripts/ansel.php +++ b/ansel/scripts/ansel.php @@ -9,21 +9,10 @@ * @author Vijay Mahrra */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -// Load Ansel. -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - // We accept the user name on the command-line. $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:lc:g:a:d:t:', @@ -32,7 +21,6 @@ $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'caption=')); if (is_a($ret, 'PEAR_Error')) { - var_dump($ret); $error = _("Couldn't read command-line options."); Horde::logMessage($error, __FILE__, __LINE__, PEAR_LOG_DEBUG); $cli->fatal($error); diff --git a/ansel/scripts/garbage_collection.php b/ansel/scripts/garbage_collection.php index 871e4812b..59d4d9b26 100755 --- a/ansel/scripts/garbage_collection.php +++ b/ansel/scripts/garbage_collection.php @@ -9,23 +9,11 @@ * directory. */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('ansel', array('authentication' => 'none')); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); // Default arguments. -$move = false; -$verbose = false; +$move = $verbose = false; // Parse command-line arguments. $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'mv', diff --git a/ansel/scripts/recursive_import.php b/ansel/scripts/recursive_import.php index b485df33a..e0245185d 100755 --- a/ansel/scripts/recursive_import.php +++ b/ansel/scripts/recursive_import.php @@ -9,21 +9,10 @@ * @author Vijay Mahrra */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -// Load Ansel. -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - // We accept the user name on the command-line. $ret = Console_Getopt::getopt(Console_Getopt::readPHPArgv(), 'hu:p:lc:g:a:d:k', array('help', 'username=', 'password=', 'dir=', 'keep')); diff --git a/ansel/scripts/remote_import.php b/ansel/scripts/remote_import.php index 96057130b..e64acb9d9 100755 --- a/ansel/scripts/remote_import.php +++ b/ansel/scripts/remote_import.php @@ -12,14 +12,8 @@ * @author Michael J. Rubinsky */ -require_once dirname(__FILE__) . '/../lib/base.load.php'; -require_once HORDE_BASE . '/lib/core.php'; - -/* Horde_CLI */ -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} -Horde_Cli::init(); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); /* Command line options */ diff --git a/ansel/scripts/upgrades/1.0_to_1.1.php b/ansel/scripts/upgrades/1.0_to_1.1.php index 767d08b04..2c7fdf236 100644 --- a/ansel/scripts/upgrades/1.0_to_1.1.php +++ b/ansel/scripts/upgrades/1.0_to_1.1.php @@ -9,20 +9,10 @@ * @author Michael J. Rubinsky */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_CLI::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_CLI::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_CLI::singleton(); -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - // First update the tables $alter = array("ALTER TABLE ansel_images ADD COLUMN image_latitude VARCHAR(32) NOT NULL DEFAULT ''", "ALTER TABLE ansel_images ADD COLUMN image_longitude VARCHAR(32) NOT NULL DEFAULT ''", diff --git a/ansel/scripts/upgrades/2008-09-16_add_original_date_values.php b/ansel/scripts/upgrades/2008-09-16_add_original_date_values.php index d7bd97c59..56d276aa5 100755 --- a/ansel/scripts/upgrades/2008-09-16_add_original_date_values.php +++ b/ansel/scripts/upgrades/2008-09-16_add_original_date_values.php @@ -11,20 +11,10 @@ * @author Michael J. Rubinsky */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - $sql = 'SELECT image_id, image_original_date, image_uploaded_date FROM ansel_images'; $results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC); foreach ($results as $image) { diff --git a/ansel/scripts/upgrades/2009-06-14_fix_geolocation_values.php b/ansel/scripts/upgrades/2009-06-14_fix_geolocation_values.php index 4d0964778..ed96e423f 100755 --- a/ansel/scripts/upgrades/2009-06-14_fix_geolocation_values.php +++ b/ansel/scripts/upgrades/2009-06-14_fix_geolocation_values.php @@ -9,20 +9,10 @@ * @author Michael J. Rubinsky */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - $sql = 'SELECT image_id, image_latitude, image_longitude FROM ansel_images_geolocation;'; $results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC); $sql = $ansel_db->prepare('UPDATE ansel_images_geolocation SET image_latitude = ?, image_longitude = ? WHERE image_id = ?'); diff --git a/ansel/scripts/upgrades/2009-06-22_move_geolocation_values.php b/ansel/scripts/upgrades/2009-06-22_move_geolocation_values.php index 5e8853bef..72e753a26 100644 --- a/ansel/scripts/upgrades/2009-06-22_move_geolocation_values.php +++ b/ansel/scripts/upgrades/2009-06-22_move_geolocation_values.php @@ -9,20 +9,10 @@ * @author Michael J. Rubinsky */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment. -Horde_Cli::init(); +Horde_Registry::appInit('ansel', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -Horde_Registry::appInit('ansel', array('authentication' => 'none')); - $sql = 'SELECT image_id, image_latitude, image_longitude FROM ansel_images_geolocation;'; $results = $ansel_db->queryAll($sql, null, MDB2_FETCHMODE_ASSOC); $sql = $ansel_db->prepare('UPDATE ansel_images SET image_latitude = ?, image_longitude = ? WHERE image_id = ?'); diff --git a/framework/Core/lib/Horde/Registry.php b/framework/Core/lib/Horde/Registry.php index abfca3c25..4fa450a38 100644 --- a/framework/Core/lib/Horde/Registry.php +++ b/framework/Core/lib/Horde/Registry.php @@ -97,20 +97,25 @@ class Horde_Registry * @param array $args Optional arguments: *
      * 'admin' - (boolean) Require authenticated user to be an admin?
+     *           DEFAULT: false
      * 'authentication' - (string) The type of authentication to use:
      *   'none'  - Do not authenticate
      *   'throw' - Authenticate; on no auth, throw a Horde_Exception
      *   [DEFAULT] - Authenticate; on no auth redirect to login screen
-     * 'nocompress' - (boolean) Controls whether the page should be
-     *                compressed.
+     * 'cli' - (boolean) Initialize a CLI interface.
+     *         DEFAULT: false
+     * 'nocompress' - (boolean) If set, the page will not be compressed.
+     *                DEFAULT: false
      * 'nologintasks' - (boolean) If set, don't perform logintasks (never
      *                  performed if authentication is 'none').
+     *                  DEFAULT: false
      * 'session_control' - (string) Sets special session control limitations:
      *   'netscape' - TODO; start read/write session
      *   'none' - Do not start a session
      *   'readonly' - Start session readonly
      *   [DEFAULT] - Start read/write session
      * 'user' - (string) Set authentication to this user.
+     *          DEFAULT: null
      * 
* * @return Horde_Registry_Application The application object. @@ -121,6 +126,7 @@ class Horde_Registry $args = array_merge(array( 'admin' => false, 'authentication' => null, + 'cli' => null, 'nocompress' => false, 'nologintasks' => false, 'session_control' => null, @@ -165,6 +171,21 @@ class Horde_Registry Horde_Auth::authenticateFailure($app, $e); } + /* CLI initialization. */ + if ($args['cli']) { + /* Make sure no one runs from the web. */ + if (!Horde_Cli::runningFromCLI()) { + fwrite(STDERR, "Must be run from the command line\n"); + exit(1); + } + + /* Load the CLI environment - make sure there's no time limit, + * init some variables, etc. */ + Horde_Cli::init(); + + $args['nocompress'] = true; + } + if (!$args['nocompress']) { Horde::compressOutput(); } diff --git a/horde/bin/alarms b/horde/bin/alarms index 23ee79619..9f839f1e2 100755 --- a/horde/bin/alarms +++ b/horde/bin/alarms @@ -9,20 +9,8 @@ * @author Jan Schneider */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -Horde_Cli::init(); - -// Include needed libraries. -Horde_Registry::appInit('horde', array('authentication' => 'none')); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); // Authenticate as administrator. if (!count($conf['auth']['admins'])) { diff --git a/horde/bin/db_migrate b/horde/bin/db_migrate index fe5fc1c15..9eca15020 100755 --- a/horde/bin/db_migrate +++ b/horde/bin/db_migrate @@ -9,22 +9,10 @@ * @author Chuck Hagenbuch */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -Horde_Cli::init(); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -// Include needed libraries. -Horde_Registry::appInit('horde', array('authentication' => 'none')); - // Get a database connection $db = $GLOBALS['injector']->getInstance('Horde_Db_Adapter_Base'); diff --git a/horde/scripts/import_squirrelmail_file_prefs.php b/horde/scripts/import_squirrelmail_file_prefs.php index 6e34610c7..8b325f4b0 100755 --- a/horde/scripts/import_squirrelmail_file_prefs.php +++ b/horde/scripts/import_squirrelmail_file_prefs.php @@ -16,20 +16,11 @@ * @author Ben Chavet */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../lib/core.php'; - -// Makre sure no one runs this from the web. -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); // Read command line parameters. +$cli = Horde_Cli::singleton(); if ($argc != 2) { $cli->message('Too many or too few parameters.', 'cli.error'); $cli->writeln('Usage: import_squirrelmail_prefs.php path-to-squirrelmail-data'); @@ -37,10 +28,6 @@ if ($argc != 2) { } $data = $argv[1]; -// Make sure we load Horde base to get the auth config -require_once dirname(__FILE__) . '/../lib/Application.php'; -Horde_Registry::appInit('horde', array('authentication' => 'none')); - require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php'; // Get list of SquirrelMail pref files diff --git a/horde/scripts/import_squirrelmail_prefs.php b/horde/scripts/import_squirrelmail_prefs.php index 670fcb6e5..b2b4ea0cd 100644 --- a/horde/scripts/import_squirrelmail_prefs.php +++ b/horde/scripts/import_squirrelmail_prefs.php @@ -90,7 +90,7 @@ function convert($sm_pref_name, $sm_pref_value) case 'hour_format': return array(array('name' => 'twentyFour', 'scope' => 'horde', 'value' => ($sm_pref_value == 1))); break; - + case 'internal_date_sort': if ($sm_pref_value == 1) { return array(array('name' => 'sortby', 'scope' => 'imp', 'value' => '1')); diff --git a/horde/scripts/import_squirrelmail_sql_prefs.php b/horde/scripts/import_squirrelmail_sql_prefs.php index 7f1f3c250..b42dffb01 100755 --- a/horde/scripts/import_squirrelmail_sql_prefs.php +++ b/horde/scripts/import_squirrelmail_sql_prefs.php @@ -16,19 +16,11 @@ */ // Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../lib/core.php'; - -// Makre sure no one runs this from the web. -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); // Read command line parameters. +$cli = Horde_Cli::singleton(); if ($argc != 2) { $cli->message('Too many or too few parameters.', 'cli.error'); $cli->writeln('Usage: import_squirrelmail_prefs.php DSN'); @@ -36,9 +28,6 @@ if ($argc != 2) { } $dsn = $argv[1]; -// Make sure we load Horde base to get the auth config -Horde_Registry::appInit('horde', array('authentication' => 'none')); - require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php'; // Connect to database. diff --git a/horde/scripts/upgrades/2008-04-09_horde_syncml_map.php b/horde/scripts/upgrades/2008-04-09_horde_syncml_map.php index 711edd8ac..42a3a4336 100755 --- a/horde/scripts/upgrades/2008-04-09_horde_syncml_map.php +++ b/horde/scripts/upgrades/2008-04-09_horde_syncml_map.php @@ -5,21 +5,10 @@ * tables and into its own database table. */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -Horde_Registry::appInit('horde', array('authentication' => 'none')); - require_once 'Horde/DataTree.php'; $datatree = DataTree::factory('sql', array_merge( diff --git a/horde/scripts/upgrades/2008-08-29_fix_mdb2_sequences.php b/horde/scripts/upgrades/2008-08-29_fix_mdb2_sequences.php index 6cf12994c..661c462f8 100755 --- a/horde/scripts/upgrades/2008-08-29_fix_mdb2_sequences.php +++ b/horde/scripts/upgrades/2008-08-29_fix_mdb2_sequences.php @@ -23,15 +23,10 @@ $to_upgrade = array('ansel_shares' => 'share_id', 'whups_shares' => 'share_id'); /* Set up the CLI environment */ -require_once dirname(__FILE__) . '/../../lib/core.php'; -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -$cli->init(); -/* Grab what we need to steal the DB config */ -require_once HORDE_BASE . '/config/conf.php'; $config = $GLOBALS['conf']['sql']; unset($config['charset']); $schema = MDB2_Schema::factory($config, array('seqcol_name' => 'id')); diff --git a/horde/scripts/upgrades/convert_datatree_groups_to_sql.php b/horde/scripts/upgrades/convert_datatree_groups_to_sql.php index 9ad3cde24..27077c386 100755 --- a/horde/scripts/upgrades/convert_datatree_groups_to_sql.php +++ b/horde/scripts/upgrades/convert_datatree_groups_to_sql.php @@ -5,19 +5,8 @@ * (Horde 3.2+) native SQL Group backend. */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('horde', array('authentication' => 'none')); +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); require_once 'Horde/Group.php'; $g = Group::factory(); diff --git a/horde/scripts/upgrades/convert_datatree_perms_to_sql.php b/horde/scripts/upgrades/convert_datatree_perms_to_sql.php index 145562e01..394f09851 100755 --- a/horde/scripts/upgrades/convert_datatree_perms_to_sql.php +++ b/horde/scripts/upgrades/convert_datatree_perms_to_sql.php @@ -5,19 +5,8 @@ * new (Horde 3.2+) native SQL Perms backend. */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('horde', array('authentication' => 'none')); +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); $p = Perms::factory('datatree'); diff --git a/horde/scripts/upgrades/migrate_user_categories.php b/horde/scripts/upgrades/migrate_user_categories.php index 21e60ef2b..d0d5b6c05 100755 --- a/horde/scripts/upgrades/migrate_user_categories.php +++ b/horde/scripts/upgrades/migrate_user_categories.php @@ -8,19 +8,8 @@ * the values stored in the preferences backend. */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../../lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('horde', array('authentication' => 'none')); +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); $cManager = new Horde_Prefs_CategoryManager(); diff --git a/horde/scripts/upgrades/move_history_out_of_datatree.php b/horde/scripts/upgrades/move_history_out_of_datatree.php index 7ef41f197..54a662c1e 100755 --- a/horde/scripts/upgrades/move_history_out_of_datatree.php +++ b/horde/scripts/upgrades/move_history_out_of_datatree.php @@ -5,24 +5,13 @@ * tables and into its own database table. */ -// Do CLI checks and environment setup first. -require_once dirname(__FILE__) . '/../../lib/core.php'; +require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('horde', array('authentication' => 'none', 'cli' => true)); -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); $cli = Horde_Cli::singleton(); - $cli->writeln($cli->yellow("Beginning migration. This may take a very long time to complete.")); $cli->writeln(); -Horde_Registry::appInit('horde', array('authentication' => 'none')); - require_once 'Horde/DataTree.php'; $datatree = DataTree::factory('sql', array_merge(Horde::getDriverConfig('datatree', 'sql'), array('group' => 'horde.history'))); diff --git a/hylax/scripts/fax_create.php b/hylax/scripts/fax_create.php index bedc0dacf..c410f66b0 100755 --- a/hylax/scripts/fax_create.php +++ b/hylax/scripts/fax_create.php @@ -2,17 +2,7 @@ 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -/* Load the CLI environment - make sure there's no time limit, init - * some variables, etc. */ -$cli = new Horde_Cli(); -$cli->init(); +$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true)); /* Create the fax information array. Set fax_type to 1 for outgoing. */ $info = array('fax_type' => 1); diff --git a/hylax/scripts/fax_create_recv.php b/hylax/scripts/fax_create_recv.php index 6aec1edad..3fa18da2b 100755 --- a/hylax/scripts/fax_create_recv.php +++ b/hylax/scripts/fax_create_recv.php @@ -2,17 +2,7 @@ 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -/* Load the CLI environment - make sure there's no time limit, init some - * variables, etc. */ -$cli = &new Horde_Cli(); -$cli->init(); +$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true)); /* Create the fax information array. Set fax_type to 0 for incoming. */ $info = array('fax_type' => 0, @@ -29,6 +19,7 @@ if (isset($args[2])) { $info['job_id'] = (int)substr($file, 9, -4); } +$cli = Horde_Cli::singleton(); $fax_info = $cli->readStdin(); $fax_info = explode("\n", $fax_info); foreach ($fax_info as $line) { diff --git a/hylax/scripts/fax_save_data.php b/hylax/scripts/fax_save_data.php index 75921e5ec..35f87b0f3 100755 --- a/hylax/scripts/fax_save_data.php +++ b/hylax/scripts/fax_save_data.php @@ -2,19 +2,10 @@ 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -/* Load the CLI environment - make sure there's no time limit, init some - * variables, etc. */ -$cli = new Horde_Cli(); -$cli->init(); +$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true)); /* Store the raw fax postscript data. */ +$cli = Horde_Cli::singleton(); $data = $cli->readStdin(); if (empty($data)) { Horde::logMessage('No print data received from standard input. Exiting fax submission.', __FILE__, __LINE__, PEAR_LOG_ERR); diff --git a/hylax/scripts/fax_save_recv_data.php b/hylax/scripts/fax_save_recv_data.php index 3e7a1f12d..4615aa139 100755 --- a/hylax/scripts/fax_save_recv_data.php +++ b/hylax/scripts/fax_save_recv_data.php @@ -2,17 +2,7 @@ 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -/* Load the CLI environment - make sure there's no time limit, init some - * variables, etc. */ -$cli = new Horde_Cli(); -$cli->init(); +$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true)); /* Get the arguments. The first argument is the filename from which the job ID * is obtained, in the format 'recvq/faxNNNNN.tif'. */ @@ -23,6 +13,7 @@ if (isset($args[1])) { } /* Store the raw fax postscript data. */ +$cli = Horde_Cli::singleton(); $data = $cli->readStdin(); if (empty($data)) { Horde::logMessage('No print data received from standard input. Exiting fax submission.', __FILE__, __LINE__, PEAR_LOG_ERR); diff --git a/hylax/scripts/install_cups_drivers.php b/hylax/scripts/install_cups_drivers.php index 99665a182..a228a73f4 100755 --- a/hylax/scripts/install_cups_drivers.php +++ b/hylax/scripts/install_cups_drivers.php @@ -2,14 +2,7 @@ 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -Horde_Cli::init(); +$hylax = Horde_Registry::appInit('hylax', array('authentication' => 'none', 'cli' => true)); /* The CUPS backend file. */ $hylafax_backend = file_get_contents(HYLAX_BASE . '/scripts/cups/hylafax'); diff --git a/imp/scripts/bounce_spam.php b/imp/scripts/bounce_spam.php index e3c098c41..d7c3e0e34 100755 --- a/imp/scripts/bounce_spam.php +++ b/imp/scripts/bounce_spam.php @@ -16,24 +16,16 @@ * @author Jan Schneider */ -define('IMP_CONFIG', dirname(__FILE__) . '/../config'); -require_once 'Horde/Cli.php'; +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('imp', array('authentication' => true, 'cli' => true)); -/* Make sure no one runs this from the web. */ -if (!Horde_Cli::runningFromCLI()) { - fwrite(STDERR, "Must be run from the command line\n"); - exit(1); -} +$bounce_template = IMP_BASE . '/config/bounce.txt'; /* If there's no bounce template file then abort */ -if (!file_exists(IMP_CONFIG . '/bounce.txt')) { +if (!file_exists($bounce_template)) { exit(0); } -/* Load the CLI environment - make sure there's no time limit, init some - * variables, etc. */ -Horde_Cli::init(); - /* Read the message content. */ $data = Horde_Cli::readStdin(); @@ -46,7 +38,7 @@ preg_match_all('/delivered-to: (.*?)\r?\n/is', $data, $matches); $delivered_to = $matches[1][count($matches[1])-1]; /* Read the bounce template and construct the mail */ -$bounce = file_get_contents(IMP_CONFIG . '/bounce.txt'); +$bounce = file_get_contents($bounce_template); $bounce = str_replace(array('%TO%', '%TARGET%'), array($return_path, $delivered_to), $bounce); diff --git a/kronolith/scripts/agenda.php b/kronolith/scripts/agenda.php index e3af94730..2eaf1e0b5 100755 --- a/kronolith/scripts/agenda.php +++ b/kronolith/scripts/agenda.php @@ -10,20 +10,9 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('kronolith', array('authentication' => 'none')); - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); +Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true)); send_agendas(); -exit(0); - /** */ diff --git a/kronolith/scripts/import_icals.php b/kronolith/scripts/import_icals.php index 82f527024..3acf24987 100755 --- a/kronolith/scripts/import_icals.php +++ b/kronolith/scripts/import_icals.php @@ -13,23 +13,11 @@ * @author Jan Schneider */ -$kronolith_authentication = 'none'; -@define('HORDE_BASE', dirname(__FILE__) . '/../..'); - -// Do CLI checks and environment setup first. -require_once HORDE_BASE . '/lib/core.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true)); // Read command line parameters. +$cli = Horde_Cli::singleton(); if (count($argv) != 3) { $cli->message('Too many or too few parameters.', 'cli.error'); usage(); @@ -44,9 +32,6 @@ if (empty($ical)) { usage(); } -// Registry. -$registry = Horde_Registry::singleton(); - // Set user. Horde_Auth::setAuth($user, array()); diff --git a/kronolith/scripts/import_squirrelmail_calendar.php b/kronolith/scripts/import_squirrelmail_calendar.php index 5b46ec25e..e6310d469 100755 --- a/kronolith/scripts/import_squirrelmail_calendar.php +++ b/kronolith/scripts/import_squirrelmail_calendar.php @@ -16,18 +16,10 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Makre sure no one runs this from the web. -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true, 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : array())); // Read command line parameters. +$cli = Horde_Cli::singleton(); if ($argc != 2) { $cli->message('Too many or too few parameters.', 'cli.error'); $cli->writeln('Usage: import_squirrelmail_file_abook.php DSN'); @@ -36,9 +28,6 @@ if ($argc != 2) { $dsn = $argv[1]; $default_tz = date_default_timezone_get(); -// Make sure we load Horde base to get the auth config -Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : array())); - // Connect to database. $db = DB::connect($dsn); if (is_a($db, 'PEAR_Error')) { diff --git a/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php b/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php index efd5c43e6..a92d7699f 100755 --- a/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -7,16 +7,10 @@ */ /* Set up the CLI environment */ -require_once dirname(__FILE__) . '/../../lib/base.load.php'; -require_once HORDE_BASE . '/lib/core.php'; -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once dirname(__FILE__) . '/../../Application.php'; +Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true)); -/* Grab what we need to steal the DB config */ -require_once HORDE_BASE . '/config/conf.php'; +$cli = Horde_Cli::singleton(); $config = $GLOBALS['conf']['sql']; unset($config['charset']); diff --git a/kronolith/scripts/upgrades/convert_to_utc.php b/kronolith/scripts/upgrades/convert_to_utc.php index 891166721..099c0a5ed 100755 --- a/kronolith/scripts/upgrades/convert_to_utc.php +++ b/kronolith/scripts/upgrades/convert_to_utc.php @@ -6,14 +6,7 @@ /* Set up the CLI environment. */ require_once dirname(__FILE__) . '/../../lib/Application.php'; -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} -$cli = Horde_Cli::singleton(); -$cli->init(); - -/* Load required libraries. */ -Horde_Registry::appInit('kronolith', array('authentication' => 'none')); +Horde_Registry::appInit('kronolith', array('authentication' => 'none', 'cli' => true)); /* Prepare DB stuff. */ PEAR::staticPushErrorHandling(PEAR_ERROR_DIE); @@ -22,6 +15,7 @@ $result = $db->query('SELECT event_title, event_id, event_creator_id, event_star $stmt = $db->prepare('UPDATE kronolith_events SET event_start = ?, event_end = ?, event_recurenddate = ? WHERE event_id = ?'); /* Confirm changes. */ +$cli = Horde_Cli::singleton(); if (!isset($argv[1]) || $argv[1] != '--yes') { $answer = $cli->prompt('Running this script will convert all existing events to UTC. This conversion is not reversible. Is this what you want?', array('y' => 'Yes', 'n' => 'No')); if ($answer != 'y') { diff --git a/nag/scripts/import_vtodos.php b/nag/scripts/import_vtodos.php index 7fabdf331..28b41de3d 100755 --- a/nag/scripts/import_vtodos.php +++ b/nag/scripts/import_vtodos.php @@ -13,20 +13,11 @@ * @author Jan Schneider */ -// Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true)); // Read command line parameters. +$cli = Horde_Cli::singleton(); if (count($argv) != 3) { $cli->message('Too many or too few parameters.', 'cli.error'); usage(); @@ -41,9 +32,6 @@ if (empty($vtodo)) { usage(); } -// Registry. -$registry = Horde_Registry::singleton(); - // Set user. Horde_Auth::setAuth($user, array()); diff --git a/nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php b/nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php index e28335dbb..444d76990 100755 --- a/nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php +++ b/nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php @@ -14,17 +14,7 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('nag', array('authentication' => 'none')); +Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true)); if ($conf['storage']['driver'] != 'sql') { exit('No conversion for drivers other than SQL currently.'); @@ -32,7 +22,7 @@ if ($conf['storage']['driver'] != 'sql') { $storage = Nag_Driver::singleton(''); $storage->initialize(); -$db = &$storage->_db; +$db = $storage->_db; // Add db fields. We don't check for success/failure here in case someone did // this manually. @@ -66,6 +56,5 @@ foreach ($tasklists as $tasklist => $share) { } } -echo "\n** Creators successfully stored. ***\n"; - -echo "\n** Please manually apply NOT NULL constraint to 'task_creator' column. ***\n"; +echo "\n** Creators successfully stored. ***\n\n". + "** Please manually apply NOT NULL constraint to 'task_creator' column. ***\n"; diff --git a/nag/scripts/upgrades/convert_datatree_shares_to_sql.php b/nag/scripts/upgrades/convert_datatree_shares_to_sql.php index a74d320cf..9460d8d0d 100755 --- a/nag/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/nag/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -8,11 +8,8 @@ /* Set up the CLI environment */ require_once dirname(__FILE__) . '/../../lib/Application.php'; -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} +Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -$cli->init(); /* Grab what we need to steal the DB config */ require_once HORDE_BASE . '/config/conf.php'; diff --git a/nag/scripts/upgrades/create_missing_add_histories_sql.php b/nag/scripts/upgrades/create_missing_add_histories_sql.php index e65442b96..9cb7cfa8b 100755 --- a/nag/scripts/upgrades/create_missing_add_histories_sql.php +++ b/nag/scripts/upgrades/create_missing_add_histories_sql.php @@ -11,25 +11,15 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../../lib/Application.php'; +Horde_Registry::appInit('nag', array('authentication' => 'none', 'cli' => true)); -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. $cli = Horde_Cli::singleton(); -$cli->init(); - -Horde_Registry::appInit('nag', array('authentication' => 'none')); - $history = Horde_History::singleton(); // Run through every tasklist. $tasklists = $nag_shares->listAllShares(); foreach ($tasklists as $tasklist => $share) { - echo "Creating default histories for $tasklist ...\n"; + $cli->writeln("Creating default histories for $tasklist ..."); // List all tasks. $storage = Nag_Driver::singleton($tasklist); @@ -51,4 +41,4 @@ foreach ($tasklists as $tasklist => $share) { } } -echo "\n** Default histories successfully created ***\n"; +$cli->writeln("** Default histories successfully created ***"); diff --git a/turba/scripts/import_squirrelmail_file_abook.php b/turba/scripts/import_squirrelmail_file_abook.php index 7cfe548e2..6b64e732b 100755 --- a/turba/scripts/import_squirrelmail_file_abook.php +++ b/turba/scripts/import_squirrelmail_file_abook.php @@ -18,18 +18,12 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true, 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); -// Makre sure no one runs this from the web. -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once TURBA_BASE . '/lib/Object/Group.php'; // Read command line parameters. +$cli = Horde_Cli::singleton(); if ($argc != 2) { $cli->message('Too many or too few parameters.', 'cli.error'); $cli->writeln('Usage: import_squirrelmail_file_abook.php path-to-squirrelmail-data'); @@ -37,11 +31,6 @@ if ($argc != 2) { } $data = $argv[1]; -// Make sure we load Horde base to get the auth config -Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); - -require_once TURBA_BASE . '/lib/Object/Group.php'; - // Get list of SquirrelMail address book files if (is_dir($data)) { if (!($handle = opendir($data))) { diff --git a/turba/scripts/import_squirrelmail_sql_abook.php b/turba/scripts/import_squirrelmail_sql_abook.php index 298d74431..f45ef1604 100755 --- a/turba/scripts/import_squirrelmail_sql_abook.php +++ b/turba/scripts/import_squirrelmail_sql_abook.php @@ -17,18 +17,12 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true, 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); -// Makre sure no one runs this from the web. -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +require_once TURBA_BASE . '/lib/Object/Group.php'; // Read command line parameters. +$cli = Horde_Cli::singleton(); if ($argc != 2) { $cli->message('Too many or too few parameters.', 'cli.error'); $cli->writeln('Usage: import_squirrelmail_file_abook.php DSN'); @@ -36,10 +30,6 @@ if ($argc != 2) { } $dsn = $argv[1]; -Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); - -require_once TURBA_BASE . '/lib/Object/Group.php'; - // Connect to database. $db = DB::connect($dsn); if (is_a($db, 'PEAR_Error')) { diff --git a/turba/scripts/import_vcards.php b/turba/scripts/import_vcards.php index 9d27c03d9..c1e062c9c 100755 --- a/turba/scripts/import_vcards.php +++ b/turba/scripts/import_vcards.php @@ -15,18 +15,10 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -$cli = Horde_Cli::singleton(); -$cli->init(); +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true, 'user' => $user)); // Read command line parameters. +$cli = Horde_Cli::singleton(); if (count($argv) != 3) { $cli->message('Too many or too few parameters.', 'cli.error'); usage(); @@ -41,9 +33,6 @@ if (empty($vcard)) { usage(); } -// Registry. -Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $user)); - // Import data. $result = $registry->call('contacts/import', array($vcard, 'text/x-vcard', $source)); diff --git a/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php b/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php index edfc05c59..bcbc64f22 100755 --- a/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php +++ b/turba/scripts/upgrades/2.1_to_2.2_sql_schema.php @@ -32,13 +32,11 @@ $do_work = true; $do_email = true; /* YOU SHOULD NOT HAVE TO TOUCH ANYTHING BELOW THIS LINE */ + /* Set up the CLI environment */ require_once dirname(__FILE__) . '/../../lib/Application.php'; -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -$cli->init(); /* Grab what we need to steal the DB config */ require_once HORDE_BASE . '/config/conf.php'; diff --git a/turba/scripts/upgrades/2005-09-23_flat_comments.php b/turba/scripts/upgrades/2005-09-23_flat_comments.php index 8c9c83258..ad4c1dc6b 100755 --- a/turba/scripts/upgrades/2005-09-23_flat_comments.php +++ b/turba/scripts/upgrades/2005-09-23_flat_comments.php @@ -11,17 +11,7 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init some -// variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('turba', array('authentication' => 'none')); +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); // Instantiate DataTree. require_once 'Horde/DataTree.php'; diff --git a/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php b/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php index edcd838f0..b42fecefc 100755 --- a/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php +++ b/turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php @@ -7,20 +7,7 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('turba', array('authentication' => 'none')); - -// Re-load source config. -// require TURBA_BASE . '/config/sources.php'; +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); // See if any of our sources are configured to use Horde_Share. if (empty($_SESSION['turba']['has_share'])) { diff --git a/turba/scripts/upgrades/2007-06-17_flatten_shares.php b/turba/scripts/upgrades/2007-06-17_flatten_shares.php index 46126235c..607c1c8d6 100755 --- a/turba/scripts/upgrades/2007-06-17_flatten_shares.php +++ b/turba/scripts/upgrades/2007-06-17_flatten_shares.php @@ -7,17 +7,7 @@ // Do CLI checks and environment setup first. require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Make sure no one runs this from the web. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} - -// Load the CLI environment - make sure there's no time limit, init -// some variables, etc. -Horde_Cli::init(); - -Horde_Registry::appInit('turba', array('authentication' => 'none')); +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); // Re-load source config. require TURBA_BASE . '/config/sources.php'; diff --git a/turba/scripts/upgrades/convert_datatree_shares_to_sql.php b/turba/scripts/upgrades/convert_datatree_shares_to_sql.php index 0aefe9fdf..a69e27c54 100755 --- a/turba/scripts/upgrades/convert_datatree_shares_to_sql.php +++ b/turba/scripts/upgrades/convert_datatree_shares_to_sql.php @@ -9,11 +9,8 @@ /* Set up the CLI environment */ require_once dirname(__FILE__) . '/../../lib/Application.php'; -if (!Horde_Cli::runningFromCli()) { - exit("Must be run from the command line\n"); -} +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true)); $cli = Horde_Cli::singleton(); -$cli->init(); /* Grab what we need to steal the DB config */ require_once HORDE_BASE . '/config/conf.php'; diff --git a/turba/scripts/upgrades/public_to_horde_share.php b/turba/scripts/upgrades/public_to_horde_share.php index 9374efcaa..1cf400072 100755 --- a/turba/scripts/upgrades/public_to_horde_share.php +++ b/turba/scripts/upgrades/public_to_horde_share.php @@ -20,17 +20,9 @@ // Load Horde and Turba enviroments require_once dirname(__FILE__) . '/../lib/Application.php'; - -// Set up the CLI enviroment. -if (!Horde_Cli::runningFromCLI()) { - exit("Must be run from the command line\n"); -} -Horde_Cli::init(); +Horde_Registry::appInit('turba', array('authentication' => 'none', 'cli' => true, 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); $CLI = Horde_Cli::singleton(); -// Make sure we load Horde base to get the auth config -Horde_Registry::appInit('turba', array('authentication' => 'none', 'user' => $conf['auth']['admins'] ? $conf['auth']['admins'][0] : null)); - $CLI->writeln('This script will turn all entries in the SQL address book into a globally shared address book.'); $CLI->writeln('Make sure you read the script comments and be sure you know what you are doing.'); $sure = $CLI->prompt('Are you ' . $CLI->bold('sure') . ' you want to do this?', array('no', 'yes')); -- 2.11.0