5bc75265066991ec504e67341a816e73b134e88a
4 require_once 'connect.db.inc.php';
6 // Fetches the list of unregistered users.
8 "SELECT a.uid, a.hruid, a.full_name, a.display_name,
9 COUNT(m.asso_id) AS nb_assos, m.asso_id, m.comm
11 LEFT JOIN group_members AS m ON (a.uid = m.uid)
12 WHERE a.type = 'xnet' AND a.directory_name IS NULL
17 // Updates directory_names.
18 while (list($uid, $hruid, $full, $display, $nb_assos, $asso, $comm) = $users->next()) {
21 // Match any of the following:
24 // \pL means 'any unicode letter'
25 if (preg_match('/([\pL- ]+)(\((.*)\)| +- +(.*))$/', $full, $matches)) {
26 $full_name = trim($matches[1]);
27 $comment = trim($matches[count($matches) - 1]);
32 if (preg_match('/^([\pL.-]+) +(.*)/u', $full_name, &$matches)) {
33 $dir_name = mb_strtoupper(trim($matches[2])) . " " . ucwords(trim($matches[1]));
36 $errors[$hruid] = "Can't update comment to |$comment|: more than one asso ($nb_assos).";
39 if ($comm != null
&& $comm != "") {
40 $errors[$hruid] = "Can't update comment to |$comment|: comment already set to |$comm|.";
44 echo "$hruid: |$full| => |$dir_name| (display: |$display|";
46 echo "; comment: |$comment|";
49 XDB
::execute('UPDATE accounts SET directory_name = {?} WHERE hruid = {?}', $dir_name, $hruid);
51 XDB
::execute('UPDATE group_members SET comm = {?} WHERE uid = {?} AND asso_id = {?}',
55 $errors[$hruid] = "Unable to match |$full|.";
59 echo "== ERRORS ==\n";
60 foreach($errors as $hruid => $error) {
61 echo "$hruid\n\t$error\n";