added more curly braces + a bit more usage of dbm::is_result()

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-01-25 15:59:27 +01:00
parent 7997df877d
commit f66cb9b0a3
No known key found for this signature in database
GPG Key ID: B72F8185C6C7BD78

View File

@ -63,7 +63,7 @@ class DFRN
* @param array $owner Owner record * @param array $owner Owner record
* *
* @return string DFRN entries * @return string DFRN entries
* @todo Add type-hints * @todo Find proper type-hints
*/ */
public static function entries($items, $owner) public static function entries($items, $owner)
{ {
@ -96,6 +96,7 @@ class DFRN
* @param boolean $onlyheader Output only the header without content? (Default is "no") * @param boolean $onlyheader Output only the header without content? (Default is "no")
* *
* @return string DFRN feed entries * @return string DFRN feed entries
* @todo Find proper type-hints
*/ */
public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false) public static function feed($dfrn_id, $owner_nick, $last_update, $direction = 0, $onlyheader = false)
{ {
@ -120,8 +121,6 @@ class DFRN
} }
} }
// default permissions - anonymous user // default permissions - anonymous user
$sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' "; $sql_extra = " AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' ";
@ -134,6 +133,8 @@ class DFRN
); );
if (! DBM::is_result($r)) { if (! DBM::is_result($r)) {
if (! dbm::is_result($r)) {
logger(sprintf('No contact found for nickname=%d', $owner_nick), LOGGER_WARNING);
killme(); killme();
} }
@ -169,6 +170,7 @@ class DFRN
); );
if (! DBM::is_result($r)) { if (! DBM::is_result($r)) {
logger(sprintf('No contact found for uid=%d', $owner_id), LOGGER_WARNING);
killme(); killme();
} }
@ -177,8 +179,9 @@ class DFRN
$groups = Group::getIdsByContactId($contact['id']); $groups = Group::getIdsByContactId($contact['id']);
if (count($groups)) { if (count($groups)) {
for ($x = 0; $x < count($groups); $x ++) for ($x = 0; $x < count($groups); $x ++) {
$groups[$x] = '<' . intval($groups[$x]) . '>' ; $groups[$x] = '<' . intval($groups[$x]) . '>' ;
}
$gs = implode('|', $groups); $gs = implode('|', $groups);
} else { } else {
$gs = '<<>>' ; // Impossible to match $gs = '<<>>' ; // Impossible to match
@ -397,7 +400,7 @@ class DFRN
* @param array $owner Owner record * @param array $owner Owner record
* *
* @return string DFRN mail * @return string DFRN mail
* @todo Add type-hints * @todo Find proper type-hints
*/ */
public static function mail($item, $owner) public static function mail($item, $owner)
{ {
@ -433,7 +436,7 @@ class DFRN
* @param array $owner Owner record * @param array $owner Owner record
* *
* @return string DFRN suggestions * @return string DFRN suggestions
* @todo Add type-hints * @todo Find proper type-hints
*/ */
public static function fsuggest($item, $owner) public static function fsuggest($item, $owner)
{ {
@ -462,7 +465,7 @@ class DFRN
* @param int $uid User ID * @param int $uid User ID
* *
* @return string DFRN relocations * @return string DFRN relocations
* @todo Add type-hints * @todo Find proper type-hints
*/ */
public static function relocate($owner, $uid) public static function relocate($owner, $uid)
{ {
@ -524,7 +527,7 @@ class DFRN
* @param bool $public Is it a header for public posts? * @param bool $public Is it a header for public posts?
* *
* @return object XML root object * @return object XML root object
* @todo Add type-hints * @todo Find proper type-hints
*/ */
private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false) private static function addHeader($doc, $owner, $authorelement, $alternatelink = "", $public = false)
{ {
@ -600,7 +603,7 @@ class DFRN
* @param boolean $public boolean * @param boolean $public boolean
* *
* @return object XML author object * @return object XML author object
* @todo Add type-hints * @todo Find proper type-hints
*/ */
private static function addAuthor($doc, $owner, $authorelement, $public) private static function addAuthor($doc, $owner, $authorelement, $public)
{ {
@ -744,7 +747,7 @@ class DFRN
* @param array $item Item elements * @param array $item Item elements
* *
* @return object XML author object * @return object XML author object
* @todo Add type-hints * @todo Find proper type-hints
*/ */
private static function addEntryAuthor($doc, $element, $contact_url, $item) private static function addEntryAuthor($doc, $element, $contact_url, $item)
{ {
@ -785,7 +788,7 @@ class DFRN
* @param string $activity activity value * @param string $activity activity value
* *
* @return object XML activity object * @return object XML activity object
* @todo Add type-hints * @todo Find proper type-hints
*/ */
private static function createActivity($doc, $element, $activity) private static function createActivity($doc, $element, $activity)
{ {
@ -796,12 +799,15 @@ class DFRN
if (!$r) { if (!$r) {
return false; return false;
} }
if ($r->type) { if ($r->type) {
XML::addElement($doc, $entry, "activity:object-type", $r->type); XML::addElement($doc, $entry, "activity:object-type", $r->type);
} }
if ($r->id) { if ($r->id) {
XML::addElement($doc, $entry, "id", $r->id); XML::addElement($doc, $entry, "id", $r->id);
} }
if ($r->title) { if ($r->title) {
XML::addElement($doc, $entry, "title", $r->title); XML::addElement($doc, $entry, "title", $r->title);
} }
@ -848,7 +854,7 @@ class DFRN
* @param array $item Item element * @param array $item Item element
* *
* @return object XML attachment object * @return object XML attachment object
* @todo Add type-hints * @todo Find proper type-hints
*/ */
private static function getAttachment($doc, $root, $item) private static function getAttachment($doc, $root, $item)
{ {
@ -888,7 +894,7 @@ class DFRN
* @param bool $single If set, the entry is created as an XML document with a single "entry" element * @param bool $single If set, the entry is created as an XML document with a single "entry" element
* *
* @return object XML entry object * @return object XML entry object
* @todo Add 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, $item, $owner, $comment = false, $cid = 0, $single = false)
{ {
@ -1289,7 +1295,6 @@ class DFRN
$postvars['dissolve'] = '1'; $postvars['dissolve'] = '1';
} }
if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) { if ((($contact['rel']) && ($contact['rel'] != CONTACT_IS_SHARING) && (! $contact['blocked'])) || ($owner['page-flags'] == PAGE_COMMUNITY)) {
$postvars['data'] = $atom; $postvars['data'] = $atom;
$postvars['perm'] = 'rw'; $postvars['perm'] = 'rw';