]> git.mxchange.org Git - friendica.git/blob - mod/repair_ostatus.php
new api for notifications
[friendica.git] / mod / repair_ostatus.php
1 <?php
2
3 require_once('include/Scrape.php');
4 require_once('include/follow.php');
5
6 if(! function_exists('repair_ostatus_content')) {
7 function repair_ostatus_content(&$a) {
8
9         if(! local_user()) {
10                 notice( t('Permission denied.') . EOL);
11                 goaway($_SESSION['return_url']);
12                 // NOTREACHED
13         }
14
15         $o = "<h2>".t("Resubscribing to OStatus contacts")."</h2>";
16
17         $uid = local_user();
18
19         $a = get_app();
20
21         $counter = intval($_REQUEST['counter']);
22
23         $r = q("SELECT COUNT(*) AS `total` FROM `contact` WHERE
24                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)",
25                 intval($uid),
26                 dbesc(NETWORK_OSTATUS),
27                 intval(CONTACT_IS_FRIEND),
28                 intval(CONTACT_IS_SHARING));
29
30         if (!$r)
31                 return($o.t("Error"));
32
33         $total = $r[0]["total"];
34
35         $r = q("SELECT `url` FROM `contact` WHERE
36                 `uid` = %d AND `network` = '%s' AND `rel` IN (%d, %d)
37                 ORDER BY `url`
38                 LIMIT %d, 1",
39                 intval($uid),
40                 dbesc(NETWORK_OSTATUS),
41                 intval(CONTACT_IS_FRIEND),
42                 intval(CONTACT_IS_SHARING), $counter++);
43
44         if (!$r) {
45                 $o .= t("Done");
46                 return $o;
47         }
48
49         $o .= "<p>".$counter."/".$total.": ".$r[0]["url"]."</p>";
50
51         $o .= "<p>".t("Keep this window open until done.")."</p>";
52
53         $result = new_contact($uid,$r[0]["url"],true);
54
55         $a->page['htmlhead'] = '<meta http-equiv="refresh" content="1; URL='.$a->get_baseurl().'/repair_ostatus?counter='.$counter.'">';
56
57         return $o;
58 }
59 }