Skip to content

Commit 86e0342

Browse files
committed
Working on fixing up forums, adding in moderation areas and adding response classes
1 parent 74754f4 commit 86e0342

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+11052
-724
lines changed

app/controllers/BaseController.php

100644100755
Lines changed: 136 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ class BaseController extends DefaultController {
55

66
protected $subMenu = array();
77

8-
protected $menu = array();
8+
protected $menu = array();
99

10-
protected $data = array();
10+
protected $data = array();
1111

1212
protected $pageTitle;
1313

@@ -21,6 +21,10 @@ class BaseController extends DefaultController {
2121

2222
protected $skipView = false;
2323

24+
protected $postResponse;
25+
26+
protected $ajaxResponse;
27+
2428
/**
2529
* Layouts array
2630
*
@@ -46,6 +50,10 @@ public function __construct()
4650
$this->activeUser->updateLastActive();
4751
}
4852

53+
// Set up the response classes
54+
$this->postResponse = new Utility_Response_Post(Request::path());
55+
$this->ajaxResponse = new Utility_Response_Ajax();
56+
4957
// Load the menu bar
5058
$this->getMenu();
5159

@@ -94,7 +102,7 @@ protected function processResponse($router, $method, $response)
94102
public function setupLayout()
95103
{
96104
if ($this->route == null) {
97-
$route = Route::getContainer()->router->currentRouteAction();
105+
$route = Route::getContainer()->router->currentRouteAction();
98106
$this->route = $this->cleanRoute($route);
99107
}
100108

@@ -128,7 +136,7 @@ protected function cleanRoute($route, $returnArray = false)
128136
$route = strtolower(str_replace('Controller', '', implode('.', $routeParts)));
129137

130138
if ($returnArray) {
131-
$routeParts = explode('.', $route);
139+
$routeParts = explode('.', $route);
132140
}
133141

134142
return $route;
@@ -189,24 +197,35 @@ public function hasPermission($permissions)
189197
return false;
190198
}
191199

192-
public static function errorRedirect()
200+
public function errorRedirect()
193201
{
194-
return Redirect::back()->with('errors', array('You lack the permission(s) required to view this area'))->send();
202+
$this->postResponse->addError('permission', 'You lack the permission(s) required to view this area');
203+
return $this->postResponse->redirect('back');
195204
}
196205

197-
public static function redirect($location, $message = null, $back = null)
206+
public function redirect($location, $message = null)
198207
{
199-
if ($message == null) {
200-
if ($back != null) {
201-
return Redirect::back()->send();
202-
}
203-
return Redirect::to($location)->send();
204-
} else {
205-
if ($back != null) {
206-
return Redirect::back()->with('message', $message)->send();
207-
}
208-
return Redirect::to($location)->with('message', $message)->send();
209-
}
208+
return $this->postResponse->redirect($location, $message);
209+
}
210+
211+
public function save($model)
212+
{
213+
$this->postResponse->save($model);
214+
}
215+
216+
public function errorCount()
217+
{
218+
$this->postResponse->errorCount();
219+
}
220+
221+
public function setSuccessPath($path)
222+
{
223+
$this->postResponse->setSuccessPath($path);
224+
}
225+
226+
public function setSuccessMessage($message)
227+
{
228+
$this->postResponse->setSuccessMessage($message);
210229
}
211230

212231
public static function arrayToSelect($array, $key = 'id', $value = 'name', $first = 'Select One')
@@ -221,20 +240,25 @@ public static function arrayToSelect($array, $key = 'id', $value = 'name', $firs
221240
return $results;
222241
}
223242

224-
public function checkErrorsRedirect($model)
225-
{
226-
if ($model == true && count($model->getErrors()->all()) > 0) {
227-
return Redirect::to(Request::path())->with('errors', $model->getErrors()->all());
228-
}
229-
}
243+
// public function checkErrorsRedirect($model)
244+
// {
245+
// if ($model == true && count($model->getErrors()->all()) > 0) {
246+
// return Redirect::to(Request::path())->with('errors', $model->getErrors()->all())->withInput()->send();
247+
// }
248+
// }
230249

231-
public function checkErrors($model)
232-
{
233-
if ($model == true && count($model->getErrors()->all()) > 0) {
234-
return true;
235-
}
250+
// public function checkErrors($model)
251+
// {
252+
// if ($model == true && count($model->getErrors()->all()) > 0) {
253+
// return true;
254+
// }
236255

237-
return false;
256+
// return false;
257+
// }
258+
259+
public function skipView()
260+
{
261+
$this->skipView = true;
238262
}
239263

240264
public function addSubMenu($text, $link, $subLinks = array())
@@ -270,4 +294,86 @@ public function emptyBoth()
270294
$this->menu = array();
271295
$this->subMenu = array();
272296
}
297+
298+
public function rollGm()
299+
{
300+
if (!$this->game->isStoryteller($this->activeUser->id)) {
301+
return $this->roll() .'Gm';
302+
}
303+
304+
$roll = rand(1,100);
305+
$overallRoll = $roll;
306+
$class = 'text-success';
307+
308+
while ($roll <= 80) {
309+
$roll = rand(1,100);
310+
$overallRoll = $overallRoll + $roll;
311+
$class = 'text-warning';
312+
}
313+
314+
if ($overallRoll == 9999) {
315+
$overallRoll = 10000;
316+
}
317+
318+
if ($this->type == 'forum') {
319+
return '[dice][spanClass='. $class .']'. $overallRoll .'[/spanClass]';
320+
} elseif ($this->type == 'chat') {
321+
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
322+
}
323+
}
324+
325+
public function roll()
326+
{
327+
$roll = rand(1,100);
328+
$overallRoll = $roll;
329+
330+
while ($roll >= 90) {
331+
$roll = rand(1,100);
332+
$overallRoll = $overallRoll + $roll;
333+
}
334+
335+
if ($overallRoll == 9999) {
336+
$overallRoll = 10000;
337+
}
338+
339+
if ($this->type == 'forum') {
340+
return $overallRoll;
341+
} elseif ($this->type == 'chat') {
342+
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
343+
}
344+
}
345+
346+
public function roll1()
347+
{
348+
$roll = rand(1,100);
349+
$overallRoll = $roll;
350+
$class = 'text-success';
351+
352+
while ($roll >= 90) {
353+
$roll = rand(1,100);
354+
$overallRoll = $overallRoll + $roll;
355+
$class = 'text-warning';
356+
}
357+
358+
if ($overallRoll == 9999) {
359+
$overallRoll = 10000;
360+
}
361+
362+
if ($this->type == 'forum') {
363+
return '[dice][spanClass='. $class .']'. $overallRoll .'[/spanClass]';
364+
}
365+
}
366+
367+
public function roll2()
368+
{
369+
$roll = rand(91,150);
370+
$overallRoll = $roll;
371+
$class = 'text-warning';
372+
373+
if ($this->type == 'forum') {
374+
return '[dice][spanClass='. $class .']'. $overallRoll .'[/spanClass]';
375+
} elseif ($this->type == 'chat') {
376+
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
377+
}
378+
}
273379
}

app/controllers/ChatController.php

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class ChatController extends BaseController {
44

55
public $game;
66

7+
public $type = 'chat';
8+
79
public function getIndex()
810
{
911
$chatRooms = Chat_Room::active()->orderByNameAsc()->get();
@@ -148,54 +150,6 @@ public function postAddmessage()
148150
}
149151
}
150152

151-
public function roll()
152-
{
153-
$roll = rand(1,100);
154-
$overallRoll = $roll;
155-
$class = 'text-success';
156-
while ($roll >= 90) {
157-
$roll = rand(1,100);
158-
$overallRoll = $overallRoll + $roll;
159-
$class = 'text-warning';
160-
}
161-
162-
if ($overallRoll == 9999) {
163-
$overallRoll = 10000;
164-
}
165-
166-
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
167-
}
168-
169-
public function rollGm()
170-
{
171-
if (!$this->game->isStoryteller($this->activeUser->id)) {
172-
return $this->roll() .'Gm';
173-
}
174-
$roll = rand(1,100);
175-
$overallRoll = $roll;
176-
$class = 'text-success';
177-
while ($roll <= 80) {
178-
$roll = rand(1,100);
179-
$overallRoll = $overallRoll + $roll;
180-
$class = 'text-warning';
181-
}
182-
183-
if ($overallRoll == 9999) {
184-
$overallRoll = 10000;
185-
}
186-
187-
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
188-
}
189-
190-
public function roll2()
191-
{
192-
$roll = rand(91,150);
193-
$overallRoll = $roll;
194-
$class = 'text-warning';
195-
196-
return HTML::image('img/dice_white.png', null, array('style' => 'width: 14px;')) .'<span class="'. $class .'">'. $overallRoll .'</span>';
197-
}
198-
199153
public function action_update($chatRoomId, $property, $value)
200154
{
201155
if(!$this->hasPermission('CHAT_CREATE')) {
@@ -248,4 +202,4 @@ public function getUsercount($chatRoomId)
248202

249203
return $jsonData->args[0];
250204
}
251-
}
205+
}

app/controllers/DefaultController.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function getMenu()
1212
if ($this->hasPermission('FORUM_ACCESS')) {
1313
$forumArray = array();
1414
if ($this->hasPermission('FORUM_MOD')) {
15-
$forumArray['Moderation Panel'] = 'forum-admin/moderation';
15+
$forumArray['Moderation Panel'] = 'forum/moderation/dashboard';
1616
}
1717
if ($this->hasPermission('FORUM_ADMIN')) {
1818
$forumArray['Admin Panel'] = 'forum-admin/';
@@ -65,7 +65,7 @@ public function getMenu()
6565
$gameArray
6666
);
6767
} else {
68-
$games = Game::order_by('name', 'asc')->get();
68+
$games = Game::orderByNameAsc()->get();
6969
$subLinks = array();
7070
foreach ($games as $game) {
7171
$subLinks[$game->name] = 'game/board/'. $game->id;
@@ -90,7 +90,7 @@ public function getMenu()
9090
$subLinks['Logout'] = 'logout';
9191
$this->addMenu(
9292
$this->activeUser->username,
93-
'profile/'. $this->activeUser->id,
93+
'user/view/'. $this->activeUser->id,
9494
$subLinks
9595
);
9696
} else {
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
3+
class Forum_ModerationController extends BaseController {
4+
5+
public function getDashboard()
6+
{
7+
// Get the data
8+
$reportedPostsCount = Forum_Moderation::count();
9+
$reportLogsCount = Forum_Moderation_Log::count();
10+
11+
$this->setViewData('reportedPostsCount', $reportedPostsCount);
12+
$this->setViewData('reportLogsCount', $reportLogsCount);
13+
}
14+
15+
public function getReportedPosts()
16+
{
17+
$reportedPosts = Forum_Moderation::all();
18+
19+
$this->setViewData('reportedPosts', $reportedPosts);
20+
}
21+
22+
public function getReportLogs()
23+
{
24+
$reportLogs = Forum_Moderation_Log::orderBy('created_at', 'desc')->get();
25+
26+
$this->setViewData('reportLogs', $reportLogs);
27+
}
28+
29+
public function getRemoveReport($reportId)
30+
{
31+
// Get the report and delete it
32+
$report = Forum_Moderation::find($reportId);
33+
$report->delete();
34+
35+
// Unset the moderation lock on the resource
36+
$resourceType = $report->resource_type;
37+
$resource = $resourceType::find($report->resource_id);
38+
$resource->unsetModeration($report->id);
39+
40+
return $this->redirect('forum/moderation/dashboard#reported-posts', 'Post successully removed from moderation.');
41+
}
42+
43+
public function getAdminReview($reportId)
44+
{
45+
// Get the report and delete it
46+
$report = Forum_Moderation::find($reportId);
47+
$report->adminReviewFlag = 1;
48+
$report->save();
49+
50+
// Unset the moderation lock on the resource
51+
$resourceType = $report->resource_type;
52+
$resource = $resourceType::find($report->resource_id);
53+
$resource->setAdminReview($report->id);
54+
55+
return $this->redirect('forum/moderation/dashboard#reported-posts', 'Post successully submitted for admin review.');
56+
}
57+
}

0 commit comments

Comments
 (0)