Skip to content

Commit

Permalink
Merge pull request #272 from Andrzejster/master
Browse files Browse the repository at this point in the history
Dodanie moderacji forum + uwzględnienie kilku wskazówek Inscure'a
  • Loading branch information
piotrex41 committed Jul 29, 2014
2 parents d8d683e + c82f2fe commit 7f2c128
Show file tree
Hide file tree
Showing 4 changed files with 200 additions and 109 deletions.
2 changes: 2 additions & 0 deletions modules/forum/app/acp/category.php
Expand Up @@ -24,6 +24,8 @@ public function add()
array(':is_locked', (bool) $this->request->post('is_locked', FALSE)->show(), PDO::PARAM_BOOL),
array(':order', $this->request->post('order')->show(), PDO::PARAM_INT),
));

$_perm = $this->pdo->exec("INSERT INTO [permissions] (`name`, `description`, `section`, `is_system`) VALUES ('module.forum.".$id.".".HELP::Title2Link($this->request->post('title')->filters('trim', 'strip'))."', 'Moderowanie działu ".$this->request->post('title')->filters('trim', 'strip')."', 6, 0)");

if ($_category)
{
Expand Down
92 changes: 60 additions & 32 deletions modules/forum/app/entry.php
Expand Up @@ -15,61 +15,89 @@ public function edit()

$user = $this->model('user', array($this->user));

if ( ! $entry || $entry['is_main'] || ! $user->isAuthor($entry['user_id']))
{
return $this->router->trace(array('controller' => 'error', 'action' => 404));
}

$thread = $this
->model('thread')
->findByID($entry['thread_id']);

if ($this->request->post('content')->show())
if ($this->user->hasPermission('module.forum.'.$thread['board_id'].'.'.HELP::Title2Link($thread['category'])))
{
$_entry = $this->pdo->exec('UPDATE [entries] SET `content` = :content WHERE `id` = :id', array(
array(':content', HELP::wordsProtect($this->request->post('content')->filters('trim', 'strip')), PDO::PARAM_STR),
array(':id', $id, PDO::PARAM_INT),
));

if ($_entry)
$thread['mod'] = TRUE;
}
else
{
$thread['mod'] = FALSE;
}

if ($this->is_admin || $thread['mod'] || $user->isAuthor($entry['user_id']))
{
if ($this->request->post('content')->show())
{
return HELP::redirect($this->url->path(array('module' => 'forum', 'controller' => 'thread', $entry['thread_id'])).'#entry-'.$id);
$_entry = $this->pdo->exec('UPDATE [entries] SET `content` = :content WHERE `id` = :id', array(
array(':content', HELP::wordsProtect($this->request->post('content')->filters('trim', 'strip')), PDO::PARAM_STR),
array(':id', $id, PDO::PARAM_INT),
));

if ($_entry)
{
return HELP::redirect($this->url->path(array('module' => 'forum', 'controller' => 'thread', $entry['thread_id'])).'#entry-'.$id);
}
}
}

return $this->view('entry/edit', array(
'entry' => $entry,
'thread' => $thread,
'bbcodes' => $this->bbcode->bbcodes(),
'smileys' => $this->bbcode->smileys(),
));
return $this->view('entry/edit', array(
'entry' => $entry,
'thread' => $thread,
'bbcodes' => $this->bbcode->bbcodes(),
'smileys' => $this->bbcode->smileys(),
));
}
else
{
return $this->router->trace(array('controller' => 'error', 'action' => 403));
}
}

public function remove()
{
if ( ! $this->is_admin)
{
return $this->router->trace(array('controller' => 'error', 'action' => 404));
}

$entry = $this
->model('entry')
->findByID($id = $this->params[0]);

$user = $this->model('user', array($this->user));

$thread = $this
->model('thread')
->findByID($entry['thread_id']);

if ($this->user->hasPermission('module.forum.'.$thread['board_id'].'.'.HELP::Title2Link($thread['category'])))
{
$thread['mod'] = TRUE;
}
else
{
$thread['mod'] = FALSE;
}

if ( ! $entry || $entry['is_main'])
{
return $this->router->trace(array('controller' => 'error', 'action' => 404));
}

if ($this->is_admin || $thread['mod'])
{
$_entry = $this->pdo->exec('DELETE FROM [entries] WHERE `id` = :id',
array(':id', $id, PDO::PARAM_INT));

$_entry = $this->pdo->exec('DELETE FROM [entries] WHERE `id` = :id',
array(':id', $id, PDO::PARAM_INT));
if ($_entry)
{
return $this->router->redirect(array('module' => 'forum', 'controller' => 'thread', $entry['thread_id']));
}

if ($_entry)
return $this->router->trace(array('controller' => 'error', 'action' => 500));
}
else
{
return $this->router->redirect(array('module' => 'forum', 'controller' => 'thread', $entry['thread_id']));
return $this->router->trace(array('controller' => 'error', 'action' => 403));
}

return $this->router->trace(array('controller' => 'error', 'action' => 500));
}

}

0 comments on commit 7f2c128

Please sign in to comment.