Continued:
- avoided else() block which reduces code complexibility - used more x() - added curly braces - added known type-hints Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
parent
e0a07d5f27
commit
57e668d9e0
|
@ -1120,7 +1120,7 @@ function builtin_activity_puller($item, &$conv_responses) {
|
||||||
|
|
||||||
$url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
|
$url = '<a href="'. $url . '"'. $sparkle .'>' . htmlentities($item['author-name']) . '</a>';
|
||||||
|
|
||||||
if (!$item['thr-parent']) {
|
if (!x($item, 'thr-parent')) {
|
||||||
$item['thr-parent'] = $item['parent-uri'];
|
$item['thr-parent'] = $item['parent-uri'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -63,17 +63,19 @@ function subthread_content(App $a) {
|
||||||
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
|
WHERE `contact`.`self` = 1 AND `contact`.`uid` = %d LIMIT 1",
|
||||||
intval($owner_uid)
|
intval($owner_uid)
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r))
|
|
||||||
|
if (DBM::is_result($r)) {
|
||||||
$owner = $r[0];
|
$owner = $r[0];
|
||||||
|
}
|
||||||
|
|
||||||
if (! $owner) {
|
if (! $owner) {
|
||||||
logger('like: no owner');
|
logger('like: no owner');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $remote_owner)
|
if (! $remote_owner) {
|
||||||
$remote_owner = $owner;
|
$remote_owner = $owner;
|
||||||
|
}
|
||||||
|
|
||||||
$contact = null;
|
$contact = null;
|
||||||
// This represents the person posting
|
// This represents the person posting
|
||||||
|
@ -85,9 +87,11 @@ function subthread_content(App $a) {
|
||||||
intval($_SESSION['visitor_id']),
|
intval($_SESSION['visitor_id']),
|
||||||
intval($owner_uid)
|
intval($owner_uid)
|
||||||
);
|
);
|
||||||
if (DBM::is_result($r))
|
|
||||||
|
if (DBM::is_result($r)) {
|
||||||
$contact = $r[0];
|
$contact = $r[0];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (! $contact) {
|
if (! $contact) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,10 +159,12 @@ EOT;
|
||||||
}
|
}
|
||||||
|
|
||||||
$term_objtype = ($item['resource-id'] ? TERM_OBJ_PHOTO : TERM_OBJ_POST);
|
$term_objtype = ($item['resource-id'] ? TERM_OBJ_PHOTO : TERM_OBJ_POST);
|
||||||
|
|
||||||
$t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
|
$t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
|
||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
dbesc($term)
|
dbesc($term)
|
||||||
);
|
);
|
||||||
|
|
||||||
if ((!$blocktags) && $t[0]['tcount'] == 0 ) {
|
if ((!$blocktags) && $t[0]['tcount'] == 0 ) {
|
||||||
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
|
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
|
||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
|
@ -176,19 +178,21 @@ EOT;
|
||||||
|
|
||||||
// if the original post is on this site, update it.
|
// if the original post is on this site, update it.
|
||||||
|
|
||||||
$r = q("select `tag`,`id`,`uid` from item where `origin` = 1 AND `uri` = '%s' LIMIT 1",
|
$r = q("SELECT `tag`,`id`,`uid` FROM `item` WHERE `origin`=1 AND `uri`='%s' LIMIT 1",
|
||||||
dbesc($item['uri'])
|
dbesc($item['uri'])
|
||||||
);
|
);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
$x = q("SELECT `blocktags` FROM `user` WHERE `uid` = %d limit 1",
|
$x = q("SELECT `blocktags` FROM `user` WHERE `uid`=%d LIMIT 1",
|
||||||
intval($r[0]['uid'])
|
intval($r[0]['uid'])
|
||||||
);
|
);
|
||||||
$t = q("SELECT count(tid) as tcount FROM term WHERE oid=%d AND term='%s'",
|
$t = q("SELECT COUNT(`tid`) AS `tcount` FROM `term` WHERE `oid`=%d AND `term`='%s'",
|
||||||
intval($r[0]['id']),
|
intval($r[0]['id']),
|
||||||
dbesc($term)
|
dbesc($term)
|
||||||
);
|
);
|
||||||
if(count($x) && !$x[0]['blocktags'] && $t[0]['tcount']==0){
|
|
||||||
q("INSERT INTO term (oid, otype, type, term, url, uid) VALUE (%d, %d, %d, '%s', '%s', %d)",
|
if (DBM::is_result($x) && !$x[0]['blocktags'] && $t[0]['tcount'] == 0){
|
||||||
|
q("INSERT INTO term (`oid`, `otype`, `type`, `term`, `url`, `uid`) VALUE (%d, %d, %d, '%s', '%s', %d)",
|
||||||
intval($r[0]['id']),
|
intval($r[0]['id']),
|
||||||
$term_objtype,
|
$term_objtype,
|
||||||
TERM_HASHTAG,
|
TERM_HASHTAG,
|
||||||
|
|
|
@ -803,10 +803,10 @@ class Event extends BaseObject
|
||||||
/**
|
/**
|
||||||
* @brief Format an item array with event data to HTML.
|
* @brief Format an item array with event data to HTML.
|
||||||
*
|
*
|
||||||
* @param arr $item Array with item and event data.
|
* @param array $item Array with item and event data.
|
||||||
* @return string HTML output.
|
* @return string HTML output.
|
||||||
*/
|
*/
|
||||||
public static function getItemHTML($item) {
|
public static function getItemHTML(array $item) {
|
||||||
$same_date = false;
|
$same_date = false;
|
||||||
$finish = false;
|
$finish = false;
|
||||||
|
|
||||||
|
|
|
@ -1032,8 +1032,9 @@ class Item extends BaseObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Is this a shadow entry?
|
// Is this a shadow entry?
|
||||||
if ($item['uid'] == 0)
|
if ($item['uid'] == 0) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Is there a shadow parent?
|
// Is there a shadow parent?
|
||||||
if (!dba::exists('item', ['uri' => $item['parent-uri'], 'uid' => 0])) {
|
if (!dba::exists('item', ['uri' => $item['parent-uri'], 'uid' => 0])) {
|
||||||
|
@ -1073,12 +1074,10 @@ class Item extends BaseObject
|
||||||
|
|
||||||
// If this was a comment to a Diaspora post we don't get our comment back.
|
// If this was a comment to a Diaspora post we don't get our comment back.
|
||||||
// This means that we have to distribute the comment by ourselves.
|
// This means that we have to distribute the comment by ourselves.
|
||||||
if ($origin) {
|
if ($origin && dba::exists('item', ['id' => $parent, 'network' => NETWORK_DIASPORA])) {
|
||||||
if (dba::exists('item', ['id' => $parent, 'network' => NETWORK_DIASPORA])) {
|
|
||||||
self::distribute($public_shadow);
|
self::distribute($public_shadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a "lang" specification in a "postopts" element of given $arr,
|
* Adds a "lang" specification in a "postopts" element of given $arr,
|
||||||
|
@ -1087,14 +1086,14 @@ class Item extends BaseObject
|
||||||
*/
|
*/
|
||||||
private static function addLanguageInPostopts(&$item)
|
private static function addLanguageInPostopts(&$item)
|
||||||
{
|
{
|
||||||
|
$postopts = "";
|
||||||
|
|
||||||
if (!empty($item['postopts'])) {
|
if (!empty($item['postopts'])) {
|
||||||
if (strstr($item['postopts'], 'lang=')) {
|
if (strstr($item['postopts'], 'lang=')) {
|
||||||
// do not override
|
// do not override
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$postopts = $item['postopts'];
|
$postopts = $item['postopts'];
|
||||||
} else {
|
|
||||||
$postopts = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$naked_body = Text\BBCode::toPlaintext($item['body'], false);
|
$naked_body = Text\BBCode::toPlaintext($item['body'], false);
|
||||||
|
|
|
@ -892,7 +892,7 @@ class DFRN
|
||||||
* @return object XML entry object
|
* @return object XML entry object
|
||||||
* @todo Find proper type-hints
|
* @todo Find proper type-hints
|
||||||
*/
|
*/
|
||||||
private static function entry($doc, $type, $item, $owner, $comment = false, $cid = 0, $single = false)
|
private static function entry($doc, $type, array $item, array $owner, $comment = false, $cid = 0, $single = false)
|
||||||
{
|
{
|
||||||
$mentioned = [];
|
$mentioned = [];
|
||||||
|
|
||||||
|
|
|
@ -1948,7 +1948,7 @@ class OStatus
|
||||||
* @param bool $complete default true
|
* @param bool $complete default true
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private static function entryFooter($doc, $entry, $item, $owner, $complete = true)
|
private static function entryFooter($doc, $entry, array $item, array $owner, $complete = true)
|
||||||
{
|
{
|
||||||
$mentioned = [];
|
$mentioned = [];
|
||||||
|
|
||||||
|
@ -1988,6 +1988,7 @@ class OStatus
|
||||||
|
|
||||||
if (isset($parent_item)) {
|
if (isset($parent_item)) {
|
||||||
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $parent_item);
|
$r = dba::fetch_first("SELECT `conversation-uri`, `conversation-href` FROM `conversation` WHERE `item-uri` = ?", $parent_item);
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($r)) {
|
||||||
if ($r['conversation-uri'] != '') {
|
if ($r['conversation-uri'] != '') {
|
||||||
$conversation_uri = $r['conversation-uri'];
|
$conversation_uri = $r['conversation-uri'];
|
||||||
|
@ -2048,9 +2049,11 @@ class OStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
if ($owner['account-type'] == ACCOUNT_TYPE_COMMUNITY) {
|
||||||
XML::addElement($doc, $entry, "link", "", ["rel" => "mentioned",
|
XML::addElement($doc, $entry, "link", "", [
|
||||||
|
"rel" => "mentioned",
|
||||||
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
|
"ostatus:object-type" => "http://activitystrea.ms/schema/1.0/group",
|
||||||
"href" => $owner['url']]);
|
"href" => $owner['url']
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$item["private"]) {
|
if (!$item["private"]) {
|
||||||
|
|
Loading…
Reference in a new issue