Clean up horde/scripts directory
authorMichael M Slusarz <slusarz@curecanti.org>
Fri, 28 Jan 2011 19:27:15 +0000 (12:27 -0700)
committerMichael M Slusarz <slusarz@curecanti.org>
Fri, 28 Jan 2011 20:14:47 +0000 (13:14 -0700)
1st attempt at cleaning up squirrelmail import script (no idea if it
still works or not)
Convert set_perms to a PHP script.

horde/bin/import/import_squirrelmail_prefs [new file with mode: 0755]
horde/bin/set_perms [new file with mode: 0755]
horde/scripts/SCRIPTS
horde/scripts/import_squirrelmail_file_prefs.php [deleted file]
horde/scripts/import_squirrelmail_prefs.php [deleted file]
horde/scripts/import_squirrelmail_sql_prefs.php [deleted file]
horde/scripts/set_perms.sh [deleted file]

diff --git a/horde/bin/import/import_squirrelmail_prefs b/horde/bin/import/import_squirrelmail_prefs
new file mode 100755 (executable)
index 0000000..f5712d6
--- /dev/null
@@ -0,0 +1,431 @@
+#!/usr/bin/env php
+<?php
+/**
+ * This script imports SquirrelMail file-based preferences into Horde.
+ * It was developed against SquirrelMail 1.4.0, so use at your own risk
+ * against different versions.
+ *
+ * Input can be either a single squirrelmail .pref file, or a directory
+ * containing multiple .pref files.
+ *
+ * Copyright 2007-2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Ben Chavet <ben@horde.org>
+ * @author   Jan Schneider <jan@horde.org>
+ * @author   Michael Slusarz <jan@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Horde
+ */
+
+require_once dirname(__FILE__) . '/../../lib/Application.php';
+Horde_Registry::appInit('horde', array('cli' => true));
+
+// Read command line parameters.
+if ($argc != 2) {
+    SM_Horde_Convert::usage();
+}
+
+if (stripos($argv[1], 'file:') === 0) {
+    $ob = new SM_Horde_Convert_File(substr($argv[1], 5));
+} elseif (stripos($argv[1], 'sql:') === 0) {
+    $ob = new SM_Horde_Convert_Sql(substr($argv[1], 4));
+} else {
+    SM_Horde_Convert::usage();
+}
+
+$ob->convert();
+
+
+class SM_Horde_Convert
+{
+    /**
+     * Print usage and exit.
+     */
+    static public function usage()
+    {
+        global $cli;
+
+        $cli->message('Incorrect parameters.', 'cli.error');
+        $cli->writeln();
+        $cli->writeln('Usage: import_squirrelmail_prefs [data]');
+        $cli->writeln();
+        $cli->writeln('Data types:');
+        $cli->writeln($cli->indent('file:[filename]'));
+        $cli->writeln($cli->indent($cli->indent('filename can be either a file or a directory')));
+        $cli->writeln();
+        $cli->writeln($cli->indent('sql:[DSN]'));
+        $cli->writeln($cli->indent($cli->indent('DSN is to database containing the "userprefs" table. Example:')));
+        $cli->writeln($cli->indent($cli->indent('mysql://root:password@localhost/squirrelmail')));
+        exit;
+    }
+
+    /**
+     */
+    public function convert()
+    {
+    }
+
+    /**
+     * Returns the horde pref value(s) that correspond with the given
+     * squirrelmail pref.
+     *
+     * @return mixed  Array of pref arrays ('name', 'scope', 'value').
+     *                False if there is no horde pref equivalent, or the horde
+     *                default should be used.
+     */
+    private function _translate($sm_pref_name, $sm_pref_value)
+    {
+        switch ($sm_pref_name) {
+        case 'compose_new_win':
+            return array(array('name' => 'compose_popup', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'draft_folder':
+            if ($sm_pref_value != '[ ' . _("Do not use Drafts") . ' ]') {
+                return array(array('name' => 'drafts_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
+            }
+            break;
+
+        case 'email_address':
+            return array(array('name' => 'from_addr', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'full_name':
+            return array(array('name' => 'fullname', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'hour_format':
+            return array(array('name' => 'twentyFour', 'scope' => 'horde', 'value' => ($sm_pref_value == 1)));
+
+        case 'internal_date_sort':
+            if ($sm_pref_value == 1) {
+                return array(array('name' => 'sortby', 'scope' => 'imp', 'value' => '1'));
+            }
+            break;
+
+        case 'language':
+            return array(array('name' => 'language', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'left_refresh':
+            return array(array('name' => 'menu_refresh_time', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'left_size':
+            return array(array('name' => 'sidebar_width', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'mdn_user_support':
+            $value = 'ask';
+            if ($sm_pref_value == 0) {
+                $value = 'never';
+            }
+            return array(array('name' => 'disposition_request_read',
+                'scope' => 'imp',
+                'value' => $value));
+
+        case 'prefix_sig':
+            return array(array('name' => 'sig_dashes', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'reply_citation_style':
+            switch ($sm_pref_value) {
+            case 'none':
+                return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => ''));
+
+            case 'author_said':
+                return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => '%p wrote'));
+
+            case 'date_time_author':
+                return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => 'On %c, %p wrote'));
+            }
+            break;
+
+        case 'reply_to':
+            return array(array('name' => 'replyto_addr', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'sent_folder':
+            if ($sm_pref_value == '[ ' . _("Do not use Sent") . ' ]') {
+                return array(array('name' => 'save_sent_mail', 'scope' => 'imp', 'value' => '0'));
+            }
+            return array(array('name' => 'save_sent_mail', 'scope' => 'imp', 'value' => '1'),
+                array('name' => 'sent_mail_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'show_num':
+            return array(array('name' => 'max_msgs', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'show_xmailer_default':
+            if ($sm_pref_value == 1) {
+                $GLOBALS['registry']->pushApp('imp');
+                $value = "X-Mailer\n" . $GLOBALS['prefs']->getValue('mail_hdr');
+                $GLOBALS['registry']->popApp();
+                return array(array('name' => 'mail_hdr', 'scope' => 'imp', 'value' => trim($value)));
+            }
+            break;
+
+        case 'sig_first':
+            return array(array('name' => 'sig_first', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'signature':
+            return array(array('name' => 'signature', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'sort_by_ref':
+            if ($sm_pref_value == 1) {
+                return array(array('name' => 'sortby', 'scope' => 'imp', 'value' => '161'));
+            }
+            break;
+
+        case 'timezone':
+            return array(array('name' => 'timezone', 'scope' => 'horde', 'value' => $sm_pref_value));
+
+        case 'trash_folder':
+            if ($sm_pref_value == '[ ' . _("Do not use Trash") . ' ]') {
+                return array(array('name' => 'use_trash', 'scope' => 'imp', 'value' => '0'));
+            }
+            return array(array('name' => 'use_trash', 'scope' => 'imp', 'value' => '1'),
+                array('name' => 'trash_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
+
+        case 'unseen_notify':
+            if ($sm_pref_value == 2) {
+                return array(array('name' => 'nav_poll_all', 'scope' => 'imp', 'value' => false));
+            } else if ($sm_pref_value == 3) {
+                return array(array('name' => 'nav_poll_all', 'scope' => 'imp', 'value' => true));
+            }
+            break;
+
+        case 'use_signature':
+            if ($sm_pref_value == 0) {
+                return array(array('name' => 'signature', 'scope' => 'imp', 'value' => ''));
+            }
+            break;
+        }
+
+        // The rest of the SquirrelMail options do not translate
+        // Default to no conversion.
+        return false;
+    }
+
+    /**
+     */
+    private function _savePrefs($user, $basename, $prefs_cache)
+    {
+        global $prefs, $registry;
+
+        // Load default SquirrelMail signature
+        $prefs_cache['signature'] = $this->_getSignature($basename);
+
+        // Loop through the SquirrelMail prefs and translate them to Horde
+        // prefs.
+        foreach ($prefs_cache as $key => $val) {
+            $horde_pref = $this->_translate($key, $val);
+            if (!$horde_pref) {
+                continue;
+            }
+
+            foreach ($horde_pref as $pref) {
+                $pushed = $registry->pushApp($pref['scope']);
+                $prefs->setValue($pref['name'], $pref['value']);
+                if ($pushed) {
+                    $registry->popApp();
+                }
+            }
+        }
+
+        // Import identities
+        if (isset($prefs_cache['identities']) &&
+            ($prefs_cache['identities'] > 1)) {
+            $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($user, 'imp');
+
+            // Intentionally off-by-one
+            for ($i = 1; $i < $prefs_cache['identities']; $i++) {
+                $new_identity = array('id' => 'Identity #' . ($i + 1),
+                    'fullname' => $prefs_cache['full_name' . $i],
+                    'replyto_addr' => $prefs_cache['reply_to' . $i],
+                    'from_addr' => $prefs_cache['email_address' . $i],
+                    'signature' => $this->_getSignature($basename, $i));
+                if (isset($prefs_cache['prefix_sig'])) {
+                    $new_identity['sig_dashes'] = $prefs_cache['prefix_sig'];
+                }
+                if (isset($prefs_cache['sig_first'])) {
+                    $new_identity['sig_first'] = $prefs_cache['sig_first'];
+                }
+                if (isset($prefs_cache['sent_folder'])) {
+                    if ($prefs_cache['sent_folder'] == '[ ' . _("Do not use Sent") . ' ]') {
+                        $new_identity['save_sent_mail'] = 0;
+                    } else {
+                        $new_identity['save_sent_mail'] = 1;
+                    }
+                }
+                $identity->add($new_identity);
+            }
+            $identity->save();
+        }
+    }
+
+    /**
+     */
+    private function _getSignature()
+    {
+        return '';
+    }
+
+}
+
+
+class SM_Horde_Convert_File extends SM_Horde_Convert
+{
+    private $_files;
+
+    /**
+     */
+    public function __construct($data)
+    {
+        // Get list of SquirrelMail pref files
+        $this->_files = is_dir($data)
+            ? glob(rtrim($data, '/') . "/*.pref")
+            : array($data);
+    }
+
+    /**
+     */
+    public function convert()
+    {
+        // Loop through SquirrelMail pref files
+        foreach ($this->_files as $file) {
+            if (!($handle = fopen($file, 'r'))) {
+                continue;
+            }
+
+            // Set current user
+            $user = substr(basename($file), 0, -5);
+            $GLOBALS['registry']->setAuth($user, array());
+            $GLOBALS['cli']->message('Importing ' . $user . '\'s preferences');
+
+            // Reset user prefs
+            $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('horde', array(
+                'cache' => false,
+                'user' => $user
+            ));
+            $prefs_cache = array();
+
+            // Read pref file, one line at a time
+            while (!feof($handle)) {
+                $buffer = fgets($handle);
+                if (empty($buffer)) {
+                    continue;
+                }
+
+                /**
+                 * BEGIN: Code from squirrelmail to parse pref (GPL)
+                 */
+                $pref = trim($buffer);
+                $equalsAt = strpos($pref, '=');
+                if ($equalsAt > 0) {
+                    $key = substr($pref, 0, $equalsAt);
+                    $value = substr($pref, $equalsAt + 1);
+                    /* this is to 'rescue' old-style highlighting rules. */
+                    if (substr($key, 0, 9) == 'highlight') {
+                        $key = 'highlight' . $highlight_num++;
+                    }
+
+                    if ($value != '') {
+                        $prefs_cache[$key] = $value;
+                    }
+                }
+                /**
+                 * END: Code from squirrelmail to parse pref (GPL)
+                 */
+            }
+
+            fclose($handle);
+
+            $this->_savePrefs($user, substr($file, 0, -5), $prefs_cache);
+        }
+    }
+
+    /**
+     */
+    private function _getSignature($basename, $number = 'g')
+    {
+        $sigfile = $basename . '.si' . $number;
+
+        return file_exists($sigfile)
+            ? file_get_contents($sigfile)
+            : '';
+    }
+
+}
+
+
+class SM_Horde_Convert_Sql extends SM_Horde_Convert
+{
+    private $_cache;
+    private $_db;
+
+    /**
+     */
+    public function __construct($dsn)
+    {
+        // Connect to database.
+        $this->_db = DB::connect($dsn);
+        if ($this->_db instanceof PEAR_Error) {
+            $GLOBALS['cli']->fatal($this->_db->toString());
+        }
+    }
+
+    /**
+     */
+    public function convert()
+    {
+        // Loop through SquirrelMail address books.
+        $handle = $this->_db->query('SELECT user, prefkey, prefval FROM userprefs ORDER BY user');
+        if ($handle instanceof PEAR_Error) {
+            $GLOBALS['cli']->fatal($handle->toString());
+        }
+
+        $user = null;
+        $prefs_cache = array();
+
+        while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
+            if (is_null($user)) {
+                $user = $row['user'];
+            }
+            if ($row['user'] != $user) {
+                $this->_importPrefs($user, $prefs_cache);
+                $prefs_cache = array();
+                $user = $row['user'];
+            }
+
+            $prefs_cache[$row['prefkey']] = $row['prefval'];
+        }
+
+        $this->_importPrefs($user, $prefs_cache);
+    }
+
+    /**
+     */
+    private function _importPrefs($user, $prefs_cache)
+    {
+        global $cli, $conf, $injector, $registry;
+
+        $registry->setAuth($user, array());
+        $cli->message('Importing ' . $user . '\'s preferences');
+
+        $prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('horde', array(
+            'cache' => false,
+            'user' => $user
+        ));
+
+        $this->_cache = $prefs_cache;
+        $this->_savePrefs($user, null, $prefs_cache);
+    }
+
+    /**
+     */
+    private function _getSignature($basename, $number = 'nature')
+    {
+        $key = '___sig' . $number . '___';
+
+        return isset($this->_cache[$key])
+            ? $this->_cache[$key]
+            : '';
+    }
+
+}
diff --git a/horde/bin/set_perms b/horde/bin/set_perms
new file mode 100755 (executable)
index 0000000..a5ce885
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/env php
+<?php
+/**
+ * This script will set the permissions on your Horde tree so that the files
+ * will be accessible by the web server.
+ *
+ * Copyright 2011 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (LGPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
+ *
+ * @author   Michael Slusarz <slusarz@horde.org>
+ * @category Horde
+ * @license  http://www.fsf.org/copyleft/lgpl.html LGPL
+ * @package  Horde
+ */
+
+require_once dirname(__FILE__) . '/../lib/Application.php';
+Horde_Registry::appInit('horde', array(
+    'authentication' => 'none',
+    'cli' => true
+));
+
+$cli->message('Horde directory: ' . realpath(HORDE_BASE), 'cli.message');
+
+$owner = $cli->prompt(
+    'Owner of Horde files?',
+    null,
+    'root'
+);
+
+$group = $cli->prompt(
+    'Group under which web server/PHP runs?',
+    null,
+    'nobody'
+);
+
+$cli->writeln();
+
+if ($cli->prompt($cli->red('Are you sure you want to alter permissions?'), array('y' => 'Yes', 'n' => 'No'), 'n') == 'y') {
+    $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(realpath(HORDE_BASE)));
+    foreach ($it as $key => $val) {
+        if (!$it->isDot()) {
+            if ($val->getOwner() != $owner) {
+                $cli->message('Changing owner for ' . $key, 'cli.message');
+                chown($key, $owner);
+            }
+
+            if ($val->getGroup() != $group) {
+                $cli->message('Changing group for ' . $key, 'cli.message');
+                chgrp($key, $group);
+            }
+
+            $octal_perms = substr(sprintf('%o', $val->getPerms()), -4);
+
+            if ($val->isDir()) {
+                if ($octal_perms != 0750) {
+                    $cli->message('Changing permissions for ' . $key, 'cli.message');
+                    chmod($key, 0750);
+                }
+            } elseif ($val->isFile()) {
+                if ($octal_perms != 0640) {
+                    $cli->message('Changing permissions for ' . $key, 'cli.message');
+                    chmod($key, 0640);
+                }
+            }
+        }
+    }
+}
index 22758d8..1843d2a 100644 (file)
@@ -4,36 +4,36 @@
 
 Introduction
 ~~~~~~~~~~~~
+
 This directory contains various utility scripts for the Horde distribution.
 They are here for your convenience.
 
 
 Script Index
 ~~~~~~~~~~~~
+
+ldap/
+
+    LDAP utilities/scripts
+
+sql/
+
+    SQL utilities/scripts
+
 cookie_login.php
+
     Allows to login with user credentials provided by cookies.
 
 get_login.php
+
     Allows to login with user credentials provided by GET parameters.
 
 http_login_refer.php
-    tbd
 
-set_perms.sh
-    Sets file ownership and permissions on the Horde tree for high security.
+    TODO
 
 temp-cleanup.cron
+
     An example cron job shell script which will clean up any temporary files
     which may get stranded by Horde users in the web server's temporary
     directory.
-
-
-Database Scripts
-~~~~~~~~~~~~~~~~
-Database table schemas and associated utility scripts are located in the sql/
-subdirectory.
-
-
-LDAP Schemas
-~~~~~~~~~~~~
-LDAP schemas are located in the ldap/ subdirectory.
diff --git a/horde/scripts/import_squirrelmail_file_prefs.php b/horde/scripts/import_squirrelmail_file_prefs.php
deleted file mode 100755 (executable)
index 8396417..0000000
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * This script imports SquirrelMail file-based preferences into Horde.
- * It was developed against SquirrelMail 1.4.0, so use at your own risk
- * against different versions.
- *
- * Input can be either a single squirrelmail .pref file, or a directory
- * containing multiple .pref files.
- *
- * Copyright 2007-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Ben Chavet <ben@horde.org>
- */
-
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('horde', array('cli' => true));
-
-// Read command line parameters.
-if ($argc != 2) {
-    $cli->message('Too many or too few parameters.', 'cli.error');
-    $cli->writeln('Usage: import_squirrelmail_prefs.php path-to-squirrelmail-data');
-    exit;
-}
-$data = $argv[1];
-
-require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
-
-// Get list of SquirrelMail pref files
-if (is_dir($data)) {
-    $files = array();
-    if (!($handle = opendir($data))) {
-        exit;
-    }
-    while (false !== ($file = readdir($handle))) {
-        if (preg_match('/.pref$/', $file)) {
-            $files[] = $data . '/' . $file;
-        }
-    }
-    closedir($handle);
-} else {
-    $files = array($data);
-}
-
-// Loop through SquirrelMail pref files
-foreach($files as $file) {
-    if (!($handle = fopen($file, 'r'))) {
-        continue;
-    }
-
-    // Set current user
-    $user = substr(basename($file), 0, -5);
-    $registry->setAuth($user, array());
-    $cli->message('Importing ' . $user . '\'s preferences');
-
-    // Reset user prefs
-    $prefs = $injector->getInstance('Horde_Core_Factory_Prefs')->create('horde', array(
-        'cache' => false,
-        'user' => $user
-    ));
-    $prefs_cache = array();
-
-    // Read pref file, one line at a time
-    while (!feof($handle)) {
-        $buffer = fgets($handle);
-        if (empty($buffer)) {
-            continue;
-        }
-
-        /**
-         * BEGIN: Code from squirrelmail to parse pref (GPL)
-         */
-        $pref = trim($buffer);
-        $equalsAt = strpos($pref, '=');
-        if ($equalsAt > 0) {
-            $key = substr($pref, 0, $equalsAt);
-            $value = substr($pref, $equalsAt + 1);
-            /* this is to 'rescue' old-style highlighting rules. */
-            if (substr($key, 0, 9) == 'highlight') {
-                $key = 'highlight' . $highlight_num++;
-            }
-
-            if ($value != '') {
-                $prefs_cache[$key] = $value;
-            }
-        }
-        /**
-         * END: Code from squirrelmail to parse pref (GPL)
-         */
-    }
-
-    fclose($handle);
-
-    savePrefs($user, substr($file, 0, -5), $prefs_cache);
-}
-
-function getSignature($basename, $number = 'g')
-{
-    $sigfile = $basename . '.si' . $number;
-    $signature = '';
-    if (file_exists($sigfile)) {
-        if ($handle = @fopen($sigfile, 'r')) {
-            while (!feof($handle)) {
-                $signature .= fgets($handle, 1024);
-            }
-            fclose($handle);
-        }
-    }
-    return $signature;
-}
diff --git a/horde/scripts/import_squirrelmail_prefs.php b/horde/scripts/import_squirrelmail_prefs.php
deleted file mode 100644 (file)
index 34e8ac7..0000000
+++ /dev/null
@@ -1,211 +0,0 @@
-<?php
-/**
- * Support functions for importing SquirreMail preferences.
- *
- * @author Ben Chavet <ben@horde.org>
- */
-
-function savePrefs($user, $basename, $prefs_cache)
-{
-    global $prefs;
-
-    // Load default SquirrelMail signature
-    $prefs_cache['signature'] = getSignature($basename);
-
-    // Loop through the SquirrelMail prefs and translate them to Horde prefs
-    foreach ($prefs_cache as $key => $val) {
-        $horde_pref = convert($key, $val);
-        if (!$horde_pref) {
-            continue;
-        }
-        foreach ($horde_pref as $pref) {
-            $prefs->retrieve($pref['scope']);
-            $prefs->setValue($pref['name'], $pref['value']);
-        }
-    }
-
-    // Import identities
-    if (isset($prefs_cache['identities']) && $prefs_cache['identities'] > 1) {
-        $identity = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Identity')->create($user, 'imp');
-        // Intentionally off-by-one
-        for ($i = 1; $i < $prefs_cache['identities']; $i++) {
-            $new_identity = array('id' => 'Identity #' . ($i + 1),
-                                  'fullname' => $prefs_cache['full_name' . $i],
-                                  'replyto_addr' => $prefs_cache['reply_to' . $i],
-                                  'from_addr' => $prefs_cache['email_address' . $i],
-                                  'signature' => getSignature($basename, $i));
-            if (isset($prefs_cache['prefix_sig'])) {
-                $new_identity['sig_dashes'] = $prefs_cache['prefix_sig'];
-            }
-            if (isset($prefs_cache['sig_first'])) {
-                $new_identity['sig_first'] = $prefs_cache['sig_first'];
-            }
-            if (isset($prefs_cache['sent_folder'])) {
-                if ($prefs_cache['sent_folder'] == '[ ' . _("Do not use Sent") . ' ]') {
-                    $new_identity['save_sent_mail'] = 0;
-                } else {
-                    $new_identity['save_sent_mail'] = 1;
-                }
-            }
-            $identity->add($new_identity);
-        }
-        $identity->save();
-    }
-
-    // Store prefs
-    $prefs->store();
-}
-
-/**
- * Returns the horde pref value(s) that correspond with the given squirrelmail
- * pref.
- *
- * @return array of pref arrays ('name', 'scope', 'value').
- *         false if there is no horde pref equivalent, or the horde default
- *           should be used.
- */
-function convert($sm_pref_name, $sm_pref_value)
-{
-
-    switch ($sm_pref_name) {
-
-    case 'compose_new_win':
-        return array(array('name' => 'compose_popup', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'draft_folder':
-        if ($sm_pref_value != '[ ' . _("Do not use Drafts") . ' ]') {
-            return array(array('name' => 'drafts_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
-        }
-        break;
-
-    case 'email_address':
-        return array(array('name' => 'from_addr', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    case 'full_name':
-        return array(array('name' => 'fullname', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    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'));
-        }
-        break;
-
-    case 'language':
-        return array(array('name' => 'language', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    case 'left_refresh':
-        return array(array('name' => 'menu_refresh_time', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    case 'left_size':
-        return array(array('name' => 'sidebar_width', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    case 'mdn_user_support':
-        $value = 'ask';
-        if ($sm_pref_value == 0) {
-            $value = 'never';
-        }
-        return array(array('name' => 'disposition_request_read',
-                           'scope' => 'imp',
-                           'value' => $value));
-        break;
-
-    case 'prefix_sig':
-        return array(array('name' => 'sig_dashes', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'reply_citation_style':
-        switch ($sm_pref_value) {
-        case 'none':
-            return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => ''));
-            break;
-        case 'author_said':
-            return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => '%p wrote'));
-            break;
-        case 'date_time_author':
-            return array(array('name' => 'attrib_text', 'scope' => 'imp', 'value' => 'On %c, %p wrote'));
-            break;
-        }
-        break;
-
-    case 'reply_to':
-        return array(array('name' => 'replyto_addr', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'sent_folder':
-        if ($sm_pref_value == '[ ' . _("Do not use Sent") . ' ]') {
-            return array(array('name' => 'save_sent_mail', 'scope' => 'imp', 'value' => '0'));
-        }
-        return array(array('name' => 'save_sent_mail', 'scope' => 'imp', 'value' => '1'),
-                     array('name' => 'sent_mail_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'show_num':
-        return array(array('name' => 'max_msgs', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'show_xmailer_default':
-        if ($sm_pref_value == 1) {
-            $GLOBALS['prefs']->retrieve('imp');
-            $value = "X-Mailer\n" . $GLOBALS['prefs']->getValue('mail_hdr');
-            return array(array('name' => 'mail_hdr', 'scope' => 'imp', 'value' => trim($value)));
-        }
-        break;
-
-    case 'sig_first':
-        return array(array('name' => 'sig_first', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'signature':
-        return array(array('name' => 'signature', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'sort_by_ref':
-        if ($sm_pref_value == 1) {
-            return array(array('name' => 'sortby', 'scope' => 'imp', 'value' => '161'));
-        }
-        break;
-
-    case 'timezone':
-        return array(array('name' => 'timezone', 'scope' => 'horde', 'value' => $sm_pref_value));
-        break;
-
-    case 'trash_folder':
-        if ($sm_pref_value == '[ ' . _("Do not use Trash") . ' ]') {
-            return array(array('name' => 'use_trash', 'scope' => 'imp', 'value' => '0'));
-        }
-        return array(array('name' => 'use_trash', 'scope' => 'imp', 'value' => '1'),
-                     array('name' => 'trash_folder', 'scope' => 'imp', 'value' => $sm_pref_value));
-        break;
-
-    case 'unseen_notify':
-        if ($sm_pref_value == 2) {
-            return array(array('name' => 'nav_poll_all', 'scope' => 'imp', 'value' => false));
-        } else if ($sm_pref_value == 3) {
-            return array(array('name' => 'nav_poll_all', 'scope' => 'imp', 'value' => true));
-        }
-        break;
-
-    case 'use_signature':
-        if ($sm_pref_value == 0) {
-            return array(array('name' => 'signature', 'scope' => 'imp', 'value' => ''));
-        }
-        break;
-
-    // The rest of the SquirrelMail options do not translate
-    default:
-        return false;
-    }
-
-    // Default to no conversion.
-    return false;
-}
diff --git a/horde/scripts/import_squirrelmail_sql_prefs.php b/horde/scripts/import_squirrelmail_sql_prefs.php
deleted file mode 100755 (executable)
index d623f83..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/usr/bin/env php
-<?php
-/**
- * This script imports SquirrelMail database preferences into Horde.
- *
- * The first argument must be a DSN to the database containing the "userprefs"
- * table, e.g.: "mysql://root:password@localhost/squirrelmail".
- *
- * Copyright 2008-2010 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- * @author Ben Chavet <ben@horde.org>
- * @author Jan Schneider <jan@horde.org>
- */
-
-// Do CLI checks and environment setup first.
-require_once dirname(__FILE__) . '/../lib/Application.php';
-Horde_Registry::appInit('horde', array('cli' => true));
-
-// Read command line parameters.
-if ($argc != 2) {
-    $cli->message('Too many or too few parameters.', 'cli.error');
-    $cli->writeln('Usage: import_squirrelmail_prefs.php DSN');
-    exit;
-}
-$dsn = $argv[1];
-
-require_once dirname(__FILE__) . '/import_squirrelmail_prefs.php';
-
-// Connect to database.
-$db = DB::connect($dsn);
-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 ($handle instanceof PEAR_Error) {
-    $cli->fatal($handle->toString());
-}
-
-$user = null;
-$prefs_cache = array();
-while ($row = $handle->fetchRow(DB_FETCHMODE_ASSOC)) {
-    if (is_null($user)) {
-        $user = $row['user'];
-    }
-    if ($row['user'] != $user) {
-        importPrefs();
-        $prefs_cache = array();
-        $user = $row['user'];
-    }
-
-    $prefs_cache[$row['prefkey']] = $row['prefval'];
-}
-
-importPrefs();
-
-function importPrefs()
-{
-    global $cli, $conf, $user, $prefs_cache;
-
-    $GLOBALS['registry']->setAuth($user, array());
-    $cli->message('Importing ' . $user . '\'s preferences');
-    $prefs = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Prefs')->create('horde', array(
-        'cache' => false,
-        'user' => $user
-    ));
-    savePrefs($user, null, $prefs_cache);
-}
-
-function getSignature($basename, $number = 'nature')
-{
-    global $prefs_cache;
-
-    $key = '___sig' . $number . '___';
-    return isset($prefs_cache[$key]) ? $prefs_cache[$key] : '';
-}
diff --git a/horde/scripts/set_perms.sh b/horde/scripts/set_perms.sh
deleted file mode 100755 (executable)
index ceec813..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-#!/bin/sh
-#
-# set_perms.sh - Jon Parise <jon@csh.rit.edu>
-#
-# "Dangerous" PHP scripts
-#
-DANGEROUS_FILES="test.php"
-
-# Default non-web server user who will own the tree.
-#
-OWNER=root
-
-# Introductory text
-#
-cat << EOF
-
-This script will set the permissions on your Horde
-tree so that the files will be accessible by the web
-server.
-
-You can cancel this script at any time using Ctrl-C.
-
-EOF
-
-# Verify that we're at the top of the Horde tree.
-#
-pwd
-echo
-echo -n "Is this directory the top of your Horde installation? [y,N] "
-read RESPONSE
-if [ "$RESPONSE" != "y" -a "$RESPONSE" != "Y" ]; then
-    echo
-    echo -n "Enter your Horde directory: "
-    read DIR
-       if [ "x$DIR" = "x" ]; then
-               echo "Exiting..."
-               exit
-       else
-       cd $DIR
-       fi
-fi
-echo
-
-# Get the web server's group.
-#
-echo -n "Under what group does the web process run? [nobody] "
-read WEB_GROUP
-if [ "x$WEB_GROUP" = "x" ]; then
-    WEB_GROUP="nobody"
-fi
-
-# Ask before proceeding.
-#
-echo
-echo -n "Proceed with changing ownership and permissions? [y,N] "
-read RESPONSE
-if [ "$RESPONSE" != 'y' -a "$RESPONSE" != 'Y' ]; then
-    echo "Exiting..."
-    exit
-fi
-
-# Set the user and group ownership recursively.
-#
-echo
-echo -n "Setting ownership recursively... "
-chown -R $OWNER .
-chgrp -R $WEB_GROUP .
-echo "done."
-
-# Set the permissions on files (0640) and directories (0750).
-#
-echo -n "Setting permissions recursively... "
-find . -type f -exec chmod 0640 {} \;
-find . -type d -exec chmod 0750 {} \;
-echo "done."
-
-# Disable any "dangerous" PHP scripts in the distribution (0000).
-#
-echo -n "Disabling potentially \"dangerous\" PHP scripts... "
-for FILE in $DANGEROUS_FILES; do
-       if [ -f $FILE ]; then
-               chmod 0000 $FILE
-       fi
-done
-echo "done."
-
-# Say good-bye.
-#
-echo
-echo "If you received any errors, you may not have sufficient access"
-echo "to change file ownership and permissions."
-echo