Some H4 updates
authorMichael M Slusarz <slusarz@curecanti.org>
Wed, 28 Jul 2010 22:56:41 +0000 (16:56 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Thu, 29 Jul 2010 17:27:56 +0000 (11:27 -0600)
horde/scripts/import_squirrelmail_file_prefs.php
horde/scripts/import_squirrelmail_sql_prefs.php
horde/scripts/upgrades/migrate_user_categories.php

index db75dd7..bd284f2 100755 (executable)
@@ -53,13 +53,11 @@ foreach($files as $file) {
 
     // Set current user
     $user = substr(basename($file), 0, -5);
-    Horde_Auth::setAuth($user, array());
+    $registry->setAuth($user, array());
     $cli->message('Importing ' . $user . '\'s preferences');
 
     // Reset user prefs
-    unset($prefs);
     $prefs = Horde_Prefs::factory($conf['prefs']['driver'], 'horde', $user, null, null, false);
-    unset($prefs_cache);
     $prefs_cache = array();
 
     // Read pref file, one line at a time
@@ -79,8 +77,7 @@ foreach($files as $file) {
             $value = substr($pref, $equalsAt + 1);
             /* this is to 'rescue' old-style highlighting rules. */
             if (substr($key, 0, 9) == 'highlight') {
-                $key = 'highlight' . $highlight_num;
-                $highlight_num ++;
+                $key = 'highlight' . $highlight_num++;
             }
 
             if ($value != '') {
index c6c3b4a..8f48995 100755 (executable)
@@ -31,15 +31,16 @@ require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
 
 // Connect to database.
 $db = DB::connect($dsn);
-if (is_a($db, 'PEAR_Error')) {
+if ($db instanceof PEAR_Error) {
     $cli->fatal($db->toString());
 }
 
 // Loop through SquirrelMail address books.
 $handle = $db->query('SELECT user, prefkey, prefval FROM userprefs ORDER BY user');
-if (is_a($handle, 'PEAR_Error')) {
+if ($handle instanceof PEAR_Error) {
     $cli->fatal($handle->toString());
 }
+
 $user = null;
 $prefs_cache = array();
 while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
@@ -54,13 +55,14 @@ while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
 
     $prefs_cache[$row['prefkey']] = $row['prefval'];
 }
+
 importPrefs();
 
 function importPrefs()
 {
     global $cli, $conf, $user, $prefs_cache;
 
-    Horde_Auth::setAuth($user, array());
+    $GLOBALS['registry']->setAuth($user, array());
     $cli->message('Importing ' . $user . '\'s preferences');
     $prefs = Horde_Prefs::factory($conf['prefs']['driver'], 'horde', $user, null, null, false);
     savePrefs($user, null, $prefs_cache);
index c5bb4a6..8219860 100755 (executable)
@@ -30,7 +30,7 @@ foreach ($users as $user) {
     echo 'Migrating prefs for ' . $cli->bold($user);
 
     // Set $user as the current user.
-    Horde_Auth::setAuth($user, array(), '');
+    $registry->setAuth($user, array());
 
     // Fetch current categories and colors.
     $colors = $cManager->colors();