4 use Friendica\Core\System;
5 use Friendica\Database\DBM;
6 use Friendica\Model\Contact;
8 require_once 'include/follow.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 Contact::terminateFriendship($r[0], $contact);
44 dba::update('contact', array('rel' => CONTACT_IS_FOLLOWER), array('id' => $contact['id']));
46 info(t('Contact unfollowed').EOL);
47 goaway(System::baseUrl().'/contacts/'.$contact['id']);
53 function unfollow_content(App $a) {
56 notice(t('Permission denied.') . EOL);
57 goaway($_SESSION['return_url']);
62 $url = notags(trim($_REQUEST['url']));
64 $submit = t('Submit Request');
66 $condition = array("`uid` = ? AND `rel` = ? AND (`nurl` = ? OR `alias` = ? OR `alias` = ?) AND `network` != ?",
67 local_user(), CONTACT_IS_FRIEND, normalise_link($url),
68 normalise_link($url), $url, NETWORK_STATUSNET);
69 $contact = dba::select('contact', array('url', 'network', 'addr', 'name'), $condition, array('limit' => 1));
71 if (!DBM::is_result($contact)) {
72 notice(t("You aren't a friend of this contact.").EOL);
77 if (!in_array($contact['network'], array(NETWORK_DIASPORA, NETWORK_OSTATUS))) {
78 notice(t("Unfollowing is currently not supported by your network.").EOL);
83 $request = System::baseUrl()."/unfollow";
84 $tpl = get_markup_template('auto_request.tpl');
86 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
89 notice(t('Permission denied.') . EOL);
90 goaway($_SESSION['return_url']);
94 $myaddr = $r[0]["url"];
96 // Makes the connection request for friendica contacts easier
97 $_SESSION["fastlane"] = $contact["url"];
99 $header = t("Disconnect/Unfollow");
101 $o = replace_macros($tpl,array(
102 '$header' => htmlentities($header),
105 '$does_know_you' => "",
112 '$your_address' => t('Your Identity Address:'),
113 '$invite_desc' => "",
115 '$submit' => $submit,
116 '$cancel' => t('Cancel'),
118 '$name' => $contact["name"],
119 '$url' => $contact["url"],
120 '$zrl' => zrl($contact["url"]),
121 '$url_label' => t("Profile URL"),
122 '$myaddr' => $myaddr,
123 '$request' => $request,
125 '$keywords_label' => ""
128 $a->page['aside'] = "";
129 profile_load($a, "", 0, Contact::getDetailsByURL($contact["url"]));
131 $o .= replace_macros(get_markup_template('section_title.tpl'),
132 array('$title' => t('Status Messages and Posts')
135 // Show last public posts
136 $o .= Contact::getPostsFromUrl($contact["url"]);