2018-02-06 06:08:19 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Http\Request;
|
2018-02-16 23:09:35 +09:00
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
2018-02-06 06:08:19 +09:00
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
2018-02-27 01:12:06 +09:00
|
|
|
use App\Http\Controllers\UserController;
|
|
|
|
use App\Http\Controllers\PermissionController;
|
|
|
|
|
2018-02-06 06:08:19 +09:00
|
|
|
class BoardController extends Controller {
|
2018-02-27 01:12:06 +09:00
|
|
|
private $objUser;
|
|
|
|
private $objPermission;
|
|
|
|
|
|
|
|
public function __construct() {
|
|
|
|
$this->objUser = new UserController();
|
|
|
|
$this->objPermission = new PermissionController();
|
|
|
|
}
|
|
|
|
|
2018-02-06 06:08:19 +09:00
|
|
|
public function getCategories() { // /api/rpc/board/category/getcategories
|
|
|
|
return DB::table('for_category')
|
|
|
|
->select('*')
|
|
|
|
->orderBy('order', 'asc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCategory($id) { // /api/rpc/board/category/getcategory/id
|
|
|
|
return DB::table('for_category')
|
|
|
|
->select('*')
|
|
|
|
->where('id', $id)
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:24:16 +09:00
|
|
|
public function getCategoryName($id) { // /api/rpc/board/category/getcategoryname/id
|
|
|
|
return DB::table('for_category')
|
|
|
|
->select('title')
|
|
|
|
->where('id', $id)
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getForums() { // /api/rpc/board/forum/getforums
|
2018-02-06 06:08:19 +09:00
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('*')
|
|
|
|
->orderBy('order', 'asc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:24:16 +09:00
|
|
|
public function getForum($id) { // /api/rpc/board/forum/getforum/id
|
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('*')
|
|
|
|
->where('id', $id)
|
|
|
|
->orderBy('order', 'asc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-16 23:09:35 +09:00
|
|
|
public function getForumIdFromTopic($id) { // /api/rpc/board/topic/getforumidfromtopic/id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('for_id')
|
|
|
|
->where('id', $id)
|
|
|
|
->first()->for_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTopicIdFromPost($id) { // /api/rpc/board/post/gettopicidfrompost/id
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->select('top_id')
|
|
|
|
->where('id', $id)
|
|
|
|
->first()->top_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getForumIdFromPost($id) { // /api/rpc/board/post/getforumidfrompost/id
|
|
|
|
$top_id = $this->getTopicIdFromPost($id);
|
|
|
|
|
|
|
|
return $this->getForumIdFromTopic($top_id);
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:24:16 +09:00
|
|
|
public function getForumName($id) { // /api/rpc/board/forum/getforumname/id
|
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('cat_id', 'title')
|
|
|
|
->where('id', $id)
|
|
|
|
->orderBy('order', 'asc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-16 23:09:35 +09:00
|
|
|
public function getPostCountFreeze($id) { // /api/rpc/board/forum/getpostcountfreeze/id
|
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('post_count_freeze')
|
|
|
|
->where('id', $id)
|
|
|
|
->first()->post_count_freeze;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getReadOnly($id) { // /api/rpc/board/forum/getreadonly/id
|
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('readonly')
|
|
|
|
->where('id', $id)
|
|
|
|
->first()->readonly;
|
|
|
|
}
|
|
|
|
|
2018-02-06 16:12:00 +09:00
|
|
|
public function getForumsInCategory($cat_id) { // /api/rpc/board/forum/getforumsincategory/cat_id
|
2018-02-06 06:08:19 +09:00
|
|
|
return DB::table('for_forums')
|
|
|
|
->select('*')
|
|
|
|
->where('cat_id', $cat_id)
|
|
|
|
->get();
|
|
|
|
}
|
2018-02-06 17:24:16 +09:00
|
|
|
|
|
|
|
public function getTopics($for, $from, $to) { // /api/rpc/board/topic/gettopics/for/from/to
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('*')
|
2018-02-19 21:08:56 +09:00
|
|
|
->where('for_id', $for)
|
2018-02-06 17:24:16 +09:00
|
|
|
->offset($from)
|
|
|
|
->limit($to)
|
|
|
|
->orderBy('last_date', 'desc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTopicsUnpinned($for_id, $from, $to) { // /api/rpc/board/topic/gettopicsunpinned/for_id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('*')
|
|
|
|
->where('for_id', $for_id)
|
|
|
|
->where('sticky', 0)
|
|
|
|
->offset($from)
|
|
|
|
->limit($to)
|
|
|
|
->orderBy('last_date', 'desc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTopicsPinned($for_id) { // /api/rpc/board/topic/gettopicspinned/for_id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('*')
|
|
|
|
->where('for_id', $for_id)
|
|
|
|
->where('sticky', 1)
|
|
|
|
->orderBy('last_date', 'desc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-19 21:08:56 +09:00
|
|
|
public function getTopicStart($top_id) { // /api/rpc/board/post/gettopicstart/top_id
|
2018-02-19 21:31:08 +09:00
|
|
|
$uid = DB::table('for_posts')
|
2018-02-19 21:08:56 +09:00
|
|
|
->where('top_id', $top_id)
|
2018-02-19 21:31:08 +09:00
|
|
|
->orderBy('post_date', 'asc')
|
|
|
|
->value('user_id');
|
|
|
|
|
|
|
|
$pdt = DB::table('for_posts')
|
|
|
|
->where('top_id', $top_id)
|
|
|
|
->orderBy('post_date', 'asc')
|
|
|
|
->value('post_date');
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'uid' => $uid,
|
|
|
|
'date' => $pdt
|
|
|
|
);
|
2018-02-19 21:08:56 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getLastPost($top_id) { // /api/rpc/board/post/getlastpost/top_id
|
2018-02-19 21:31:08 +09:00
|
|
|
$uid = DB::table('for_posts')
|
2018-02-19 21:08:56 +09:00
|
|
|
->where('top_id', $top_id)
|
2018-02-19 21:31:08 +09:00
|
|
|
->orderBy('post_date', 'desc')
|
|
|
|
->value('user_id');
|
|
|
|
|
|
|
|
$pdt = DB::table('for_posts')
|
|
|
|
->where('top_id', $top_id)
|
|
|
|
->orderBy('post_date', 'desc')
|
|
|
|
->value('post_date');
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'uid' => $uid,
|
|
|
|
'date' => $pdt
|
|
|
|
);
|
2018-02-19 21:08:56 +09:00
|
|
|
}
|
|
|
|
|
2018-02-19 22:35:31 +09:00
|
|
|
public function getFirstAndLastPosts($top_id) { // /api/rpc/board/post/getfirstandlastposts/top_id
|
|
|
|
$first = $this->getTopicStart($top_id);
|
|
|
|
$last = $this->getLastPost($top_id);
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'first' => $first,
|
|
|
|
'last' => $last
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-06 17:24:16 +09:00
|
|
|
public function countUnpinnedTopicsInForum($for_id) { // /api/rpc/board/topic/countunpinnedtopicsinforum/for_id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->where('for_id', $for_id)
|
|
|
|
->where('sticky', 0)
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
|
2018-02-06 19:51:43 +09:00
|
|
|
public function getTopic($id, $from, $to) { // /api/rpc/board/topic/gettopic/id/from/to
|
2018-02-06 17:24:16 +09:00
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('*')
|
|
|
|
->where('id', $id)
|
|
|
|
->offset($from)
|
|
|
|
->limit($to)
|
|
|
|
->orderBy('last_date', 'desc')
|
|
|
|
->get();
|
|
|
|
}
|
2018-02-06 19:51:43 +09:00
|
|
|
|
|
|
|
public function getTopicLock($id) { // /api/rpc/board/topic/gettopiclock/id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('lock')
|
|
|
|
->where('id', $id)
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTopicName($id) { // /api/rpc/board/topic/gettopicname/id
|
|
|
|
return DB::table('for_threads')
|
|
|
|
->select('for_id', 'title')
|
|
|
|
->where('id', $id)
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPostsInTopic($top_id, $from, $to) { // /api/rpc/board/post/getpostsintopic/top_id/from/to
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->select('*')
|
|
|
|
->where('top_id', $top_id)
|
|
|
|
->offset($from)
|
|
|
|
->limit($to)
|
|
|
|
->orderBy('post_date', 'asc')
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function countPostsInTopic($top_id) { // /api/rpc/board/post/countpostsintopic/top_id
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->where('top_id', $top_id)
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPost($id) { // /api/rpc/board/post/getpost/id
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->select('*')
|
|
|
|
->where('id', $id)
|
|
|
|
->get();
|
|
|
|
}
|
|
|
|
|
2018-02-16 18:19:37 +09:00
|
|
|
public function getCurrentPostCount($user_id) { // /api/rpc/board/post/getcurrentpostcount/user_id
|
|
|
|
return DB::table('for_posts')->where('user_id', $user_id)->max('postcount');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getNextPostCount($user_id) { // /api/rpc/board/post/getnextpostcount/user_id
|
|
|
|
$get = DB::table('for_posts')->where('user_id', $user_id)->max('postcount');
|
|
|
|
$get++;
|
|
|
|
|
|
|
|
return $get;
|
|
|
|
}
|
|
|
|
|
2018-02-06 19:51:43 +09:00
|
|
|
public function getUserPosts($top_id, $from, $to) { // /api/rpc/board/post/getuserposts/top/from/to
|
|
|
|
return DB::table('for_posts')
|
2018-02-07 22:24:41 +09:00
|
|
|
->join('users', 'for_posts.user_id', '=', 'users.id')
|
2018-02-07 21:38:42 +09:00
|
|
|
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
|
|
|
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
|
|
|
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
2018-02-06 19:51:43 +09:00
|
|
|
->where('for_posts.top_id', $top_id)
|
|
|
|
->offset($from)
|
|
|
|
->limit($to)
|
|
|
|
->orderBy('for_posts.post_date', 'asc')
|
|
|
|
->get(array(
|
2018-02-16 23:09:35 +09:00
|
|
|
'for_posts.id',
|
|
|
|
'top_id',
|
|
|
|
'for_posts.user_id',
|
|
|
|
'post_date',
|
|
|
|
'message',
|
|
|
|
'delete',
|
|
|
|
'lastedit',
|
|
|
|
'ipaddress',
|
|
|
|
'delreason',
|
|
|
|
'nolayout',
|
|
|
|
'postcount',
|
|
|
|
'username',
|
|
|
|
'perm_id',
|
|
|
|
'total_posts',
|
|
|
|
'header',
|
|
|
|
'footer',
|
|
|
|
'member_title',
|
|
|
|
'gender',
|
|
|
|
'avatar',
|
|
|
|
'name_style',
|
|
|
|
'display_name',
|
|
|
|
'country'
|
2018-02-06 19:51:43 +09:00
|
|
|
));
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUserPost($id) { // /api/rpc/board/post/getuserpost/id
|
|
|
|
return DB::table('for_posts')
|
2018-02-07 22:24:41 +09:00
|
|
|
->join('users', 'for_posts.user_id', '=', 'users.id')
|
2018-02-07 21:38:42 +09:00
|
|
|
->join('usr_details', 'usr_details.user_id', '=', 'for_posts.user_id')
|
|
|
|
->join('usr_profile', 'usr_profile.user_id', '=', 'for_posts.user_id')
|
|
|
|
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'for_posts.user_id')
|
2018-02-06 19:51:43 +09:00
|
|
|
->where('for_posts.id', $id)
|
|
|
|
->orderBy('for_posts.post_date', 'asc')
|
|
|
|
->get(array(
|
2018-02-16 23:09:35 +09:00
|
|
|
'for_posts.id',
|
|
|
|
'top_id',
|
|
|
|
'for_posts.user_id',
|
|
|
|
'post_date',
|
|
|
|
'message',
|
|
|
|
'delete',
|
|
|
|
'lastedit',
|
|
|
|
'ipaddress',
|
|
|
|
'delreason',
|
|
|
|
'nolayout',
|
|
|
|
'postcount',
|
|
|
|
'username',
|
|
|
|
'perm_id',
|
|
|
|
'total_posts',
|
|
|
|
'header',
|
|
|
|
'footer',
|
|
|
|
'member_title',
|
|
|
|
'gender',
|
|
|
|
'avatar',
|
|
|
|
'name_style',
|
|
|
|
'display_name',
|
|
|
|
'country'
|
2018-02-06 19:51:43 +09:00
|
|
|
));
|
|
|
|
}
|
2018-02-15 06:39:26 +09:00
|
|
|
|
|
|
|
public function addPost(Request $request) { // /api/rpc/board/post/addpost
|
2018-02-16 23:09:35 +09:00
|
|
|
$add = DB::table('for_posts')
|
2018-02-15 06:39:26 +09:00
|
|
|
->insert([
|
|
|
|
'top_id' => $request->top_id,
|
|
|
|
'user_id' => $request->user_id,
|
|
|
|
'post_date' => $request->post_date,
|
|
|
|
'message' => $request->message,
|
2018-02-16 23:09:35 +09:00
|
|
|
'delete' => 0,
|
|
|
|
'lastedit' => 0,
|
2018-02-15 06:39:26 +09:00
|
|
|
'ipaddress' => $request->ipaddress,
|
2018-02-16 23:09:35 +09:00
|
|
|
'delreason' => '',
|
2018-02-15 06:39:26 +09:00
|
|
|
'nolayout' => $request->nolayout,
|
2018-02-16 23:09:35 +09:00
|
|
|
'postcount' => $request->postcount,
|
|
|
|
// Deprecated: remove like and read stuff after full release!
|
|
|
|
'likes' => 0,
|
|
|
|
'likers' => '',
|
|
|
|
'read' => ''
|
2018-02-15 06:39:26 +09:00
|
|
|
]);
|
2018-02-16 23:09:35 +09:00
|
|
|
|
|
|
|
return \Response::json($add);
|
2018-02-15 06:39:26 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
public function editPost(Request $request) { // /api/rpc/board/post/editpost
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->where('id', $request->id)
|
|
|
|
->update([
|
|
|
|
'lastedit' => $request->lastedit,
|
|
|
|
'message' => $request->message,
|
|
|
|
'nolayout' => $request->nolayout
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletePost(Request $request) { // /api/rpc/board/post/deletepost
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->where('id', $request->id)
|
|
|
|
->update([
|
|
|
|
'delete' => 1,
|
|
|
|
'delreason' => $request->delreason
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function undeletePost(Request $request) { // /api/rpc/board/post/undeletepost
|
|
|
|
return DB::table('for_posts')
|
|
|
|
->where('id', $request->id)
|
|
|
|
->update([
|
|
|
|
'delete' => 0,
|
|
|
|
'delreason' => ''
|
|
|
|
]);
|
|
|
|
}
|
2018-02-27 01:12:06 +09:00
|
|
|
|
|
|
|
public function browseTopicInfo($tp, $id, $to) {
|
|
|
|
if ($tp == 'p') {
|
|
|
|
// Get information for the navigation.
|
|
|
|
$tid = $this->getTopicIdFromPost($id);
|
|
|
|
$tinfo = $this->getTopicName($tid);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Get information for the navigation.
|
|
|
|
$tinfo = $this->getTopicName($id);
|
|
|
|
}
|
|
|
|
|
|
|
|
$finfo = $this->getForumName($tinfo[0]->for_id);
|
|
|
|
$cinfo = $this->getCategoryName($finfo[0]->cat_id);
|
|
|
|
|
|
|
|
// Count posts for navigation.
|
|
|
|
if ($tp == 't') $pcount = $this->countPostsInTopic($id);
|
|
|
|
|
|
|
|
// Is this topic locked?
|
|
|
|
if ($tp == 't') $tlock = $this->getTopicLock($id);
|
|
|
|
else $tlock = $this->getTopicLock($tid);
|
|
|
|
$glock = false;
|
|
|
|
|
|
|
|
if ($tlock[0]->lock == 0) $glock = false;
|
|
|
|
else $glock = true;
|
|
|
|
|
|
|
|
if ($tp == 'p') {
|
|
|
|
// Compile.
|
|
|
|
return array(
|
|
|
|
'topId' => $tid,
|
|
|
|
'forId' => $tinfo[0]->for_id,
|
|
|
|
'topName' => $tinfo[0]->title,
|
|
|
|
'catId' => $finfo[0]->cat_id,
|
|
|
|
'forName' => $finfo[0]->title,
|
|
|
|
'catName' => $cinfo[0]->title,
|
|
|
|
'lock' => $glock,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Compile.
|
|
|
|
return array(
|
|
|
|
'forId' => $tinfo[0]->for_id,
|
|
|
|
'topName' => $tinfo[0]->title,
|
|
|
|
'catId' => $finfo[0]->cat_id,
|
|
|
|
'forName' => $finfo[0]->title,
|
|
|
|
'catName' => $cinfo[0]->title,
|
|
|
|
'maxPage' => ceil($pcount / $to),
|
|
|
|
'lock' => $glock,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function browseTopicPosts($tp, $id, $from, $to) {
|
|
|
|
// Load group colours.
|
|
|
|
$ucol = $this->objUser->getGroupColours();
|
|
|
|
|
|
|
|
// All the user posts' user IDs.
|
|
|
|
if ($tp == 't') $uid = $this->getUserPosts($id, $from, $to);
|
|
|
|
else $uid = $this->getUserPost($id);
|
|
|
|
$udat = array();
|
|
|
|
$key = 0;
|
|
|
|
|
|
|
|
foreach ($uid as $i) {
|
|
|
|
$showName = '';
|
|
|
|
$showCol = '';
|
|
|
|
$showGroupName = '';
|
|
|
|
|
|
|
|
// Display name or username?
|
|
|
|
if (!empty($i->display_name)) {
|
|
|
|
$showName = $i->display_name;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$showName = $i->username;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Custom name styling or default?
|
|
|
|
if (!empty($i->name_style)) {
|
|
|
|
$showCol = $i->name_style;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
foreach ($ucol as $j) {
|
|
|
|
if ($j->id == $i->perm_id) {
|
|
|
|
if ($i->gender == 1) $showCol = $j->colour_m;
|
|
|
|
else if ($i->gender == 2) $showCol = $j->colour_f;
|
|
|
|
else $showCol = $j->colour_u;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Group names.
|
|
|
|
$gname = $this->objUser->getGroupName($i->user_id);
|
|
|
|
$showGroupName = $gname[0]->name;
|
|
|
|
|
|
|
|
array_push($udat, [
|
|
|
|
'key' => $key,
|
|
|
|
'id' => $i->id,
|
|
|
|
'tid' => $i->top_id,
|
|
|
|
'uid' => $i->user_id,
|
|
|
|
'post_date' => date('Y/m/d, G:i:s T', $i->post_date),
|
|
|
|
'message' => $i->message,
|
|
|
|
'delete' => $i->delete,
|
|
|
|
'delreason' => $i->delreason,
|
|
|
|
'lastedit' => date('Y/m/d, G:i:s T', $i->lastedit),
|
|
|
|
'lasteditUnix' => $i->lastedit,
|
|
|
|
'ipaddress' => $i->ipaddress,
|
|
|
|
'nolayout' => $i->nolayout,
|
|
|
|
'postcount' => $i->postcount,
|
|
|
|
'total_posts' => $i->total_posts,
|
|
|
|
'header' => $i->header,
|
|
|
|
'footer' => $i->footer,
|
|
|
|
'member_title' => $i->member_title,
|
|
|
|
'gender' => $i->gender,
|
|
|
|
'avatar' => $i->avatar,
|
|
|
|
'showcol' => $showCol,
|
|
|
|
'showname' => $showName,
|
|
|
|
'showgroup' => $showGroupName,
|
|
|
|
'country' => $i->country,
|
|
|
|
]);
|
|
|
|
$key++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Assign group names.
|
|
|
|
return $udat;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function browsePermissions($uid) {
|
|
|
|
// Get user ID.
|
|
|
|
$perm = $this->objUser->getUser($uid);
|
|
|
|
|
|
|
|
// Does the user ID exist? Grand the appropriate rights. Otherwise, use guest.
|
|
|
|
if ($uid != 0) {
|
|
|
|
// Forum permissions.
|
|
|
|
$grouppermfor = $this->objPermission->getPermissionGroup('for', $perm[0]->perm_id);
|
|
|
|
$userpermfor = $this->objPermission->getPermissionUser('for', $uid);
|
|
|
|
|
|
|
|
// User permissions.
|
|
|
|
$grouppermusr = $this->objPermission->getPermissionGroup('usr', $perm[0]->perm_id);
|
|
|
|
$userpermusr = $this->objPermission->getPermissionUser('usr', $uid);
|
|
|
|
|
|
|
|
// Now provide an array of user overwritten permissions if it exists. Otherwise, give its group permissions.
|
|
|
|
$forarr = array();
|
|
|
|
$usrarr = array();
|
|
|
|
|
|
|
|
if (!empty($userpermfor[0])) {
|
|
|
|
$forarr = (array)$userpermfor[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$forarr = (array)$grouppermfor[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($userpermusr[0])) {
|
|
|
|
$usrarr = (array)$userpermusr[0];
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$usrarr = (array)$grouppermusr[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
$merge = array();
|
|
|
|
$merge = array_merge($forarr, $usrarr);
|
|
|
|
|
|
|
|
return $merge;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Forum permissions.
|
|
|
|
$grouppermfor = $this->objPermission->getPermissionGroup('for', 6);
|
|
|
|
|
|
|
|
// User permissions.
|
|
|
|
$grouppermusr = $this->objPermission->getPermissionGroup('usr', 6);
|
|
|
|
|
|
|
|
// Since guests don't have user overwritten permissions, simply return the group permissions.
|
|
|
|
$merge = array();
|
|
|
|
$merge = array_merge((array)$grouppermfor[0], (array)$grouppermusr[0]);
|
|
|
|
|
|
|
|
return $merge;
|
|
|
|
}
|
|
|
|
}
|
2018-02-06 06:08:19 +09:00
|
|
|
}
|