Hi,
I am fresh new on this list, and it seems that its archives are not available. So, excuse me if this topic has alreadey been discussed.
I am working on an update of the squirrelmail_usercopy plugin, to permit the transfer of address groups and the equivalent of the roundcube's "message_highlight" plugin when creating à new user on roundcube with data taken from a current squirrelmail account. Many of our squirrelmail users use these features.
If the addition of address groups has been done updating only the original plugin's code, I had to make some change in the "create" function in the program/lib/Roundcube/rcube_user.php file to permit the import of the message highlight preferences.
This change is simply the addition of the field 'preferences' for the call of the "user_create" hook, and the storage of the returned value in the "preferences" column of the "users" table of the database.
--- rcube_user.php.orig 2020-08-10 21:05:20.000000000 +0200 +++ rcube_user.php 2020-10-12 15:27:40.574055096 +0200 @@ -621,6 +621,7 @@ 'user_email' => $user_email, 'email_list' => $email_list, 'language' => $_SESSION['language'],
'preferences' => serialize(array()),
));
// plugin aborted this operation
@@ -630,11 +631,12 @@
$insert = $dbh->query(
"INSERT INTO ".$dbh->table_name('users', true).
" (`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().", ?, ?, ?, ?)",
$data['user'],
$data['host'],
$data['language']);
$data['language'],
$data['preferences']);
if ($dbh->affected_rows($insert) && ($user_id = $dbh->insert_id('users'))) {
// create rcube_user instance to make plugin hooks work
@@ -643,6 +645,7 @@ 'username' => $data['user'], 'mail_host' => $data['host'], 'language' => $data['language'],
'preferences' => $data['preferences'],
));
$rcube->user = $user_instance;
$mail_domain = $rcube->config->mail_domain($data['host']);
The change has to be made because if the user_create hook permits to populate all columns of the "users" table, the "preferences" column is not treated by the hook, while the "messages highlight" plugin stores its preferences there.
Adding the change as I suggest could be seen only as a measure of consistency about the initialization of the "users" table. When I searched in the code to understand why my updated plugin didn't work, I was surprised to see that the "preferences" field was simply not treated...
And even beyond the squirrelmail_usercopy plugin, I think this change could help others user-creation related plugins.
So, do you think it would be considered to add this change in roundcube ?
The last man connected to the Interet was browsing some old WebSites. "You have new mail" appeared on the screen... --------------------------- adapted from a short Fredric Brown's story
Le lundi 12 octobre 2020 15:34:22, Jacques Belin jbelin@oryva.net a écrit:
So, do you think it would be considered to add this change in roundcube ?
I see no reaction about my last message, so I think I have to say that it will be not implemented.
But, would it be possible to know (if there is one) what is the reason that forbids you to add it ?
The last man connected to the Internet was browsing some old Web sites. "You have new mail" appeared on the screen... --------------------------- adapted from a short Fredric Brown's story
On 12.10.2020 15:34, Jacques Belin wrote:
@@ -621,6 +621,7 @@ 'user_email' => $user_email, 'email_list' => $email_list, 'language' => $_SESSION['language'],
'preferences' => serialize(array()),
At this stage it would be better to use an array, and serialize later (on insert).
And even beyond the squirrelmail_usercopy plugin, I think this change could help others user-creation related plugins.
Please, create a pull request. I don't have much time recently, but the feature makes sense, so we'll most likely accept it.
Le mercredi 21 octobre 2020 16:08:08, Aleksander Machniak alec@alec.pl a écrit:
On 12.10.2020 15:34, Jacques Belin wrote:
@@ -621,6 +621,7 @@ 'user_email' => $user_email, 'email_list' => $email_list, 'language' => $_SESSION['language'],
'preferences' => serialize(array()),
At this stage it would be better to use an array, and serialize later (on insert).
True, and it is a little more simple to manage on the plugin's side...
And even beyond the squirrelmail_usercopy plugin, I think this change could help others user-creation related plugins.
Please, create a pull request. I don't have much time recently, but the feature makes sense, so we'll most likely accept it.
The pull request is on its way. :-)
The last man connected to the Internet was browsing some old Web sites. "You have new mail" appeared on the screen... --------------------------- adapted from a short Fredric Brown's story