Added user stuff in other site API calls too.

このコミットが含まれているのは:
テクニカル諏訪子 2018-03-14 13:41:12 +01:00
コミット c6140435ac
1個のファイルの変更175行の追加13行の削除

ファイルの表示

@ -54,7 +54,6 @@ class SiteController extends Controller {
$res = array();
$key = 0;
setlocale(LC_ALL, 'ja_JP.utf8');
foreach ($get as $i) {
@ -97,11 +96,9 @@ class SiteController extends Controller {
'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,
'gender' => $i->gender,
'avatar' => $i->avatar,
'showcol' => $showCol,
'showname' => $showName,
'showgroup' => $showGroupName
'showname' => $showName
]);
$key++;
}
@ -159,17 +156,68 @@ class SiteController extends Controller {
}
public function getPost($slug) { // /api/rpc/site/post/getpost/slug
// 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)
->where('slug', $slug)
->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();
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, [
'id' => $i->id,
'user_id' => $i->user_id,
@ -177,7 +225,10 @@ 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,
'showcol' => $showCol,
'showname' => $showName
]);
}
@ -202,17 +253,69 @@ class SiteController extends Controller {
// Comments
public function getComments($id) { // /api/rpc/site/post/getcomments/id
// Load group colours.
$ucol = $this->objUser->getGroupColours();
// Load content.
$get = DB::table('blg_comments')
->select('id', 'user_id', 'votes', 'post_date', 'last_date', 'isDeleted', 'message', 'ip_address')
->join('users', 'blg_comments.user_id', '=', 'users.id')
->join('usr_details', 'usr_details.user_id', '=', 'blg_comments.user_id')
->join('usr_profile', 'usr_profile.user_id', '=', 'blg_comments.user_id')
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'blg_comments.user_id')
->where('content_id', $id)
->orderBy('post_date', 'asc')
->get();
->get(array(
'blg_comments.id',
'blg_comments.user_id',
'votes',
'post_date',
'last_date',
'isDeleted',
'message',
'ip_address',
'username',
'perm_id',
'gender',
'avatar',
'name_style',
'display_name'
));
$res = array();
$key = 1;
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,
@ -223,7 +326,10 @@ class SiteController extends Controller {
'last_unix' => $i->last_date,
'isDeleted' => $i->isDeleted,
'message' => $i->message,
'ip_address' => $i->ip_address
'ip_address' => $i->ip_address,
'avatar' => $i->avatar,
'showcol' => $showCol,
'showname' => $showName
]);
$key++;
}
@ -232,15 +338,68 @@ class SiteController extends Controller {
}
public function getComment($id) { // /api/rpc/site/post/getcomment/id
// Load group colours.
$ucol = $this->objUser->getGroupColours();
// Load content.
$get = DB::table('blg_comments')
->select('user_id', 'content_id', 'votes', 'post_date', 'last_date', 'isDeleted', 'message', 'ip_address')
->join('users', 'blg_comments.user_id', '=', 'users.id')
->join('usr_details', 'usr_details.user_id', '=', 'blg_comments.user_id')
->join('usr_profile', 'usr_profile.user_id', '=', 'blg_comments.user_id')
->join('usr_perm_id', 'usr_perm_id.user_id', '=', 'blg_comments.user_id')
->where('id', $id)
->get();
->orderBy('post_date', 'asc')
->get(array(
'blg_comments.user_id',
'content_id',
'votes',
'post_date',
'last_date',
'isDeleted',
'message',
'ip_address',
'username',
'perm_id',
'gender',
'avatar',
'name_style',
'display_name'
));
$res = array();
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, [
'user_id' => $i->user_id,
'content_id' => $i->content_id,
@ -250,7 +409,10 @@ class SiteController extends Controller {
'last_unix' => $i->last_date,
'isDeleted' => $i->isDeleted,
'message' => $i->message,
'ip_address' => $i->ip_address
'ip_address' => $i->ip_address,
'avatar' => $i->avatar,
'showcol' => $showCol,
'showname' => $showName
]);
}