6.0.0-git
2019-11-13

Diff for RenameUsers between 7 and 8

Sometimes there is a requirement to rename users in the Horde DB. eg: you move from a system with 'standard' users to one where virtual hosting is used. In such a situation the old user may be 'fred' and the new user may be 'fred@hisdomain.com'



The script below seems to work for the following apps:



* Address Book (turba)

* Calendar (kronolith)

* File Manager (gollem)

* Filters (ingo)

* Horde (horde)

* Mail (imp)

* News (jonah)

* Notes (mnemo)

* Password (passwd)

* Tasks (nag)

* Tickets (whups)

* Time Tracking (hermes)



YMMV and more apps will need more changes of course.



**BACKUP YOUR DB BEFORE RUNNING ANYTHING LIKE THIS!**



<code>

#!/bin/sh



function horde_rename() {

  new=$2; old=$1

  echo "Rename $old -> $new"



  mysql -u horde -ppassword horde << EOF

update hermes_timeslices set employee_id = '$new' where employee_id = '$old';

update horde_datatree set user_uid = '$new' where user_uid = '$old';

update horde_datatree set datatree_name = '$new' where datatree_name = '$old' and user_uid = '$new';

update horde_datatree_attributes set attribute_value = '$new' where attribute_value = '$old' and attribute_key = 'who';

update horde_datatree_attributes set attribute_key= '$new' where attribute_key = '$old' and attribute_name = 'perm_users';

update horde_datatree_attributes set attribute_value = '$new' where attribute_value = '$old' and attribute_name = 'uid';

update horde_datatree_attributes set attribute_value = '$new' where attribute_value = '$old' and attribute_name = 'owner';

update horde_histories set history_who = '$new' where history_who = '$old';

update horde_prefs set pref_uid = '$new' where pref_uid = '$old';

update kronolith_events set event_creator_id = '$new' where event_creator_id = '$old';

update kronolith_events set calendar_id = '$new' where calendar_id = '$old';

update mnemo_memos set memo_owner = '$new' where memo_owner = '$old';

update nag_tasks set task_owner = '$new' where task_owner = '$old';

update turba_objects set owner_id = '$new' where owner_id = '$old';
update whups_tickets set user_id_requester = '$new' where user_id_requester = '$old';
update whups_queues_users set user_uid = '$new' where user_uid = '$old';

update whups_users_searches set user_uid = '$new' where user_uid = '$old';

EOF

  echo "Done with $new"

}



horde_rename 'fred' 'fred@hisdomain.com'

</code>



I did notice that notepads, tasks lists, calendars, etc. become 'hidden' after doing this. No data appears to be lost and users simply have to re-select the ones they want to see though.