4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
6 use Friendica\Object\Contact;
8 require_once 'include/follow.php';
9 require_once 'include/Contact.php';
10 require_once 'include/contact_selectors.php';
12 function unfollow_post(App $a) {
15 notice(t('Permission denied.') . EOL);
16 goaway($_SESSION['return_url']);
20 if ($_REQUEST['cancel']) {
21 goaway($_SESSION['return_url']);
25 $url = notags(trim($_REQUEST['url']));
26 $return_url = $_SESSION['return_url'];
28 $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
29 $uid, CONTACT_IS_FRIEND, normalise_link($url),
30 normalise_link($url), $url, NETWORK_STATUSNET);
31 $contact = dba::select('contact', array(), $condition, array('limit' => 1));
33 if (!DBM::is_result($contact)) {
34 notice(t("Contact wasn't found or can't be unfollowed."));
36 if (in_array($contact['network'], array(NETWORK_OSTATUS, NETWORK_DIASPORA))) {
37 $r = q("SELECT `contact`.*, `user`.* FROM `contact` INNER JOIN `user` ON `contact`.`uid` = `user`.`uid`
38 WHERE `user`.`uid` = %d AND `contact`.`self` LIMIT 1",
41 if (DBM::is_result($r)) {
42 $self = ""; // Unused parameter
43 terminate_friendship($r[0], $self, $contact);
46 dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
48 info(t('Contact unfollowed').EOL);
49 goaway(System::baseUrl().'/contacts/'.$contact['id']);
55 function unfollow_content(App $a) {
58 notice(t('Permission denied.') . EOL);
59 goaway($_SESSION['return_url']);
64 $url = notags(trim($_REQUEST['url']));
66 $submit = t('Submit Request');
68 $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
69 local_user(), CONTACT_IS_FRIEND, normalise_link($url),
70 normalise_link($url), $url, NETWORK_STATUSNET);
71 $contact = dba::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
73 if (!DBM::is_result($contact)) {
74 notice(t("You aren't a friend of this contact.").EOL);
79 if (!in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
80 notice(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(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 = t("Disconnect/Unfollow");
103 $o = replace_macros($tpl,array(
104 '$header' => htmlentities($header),
107 '$does_know_you' => "",
114 '$your_address' => t('Your Identity Address:'),
115 '$invite_desc' => "",
117 '$submit' => $submit,
118 '$cancel' => t('Cancel'),
120 '$name' => $contact["name"],
121 '$url' => $contact["url"],
122 '$zrl' => zrl($contact["url"]),
123 '$url_label' => t("Profile URL"),
124 '$myaddr' => $myaddr,
125 '$request' => $request,
127 '$keywords_label' => ""
130 $a->page['aside'] = "";
131 profile_load($a, "", 0, get_contact_details_by_url($contact["url"]));
133 $o .= replace_macros(get_markup_template('section_title.tpl'),
134 array('$title' => t('Status Messages and Posts')
137 // Show last public posts
138 $o .= posts_from_contact_url($a, $contact["url"]);