// get contact info for owner
if ($profile_uid == local_user() || $allow_comment) {
- $contact_record = $author;
+ $contact_record = $author ?: [];
} else {
- $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]);
+ $contact_record = DBA::selectFirst('contact', [], ['uid' => $profile_uid, 'self' => true]) ?: [];
}
// Look for any tags and linkify them
$original_contact_id = $contact_id;
- if (!$toplevel_item_id && count($forum_contact) && ($private_forum || $only_to_forum)) {
+ if (!$toplevel_item_id && !empty($forum_contact) && ($private_forum || $only_to_forum)) {
// we tagged a forum in a top level post. Now we change the post
$private = $private_forum;
$datarray['gravity'] = $gravity;
$datarray['network'] = $network;
$datarray['contact-id'] = $contact_id;
- $datarray['owner-name'] = $contact_record['name'];
- $datarray['owner-link'] = $contact_record['url'];
- $datarray['owner-avatar'] = $contact_record['thumb'];
+ $datarray['owner-name'] = $contact_record['name'] ?? '';
+ $datarray['owner-link'] = $contact_record['url'] ?? '';
+ $datarray['owner-avatar'] = $contact_record['thumb'] ?? '';
$datarray['owner-id'] = Contact::getIdForURL($datarray['owner-link']);
$datarray['author-name'] = $author['name'];
$datarray['author-link'] = $author['url'];
FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category');
// These notifications are sent if someone else is commenting other your wall
- if ($toplevel_item_id) {
- if ($contact_record != $author) {
+ if ($contact_record != $author) {
+ if ($toplevel_item_id) {
notification([
'type' => Type::COMMENT,
'notify_flags' => $user['notify-flags'],
'parent' => $toplevel_item_id,
'parent_uri' => $toplevel_item['uri']
]);
- }
- } else {
- if (($contact_record != $author) && !count($forum_contact)) {
+ } elseif (empty($forum_contact)) {
notification([
'type' => Type::WALL,
'notify_flags' => $user['notify-flags'],
DI::baseUrl()->redirect('display/' . $item['guid']);
}
- $is_comment = ($item['gravity'] == GRAVITY_COMMENT) ? true : false;
+ $is_comment = $item['gravity'] == GRAVITY_COMMENT;
$parentitem = null;
- if (!empty($item['parent'])){
+ if (!empty($item['parent'])) {
$fields = ['guid'];
$parentitem = Item::selectFirstForUser(local_user(), $fields, ['id' => $item['parent']]);
}
if (!empty($parentitem)) {
DI::baseUrl()->redirect('display/' . $parentitem['guid']);
//NOTREACHED
- }
- // In case something goes wrong
+ } // In case something goes wrong
else {
DI::baseUrl()->redirect('network');
//NOTREACHED
}
- }
- else {
+ } else {
// if unknown location or deleting top level post called from display
if (empty($return_url) || strpos($return_url, 'display') !== false) {
DI::baseUrl()->redirect('network');