Class file relocations

Issue #3878
This commit is contained in:
Adam Magness 2017-11-07 22:57:46 -05:00
parent 6189f6c8e7
commit 4ca68c7af0
151 changed files with 987 additions and 8742 deletions

View file

@ -12,7 +12,7 @@ use Friendica\App;
use Friendica\Core\Config;
use Friendica\Core\System;
use Friendica\Core\Worker;
use Friendica\Database\Dbm;
use Friendica\Database\DBM;
use dba;
@ -35,7 +35,7 @@ require_once("include/xml.php");
* @brief This class contain functions to create and send DFRN XML files
*
*/
class Dfrn {
class DFRN {
const DFRN_TOP_LEVEL = 0; // Top level posting
const DFRN_REPLY = 1; // Regular reply that is stored locally
@ -119,7 +119,7 @@ class Dfrn {
dbesc($owner_nick)
);
if (! Dbm::is_result($r)) {
if (! DBM::is_result($r)) {
killme();
}
@ -154,7 +154,7 @@ class Dfrn {
intval($owner_id)
);
if (! Dbm::is_result($r)) {
if (! DBM::is_result($r)) {
killme();
}
@ -252,7 +252,7 @@ class Dfrn {
/// @TODO This hook can't work anymore
// call_hooks('atom_feed', $atom);
if (!Dbm::is_result($items) || $onlyheader) {
if (!DBM::is_result($items) || $onlyheader) {
$atom = trim($doc->saveXML());
call_hooks('atom_feed_end', $atom);
@ -321,7 +321,7 @@ class Dfrn {
intval($item_id)
);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
killme();
}
@ -334,7 +334,7 @@ class Dfrn {
intval($item['uid'])
);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
killme();
}
@ -582,7 +582,7 @@ class Dfrn {
$r = q("SELECT `id` FROM `profile` INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE (`hidewall` OR NOT `net-publish`) AND `user`.`uid` = %d",
intval($owner['uid']));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$hidewall = true;
} else {
$hidewall = false;
@ -638,7 +638,7 @@ class Dfrn {
INNER JOIN `user` ON `user`.`uid` = `profile`.`uid`
WHERE `profile`.`is-default` AND NOT `user`.`hidewall` AND `user`.`uid` = %d",
intval($owner['uid']));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$profile = $r[0];
xml::add_element($doc, $author, "poco:displayName", $profile["name"]);
@ -929,7 +929,7 @@ class Dfrn {
if (isset($parent_item)) {
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $item['parent-uri']);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
if ($r['conversation-uri'] != '') {
$conversation_uri = $r['conversation-uri'];
}
@ -1044,7 +1044,7 @@ class Dfrn {
intval($owner["uid"]),
dbesc(normalise_link($mention)));
if (Dbm::is_result($r) && ($r[0]["forum"] || $r[0]["prv"])) {
if (DBM::is_result($r) && ($r[0]["forum"] || $r[0]["prv"])) {
xml::add_element($doc, $entry, "link", "", array("rel" => "mentioned",
"ostatus:object-type" => ACTIVITY_OBJ_GROUP,
"href" => $mention));
@ -1356,7 +1356,7 @@ class Dfrn {
dbesc(datetime_convert("UTC","UTC", $birthday)),
dbesc("birthday"));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return;
}
@ -1402,7 +1402,7 @@ class Dfrn {
FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' AND `network` != '%s'",
intval($importer["uid"]), dbesc(normalise_link($author["link"])), dbesc(NETWORK_STATUSNET));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$contact = $r[0];
$author["contact-id"] = $r[0]["id"];
$author["network"] = $r[0]["network"];
@ -1444,7 +1444,7 @@ class Dfrn {
$author["avatar"] = current($avatarlist);
}
if (Dbm::is_result($r) && !$onlyfetch) {
if (DBM::is_result($r) && !$onlyfetch) {
logger("Check if contact details for contact " . $r[0]["id"] . " (" . $r[0]["nick"] . ") have to be updated.", LOGGER_DEBUG);
$poco = array("url" => $contact["url"]);
@ -1596,7 +1596,7 @@ class Dfrn {
dbesc($contact["name"]), dbesc($contact["nick"]), dbesc($contact["about"]), dbesc($contact["location"]),
dbesc($contact["addr"]), dbesc($contact["keywords"]), dbesc($contact["bdyear"]),
dbesc($contact["bd"]), intval($contact["hidden"]), dbesc($contact["xmpp"]),
dbesc(Dbm::date($contact["name-date"])), dbesc(Dbm::date($contact["uri-date"])),
dbesc(DBM::date($contact["name-date"])), dbesc(DBM::date($contact["uri-date"])),
intval($contact["id"]), dbesc($contact["network"]));
}
@ -1765,7 +1765,7 @@ class Dfrn {
*
* @see https://github.com/friendica/friendica/pull/3254#discussion_r107315246
*/
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return false;
}
@ -1777,7 +1777,7 @@ class Dfrn {
dbesc($suggest["name"]),
dbesc($suggest["request"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$fid = $r[0]["id"];
// OK, we do. Do we already have an introduction for this person ?
@ -1793,7 +1793,7 @@ class Dfrn {
*
* @see https://github.com/friendica/friendica/pull/3254#discussion_r107315246
*/
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return false;
}
}
@ -1815,7 +1815,7 @@ class Dfrn {
* If no record in fcontact is found, below INSERT statement will not
* link an introduction to it.
*/
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
// database record did not get created. Quietly give up.
killme();
}
@ -1897,7 +1897,7 @@ class Dfrn {
intval($importer["id"]),
intval($importer["importer_uid"]));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
logger("Query failed to execute, no result returned in " . __FUNCTION__);
return false;
}
@ -1973,7 +1973,7 @@ class Dfrn {
$n, dbesc($f[0]),
intval($importer["importer_uid"]));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$x = q("UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d",
$n, dbesc($f[1]),
$n, dbesc($f[0]),
@ -2077,7 +2077,7 @@ class Dfrn {
LIMIT 1",
dbesc($item["parent-uri"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$r = q("SELECT `item`.`forum_mode`, `item`.`wall` FROM `item`
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
WHERE `item`.`uri` = '%s' AND (`item`.`parent-uri` = '%s' OR `item`.`thr-parent` = '%s')
@ -2089,7 +2089,7 @@ class Dfrn {
dbesc($r[0]["parent-uri"]),
intval($importer["importer_uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$is_a_remote_action = true;
}
}
@ -2233,7 +2233,7 @@ class Dfrn {
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return false;
}
@ -2243,7 +2243,7 @@ class Dfrn {
dbesc($item["verb"]),
dbesc($item["parent-uri"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return false;
}
} else {
@ -2261,7 +2261,7 @@ class Dfrn {
intval($importer["importer_uid"])
);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
logger("Query failed to execute, no result returned in " . __FUNCTION__);
return false;
}
@ -2362,7 +2362,7 @@ class Dfrn {
);
// Is there an existing item?
if (Dbm::is_result($current) && edited_timestamp_is_newer($current[0], $item) &&
if (DBM::is_result($current) && edited_timestamp_is_newer($current[0], $item) &&
(datetime_convert("UTC","UTC",$item["edited"]) < $current[0]["edited"])) {
logger("Item ".$item["uri"]." already existed.", LOGGER_DEBUG);
return;
@ -2597,7 +2597,7 @@ class Dfrn {
dbesc($item["uri"]),
intval($importer["uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$ev["id"] = $r[0]["id"];
}
@ -2614,7 +2614,7 @@ class Dfrn {
}
// Update content if 'updated' changes
if (Dbm::is_result($current)) {
if (DBM::is_result($current)) {
if (self::update_content($r[0], $item, $importer, $entrytype)) {
logger("Item ".$item["uri"]." was updated.", LOGGER_DEBUG);
} else {
@ -2637,7 +2637,7 @@ class Dfrn {
intval($posted_id),
intval($importer["importer_uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$parent = $r[0]["parent"];
$parent_uri = $r[0]["parent-uri"];
}
@ -2732,7 +2732,7 @@ class Dfrn {
intval($importer["uid"]),
intval($importer["id"])
);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
logger("Item with uri " . $uri . " from contact " . $importer["id"] . " for user " . $importer["uid"] . " wasn't found.", LOGGER_DEBUG);
return;
} else {
@ -2762,7 +2762,7 @@ class Dfrn {
dbesc($xt->id),
intval($importer["importer_uid"])
);
if (Dbm::is_result($i)) {
if (DBM::is_result($i)) {
// For tags, the owner cannot remove the tag on the author's copy of the post.
@ -2830,7 +2830,7 @@ class Dfrn {
dbesc($item["parent-uri"]),
intval($importer["uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
q("UPDATE `item` SET `last-child` = 1 WHERE `id` = %d",
intval($r[0]["id"])
);

View file

@ -15,7 +15,7 @@ use Friendica\Core\System;
use Friendica\Core\Config;
use Friendica\Core\PConfig;
use Friendica\Core\Worker;
use Friendica\Database\Dbm;
use Friendica\Database\DBM;
use Friendica\Network\Probe;
use dba;
@ -459,7 +459,7 @@ class Diaspora {
dbesc($msg["author"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
foreach ($r as $rr) {
logger("delivering to: ".$rr["username"]);
self::dispatch($rr, $msg, $fields);
@ -840,7 +840,7 @@ class Diaspora {
$r = q("SELECT `addr` FROM `gcontact` WHERE `id` = %d AND `addr` != ''",
intval($gcontact_id));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return strtolower($r[0]["addr"]);
}
}
@ -848,7 +848,7 @@ class Diaspora {
$r = q("SELECT `network`, `addr`, `self`, `url`, `nick` FROM `contact` WHERE `id` = %d",
intval($contact_id));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$contact = $r[0];
logger("contact 'self' = ".$contact['self']." 'url' = ".$contact['url'], LOGGER_DEBUG);
@ -882,7 +882,7 @@ class Diaspora {
dbesc($fcontact_guid)
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0]['url'];
}
@ -905,7 +905,7 @@ class Diaspora {
dbesc($handle)
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0];
} else {
/*
@ -918,7 +918,7 @@ class Diaspora {
/// @TODO Contact retrieval should be encapsulated into an "entity" class like `Contact`
$r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1", intval($cid));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0];
}
}
@ -931,7 +931,7 @@ class Diaspora {
intval($uid),
dbesc($nurl_sql)
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0];
}
@ -1026,7 +1026,7 @@ class Diaspora {
dbesc($guid)
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
logger("message ".$guid." already exists for user ".$uid);
return $r[0]["id"];
}
@ -1298,7 +1298,7 @@ class Diaspora {
$r = q("SELECT `url`, `nick`, `network` FROM `fcontact` WHERE `addr`='%s' LIMIT 1", dbesc($addr));
// Fallback
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
if ($parent_guid != '') {
return "https://".substr($addr,strpos($addr,"@") + 1)."/posts/".$parent_guid."#".$guid;
} else {
@ -1309,7 +1309,7 @@ class Diaspora {
// Friendica contacts are often detected as Diaspora contacts in the "fcontact" table
// So we try another way as well.
$s = q("SELECT `network` FROM `gcontact` WHERE `nurl`='%s' LIMIT 1", dbesc(normalise_link($r[0]["url"])));
if (Dbm::is_result($s)) {
if (DBM::is_result($s)) {
$r[0]["network"] = $s[0]["network"];
}
@ -1396,7 +1396,7 @@ class Diaspora {
$n, dbesc($f[0]),
intval($importer["uid"]));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
$x = q("UPDATE `item` SET `%s` = '%s' WHERE `%s` = '%s' AND `uid` = %d",
$n, dbesc($f[1]),
$n, dbesc($f[0]),
@ -1450,7 +1450,7 @@ class Diaspora {
private static function get_uri_from_guid($author, $guid, $onlyfound = false) {
$r = q("SELECT `uri` FROM `item` WHERE `guid` = '%s' LIMIT 1", dbesc($guid));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0]["uri"];
} elseif (!$onlyfound) {
return $author.":".$guid;
@ -1470,7 +1470,7 @@ class Diaspora {
private static function get_guid_from_uri($uri, $uid) {
$r = q("SELECT `guid` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($uri), intval($uid));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
return $r[0]["guid"];
} else {
return false;
@ -1487,10 +1487,10 @@ class Diaspora {
private static function importer_for_guid($guid) {
$item = dba::fetch_first("SELECT `uid` FROM `item` WHERE `origin` AND `guid` = ? LIMIT 1", $guid);
if (Dbm::is_result($item)) {
if (DBM::is_result($item)) {
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
$contact = dba::fetch_first("SELECT * FROM `contact` WHERE `self` AND `uid` = ?", $item['uid']);
if (Dbm::is_result($contact)) {
if (DBM::is_result($contact)) {
return $contact;
}
}
@ -1664,7 +1664,7 @@ class Diaspora {
dbesc($msg_guid),
intval($importer["uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
logger("duplicate message already delivered.", LOGGER_DEBUG);
return false;
}
@ -1977,7 +1977,7 @@ class Diaspora {
dbesc($guid),
intval($importer["uid"])
);
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
logger("duplicate message already delivered.", LOGGER_DEBUG);
return false;
}
@ -2419,7 +2419,7 @@ class Diaspora {
FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
dbesc($guid));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
logger("reshared message ".$guid." already exists on system.");
// Maybe it is already a reshared item?
@ -2441,7 +2441,7 @@ class Diaspora {
}
}
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
$server = "https://".substr($orig_author, strpos($orig_author, "@") + 1);
logger("1st try: reshared message ".$guid." will be fetched via SSL from the server ".$server);
$item_id = self::store_by_guid($guid, $server);
@ -2458,7 +2458,7 @@ class Diaspora {
FROM `item` WHERE `id` = %d AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
intval($item_id));
if (Dbm::is_result($r)) {
if (DBM::is_result($r)) {
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
if (self::is_reshare($r[0]["body"], false)) {
$r[0]["body"] = diaspora2bb(bb2diaspora($r[0]["body"]));
@ -2589,7 +2589,7 @@ class Diaspora {
$condition = array("`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']);
}
$r = dba::select('item', $fields, $condition);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");
return false;
}
@ -3231,7 +3231,7 @@ class Diaspora {
private static function build_event($event_id) {
$r = q("SELECT `guid`, `uid`, `start`, `finish`, `nofinish`, `summary`, `desc`, `location`, `adjust` FROM `event` WHERE `id` = %d", intval($event_id));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
return array();
}
@ -3240,14 +3240,14 @@ class Diaspora {
$eventdata = array();
$r = q("SELECT `timezone` FROM `user` WHERE `uid` = %d", intval($event['uid']));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
return array();
}
$user = $r[0];
$r = q("SELECT `addr`, `nick` FROM `contact` WHERE `uid` = %d AND `self`", intval($event['uid']));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
return array();
}
@ -3424,7 +3424,7 @@ class Diaspora {
$p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"]));
if (!Dbm::is_result($p))
if (!DBM::is_result($p))
return false;
$parent = $p[0];
@ -3456,7 +3456,7 @@ class Diaspora {
$p = q("SELECT `guid`, `uri`, `parent-uri` FROM `item` WHERE `uri` = '%s' LIMIT 1",
dbesc($item["thr-parent"]));
if (!Dbm::is_result($p))
if (!DBM::is_result($p))
return false;
$parent = $p[0];
@ -3505,7 +3505,7 @@ class Diaspora {
intval($item["parent"])
);
if (!Dbm::is_result($p))
if (!DBM::is_result($p))
return false;
$parent = $p[0];
@ -3727,7 +3727,7 @@ class Diaspora {
intval($item["uid"])
);
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
logger("conversation not found.");
return;
}
@ -3886,14 +3886,14 @@ class Diaspora {
}
$r = q("SELECT `prvkey` FROM `user` WHERE `uid` = %d LIMIT 1", intval($contact['uid']));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
return false;
}
$contact["uprvkey"] = $r[0]['prvkey'];
$r = q("SELECT * FROM `item` WHERE `id` = %d LIMIT 1", intval($post_id));
if (!Dbm::is_result($r)) {
if (!DBM::is_result($r)) {
return false;
}