use Friendica\Core\Worker;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
+use Friendica\Object\Contact;
+use Friendica\Object\Profile;
use Friendica\Protocol\PortableContact;
use dba;
use Exception;
require_once 'include/datetime.php';
require_once 'include/network.php';
require_once 'include/html2bbcode.php';
-require_once 'include/Contact.php';
-require_once 'include/Photo.php';
/**
* @brief This class handles GlobalContact related functions
* @param integer $uid User ID
* @param integer $cid Contact ID
* @param integer $zcid Global Contact ID
+ * @return void
*/
public static function link($gcid, $uid = 0, $cid = 0, $zcid = 0)
{
* 2: Contacts of profiles on this server
* 3: Contacts of contacts of profiles on this server
* 4: ...
+ * @return array $gcontact
*/
public static function sanitize($gcontact)
{
return $gcontact;
}
+ /**
+ * @param integer $uid id
+ * @param integer $cid id
+ * @return integer
+ */
public static function countCommonFriends($uid, $cid)
{
$r = q(
return 0;
}
+ /**
+ * @param integer $uid id
+ * @param integer $zcid zcid
+ * @return integer
+ */
public static function countCommonFriendsZcid($uid, $zcid)
{
$r = q(
return 0;
}
+ /**
+ * @param object $uid user
+ * @param object $cid cid
+ * @param integer $start optional, default 0
+ * @param integer $limit optional, default 9999
+ * @param boolean $shuffle optional, default false
+ * @return object
+ */
public static function commonFriends($uid, $cid, $start = 0, $limit = 9999, $shuffle = false)
{
if ($shuffle) {
return $r;
}
- function commonFriendsZcid($uid, $zcid, $start = 0, $limit = 9999, $shuffle = false)
+ /**
+ * @param object $uid user
+ * @param object $zcid zcid
+ * @param integer $start optional, default 0
+ * @param integer $limit optional, default 9999
+ * @param boolean $shuffle optional, default false
+ * @return object
+ */
+ public static function commonFriendsZcid($uid, $zcid, $start = 0, $limit = 9999, $shuffle = false)
{
if ($shuffle) {
$sql_extra = " order by rand() ";
return $r;
}
+ /**
+ * @param object $uid user
+ * @param object $cid cid
+ * @return integer
+ */
public static function countAllFriends($uid, $cid)
{
$r = q(
if (DBM::is_result($r)) {
return $r[0]['total'];
}
-
+
return 0;
}
-
+ /**
+ * @param object $uid user
+ * @param object $cid cid
+ * @param integer $start optional, default 0
+ * @param integer $limit optional, default 80
+ * @return object
+ */
public static function allFriends($uid, $cid, $start = 0, $limit = 80)
{
$r = q(
return $r;
}
+ /**
+ * @param object $uid user
+ * @param integer $start optional, default 0
+ * @param integer $limit optional, default 80
+ * @return array
+ */
public static function suggestionQuery($uid, $start = 0, $limit = 80)
{
if (!$uid) {
return $list;
}
+ /**
+ * @return void
+ */
public static function updateSuggestions()
{
$a = get_app();
* @brief Replace alternate OStatus user format with the primary one
*
* @param arr $contact contact array (called by reference)
+ * @return void
*/
public static function fixAlternateContactAddress(&$contact)
{
if (DBM::is_result($r)) {
logger("Update public contact ".$r[0]["id"], LOGGER_DEBUG);
- update_contact_avatar($contact["photo"], 0, $r[0]["id"]);
+ Contact::updateAvatar($contact["photo"], 0, $r[0]["id"]);
$fields = array('name', 'nick', 'addr',
'network', 'bd', 'gender',
* @brief Updates the gcontact entry from probe
*
* @param str $url profile link
+ * @return void
*/
public static function updateFromProbe($url)
{
* @brief Update the gcontact entry for a given user id
*
* @param int $uid User ID
+ * @return void
*/
public static function updateForUser($uid)
{
intval($uid)
);
- $location = formatted_location(
+ $location = Profile::formatLocation(
array("locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"])
);
* If the "Statistics" plugin is enabled (See http://gstools.org/ for details) we query user data with this.
*
* @param str $server Server address
+ * @return void
*/
public static function fetchGsUsers($server)
{
/**
* @brief Asking GNU Social server on a regular base for their user data
- *
+ * @return void
*/
public static function discoverGsUsers()
{
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
}
}
+
+ /**
+ * @return string
+ */
+ public static function getRandomUrl()
+ {
+ $r = q(
+ "SELECT `url` FROM `gcontact` WHERE `network` = '%s'
+ AND `last_contact` >= `last_failure`
+ AND `updated` > UTC_TIMESTAMP - INTERVAL 1 MONTH
+ ORDER BY rand() LIMIT 1",
+ dbesc(NETWORK_DFRN)
+ );
+
+ if (DBM::is_result($r)) {
+ return dirname($r[0]['url']);
+ }
+
+ return '';
+ }
}