X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=bin%2Fcron%2Fphones.check.php;h=92707ee5a4f8f4aac226e9f3b19ba7a91665ef1c;hb=673e56aa757fce4ea57c27ab2c0d5ce87d713e51;hp=62fa4e56704579200e73fe62065a45fc73699212;hpb=950a769bb3f3154de64960ffc5cac111263bc8b0;p=platal.git diff --git a/bin/cron/phones.check.php b/bin/cron/phones.check.php index 62fa4e5..92707ee 100755 --- a/bin/cron/phones.check.php +++ b/bin/cron/phones.check.php @@ -1,11 +1,10 @@ #!/usr/bin/php5 debug = 0; //do not store backtraces +require './connect.db.inc.php'; +$globals->debug = 0; // do not store backtraces +// TODO: Improve this using Phone::iterate. function do_update_by_block($values) { @@ -13,7 +12,7 @@ function do_update_by_block($values) // Because there is no mysql update syntax for multiple updates in one query // we use a multiple insert syntax which will fail because the key already exist // and then update the display_tel - XDB::execute("INSERT INTO profile_phones (uid, link_type, link_id, tel_id ,tel_type, + XDB::execute("INSERT INTO profile_phones (pid, link_type, link_id, tel_id ,tel_type, search_tel, display_tel, pub, comment) VALUES " . $values . " ON DUPLICATE KEY UPDATE display_tel = VALUES(display_tel)"); @@ -65,7 +64,7 @@ foreach ($prefixes as $i => $prefix) { $regexp .= ')?'; } $regexp .= '$'; - $res = XDB::iterator("SELECT uid, link_type, link_id, tel_id, tel_type, search_tel, + $res = XDB::iterator("SELECT pid, link_type, link_id, tel_id, tel_type, search_tel, display_tel, pub, comment FROM profile_phones WHERE search_tel LIKE {?} AND display_tel NOT REGEXP {?}", @@ -76,14 +75,15 @@ foreach ($prefixes as $i => $prefix) { $values = ''; $i = 0; while ($phone = $res->next()) { - $disp = format_display_number($phone['search_tel'], $error, array('format' => $format, 'phoneprf' => $prefix)); + $phone = new Phone(array('display' => $phone['display_tel'])); + $phone->format(array('format' => $format, 'phoneprf' => $prefix)); if ($values != '') { $values .= ",\n"; } - $values .= "('" . addslashes($phone['uid']) . "', '" . addslashes($phone['link_type']) + $values .= "('" . addslashes($phone['pid']) . "', '" . addslashes($phone['link_type']) . "', '" . addslashes($phone['link_id']) . "', '" . addslashes($phone['tel_id']) . "', '" . addslashes($phone['tel_type']) - . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($disp) + . "', '" . addslashes($phone['search_tel']) . "', '" . addslashes($phone->display) . "', '" . addslashes($phone['pub']) . "', '" . addslashes($phone['comment']) . "')"; $i++; if ($i == 1000) {