4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
7 require_once 'include/follow.php';
8 require_once 'include/Contact.php';
9 require_once 'include/contact_selectors.php';
11 function unfollow_post(App $a) {
14 notice(t('Permission denied.') . EOL);
15 goaway($_SESSION['return_url']);
19 if ($_REQUEST['cancel']) {
20 goaway($_SESSION['return_url']);
24 $url = notags(trim($_REQUEST['url']));
25 $return_url = $_SESSION['return_url'];
27 $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
28 $uid, CONTACT_IS_FRIEND, normalise_link($url),
29 normalise_link($url), $url, NETWORK_STATUSNET);
30 $contact = dba::select('contact', array(), $condition, array('limit' => 1));
32 if (!DBM::is_result($contact)) {
33 notice(t("Contact wasn't found or can't be unfollowed."));
35 if (in_array($contact['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA))) {
36 $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
37 WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
40 if (DBM::is_result($r)) {
41 $self = ""; // Unused parameter
42 terminate_friendship($r[0], $self, $contact);
45 dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
47 info(t('Contact unfollowed').EOL);
48 goaway(System::baseUrl().'/contacts/'.$contact['id']);
54 function unfollow_content(App $a) {
57 notice(t('Permission denied.') . EOL);
58 goaway($_SESSION['return_url']);
63 $url = notags(trim($_REQUEST['url']));
65 $submit = t('Submit Request');
67 $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
68 local_user(), CONTACT_IS_FRIEND, normalise_link($url),
69 normalise_link($url), $url, NETWORK_STATUSNET);
70 $contact = dba::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
72 if (!DBM::is_result($contact)) {
73 notice(t("You aren't a friend of this contact.").EOL);
78 if (!in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
79 notice(t("Unfollowing is currently not supported by your network.").EOL);
84 $request = System::baseUrl()."/unfollow";
85 $tpl = get_markup_template('auto_request.tpl');
87 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
90 notice(t('Permission denied.') . EOL);
91 goaway($_SESSION['return_url']);
95 $myaddr = $r[0]["url"];
97 // Makes the connection request for friendica contacts easier
98 $_SESSION["fastlane"] = $contact["url"];
100 $header = t("Disconnect/Unfollow");
102 $o = replace_macros($tpl,array(
103 '$header' => htmlentities($header),
106 '$does_know_you' => "",
113 '$your_address' => t('Your Identity Address:'),
114 '$invite_desc' => "",
116 '$submit' => $submit,
117 '$cancel' => t('Cancel'),
119 '$name' => $contact["name"],
120 '$url' => $contact["url"],
121 '$zrl' => zrl($contact["url"]),
122 '$url_label' => t("Profile URL"),
123 '$myaddr' => $myaddr,
124 '$request' => $request,
126 '$keywords_label' => ""
129 $a->page['aside'] = "";
130 profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
132 $o .= replace_macros(get_markup_template('section_title.tpl'),
133 array('$title' => t('Status Messages and Posts')
136 // Show last public posts
137 $o .= posts_from_contact_url($a, $contact["url"]);