Add 'cli' option to Horde_Registry_Application::appInit()
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 20 Jan 2010 01:53:32 +0000 (18:53 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Wed, 20 Jan 2010 15:35:08 +0000 (08:35 -0700)
45 files changed:
ansel/scripts/all_images_exif_to_tags.php
ansel/scripts/ansel.php
ansel/scripts/garbage_collection.php
ansel/scripts/recursive_import.php
ansel/scripts/remote_import.php
ansel/scripts/upgrades/1.0_to_1.1.php
ansel/scripts/upgrades/2008-09-16_add_original_date_values.php
ansel/scripts/upgrades/2009-06-14_fix_geolocation_values.php
ansel/scripts/upgrades/2009-06-22_move_geolocation_values.php
framework/Core/lib/Horde/Registry.php
horde/bin/alarms
horde/bin/db_migrate
horde/scripts/import_squirrelmail_file_prefs.php
horde/scripts/import_squirrelmail_prefs.php
horde/scripts/import_squirrelmail_sql_prefs.php
horde/scripts/upgrades/2008-04-09_horde_syncml_map.php
horde/scripts/upgrades/2008-08-29_fix_mdb2_sequences.php
horde/scripts/upgrades/convert_datatree_groups_to_sql.php
horde/scripts/upgrades/convert_datatree_perms_to_sql.php
horde/scripts/upgrades/migrate_user_categories.php
horde/scripts/upgrades/move_history_out_of_datatree.php
hylax/scripts/fax_create.php
hylax/scripts/fax_create_recv.php
hylax/scripts/fax_save_data.php
hylax/scripts/fax_save_recv_data.php
hylax/scripts/install_cups_drivers.php
imp/scripts/bounce_spam.php
kronolith/scripts/agenda.php
kronolith/scripts/import_icals.php
kronolith/scripts/import_squirrelmail_calendar.php
kronolith/scripts/upgrades/convert_datatree_shares_to_sql.php
kronolith/scripts/upgrades/convert_to_utc.php
nag/scripts/import_vtodos.php
nag/scripts/upgrades/2006-04-18_add_creator_and_assignee_fields.php
nag/scripts/upgrades/convert_datatree_shares_to_sql.php
nag/scripts/upgrades/create_missing_add_histories_sql.php
turba/scripts/import_squirrelmail_file_abook.php
turba/scripts/import_squirrelmail_sql_abook.php
turba/scripts/import_vcards.php
turba/scripts/upgrades/2.1_to_2.2_sql_schema.php
turba/scripts/upgrades/2005-09-23_flat_comments.php
turba/scripts/upgrades/2007-06-17_delete_old_vbooks.php
turba/scripts/upgrades/2007-06-17_flatten_shares.php
turba/scripts/upgrades/convert_datatree_shares_to_sql.php
turba/scripts/upgrades/public_to_horde_share.php

index 51a0315..747f767 100755 (executable)
@@ -9,22 +9,14 @@
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 */
 
-// 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());
 }
index e97c16e..291f192 100755 (executable)
@@ -9,21 +9,10 @@
 * @author Vijay Mahrra <webmaster@stain.net>
 */
 
-// 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);
index 871e481..59d4d9b 100755 (executable)
@@ -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',
index b485df3..e024518 100755 (executable)
@@ -9,21 +9,10 @@
 * @author Vijay Mahrra <webmaster@stain.net>
 */
 
-// 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'));
index 9605713..e64acb9 100755 (executable)
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 */
 
-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 */
index 767d08b..2c7fdf2 100644 (file)
@@ -9,20 +9,10 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  */
 
-// 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 ''",
index d7bd97c..56d276a 100755 (executable)
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 */
 
-// 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) {
index 4d09647..ed96e42 100755 (executable)
@@ -9,20 +9,10 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  */
 
-// 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 = ?');
index 5e8853b..72e753a 100644 (file)
@@ -9,20 +9,10 @@
  * @author Michael J. Rubinsky <mrubinsk@horde.org>
  */
 
