Added user stuff to site's getPosts call.
このコミットが含まれているのは:
コミット
f1009c8190
|
@ -16,7 +16,7 @@ class SiteController extends Controller {
|
|||
private $objUser;
|
||||
private $objPermission;
|
||||
|
||||
public function __contruct() {
|
||||
public function __construct() {
|
||||
$this->objAuth = new AuthController();
|
||||
$this->objUser = new UserController();
|
||||
$this->objPermission = new PermissionController();
|
||||
|
@ -24,12 +24,33 @@ class SiteController extends Controller {
|
|||
|
||||
// Posts
|
||||
public function getPosts() { // /api/rpc/site/post/getposts
|
||||
// Load group colours.
|
||||
$ucol = $this->objUser->getGroupColours();
|
||||
|
||||
// Load content.
|
||||
$get = DB::table('blg_content')
|
||||
->select('id', 'user_id', 'title', 'slug', 'post_date', 'publish_date', 'message')
|
||||
->join('users', 'blg_content.user_id', '=', 'users.id')
|
||||
->join('usr_details', 'usr_details.user_id', '=', 'blg_content.user_id')
|
||||
->join('usr_profile', 'usr_profile.user_id', '=', 'blg_content.user_id')
|
||||
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'blg_content.user_id')
|
||||
->where('public_status', 1)
|
||||
->where('isPost', 1)
|
||||
->orderBy('publish_date', 'desc')
|
||||
->get();
|
||||
->get(array(
|
||||
'blg_content.id',
|
||||
'blg_content.user_id',
|
||||
'title',
|
||||
'slug',
|
||||
'post_date',
|
||||
'publish_date',
|
||||
'message',
|
||||
'username',
|
||||
'perm_id',
|
||||
'gender',
|
||||
'avatar',
|
||||
'name_style',
|
||||
'display_name'
|
||||
));
|
||||
|
||||
$res = array();
|
||||
$key = 0;
|
||||
|
@ -37,6 +58,36 @@ class SiteController extends Controller {
|
|||
setlocale(LC_ALL, 'ja_JP.utf8');
|
||||
|
||||
foreach ($get 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($res, [
|
||||
'key' => $key,
|
||||
'id' => $i->id,
|
||||
|
@ -45,7 +96,12 @@ class SiteController extends Controller {
|
|||
'slug' => $i->slug,
|
||||
'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->post_date),
|
||||
'publish_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->publish_date),
|
||||
'message' => $i->message
|
||||
'message' => $i->message,
|
||||
'gender' => $i->gender,
|
||||
'avatar' => $i->avatar,
|
||||
'showcol' => $showCol,
|
||||
'showname' => $showName,
|
||||
'showgroup' => $showGroupName
|
||||
]);
|
||||
$key++;
|
||||
}
|
||||
|
|
新しいイシューから参照