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'];
if (!$update) {
$tab = 'posts';
if (x($_GET, 'tab')) {
$tab = notags(trim($_GET['tab']));
$tab = ( $tab ? $tab : 'posts' );
}
if ($tab === 'posts') {
/*
* 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++;
$comment = '';
$owner_url = '';
$owner_name = '';
$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.
if ($item['network'] === NETWORK_MAIL && local_user() != $item['uid']) {
continue;
@ -813,7 +805,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false) {
'like' => '',
'dislike' => '',
'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'))),
'previewing' => $previewing,
'wait' => t('Please wait'),
@ -1197,10 +1188,11 @@ function format_like($cnt, array $arr, $type, $id) {
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 = '';
$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');
$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(
'$return_path' => $query_str,
'$action' => 'item',
'$share' => (x($x,'button') ? $x['button'] : t('Share')),
'$share' => defaults($x, 'button', t('Share')),
'$upload' => t('Upload photo'),
'$shortupload' => t('upload photo'),
'$attach' => t('Attach file'),
@ -1279,26 +1271,25 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) {
'$shortsetloc' => t('set location'),
'$noloc' => t('Clear browser location'),
'$shortnoloc' => t('clear location'),
'$title' => $x['title'],
'$title' => defaults($x, 'title', ''),
'$placeholdertitle' => t('Set title'),
'$category' => $x['category'],
'$placeholdercategory' => (Feature::isEnabled(local_user(), 'categories') ? t('Categories (comma-separated list)') : ''),
'$category' => defaults($x, 'category', ''),
'$placeholdercategory' => Feature::isEnabled(local_user(), 'categories') ? t('Categories (comma-separated list)') : '',
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
'$shortpermset' => t('permissions'),
'$ptyp' => (($notes_cid) ? 'note' : 'wall'),
'$content' => $x['content'],
'$post_id' => $x['post_id'],
'$ptyp' => $notes_cid ? 'note' : 'wall',
'$content' => defaults($x, 'content', ''),
'$post_id' => defaults($x, 'post_id', ''),
'$baseurl' => System::baseUrl(true),
'$defloc' => $x['default_location'],
'$visitor' => $x['visitor'],
'$pvisit' => (($notes_cid) ? 'none' : $x['visitor']),
'$pvisit' => $notes_cid ? 'none' : $x['visitor'],
'$public' => t('Public post'),
'$jotnets' => $jotnets,
'$lockstate' => $x['lockstate'],
'$bang' => $x['bang'],
'$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,
'$notes_cid' => $notes_cid,
'$sourceapp' => t($a->sourcename),
@ -1577,9 +1568,9 @@ function get_responses($conv_responses, $response_verbs, $ob, $item) {
$ret = array();
foreach ($response_verbs as $v) {
$ret[$v] = array();
$ret[$v]['count'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri']] : '');
$ret[$v]['list'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri'] . '-l'] : '');
$ret[$v]['self'] = ((x($conv_responses[$v], $item['uri'])) ? $conv_responses[$v][$item['uri'] . '-self'] : '0');
$ret[$v]['count'] = defaults($conv_responses[$v], $item['uri'], '');
$ret[$v]['list'] = defaults($conv_responses[$v], $item['uri'] . '-l', '');
$ret[$v]['self'] = defaults($conv_responses[$v], $item['uri'] . '-self', '0');
if (count($ret[$v]['list']) > 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-'