-// 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 = ?');
index abfca3c..4fa450a 100644 (file)
@@ -97,20 +97,25 @@ class Horde_Registry
      * @param array $args  Optional arguments:
      * <pre>
      * '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
      * </pre>
      *
      * @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();
         }
index 23ee796..9f839f1 100755 (executable)
@@ -9,20 +9,8 @@
  * @author Jan Schneider <jan@horde.org>
  */
 
-// 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'])) {
index fe5fc1c..9eca150 100755 (executable)
@@ -9,22 +9,10 @@
  * @author Chuck Hagenbuch <chuck@horde.org>
  */
 
-// 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');
 
index 6e34610..8b325f4 100755 (executable)
  * @author Ben Chavet <ben@horde.org>
  */
 
-// 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
index 670fcb6..b2b4ea0 100644 (file)
@@ -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'));
index 7f1f3c2..b42dffb 100755 (executable)
  */
 
 // 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.
index 711edd8..42a3a43 100755 (executable)
@@ -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(
index 6cf1299..661c462 100755 (executable)
@@ -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'));
index 9ad3cde..27077c3 100755 (executable)
@@ -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();
index 145562e..394f098 100755 (executable)
@@ -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');
 
index 21e60ef..d0d5b6c 100755 (executable)
@@ -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();
index 7ef41f1..54a662c 100755 (executable)
@@ -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')));
index bedc0da..c410f66 100755 (executable)
@@ -2,17 +2,7 @@
 <?php
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-$hylax = Horde_Registry::appInit('hylax', 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. */
-$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);
index 6aec1ed..3fa18da 100755 (executable)
@@ -2,17 +2,7 @@
 <?php
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-$hylax = Horde_Registry::appInit('hylax', 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. */
-$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) {
index 75921e5..35f87b0 100755 (executable)
@@ -2,19 +2,10 @@
 <?php
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-$hylax = Horde_Registry::appInit('hylax', 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. */
-$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);
index 3e7a1f1..4615aa1 100755 (executable)
@@ -2,17 +2,7 @@
 <?php
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-$hylax = Horde_Registry::appInit('hylax', 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. */
-$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);
index 99665a1..a228a73 100755 (executable)
@@ -2,14 +2,7 @@
 <?php
 
 require_once dirname(__FILE__) . '/../lib/Application.php';
-$hylax = Horde_Registry::appInit('hylax', 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");
-}
-
-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');
index e3c098c..d7c3e0e 100755 (executable)
  * @author Jan Schneider <jan@horde.org>
  */
 
-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);
index e3af947..2eaf1e0 100755 (executable)
  */
 
 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);
-
 
 /**
  */
index 82f5270..3acf249 100755 (executable)
  * @author Jan Schneider <jan@horde.org>
  */
 
-$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());
 
index 5b46ec2..e6310d4 100755 (executable)
 
 // 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')) {
index efd5c43..a92d769 100755 (executable)
@@ -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']);
index 8911667..099c0a5 100755 (executable)
@@ -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') {
index 7fabdf3..28b41de 100755 (executable)
  * @author Jan Schneider <jan@horde.org>
  */
 
-// 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());
 
index e28335d..444d769 100755 (executable)
 
 // 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";
index a74d320..9460d8d 100755 (executable)
@@ -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';
index e65442b..9cb7cfa 100755 (executable)
 
 // 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 ***");
index 7cfe548..6b64e73 100755 (executable)
 
 // 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))) {
index 298d744..f45ef16 100755 (executable)
 
 // 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')) {
index 9d27c03..c1e062c 100755 (executable)
 
 // 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));
index edfc05c..bcbc64f 100755 (executable)
@@ -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';
index 8c9c832..ad4c1dc 100755 (executable)
 
 // 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';
index edcd838..b42fece 100755 (executable)
@@ -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'])) {
index 4612623..607c1c8 100755 (executable)
@@ -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';
index 0aefe9f..a69e27c 100755 (executable)
@@ -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';
index 9374efc..1cf4000 100755 (executable)
 
 // 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'));