4 use Friendica\Core\Config;
5 use Friendica\Core\System;
6 use Friendica\Network\Probe;
7 use Friendica\Object\Contact;
9 require_once 'include/follow.php';
10 require_once 'include/Contact.php';
11 require_once 'include/contact_selectors.php';
13 function follow_post(App $a) {
16 notice( 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 // Makes the connection request for friendica contacts easier
30 // This is just a precaution if maybe this page is called somewhere directly via POST
31 $_SESSION["fastlane"] = $url;
33 $result = new_contact($uid,$url,true);
35 if ($result['success'] == false) {
36 if ($result['message']) {
37 notice($result['message']);
40 } elseif ($result['cid']) {
41 goaway(System::baseUrl().'/contacts/'.$result['cid']);
44 info( t('Contact added').EOL);
46 if (strstr($return_url,'contacts')) {
47 goaway(System::baseUrl().'/contacts/'.$contact_id);
54 function follow_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 // There is a current issue. It seems as if you can't start following a Friendica that is following you
68 // With Diaspora this works - but Friendica is special, it seems ...
69 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND ((`rel` != %d) OR (`network` = '%s')) AND
70 (`nurl` = '%s' OR `alias` = '%s' OR `alias` = '%s') AND
71 `network` != '%s' LIMIT 1",
72 intval(local_user()), dbesc(CONTACT_IS_FOLLOWER), dbesc(NETWORK_DFRN), dbesc(normalise_link($url)),
73 dbesc(normalise_link($url)), dbesc($url), dbesc(NETWORK_STATUSNET));
76 notice(t('You already added this contact.').EOL);
78 //goaway($_SESSION['return_url']);
82 $ret = Probe::uri($url);
84 if (($ret["network"] == NETWORK_DIASPORA) && !Config::get('system','diaspora_enabled')) {
85 notice( t("Diaspora support isn't enabled. Contact can't be added.") . EOL);
87 //goaway($_SESSION['return_url']);
91 if (($ret["network"] == NETWORK_OSTATUS) && Config::get('system','ostatus_disabled')) {
92 notice( t("OStatus support is disabled. Contact can't be added.") . EOL);
94 //goaway($_SESSION['return_url']);
98 if ($ret["network"] == NETWORK_PHANTOM) {
99 notice( t("The network type couldn't be detected. Contact can't be added.") . EOL);
101 //goaway($_SESSION['return_url']);
105 if ($ret["network"] == NETWORK_MAIL) {
106 $ret["url"] = $ret["addr"];
109 if ($ret['network'] === NETWORK_DFRN) {
110 $request = $ret["request"];
111 $tpl = get_markup_template('dfrn_request.tpl');
113 $request = System::baseUrl()."/follow";
114 $tpl = get_markup_template('auto_request.tpl');
117 $r = q("SELECT `url` FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($uid));
120 notice( t('Permission denied.') . EOL);
121 goaway($_SESSION['return_url']);
125 $myaddr = $r[0]["url"];
128 // Makes the connection request for friendica contacts easier
129 $_SESSION["fastlane"] = $ret["url"];
131 $r = q("SELECT `id`, `location`, `about`, `keywords` FROM `gcontact` WHERE `nurl` = '%s'",
132 normalise_link($ret["url"]));
135 $r = array(array("location" => "", "about" => "", "keywords" => ""));
137 $gcontact_id = $r[0]["id"];
140 if ($ret['network'] === NETWORK_DIASPORA) {
141 $r[0]["location"] = "";
145 $header = t("Connect/Follow");
147 $o = replace_macros($tpl,array(
148 '$header' => htmlentities($header),
149 //'$photo' => proxy_url($ret["photo"], false, PROXY_SIZE_SMALL),
151 '$pls_answer' => t('Please answer the following:'),
152 '$does_know_you' => array('knowyou', sprintf(t('Does %s know you?'),$ret["name"]), false, '', array(t('No'), t('Yes'))),
153 '$add_note' => t('Add a personal note:'),
159 '$your_address' => t('Your Identity Address:'),
160 '$invite_desc' => "",
162 '$submit' => $submit,
163 '$cancel' => t('Cancel'),
165 '$name' => $ret["name"],
166 '$url' => $ret["url"],
167 '$zrl' => zrl($ret["url"]),
168 '$url_label' => t("Profile URL"),
169 '$myaddr' => $myaddr,
170 '$request' => $request,
171 /*'$location' => bbcode($r[0]["location"]),
172 '$location_label' => t("Location:"),
173 '$about' => bbcode($r[0]["about"], false, false),
174 '$about_label' => t("About:"), */
175 '$keywords' => $r[0]["keywords"],
176 '$keywords_label' => t("Tags:")
179 $a->page['aside'] = "";
180 profile_load($a, "", 0, get_contact_details_by_url($ret["url"]));
182 if ($gcontact_id <> 0) {
183 $o .= replace_macros(get_markup_template('section_title.tpl'),
184 array('$title' => t('Status Messages and Posts')
187 // Show last public posts
188 $o .= posts_from_contact_url($a, $ret["url"]);