3 // WARNING: this script takes a few days to be executed completly, thus run it into a screen.
5 require_once 'connect.db.inc.php';
6 require_once '../../classes/phone.php';
8 $globals->debug
= 0; // Do not store backtraces.
10 echo "Formats non formated phones. (1/2)\n";
11 $it = XDB
::rawIterator("SELECT search_tel AS search, display_tel AS display, comment, link_id,
12 tel_type AS type, link_type, tel_id AS id, pid, pub
14 WHERE search_tel = '' OR search_tel IS NULL
15 ORDER BY pid, link_id, tel_id");
16 while ($phone = new Phone($it->next())) {
21 echo "Deletes duplicated phones. (2/2)\n";
22 $it = XDB
::rawIterator("SELECT search_tel AS search, display_tel AS display, comment, link_id,
23 tel_type AS type, link_type, tel_id AS id, pid, pub
25 WHERE link_type = 'user'
26 ORDER BY pid, tel_id");
28 $duplicates = array();
29 $phone = new Phone($it->next());
33 while ($phone = new Phone($it->next())) {
34 if ($phone->pid() == $pid) {
39 for ($i = 0; $i < $count; ++
$i) {
40 for ($j = $i +
1; $j < $count; ++
$j) {
41 if ($phones[$i]->search() == $phones[$j]->search()) {
42 $duplicates[$i] = true
;
46 foreach ($duplicates as $key => $bool) {
49 if (count($phones) != $count) {
50 Phone
::deletePhones($pid, 'user');
52 foreach ($phones as $phone) {
57 XDB
::execute('UPDATE profile_merge_issues
58 SET issues = REPLACE(issues, \'phone\', \'\')
59 WHERE pid = {?}', $pid);
70 echo "That's all folks!\n";
72 /* vim:set et sw=4 sts=4 ts=4: */