Profile comments and replies.

このコミットが含まれているのは:
テクニカル諏訪子 2018-08-06 10:55:06 +09:00
コミット 22bd573e32
2個のファイルの変更62行の追加46行の削除

ファイルの表示

@ -598,18 +598,6 @@ class UserController extends Controller {
}
}
$rep = DB::table('usr_comments')
->where('reply_id', $g->come_id)
->orderBy('usr_comments.postdate', 'asc')
->get(array(
'usr_comments.id as come_id',
'user_id',
'postdate',
'message',
'isEdit',
'isDel'
));
$come[] = array(
'come_id' => $g->come_id,
'user_id' => $g->user_id,
@ -617,49 +605,76 @@ class UserController extends Controller {
'avatar' => ($user[0]->avatar != '' ? $user[0]->avatar : 'assets/avatars/haznoavaz.png'),
'col' => $showCol,
'message' => $g->message,
'postdate' => $g->postdate,
'postdate' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', date($g->postdate)),
'isEdit' => $g->isEdit,
'isDel' => $g->isDel
);
}
foreach($rep as $r) {
$user = $this->getUser($r->user_id, $request)->toArray();
$showName = "";
$showCol = "";
return $come;
}
else {
return 'Permission denied.';
}
}
if ($user[0]->display_name !== '') {
$showName = $user[0]->display_name;
}
else {
$showName = $user[0]->username;
}
public function getReplies ($id, Request $request) { // /api/rpc/user/comment/reply/id
$cols = $this->getGroupColours()->toArray();
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($user[0]->name_style !== '') {
$showCol = $user[0]->name_style;
}
else {
foreach($cols as $cl) {
if ($cl->id === $user[0]->perm_id) {
if ($user[0]->gender === 1) $showCol = $cl->colour_m;
else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
else $showCol = $cl->colour_u;
}
if ($valid['usr_viewcomment'] == 1) {
$come = array();
$get = DB::table('usr_comments')
->where('reply_id', $id)
->orderBy('usr_comments.postdate', 'asc')
->get(array(
'reply_id',
'usr_comments.id as come_id',
'user_id',
'postdate',
'message',
'isEdit',
'isDel'
));
// Foreach, new getter but check on replies, and only if isDel is 0.
foreach ($get as $g) {
$user = $this->getUser($g->user_id, $request)->toArray();
$showName = "";
$showCol = "";
if ($user[0]->display_name !== '') {
$showName = $user[0]->display_name;
}
else {
$showName = $user[0]->username;
}
if ($user[0]->name_style !== '') {
$showCol = $user[0]->name_style;
}
else {
foreach($cols as $cl) {
if ($cl->id === $user[0]->perm_id) {
if ($user[0]->gender === 1) $showCol = $cl->colour_m;
else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
else $showCol = $cl->colour_u;
}
}
$come[] = array(
'reply_to' => $g->come_id,
'come_id' => $r->come_id,
'user_id' => $r->user_id,
'name' => $showName,
'avatar' => ($user[0]->avatar != '' ? $user[0]->avatar : 'assets/avatars/haznoavaz.png'),
'col' => $showCol,
'message' => $r->message,
'postdate' => $r->postdate,
'isEdit' => $r->isEdit,
'isDel' => $r->isDel
);
}
$come[] = array(
'reply_id' => $g->reply_id,
'come_id' => $g->come_id,
'user_id' => $g->user_id,
'name' => $showName,
'avatar' => ($user[0]->avatar != '' ? $user[0]->avatar : 'assets/avatars/haznoavaz.png'),
'col' => $showCol,
'message' => $g->message,
'postdate' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', date($g->postdate)),
'isEdit' => $g->isEdit,
'isDel' => $g->isDel
);
}
return $come;

ファイルの表示

@ -41,6 +41,7 @@ Route::post('/api/rpc/user/user/edit', 'UserController@editUser');
// Comment
Route::get('/api/rpc/user/comment/get/{id}', 'UserController@getComments');
Route::get('/api/rpc/user/comment/reply/{id}', 'UserController@getReplies');
Route::post('/api/rpc/user/comment/add', 'UserController@addComment');
Route::post('/api/rpc/user/comment/edit', 'UserController@editComment');