<?php
/**
- *
- * Module: dfrn_request
+ * @file mod/dfrn_request.php
+ * @brief Module: dfrn_request
*
* Purpose: Handles communication associated with the issuance of
* friend requests.
*
+ * @see PDF with dfrn specs: https://github.com/friendica/friendica/blob/master/spec/dfrn2.pdf
*/
require_once('include/enotify.php');
require_once('include/Probe.php');
require_once('include/group.php');
-if(! function_exists('dfrn_request_init')) {
function dfrn_request_init(&$a) {
if($a->argc > 1)
profile_load($a,$which);
return;
-}}
+}
/**
* After logging in, we click 'submit' to approve the linkage.
*
*/
-
-if(! function_exists('dfrn_request_post')) {
function dfrn_request_post(&$a) {
if(($a->argc != 2) || (! count($a->profile))) {
}
- /**
+ /*
*
* Scenario 2: We've introduced ourself to another cell, then have been returned to our own cell
* to confirm the request, and then we've clicked submit (perhaps after logging in).
if((x($_POST,'localconfirm')) && ($_POST['localconfirm'] == 1)) {
- /**
+ /*
* Ensure this is a valid request
*/
if(x($dfrn_url)) {
- /**
+ /*
* Lookup the contact based on their URL (which is the only unique thing we have at the moment)
*/
- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND (`url` = '%s' OR `nurl` = '%s') AND `self` = 0 LIMIT 1",
- intval(local_user()),
+ $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND NOT `self` LIMIT 1",
dbesc($dfrn_url),
dbesc(normalise_link($dfrn_url))
);
if(count($r)) {
if(strlen($r[0]['dfrn-id'])) {
- /**
+ /*
* We don't need to be here. It has already happened.
*/
}
else {
- /**
+ /*
* Scrape the other site's profile page to pick up the dfrn links, key, fn, and photo
*/
$photo = $parms["photo"];
- /********* Escape the entire array ********/
+ // Escape the entire array
dbesc_array($parms);
- /******************************************/
- /**
+ /*
* Create a contact record on our site for the other person
*/
} else
$forwardurl = $a->get_baseurl()."/contacts";
- /**
+ /*
* Allow the blocked remote notification to complete
*/
return; // NOTREACHED
}
- /**
+ /*
* Otherwise:
*
* Scenario 1:
if( x($_POST,'dfrn_url')) {
- /**
+ /*
* Block friend request spam
*/
}
}
- /**
+ /*
*
* Cleanup old introductions that remain blocked.
* Also remove the contact record, but only if there is no existing relationship
}
}
- /**
+ /*
*
* Cleanup any old email intros - which will have a greater lifetime
*/
// END $network === NETWORK_DFRN
} elseif (($network != NETWORK_PHANTOM) AND ($url != "")) {
- /**
+ /*
*
* Substitute our user's feed URL into $url template
* Send the subscriber home to subscribe
}
} return;
-}}
-
-
+}
-if(! function_exists('dfrn_request_content')) {
function dfrn_request_content(&$a) {
if(($a->argc != 2) || (! count($a->profile)))
}
else {
- /**
+ /*
* Normal web request. Display our user's introduction form.
*/
}
- /**
+ /*
* Try to auto-fill the profile address
*/
$target_addr = $a->profile['nickname'] . '@' . substr(z_root(), strpos(z_root(),'://') + 3 );
- /**
+ /*
*
* The auto_request form only has the profile address
* because nobody is going to read the comments and
}
return; // Somebody is fishing.
-}}
+}