Skip to content

Commit

Permalink
Fix #2224 no inline moderation checkbox in quick reply post
Browse files Browse the repository at this point in the history
Also added several other `!isset()` checks just in case a plugin or
whatever will miss definition of these globals.. And shortened some
conditionals to simple assignments.

#2224
  • Loading branch information
Destroy666x committed Jan 30, 2016
1 parent 0aa7736 commit 3ed8910
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 80 deletions.
32 changes: 30 additions & 2 deletions inc/functions_post.php
Expand Up @@ -265,7 +265,7 @@ function build_postbit($post, $post_type=0)
}
}
}

$post['usertitle'] = htmlspecialchars_uni($post['usertitle']);

if($usergroup['stars'])
Expand Down Expand Up @@ -482,7 +482,7 @@ function build_postbit($post, $post_type=0)
{
$post['usertitle'] = $lang->guest;
}

$post['usertitle'] = htmlspecialchars_uni($post['usertitle']);

$usergroup['title'] = $lang->na;
Expand Down Expand Up @@ -529,6 +529,11 @@ function build_postbit($post, $post_type=0)
$post['editedmsg'] = '';
if(!$post_type)
{
if(!isset($forumpermissions))
{
$forumpermissions = forum_permissions($fid);
}

// Figure out if we need to show an "edited by" message
if($post['edituid'] != 0 && $post['edittime'] != 0 && $post['editusername'] != "" && (($mybb->settings['showeditedby'] != 0 && $usergroup['cancp'] == 0) || ($mybb->settings['showeditedbyadmin'] != 0 && $usergroup['cancp'] == 1)))
{
Expand Down Expand Up @@ -614,6 +619,11 @@ function build_postbit($post, $post_type=0)
}
}

if(!isset($ismod))
{
$ismod = is_moderator($fid);
}

