Roundcube Community Forum

News and Announcements => General Discussion => Topic started by: spo0lsh on May 31, 2013, 01:51:10 PM

Title: default value in users.preferences
Post by: spo0lsh on May 31, 2013, 01:51:10 PM
Hello,
How to I can set default preferences in table `users.preferences` when user first login to webmail?
I not found any informations about this.
Title: Re: default value in users.preferences
Post by: SKaero on May 31, 2013, 03:50:55 PM
You can set the default preferences by changing the settings in the main.inc.php.
Title: Re: default value in users.preferences
Post by: spo0lsh on May 31, 2013, 04:20:48 PM
How? I not see any variables for this.

I'll add this for any user:
'a:1:{s:7:"filters";a:1:{i:0;a:4:{s:10:"whatfilter";s:7:"subject";s:12:"searchstring";s:10:"***spam***";s:10:"destfolder";s:4:"Junk";s:8:"messages";s:3:"all";}}}'

Now I must by script like this:
UPDATE `roundcube`.`users` SET `preferences` = 'a:1:{s:7:"filters";a:1:{i:0;a:4:{s:10:"whatfilter";s:7:"subject";s:12:"searchstring";s:10:"***spam***";s:10:"destfolder";s:4:"Junk";s:8:"messages";s:3:"all";}}}' WHERE `users`.`preferences` = NULL;

Title: Re: default value in users.preferences
Post by: SKaero on May 31, 2013, 05:40:54 PM
It looks like your trying to store preferences for a plugin which probably works differently. Check if the plugin has config file with defaults.
Title: Re: default value in users.preferences
Post by: spo0lsh on June 01, 2013, 02:32:01 PM
Plugin have not this options.
So, how to add to tuple 'preferences' in roundcube.users something when roundcube init user data in mysql what I want?
Unfortunately 'text' tuple in mysql have not default value :(

Title: Re: default value in users.preferences
Post by: spo0lsh on June 01, 2013, 03:05:03 PM
I done it like this:


--- rcube_user.php.old  2013-05-16 20:06:31.000000000 +0200
+++ rcube_user.php      2013-06-01 21:01:44.000000000 +0200
@@ -493,12 +493,13 @@

         $dbh->query(
             "INSERT INTO ".$dbh->table_name('users').
-            " (created, last_login, username, mail_host, language)".
-            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?)",
+            " (created, last_login, username, mail_host, language, preferences)".
+            " VALUES (".$dbh->now().", ".$dbh->now().", ?, ?, ?,?)",
             strip_newlines($data['user']),
             strip_newlines($data['host']),
-            strip_newlines($data['language']));
-
+            strip_newlines($data['language']),
+            'a:1:{s:7:"filters";a:1:{i:0;a:4:{s:10:"whatfilter";s:7:"subject";s:12:"searchstring";s:10:"***spam***";s:10:"destfolder";s:4:"Junk";s:8:"messages";s:3:"all";}}}'
+            );
         if ($user_id = $dbh->insert_id('users')) {
             // create rcube_user instance to make plugin hooks work
             $user_instance = new rcube_user($user_id, array(



In my opinion should be possibility in main.inc.php for this.