このコミットが含まれているのは:
テクニカル諏訪子 2019-03-17 07:00:22 +09:00
コミット cc0822a881
3個のファイルの変更72行の追加3行の削除

ファイルの表示

@ -571,7 +571,7 @@ class SiteController extends Controller {
if ($valid['blg_addcomment'] == 1) {
$add = DB::table('blg_comments')
->insert([
->insertGetId([
'user_id' => $check,
'content_id' => $request->content_id,
'votes' => 0,
@ -582,6 +582,10 @@ class SiteController extends Controller {
'ip_address' => $request->ip_address
]);
$g = DB::table('blg_content')->select('slug', 'user_id')->where('id', $request->content_id)->first();
if ($check != $g->user_id) $this->objUser->addNotification($request, $g->user_id, 1, '新規ブログコメント', 'blog/'.$g->slug, 'comment-'.$add);
return \Response::json($add);
}
else {

ファイルの表示

@ -754,7 +754,7 @@ class UserController extends Controller {
if ($valid['usr_addcomment'] == 1) {
$add = DB::table('usr_comments')
->insert([
->insertGetId([
'user_id' => $check,
'profile_id' => $request->profile_id,
'reply_id' => ($request->reply_id > 0 ? $request->reply_id : 0),
@ -764,6 +764,8 @@ class UserController extends Controller {
'isDel' => 0
]);
if ($check != $request->profile_id) $this->addNotification($request, $request->profile_id, 2, '新規プロファイルコメント', 'profile/'.$request->profile_id, 'comment-'.$add);
return \Response::json($add);
}
else {
@ -844,4 +846,62 @@ class UserController extends Controller {
}
}
}
public function getNotification(Request $r) { // /api/rpc/user/notification/get
$check = $this->objAuth->checkLegit($r->username, $r->password);
if ($check != 0) {
$get = DB::table('usr_notification')
->select('id', 'app_id', 'text', 'section', 'goto')
->where('user_id', $check)
->get();
$res = array();
foreach ($get as $g) {
$prot = DB::table('sys_settings')->select('protocol')->first()->protocol;
$goto = DB::table('sys_apps')->select('url')->where('id', $g->app_id)->first()->url;
$res[] = array(
'id' => $g->id,
'text' => $g->text,
'url' => 'http'.($prot == 1 ? 's' : '').'://'.$goto.'/#/'.$g->section
);
}
return $res;
}
else {
return array();
}
}
public function addNotification(Request $r, $uid, $aid, $txt, $sec, $goto) { // /api/rpc/user/notification/add
$check = $this->objAuth->checkLegit($r->username, $r->password);
if ($check != 0) {
$add = DB::table('usr_notification')
->insert([
'user_id' => $uid,
'app_id' => $aid,
'text' => $txt,
'section' => $sec,
'goto' => $goto
]);
return 1;
}
}
public function delNotification(Request $r) { // /api/rpc/user/notification/del
$check = $this->objAuth->checkLegit($r->username, $r->password);
if ($check != 0) {
return DB::table('usr_notification')
->where('id', $r->id)
->where('user_id', $check)
->delete();
}
}
}

ファイルの表示

@ -47,4 +47,9 @@ 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');
Route::post('/api/rpc/user/comment/delete', 'UserController@deleteComment');
Route::post('/api/rpc/user/comment/undelete', 'UserController@undeleteComment');
Route::post('/api/rpc/user/comment/undelete', 'UserController@undeleteComment');
// Notifications
Route::get('/api/rpc/user/notification/get', 'UserController@getNotification');
Route::post('/api/rpc/user/notification/del', 'UserController@delNotification');