3 /***************************************************************************
4 * Copyright (C) 2003-2011 Polytechnique.org *
5 * http://opensource.polytechnique.org/ *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
20 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
21 ***************************************************************************/
23 require './connect.db.inc.php';
24 require '../include/name.func.inc.php';
26 $globals->debug
= 0; // Do not store backtraces
28 $opts = getopt('f:p:');
30 if (empty($opts['f']) ||
empty($opts['p'])) {
31 print "File name missing (-f=file_name) or promotion missing (-p=file_name).\n";
36 $handle = fopen($file, 'r');
37 $promo_year = $opts['p'];
43 while ($line = trim(fgets($handle))) {
44 $data = explode(';', $line);
45 $cond = new PFC_And(new UFC_NameTokens(split_name_for_search($data[0]), array(), false
, false
, Profile
::LASTNAME
));
46 $cond->addChild(new UFC_NameTokens(split_name_for_search($data[1]), array(), false
, false
, Profile
::FIRSTNAME
));
47 $uf = new UserFilter($cond);
48 $profiles = $uf->getProfiles();
49 switch (count($profiles)) {
54 foreach ($profiles as $profile) {
55 $already[] = $profile->hrid();
60 foreach ($profiles as $profile) {
61 $hrids[] = $profile->hrid();
63 $ambiguous[] = $line . ': ' . implode(', ', $hrids);
68 $cond = new UFC_Promo('=', UserFilter
::GRADE_MST
, $promo_year);
69 $uf = new UserFilter($cond);
70 $profiles = $uf->getProfiles();
72 foreach ($profiles as $profile) {
73 $promo[] = $profile->hrid();
76 $intersect = array_intersect($promo, $already);
77 if (count($intersect) != count($already)) {
78 print "There seems to be a problem: intersection of this promo and already found users differ.\n";
80 $to_remove = array_diff($promo, $intersect);
86 print "New users:\n" . implode("\n", $new) . "\n\n";
87 print "Ambiguous users:\n" . implode("\n", $ambiguous) . "\n\n";
88 print "Users to remove (louk out for ambiguous users before!):\n" . implode("\n", $to_remove) . "\n";
90 // vim:set et sw=4 sts=4 sws=4 foldmethod=marker enc=utf-8: