Moves upgrade scripts to a dedicated directory (will ease up merge of hruid feature...
[platal.git] / upgrade / hruid / hruid.update.php
1 #!/usr/bin/php5
2 <?php
3
4 require_once 'connect.db.inc.php';
5 require_once 'xorg.misc.inc.php';
6
7 // Fetches the list of unregistered users.
8 $users = XDB::iterRow(
9 "SELECT user_id, prenom, nom, promo
10 FROM auth_user_md5
11 WHERE hruid IS NULL");
12
13 // Creates missing human readable uids.
14 while (list($user_id, $prenom, $nom, $promo) = $users->next()) {
15 $forlife = make_forlife($prenom, $nom, $promo);
16 if (!XDB::execute("UPDATE auth_user_md5 SET hruid = {?} WHERE user_id = {?}", $forlife, $user_id)) {
17 echo "WARNING: Duplicate forlife for user $user_id and forlife '$forlife'. Please check manually the entry.\n";
18 }
19 }
20 ?>