summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2009-07-02 08:40:56 +0000
committerthomascube <thomas@roundcube.net>2009-07-02 08:40:56 +0000
commit2a4abc1286ee57b804996a1c9fe410b5b9837ef3 (patch)
treebfe1b844dc94bab41fedb30e987ae91c282d97df /plugins
parent07722a2d1d9e4ff6e04a9b34a8ba42e4c4a66606 (diff)
Plugin to copy user prefs from a Qquirrelmail installation (when a new user is registered)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/password/config.inc.php4
-rw-r--r--plugins/squirrelmail_usercopy/config.inc.php.dist5
-rw-r--r--plugins/squirrelmail_usercopy/squirrelmail_usercopy.php91
3 files changed, 98 insertions, 2 deletions
diff --git a/plugins/password/config.inc.php b/plugins/password/config.inc.php
index 1b964e3fc..3945ea098 100644
--- a/plugins/password/config.inc.php
+++ b/plugins/password/config.inc.php
@@ -3,7 +3,7 @@
// Password Plugin options
// -----------------------
// A driver to use for password change. Default: "sql".
-$rcmail_config['password_driver'] = 'poppassd';
+$rcmail_config['password_driver'] = 'sasl';
// Determine whether current password is required to change password.
// Default: false.
@@ -41,7 +41,7 @@ $rcmail_config['password_pop_port'] = 106;
// SASL Driver options
// -------------------
// Additional arguments for the saslpasswd2 call
-$rcmail_config['password_saslpasswd_args'] = '';
+$rcmail_config['password_saslpasswd_args'] = '-u rolig';
// LDAP Driver options
diff --git a/plugins/squirrelmail_usercopy/config.inc.php.dist b/plugins/squirrelmail_usercopy/config.inc.php.dist
new file mode 100644
index 000000000..5c2560f15
--- /dev/null
+++ b/plugins/squirrelmail_usercopy/config.inc.php.dist
@@ -0,0 +1,5 @@
+<?php
+
+// full path to the squirrelmail data directory
+$rcmail_config['squirrelmail_data_dir'] = '';
+
diff --git a/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php
new file mode 100644
index 000000000..cc44f35e4
--- /dev/null
+++ b/plugins/squirrelmail_usercopy/squirrelmail_usercopy.php
@@ -0,0 +1,91 @@
+<?php
+
+/**
+ * Copy a new users identity and settings from a nearby Squirrelmail installation
+ *
+ * Currently only file-based data storage of Squirrelmail is supported.
+ *
+ * @version 1.0
+ * @author Thomas Bruederli
+ */
+class squirrelmail_usercopy extends rcube_plugin
+{
+ private $prefs = null;
+ private $abook = array();
+
+ public function init()
+ {
+ $this->add_hook('create_user', array($this, 'create_user'));
+ $this->add_hook('create_identity', array($this, 'create_identity'));
+ }
+
+ public function create_user($p)
+ {
+ // read prefs and add email address
+ $this->read_squirrel_prefs($p['user']);
+ if ($this->prefs['email_address'])
+ $p['user_email'] = $this->prefs['email_address'];
+
+ return $p;
+ }
+
+ public function create_identity($p)
+ {
+ // only execute on login
+ if ($p['login'] && $this->prefs) {
+ if ($this->prefs['full_name'])
+ $p['record']['name'] = $this->prefs['full_name'];
+ if ($this->prefs['email_address'])
+ $p['record']['email'] = $this->prefs['email_address'];
+ if ($this->prefs['signature'])
+ $p['record']['signature'] = $this->prefs['signature'];
+
+ // copy address book
+ $rcmail = rcmail::get_instance();
+ $contacts = $rcmail->get_address_book(null, true);
+ if ($contacts && count($this->abook)) {
+ foreach ($this->abook as $rec)
+ $contacts->insert($rec, true);
+ }
+ }
+
+ return $p;
+ }
+
+ private function read_squirrel_prefs($uname)
+ {
+ $this->load_config();
+ $rcmail = rcmail::get_instance();
+
+ if ($srcdir = $rcmail->config->get('squirrelmail_data_dir')) {
+ $prefsfile = slashify($srcdir) . $uname . '.pref';
+ $abookfile = slashify($srcdir) . $uname . '.abook';
+ $sigfile = slashify($srcdir) . $uname . '.sig';
+
+ if (is_readable($prefsfile)) {
+ $this->prefs = array();
+ foreach (file($prefsfile) as $line) {
+ list($key, $value) = explode('=', $line);
+ $this->prefs[$key] = utf8_encode(rtrim($value));
+ }
+
+ // also read signature file if exists
+ if (is_readable($sigfile)) {
+ $this->prefs['signature'] = utf8_encode(file_get_contents($sigfile));
+ }
+
+ // parse addres book file
+ if (filesize($abookfile)) {
+ foreach(file($abookfile) as $line) {
+ list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
+ if ($rec['name'] && $rec['email'])
+ $this->abook[] = $rec;
+ }
+ }
+ }
+ }
+ }
+
+}
+
+?> \ No newline at end of file