Change called method names
- Add GlobalContact::getRandomUrl - Rename Contact::getIdForURL - Rename Diaspora::sendUnshare - Remove unused parameter $self in Contact::terminateFriendship
This commit is contained in:
parent
b92fc24ff0
commit
ec02af593d
48 changed files with 133 additions and 133 deletions
|
@ -775,7 +775,7 @@ class NotificationsManager
|
|||
$sql_extra = " AND `ignore` = 0 ";
|
||||
}
|
||||
|
||||
/// @todo Fetch contact details by "get_contact_details_by_url" instead of queries to contact, fcontact and gcontact
|
||||
/// @todo Fetch contact details by "Contact::getDetailsByUrl" instead of queries to contact, fcontact and gcontact
|
||||
$r = q(
|
||||
"SELECT `intro`.`id` AS `intro_id`, `intro`.*, `contact`.*,
|
||||
`fcontact`.`name` AS `fname`, `fcontact`.`url` AS `furl`,
|
||||
|
@ -904,7 +904,7 @@ class NotificationsManager
|
|||
// If the network and addr is still not available
|
||||
// get the missing data data from other sources
|
||||
if ($arr['gnetwork'] == "" || $arr['gaddr'] == "") {
|
||||
$ret = get_contact_details_by_url($arr['url']);
|
||||
$ret = Contact::getDetailsByURL($arr['url']);
|
||||
|
||||
if ($arr['gnetwork'] == "" && $ret['network'] != "") {
|
||||
$arr['gnetwork'] = $ret['network'];
|
||||
|
|
|
@ -895,7 +895,7 @@ class GlobalContact
|
|||
intval($uid)
|
||||
);
|
||||
|
||||
$location = formatted_location(
|
||||
$location = Profile::formatLocation(
|
||||
array("locality" => $r[0]["locality"], "region" => $r[0]["region"], "country-name" => $r[0]["country-name"])
|
||||
);
|
||||
|
||||
|
@ -1002,4 +1002,16 @@ class GlobalContact
|
|||
q("UPDATE `gserver` SET `last_poco_query` = '%s' WHERE `nurl` = '%s'", dbesc(datetime_convert()), dbesc($server["nurl"]));
|
||||
}
|
||||
}
|
||||
|
||||
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 '';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -793,7 +793,7 @@ class Probe {
|
|||
}
|
||||
}
|
||||
|
||||
$location = formatted_location($json);
|
||||
$location = Profile::formatLocation($json);
|
||||
if ($location) {
|
||||
$data["location"] = $location;
|
||||
}
|
||||
|
|
|
@ -538,7 +538,7 @@ class Contact extends BaseObject
|
|||
*
|
||||
* @return integer Contact ID
|
||||
*/
|
||||
public static function getIdForUrl($url, $uid = 0, $no_update = false)
|
||||
public static function getIdForURL($url, $uid = 0, $no_update = false)
|
||||
{
|
||||
logger("Get contact data for url " . $url . " and user " . $uid . " - " . System::callstack(), LOGGER_DEBUG);
|
||||
|
||||
|
@ -603,7 +603,7 @@ class Contact extends BaseObject
|
|||
}
|
||||
|
||||
if (!$contact_id && ($data["alias"] != '') && ($data["alias"] != $url)) {
|
||||
$contact_id = self::getIdForUrl($data["alias"], $uid, true);
|
||||
$contact_id = self::getIdForURL($data["alias"], $uid, true);
|
||||
}
|
||||
|
||||
$url = $data["url"];
|
||||
|
|
|
@ -708,7 +708,7 @@ class DFRN
|
|||
if (trim($profile["locality"].$profile["region"].$profile["country-name"]) != "") {
|
||||
$element = $doc->createElement("poco:address");
|
||||
|
||||
XML::add_element($doc, $element, "poco:formatted", formatted_location($profile));
|
||||
XML::add_element($doc, $element, "poco:formatted", Profile::formatLocation($profile));
|
||||
|
||||
if (trim($profile["locality"]) != "") {
|
||||
XML::add_element($doc, $element, "poco:locality", $profile["locality"]);
|
||||
|
@ -742,8 +742,7 @@ class DFRN
|
|||
*/
|
||||
private static function add_entry_author($doc, $element, $contact_url, $item)
|
||||
{
|
||||
|
||||
$contact = get_contact_details_by_url($contact_url, $item["uid"]);
|
||||
$contact = Contact::getDetailsByURL($contact_url, $item["uid"]);
|
||||
|
||||
$author = $doc->createElement($element);
|
||||
XML::add_element($doc, $author, "name", $contact["name"]);
|
||||
|
@ -1373,8 +1372,7 @@ class DFRN
|
|||
|
||||
if ($contact['term-date'] > NULL_DATE) {
|
||||
logger("dfrn_deliver: $url back from the dead - removing mark for death");
|
||||
include_once 'include/Contact.php';
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
$res = parse_xml_string($xml);
|
||||
|
|
|
@ -950,7 +950,7 @@ class Diaspora
|
|||
* We haven't found it?
|
||||
* We use another function for it that will possibly create a contact entry.
|
||||
*/
|
||||
$cid = get_contact($handle, $uid);
|
||||
$cid = Contact::getIdForURL($handle, $uid);
|
||||
|
||||
if ($cid > 0) {
|
||||
/// @TODO Contact retrieval should be encapsulated into an "entity" class like `Contact`
|
||||
|
@ -1342,7 +1342,7 @@ class Diaspora
|
|||
|
||||
// We are receiving content from a user that possibly is about to be terminated
|
||||
// This means the user is vital, so we remove a possible termination date.
|
||||
unmark_for_death($r[0]);
|
||||
Contact::unmarkForArchival($r[0]);
|
||||
} else {
|
||||
$cid = $contact["id"];
|
||||
$network = NETWORK_DIASPORA;
|
||||
|
@ -1521,7 +1521,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
// We now remove the contact
|
||||
contact_remove($contact["id"]);
|
||||
Contact::remove($contact["id"]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2810,7 +2810,7 @@ class Diaspora
|
|||
case "Person":
|
||||
/// @todo What should we do with an "unshare"?
|
||||
// Removing the contact isn't correct since we still can read the public items
|
||||
contact_remove($contact["id"]);
|
||||
Contact::remove($contact["id"]);
|
||||
return true;
|
||||
|
||||
default:
|
||||
|
@ -3151,11 +3151,11 @@ class Diaspora
|
|||
add_to_queue($contact["id"], NETWORK_DIASPORA, $envelope, $public_batch);
|
||||
|
||||
// The message could not be delivered. We mark the contact as "dead"
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
}
|
||||
} elseif (($return_code >= 200) && ($return_code <= 299)) {
|
||||
// We successfully delivered a message, the contact is alive
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
return(($return_code) ? $return_code : (-1));
|
||||
|
@ -3291,7 +3291,7 @@ class Diaspora
|
|||
*
|
||||
* @return int The result of the transmission
|
||||
*/
|
||||
public static function send_unshare($owner, $contact)
|
||||
public static function sendUnshare($owner, $contact)
|
||||
{
|
||||
$message = array("author" => self::my_handle($owner),
|
||||
"recipient" => $contact["addr"],
|
||||
|
@ -4007,7 +4007,7 @@ class Diaspora
|
|||
$about = $profile['about'];
|
||||
$about = strip_tags(bbcode($about));
|
||||
|
||||
$location = formatted_location($profile);
|
||||
$location = Profile::formatLocation($profile);
|
||||
$tags = '';
|
||||
if ($profile['pub_keywords']) {
|
||||
$kw = str_replace(',', ' ', $profile['pub_keywords']);
|
||||
|
|
|
@ -153,7 +153,7 @@ class OStatus
|
|||
// Only update the contacts if it is an OStatus contact
|
||||
if ($r && ($r['id'] > 0) && !$onlyfetch && ($contact["network"] == NETWORK_OSTATUS)) {
|
||||
// This contact is vital, so we awake it from the dead
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
|
||||
// Update contact data
|
||||
|
||||
|
@ -208,7 +208,7 @@ class OStatus
|
|||
}
|
||||
|
||||
// Ensure that we are having this contact (with uid=0)
|
||||
$cid = get_contact($aliaslink, 0);
|
||||
$cid = Contact::getIdForURL($aliaslink, 0);
|
||||
|
||||
if ($cid) {
|
||||
$fields = array('url', 'nurl', 'name', 'nick', 'alias', 'about', 'location');
|
||||
|
@ -2098,7 +2098,7 @@ class OStatus
|
|||
}
|
||||
|
||||
$check_date = datetime_convert('UTC', 'UTC', $last_update, 'Y-m-d H:i:s');
|
||||
$authorid = get_contact($owner["url"], 0);
|
||||
$authorid = Contact::getIdForURL($owner["url"], 0);
|
||||
|
||||
$items = q(
|
||||
"SELECT `item`.*, `item`.`id` AS `item_id` FROM `item` USE INDEX (`uid_contactid_created`)
|
||||
|
|
|
@ -401,7 +401,7 @@ class PortableContact
|
|||
}
|
||||
}
|
||||
|
||||
$location = formatted_location($noscrape);
|
||||
$location = Profile::formatLocation($noscrape);
|
||||
if ($location) {
|
||||
$contact["location"] = $location;
|
||||
}
|
||||
|
|
|
@ -354,10 +354,10 @@ class Delivery {
|
|||
add_to_queue($contact['id'],NETWORK_DFRN,$atom);
|
||||
|
||||
// The message could not be delivered. We mark the contact as "dead"
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
} else {
|
||||
// We successfully delivered a message, the contact is alive
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -120,19 +120,13 @@ class Notifier {
|
|||
|
||||
$user = $r[0];
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` LIMIT 1", intval($item_id));
|
||||
if (!$r)
|
||||
return;
|
||||
|
||||
$self = $r[0];
|
||||
|
||||
$r = q("SELECT * FROM `contact` WHERE NOT `self` AND `uid` = %d", intval($item_id));
|
||||
if (!$r) {
|
||||
return;
|
||||
}
|
||||
require_once 'include/Contact.php';
|
||||
foreach ($r as $contact) {
|
||||
terminate_friendship($user, $self, $contact);
|
||||
Contact::terminateFriendship($user, $contact);
|
||||
}
|
||||
return;
|
||||
} elseif ($cmd === 'relocate') {
|
||||
|
|
|
@ -127,11 +127,11 @@ Class OnePoll
|
|||
}
|
||||
|
||||
if (!update_contact($contact["id"])) {
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
logger('Contact is marked dead');
|
||||
return;
|
||||
} else {
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,7 +197,7 @@ Class OnePoll
|
|||
// mean the software was uninstalled or the domain expired.
|
||||
// Will keep trying for one month.
|
||||
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
// set the last-update so we don't keep polling
|
||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||
|
@ -209,7 +209,7 @@ Class OnePoll
|
|||
if (!strstr($handshake_xml, '<')) {
|
||||
logger('poller: response from ' . $url . ' did not contain XML.');
|
||||
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
|
||||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
||||
|
@ -228,10 +228,10 @@ Class OnePoll
|
|||
$fields = array('last-update' => datetime_convert(), 'failure_update' => datetime_convert());
|
||||
dba::update('contact', $fields, array('id' => $contact['id']));
|
||||
|
||||
mark_for_death($contact);
|
||||
Contact::markForArchival($contact);
|
||||
} elseif ($contact['term-date'] > NULL_DATE) {
|
||||
logger("poller: $url back from the dead - removing mark for death");
|
||||
unmark_for_death($contact);
|
||||
Contact::unmarkForArchival($contact);
|
||||
}
|
||||
|
||||
if ((intval($res->status) != 0) || !strlen($res->challenge) || !strlen($res->dfrn_id)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue