4 use Friendica\Core\Config;
5 use Friendica\Core\System;
6 use Friendica\Network\Probe;
8 require_once 'include/follow.php';
9 require_once 'include/Contact.php';
10 require_once 'include/contact_selectors.php';
12 function follow_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 // Makes the connection request for friendica contacts easier
29 // This is just a precaution if maybe this page is called somewhere directly via POST
30 $_SESSION["fastlane"] = $url;
32 $result = new_contact($uid,$url,true);
34 if ($result['success'] == false) {
35 if ($result['message']) {
36 notice($result['message']);
39 } elseif ($result['cid']) {
40 goaway(System::baseUrl().'/contacts/'.$result['cid']);
43 info( t('Contact added').EOL);
45 if (strstr($return_url,'contacts')) {
46 goaway(System::baseUrl().'/contacts/'.$contact_id);
53 function follow_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 // There is a current issue. It seems as if you can't start following a Friendica that is following you
67 // With Diaspora this works - but Friendica is special, it seems ...
68 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
69 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
70 `network` != '%s' LIMIT 1",
71 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
72 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
75 notice(t('You already added this contact.').EOL);
77 //goaway($_SESSION['return_url']);
81 $ret = Probe::uri($url);
83 if (($ret["network"] == NETWORK_DIASPORA) && !Config::get('system','diaspora_enabled')) {
84 notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
86 //goaway($_SESSION['return_url']);
90 if (($ret["network"] == NETWORK_OSTATUS) && Config::get('system','ostatus_disabled')) {
91 notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
93 //goaway($_SESSION['return_url']);
97 if ($ret["network"] == NETWORK_PHANTOM) {
98 notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
100 //goaway($_SESSION['return_url']);
104 if ($ret["network"] == NETWORK_MAIL) {
105 $ret["url"] = $ret["addr"];
108 if ($ret['network'] === NETWORK_DFRN) {
109 $request = $ret["request"];
110 $tpl = get_markup_template('dfrn_request.tpl');
112 $request = System::baseUrl()."/follow";
113 $tpl = get_markup_template('auto_request.tpl');
116 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
119 notice( t('Permission denied.') . EOL);
120 goaway($_SESSION['return_url']);
124 $myaddr = $r[0]["url"];
127 // Makes the connection request for friendica contacts easier
128 $_SESSION["fastlane"] = $ret["url"];
130 $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
131 normalise_link($ret["url"]));
134 $r = array(array("location" => "", "about" => "", "keywords" => ""));
136 $gcontact_id = $r[0]["id"];
139 if ($ret['network'] === NETWORK_DIASPORA) {
140 $r[0]["location"] = "";
144 $header = t("Connect/Follow");
146 $o = replace_macros($tpl,array(
147 '$header' => htmlentities($header),
148 //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
150 '$pls_answer' => t('Please answer the following:'),
151 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'), t('Yes'))),
152 '$add_note' => t('Add a personal note:'),
158 '$your_address' => t('Your Identity Address:'),
159 '$invite_desc' => "",
161 '$submit' => $submit,
162 '$cancel' => t('Cancel'),
164 '$name' => $ret["name"],
165 '$url' => $ret["url"],
166 '$zrl' => zrl($ret["url"]),
167 '$url_label' => t("Profile URL"),
168 '$myaddr' => $myaddr,
169 '$request' => $request,
170 /*'$location' => bbcode($r[0]["location"]),
171 '$location_label' => t("Location:"),
172 '$about' => bbcode($r[0]["about"], false, false),
173 '$about_label' => t("About:"), */
174 '$keywords' => $r[0]["keywords"],
175 '$keywords_label' => t("Tags:")
178 $a->page['aside'] = "";
179 profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
181 if ($gcontact_id <> 0) {
182 $o .= replace_macros(get_markup_template('section_title.tpl'),
183 array('$title' => t('Status Messages and Posts')
186 // Show last public posts
187 $o .= posts_from_contact_url($a, $ret["url"]);