Fix formatting and PHP notices in include/conversation

- Remove unused $nickname variable
- Remove unused $comment variable
- Use defaults() in get_responses() to check for array key existence
This commit is contained in:
Hypolite Petovan 2018-01-01 15:27:33 -05:00
parent 66dbef93e3
commit 3069f3b59d

View file

@ -545,8 +545,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$profile_owner = $a->profile['profile_uid']; $profile_owner = $a->profile['profile_uid'];
if (!$update) { if (!$update) {
$tab = 'posts';
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab'])); $tab = notags(trim($_GET['tab']));
$tab = ( $tab ? $tab : 'posts' ); }
if ($tab === 'posts') { if ($tab === 'posts') {
/* /*
* This is ugly, but we can't pass the profile_uid through the session to the ajax updater, * This is ugly, but we can't pass the profile_uid through the session to the ajax updater,
@ -647,20 +649,10 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
$threadsid++; $threadsid++;
$comment = '';
$owner_url = ''; $owner_url = '';
$owner_name = ''; $owner_name = '';
$sparkle = ''; $sparkle = '';
if ($mode === 'search' || $mode === 'community') {
if (((activity_match($item['verb'], ACTIVITY_LIKE)) || (activity_match($item['verb'], ACTIVITY_DISLIKE)))
&& ($item['id'] != $item['parent']))
continue;
$nickname = $item['nickname'];
} else {
$nickname = $a->user['nickname'];
}
// prevent private email from leaking. // prevent private email from leaking.
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) { if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
continue; continue;
@ -813,7 +805,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'like' => '', 'like' => '',
'dislike' => '', 'dislike' => '',
'comment' => '', 'comment' => '',
//'conv' => (($preview) ? '' : array('href'=> 'display/' . $nickname . '/' . $item['id'], 'title'=> t('View in context'))),
'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))), 'conv' => (($preview) ? '' : array('href'=> 'display/'.$item['guid'], 'title'=> t('View in context'))),
'previewing' => $previewing, 'previewing' => $previewing,
'wait' => t('Please wait'), 'wait' => t('Please wait'),
@ -1197,10 +1188,11 @@ function format_like($cnt, array $arr, $type, $id) {
return $o; return $o;
} }
function status_editor(App $a, $x, $notes_cid = 0, $popup = false) { function status_editor(App $a, $x, $notes_cid = 0, $popup = false)
{
$o = ''; $o = '';
$geotag = (x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : ''); $geotag = x($x, 'allow_location') ? replace_macros(get_markup_template('jot_geotag.tpl'), array()) : '';
$tpl = get_markup_template('jot-header.tpl'); $tpl = get_markup_template('jot-header.tpl');
$a->page['htmlhead'] .= replace_macros($tpl, array( $a->page['htmlhead'] .= replace_macros($tpl, array(
@ -1264,7 +1256,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) {
$o .= replace_macros($tpl,array( $o .= replace_macros($tpl,array(
'$return_path' => $query_str, '$return_path' => $query_str,
'$action' => 'item', '$action' => 'item',
'$share' => (x($x,'button') ? $x['button'] : t('Share')), '$share' => defaults($x, 'button', t('Share')),
'$upload' => t('Upload photo'), '$upload' => t('Upload photo'),
'$shortupload' => t('upload photo'), '$shortupload' => t('upload photo'),
'$attach' => t('Attach file'), '$attach' => t('Attach file'),
@ -1279,26 +1271,25 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) {
'$shortsetloc' => t('set location'), '$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'), '$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'), '$shortnoloc' => t('clear location'),
'$title' => $x['title'], '$title' => defaults($x, 'title', ''),
'$placeholdertitle' => t('Set title'), '$placeholdertitle' => t('Set title'),
'$category' => $x['category'], '$category' => defaults($x, 'category', ''),
'$placeholdercategory' => (Feature::isEnabled(local_user(), 'categories') ? t('Categories (comma-separated list)') : ''), '$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? t('Categories (comma-separated list)') : '',
'$wait' => t('Please wait'), '$wait' => t('Please wait'),
'$permset' => t('Permission settings'), '$permset' => t('Permission settings'),
'$shortpermset' => t('permissions'), '$shortpermset' => t('permissions'),
'$ptyp' => (($notes_cid) ? 'note' : 'wall'), '$ptyp' => $notes_cid ? 'note' : 'wall',
'$content' => $x['content'], '$content' => defaults($x, 'content', ''),
'$post_id' => $x['post_id'], '$post_id' => defaults($x, 'post_id', ''),
'$baseurl' => System::baseUrl(true), '$baseurl' => System::baseUrl(true),
'$defloc' => $x['default_location'], '$defloc' => $x['default_location'],
'$visitor' => $x['visitor'], '$visitor' => $x['visitor'],
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']), '$pvisit' => $notes_cid ? 'none' : $x['visitor'],
'$public' => t('Public post'), '$public' => t('Public post'),
'$jotnets' => $jotnets,
'$lockstate' => $x['lockstate'], '$lockstate' => $x['lockstate'],
'$bang' => $x['bang'], '$bang' => $x['bang'],
'$profile_uid' => $x['profile_uid'], '$profile_uid' => $x['profile_uid'],
'$preview' => ((Feature::isEnabled($x['profile_uid'],'preview')) ? t('Preview') : ''), '$preview' => Feature::isEnabled($x['profile_uid'], 'preview') ? t('Preview') : '',
'$jotplugins' => $jotplugins, '$jotplugins' => $jotplugins,
'$notes_cid' => $notes_cid, '$notes_cid' => $notes_cid,
'$sourceapp' => t($a->sourcename), '$sourceapp' => t($a->sourcename),
@ -1577,9 +1568,9 @@ function get_responses($conv_responses, $response_verbs, $ob, $item) {
$ret = array(); $ret = array();
foreach ($response_verbs as $v) { foreach ($response_verbs as $v) {
$ret[$v] = array(); $ret[$v] = array();
$ret[$v]['count'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri']] : ''); $ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['list'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : ''); $ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', '');
$ret[$v]['self'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri'] . '-self'] : '0'); $ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
if (count($ret[$v]['list']) > MAX_LIKERS) { if (count($ret[$v]['list']) > MAX_LIKERS) {
$ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS); $ret[$v]['list_part'] = array_slice($ret[$v]['list'], 0, MAX_LIKERS);
array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-' array_push($ret[$v]['list_part'], '<a href="#" data-toggle="modal" data-target="#' . $v . 'Modal-'