Jeremy D commited on 2011-11-08 14:00:34
Showing 1 changed files, with 48 additions and 0 deletions.
... | ... |
@@ -529,6 +529,7 @@ class mbt_to_tbg extends tbg_converter |
529 | 529 |
array('Comments', 'doStep7', 500), |
530 | 530 |
array('Relationships', 'doStep8', 500), |
531 | 531 |
array('Attachments', 'doStep9', 100), |
532 |
+ array('Create Guest', 'doStep10', 999), |
|
532 | 533 |
); |
533 | 534 |
/** |
534 | 535 |
* Set the prefix that will be used prior to every reference of a table |
... | ... |
@@ -977,6 +978,53 @@ class mbt_to_tbg extends tbg_converter |
977 | 978 |
return $i; |
978 | 979 |
} |
979 | 980 |
|
981 |
+ /** |
|
982 |
+ * Recreate the guest user. |
|
983 |
+ * |
|
984 |
+ */ |
|
985 |
+ function doStep10($step_size, $substep) |
|
986 |
+ { |
|
987 |
+ // First figure out what the guest id is. |
|
988 |
+ $setting = $this->tbg_db->query(' |
|
989 |
+ SELECT value |
|
990 |
+ FROM ' . $this->tbg_db_prefix . 'settings |
|
991 |
+ WHERE name = "defaultuserid" |
|
992 |
+ AND scope = 1 |
|
993 |
+ AND uid = 0 |
|
994 |
+ AND module = "core"'); |
|
995 |
+ $setting = $setting->fetch(PDO::FETCH_ASSOC); |
|
996 |
+ $guest_id = $setting['value']; |
|
997 |
+ |
|
998 |
+ // Lets verify if this matches. |
|
999 |
+ $user = $this->tbg_db->query(' |
|
1000 |
+ SELECT username, buddyname, realname, group_id, scope |
|
1001 |
+ FROM ' . $this->tbg_db_prefix . 'users |
|
1002 |
+ WHERE id = ' . $guest_id); |
|
1003 |
+ $user = $user->fetch(PDO::FETCH_ASSOC); |
|
1004 |
+ |
|
1005 |
+ // Do not continue if this matches! |
|
1006 |
+ if ($user['username'] == 'guest' && $user['buddyname'] = 'Guest user' && $user['realname'] = 'Guest user' && $user['group_id'] == '3' && $user['scope'] == '1') |
|
1007 |
+ return 1; |
|
1008 |
+ |
|
1009 |
+ |
|
1010 |
+ |
|
1011 |
+ // Alright, lets insert. |
|
1012 |
+ $this->tbg_db->query(' |
|
1013 |
+ INSERT INTO tbg_users (username, password, buddyname, realname, email, userstate, customstate, homepage, language, lastseen, quota, activated, enabled, deleted, avatar, use_gravatar, private_email, openid_locked, joined, group_id, scope) VALUES |
|
1014 |
+ ("guest", "$2a$07$7aed297690838a118c449uI/0rZ/C9RtAufoZzUv/zTHGaseWCM0e", "Guest user", "Guest user", "", NULL, 0, "", "", 0, NULL, 1, 1, 0, NULL, 1, 1, 0, 0, 3, 1)'); |
|
1015 |
+ |
|
1016 |
+ $new_guest_id = $this->tbg_db->lastInsertId(); |
|
1017 |
+ |
|
1018 |
+ // Update the settings table. |
|
1019 |
+ $this->tbg_db->query(' |
|
1020 |
+ UPDATE ' . $this->tbg_db_prefix . 'settings |
|
1021 |
+ SET value = ' . $new_guest_id . ' |
|
1022 |
+ WHERE name = "defaultuserid" |
|
1023 |
+ AND scope = 1 |
|
1024 |
+ AND uid = 0 |
|
1025 |
+ AND module = "core"'); |
|
1026 |
+ } |
|
1027 |
+ |
|
980 | 1028 |
// @ TODO: Duplicate function, merge or remove. |
981 | 1029 |
public function getIssues() |
982 | 1030 |
{ |
983 | 1031 |