Skip to content
This repository has been archived by the owner on Dec 4, 2019. It is now read-only.

Commit

Permalink
#697: Fix permissions for posting page
Browse files Browse the repository at this point in the history
  • Loading branch information
daris committed Aug 19, 2012
1 parent 78bc282 commit 283e487
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
17 changes: 16 additions & 1 deletion classes/models/forum.php
Expand Up @@ -22,7 +22,7 @@
* @copyright Copyright (c) 2008-2012 FluxBB (http://fluxbb.org)
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License
*/

namespace fluxbb\Models;

class Forum extends Base
Expand Down Expand Up @@ -68,4 +68,19 @@ public function is_user_subscribed()
return Auth::check() && !is_null($this->subscription);
}

public function moderators()
{
return $this->moderators != '' ? unserialize($this->moderators) : array();
}

public function is_moderator()
{
return User::current()->is_moderator() && array_key_exists(User::current()->username, $this->moderators());
}

public function is_admmod()
{
return User::current()->is_admin() || $this->is_moderator();
}

}
13 changes: 11 additions & 2 deletions controllers/posting.php
Expand Up @@ -35,7 +35,12 @@ class FluxBB_Posting_Controller extends Base

public function get_reply($tid)
{
$topic = Topic::where_id($tid)->first();
$topic = Topic::with(array(
'forum',
'forum.perms',
))
->where_id($tid)
->first();

if ($topic === NULL)
{
Expand Down Expand Up @@ -94,7 +99,11 @@ public function put_reply($tid)

public function get_topic($fid)
{
$forum = Forum::where_id($fid)->first();
$forum = Forum::with(array(
'perms',
))
->where_id($fid)
->first();

if ($forum === NULL)
{
Expand Down
4 changes: 1 addition & 3 deletions views/posting/post.blade.php
Expand Up @@ -45,10 +45,8 @@
</fieldset>
<?php
$is_admmod = true;// TODO: fix
$checkboxes = array();
if ($is_admmod)
if (isset($topic) && $topic->forum->is_admmod() || isset($forum) && $forum->is_admmod())
$checkboxes[] = '<label><input type="checkbox" name="stick_topic" value="1" tabindex="'.($cur_index++).'"'.(Input::has('stick_topic') ? ' checked="checked"' : '').' />'.__('fluxbb::common.stick_topic').'<br /></label>';
if (!Auth::check())
Expand Down

0 comments on commit 283e487

Please sign in to comment.