// Inline moderation stuff
if($ismod)
{
Expand Down Expand Up @@ -788,6 +798,19 @@ function build_postbit($post, $post_type=0)
default: // Regular post
$post = $plugins->run_hooks("postbit", $post);

if(!isset($ignored_users))
{
$ignored_users = array();
if($mybb->user['uid'] > 0 && $mybb->user['ignorelist'] != "")
{
$ignore_list = explode(',', $mybb->user['ignorelist']);
foreach($ignore_list as $uid)
{
$ignored_users[$uid] = 1;
}
}
}

// Is this author on the ignore list of the current user? Hide this post
if(is_array($ignored_users) && $post['uid'] != 0 && isset($ignored_users[$post['uid']]) && $ignored_users[$post['uid']] == 1)
{
Expand Down Expand Up @@ -825,6 +848,11 @@ function get_post_attachments($id, &$post)
$validationcount = 0;
$tcount = 0;
$post['attachmentlist'] = $post['thumblist'] = $post['imagelist'] = '';
if(!isset($forumpermissions))
{
$forumpermissions = forum_permissions($post['fid']);
}

if(isset($attachcache[$id]) && is_array($attachcache[$id]))
{ // This post has 1 or more attachments
foreach($attachcache[$id] as $aid => $attachment)
Expand Down
12 changes: 6 additions & 6 deletions newreply.php
Expand Up @@ -312,7 +312,7 @@
$username = $mybb->get_input('username');
}
$uid = 0;


if($mybb->settings['stopforumspam_on_newreply'])
{
Expand Down Expand Up @@ -616,7 +616,7 @@
redirect(get_thread_link($tid, 0, "lastpost"));
}
}

if(!$mybb->settings['postsperpage'] || (int)$mybb->settings['postsperpage'] < 1)
{
$mybb->settings['postsperpage'] = 20;
Expand Down Expand Up @@ -681,7 +681,7 @@
$data .= $post;

// Build a new posthash incase the user wishes to quick reply again
$new_posthash = md5($mybb->user['uid'].random_str());
$new_posthash = md5($mybb->user['uid'].random_str());
$data .= "<script type=\"text/javascript\">\n";
$data .= "var hash = document.getElementById('posthash'); if(hash) { hash.value = '{$new_posthash}'; }\n";
$data .= "if(typeof(inlineModeration) != 'undefined') {
Expand Down Expand Up @@ -1015,7 +1015,7 @@
// Now let the post handler do all the hard work.
$valid_post = $posthandler->verify_message();
$valid_subject = $posthandler->verify_subject();

// guest post --> verify author
if($post['uid'] == 0)
{
Expand Down Expand Up @@ -1218,7 +1218,7 @@

if(!$correct)
{
if($post_captcha->type == 1)
if($post_captcha->type == 1)
{
$post_captcha->build_captcha();
}
Expand Down Expand Up @@ -1274,7 +1274,7 @@
}
$query = $db->simple_select("posts", "COUNT(pid) AS post_count", "tid='{$tid}' AND {$visibility}");
$numposts = $db->fetch_field($query, "post_count");

if(!$mybb->settings['postsperpage'] || (int)$mybb->settings['postsperpage'] < 1)
{
$mybb->settings['postsperpage'] = 20;
Expand Down
25 changes: 9 additions & 16 deletions polls.php
Expand Up @@ -57,14 +57,7 @@
}

// Is the currently logged in user a moderator of this forum?
if(is_moderator($thread['fid']))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down Expand Up @@ -166,7 +159,7 @@
{
$timeout = 0;
}

if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $polloptions)
{
$maxoptions = $mybb->get_input('maxoptions', MyBB::INPUT_INT);
Expand Down Expand Up @@ -277,7 +270,7 @@
{
error($lang->error_polloptiontoolong);
}

if(isset($sequenceerror))
{
error($lang->error_polloptionsequence);
Expand Down Expand Up @@ -323,7 +316,7 @@
{
$maxoptions = 0;
}

$newpoll = array(
"tid" => $thread['tid'],
"question" => $db->escape_string($mybb->input['question']),
Expand Down Expand Up @@ -466,7 +459,7 @@
{
$timeout = $poll['timeout'];
}

if(!$poll['maxoptions'])
{
$maxoptions = 0;
Expand Down Expand Up @@ -542,7 +535,7 @@
{
$timeout = 0;
}

if(!$poll['maxoptions'])
{
$maxoptions = 0;
Expand Down Expand Up @@ -709,7 +702,7 @@
{
$timeout = 0;
}

if($mybb->get_input('maxoptions', MyBB::INPUT_INT) > 0 && $mybb->get_input('maxoptions', MyBB::INPUT_INT) < $numoptions)
{
$maxoptions = $mybb->get_input('maxoptions', MyBB::INPUT_INT);
Expand Down Expand Up @@ -1002,7 +995,7 @@
if(is_array($option))
{
$total_options = 0;

foreach($option as $voteoption => $vote)
{
if($vote == 1 && isset($votesarray[$voteoption-1]))
Expand All @@ -1017,7 +1010,7 @@
$total_options++;
}
}

if($total_options > $poll['maxoptions'] && $poll['maxoptions'] != 0)
{
error($lang->sprintf($lang->error_maxpolloptions, $poll['maxoptions']));
Expand Down
23 changes: 8 additions & 15 deletions printthread.php
Expand Up @@ -49,14 +49,7 @@
$tid = $thread['tid'];

// Is the currently logged in user a moderator of this forum?
if(is_moderator($fid))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($fid);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down Expand Up @@ -133,18 +126,18 @@
$postrows = '';
if(is_moderator($forum['fid'], "canviewunapprove"))
{
$visible = "AND (p.visible='0' OR p.visible='1')";
$visible = "AND (p.visible='0' OR p.visible='1')";
}
else
{
$visible = "AND p.visible='1'";
$visible = "AND p.visible='1'";
}
$query = $db->query("
SELECT u.*, u.username AS userusername, p.*
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid' {$visible}
ORDER BY p.dateline
SELECT u.*, u.username AS userusername, p.*
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='$tid' {$visible}
ORDER BY p.dateline
LIMIT {$start}, {$perpage}
");
while($postrow = $db->fetch_array($query))
Expand Down
9 changes: 1 addition & 8 deletions ratethread.php
Expand Up @@ -27,14 +27,7 @@
}

// Is the currently logged in user a moderator of this forum?
if(is_moderator($thread['fid']))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down
12 changes: 3 additions & 9 deletions search.php
Expand Up @@ -166,7 +166,7 @@
$sorturl = "search.php?action=results&amp;sid={$sid}";
$thread_url = "";
$post_url = "";

$orderarrow = array('replies' => '', 'views' => '', 'subject' => '', 'forum' => '', 'starter' => '', 'lastpost' => '', 'dateline' => '');

eval("\$orderarrow['$sortby'] = \"".$templates->get("search_orderarrow")."\";");
Expand Down Expand Up @@ -1567,14 +1567,8 @@
{
// Fetch thread info
$thread = get_thread($mybb->get_input('tid', MyBB::INPUT_INT));
if(is_moderator($fid))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

if(!$thread || ($thread['visible'] != 1 && $ismod == false && ($thread['visible'] != -1 || $mybb->settings['soft_delete'] != 1 || !$mybb->user['uid'] || $mybb->user['uid'] != $thread['uid'])) || ($thread['visible'] > 1 && $ismod == true))
{
error($lang->error_invalidthread);
Expand Down
27 changes: 3 additions & 24 deletions usercp2.php
Expand Up @@ -42,14 +42,7 @@
}

// Is the currently logged in user a moderator of this forum?
if(is_moderator($thread['fid']))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down Expand Up @@ -114,14 +107,7 @@
}

// Is the currently logged in user a moderator of this forum?
if(is_moderator($thread['fid']))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down Expand Up @@ -202,14 +188,7 @@
}

// Is the currently logged in user a moderator of this forum?
if(is_moderator($thread['fid']))
{
$ismod = true;
}
else
{
$ismod = false;
}
$ismod = is_moderator($thread['fid']);

// Make sure we are looking at a real thread here.
if(($thread['visible'] != 1 && $ismod == false) || ($thread['visible'] > 1 && $ismod == true))
Expand Down

0 comments on commit 3ed8910

Please sign in to comment.