3 * @file mod/unfollow.php
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Database\DBA;
10 use Friendica\Model\Contact;
11 use Friendica\Model\Profile;
13 function unfollow_post(App $a)
16 notice(L10n::t('Permission denied.') . EOL);
17 goaway($_SESSION['return_url']);
21 if ($_REQUEST['cancel']) {
22 goaway($_SESSION['return_url']);
26 $url = notags(trim($_REQUEST['url']));
27 $return_url = $_SESSION['return_url'];
29 $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
30 $uid, Contact::FRIEND, normalise_link($url),
31 normalise_link($url), $url, NETWORK_STATUSNET];
32 $contact = DBA::selectFirst('contact', [], $condition);
34 if (!DBA::isResult($contact)) {
35 notice(L10n::t("Contact wasn't found or can't be unfollowed."));
37 if (in_array($contact['network'], [NETWORK_OSTATUS, NETWORK_DIASPORA, NETWORK_DFRN])) {
38 $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
39 WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
42 if (DBA::isResult($r)) {
43 Contact::terminateFriendship($r[0], $contact);
46 DBA::update('contact', ['rel' => Contact::FOLLOWER], ['id' => $contact['id']]);
48 info(L10n::t('Contact unfollowed').EOL);
49 goaway(System::baseUrl().'/contacts/'.$contact['id']);
55 function unfollow_content(App $a)
58 notice(L10n::t('Permission denied.') . EOL);
59 goaway($_SESSION['return_url']);
64 $url = notags(trim($_REQUEST['url']));
66 $submit = L10n::t('Submit Request');
68 $condition = ["`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
69 local_user(), Contact::FRIEND, normalise_link($url),
70 normalise_link($url), $url, NETWORK_STATUSNET];
71 $contact = DBA::selectFirst('contact', ['url', 'network', 'addr', 'name'], $condition);
73 if (!DBA::isResult($contact)) {
74 notice(L10n::t("You aren't a friend of this contact.").EOL);
79 if (!in_array($contact['network'], [NETWORK_DIASPORA, NETWORK_OSTATUS, NETWORK_DFRN])) {
80 notice(L10n::t("Unfollowing is currently not supported by your network.").EOL);
85 $request = System::baseUrl()."/unfollow";
86 $tpl = get_markup_template('auto_request.tpl');
88 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
91 notice(L10n::t('Permission denied.') . EOL);
92 goaway($_SESSION['return_url']);
96 $myaddr = $r[0]["url"];
98 // Makes the connection request for friendica contacts easier
99 $_SESSION["fastlane"] = $contact["url"];
101 $header = L10n::t("Disconnect/Unfollow");
103 $o = replace_macros($tpl, [
104 '$header' => htmlentities($header),
107 '$does_know_you' => "",
114 '$your_address' => L10n::t('Your Identity Address:'),
115 '$invite_desc' => "",
117 '$submit' => $submit,
118 '$cancel' => L10n::t('Cancel'),
120 '$name' => $contact["name"],
121 '$url' => $contact["url"],
122 '$zrl' => Contact::magicLink($contact["url"]),
123 '$url_label' => L10n::t("Profile URL"),
124 '$myaddr' => $myaddr,
125 '$request' => $request,
127 '$keywords_label' => ""
130 $a->page['aside'] = "";
131 Profile::load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
133 $o .= replace_macros(get_markup_template('section_title.tpl'), ['$title' => L10n::t('Status Messages and Posts')]);
135 // Show last public posts
136 $o .= Contact::getPostsFromUrl($contact["url"]);