読書済機能性

このコミットが含まれているのは:
テクニカル諏訪子 2019-03-11 18:06:32 +09:00
コミット 0f40d0e2f9
2個のファイルの変更162行の追加3行の削除

ファイルの表示

@ -105,6 +105,162 @@ class BoardController extends Controller {
return $yetToRead;
}
public function markReadAll (Request $request) {
$check = $this->objAuth->checkLegit($request->username, $request->password);
if ($check == 0) {
return 'Guests can\'t read';
}
else {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_canview']) {
$tid = DB::table('for_threads')
->select('id')
->get();
foreach ($tid as $t) {
$chk = DB::table('for_read')
->where('user_id', $check)
->where('top_id', $t->id)
->count();
if ($chk) {
$request->top_id = $t->id;
$this->readTopic($request);
}
else {
$getPost = DB::table('for_posts')
->select('post_date')
->where('top_id', $t->id)
->orderBy('post_date', 'desc')
->limit(1)
->first();
DB::table('for_read')
->insert([
'user_id' => $check,
'top_id' => $t->id,
'view_time' => $getPost->post_date
]);
}
}
return 'Done.';
}
else {
return 'Permission denied.';
}
}
}
public function markReadCat (Request $request) {
$check = $this->objAuth->checkLegit($request->username, $request->password);
if ($check == 0) {
return 'Guests can\'t read';
}
else {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_canview']) {
$fid = DB::table('for_forums')
->select('id')
->where('cat_id', $request->cat_id)
->get();
foreach ($fid as $f) {
$tid = DB::table('for_threads')
->select('id')
->where('for_id', $f->id)
->get();
foreach ($tid as $t) {
$chk = DB::table('for_read')
->where('user_id', $check)
->where('top_id', $t->id)
->count();
if ($chk) {
$request->top_id = $t->id;
$this->readTopic($request);
}
else {
$getPost = DB::table('for_posts')
->select('post_date')
->where('top_id', $t->id)
->orderBy('post_date', 'desc')
->limit(1)
->first();
DB::table('for_read')
->insert([
'user_id' => $check,
'top_id' => $t->id,
'view_time' => $getPost->post_date
]);
}
}
}
return 'Done.';
}
else {
return 'Permission denied.';
}
}
}
public function markRead (Request $request) {
$check = $this->objAuth->checkLegit($request->username, $request->password);
if ($check == 0) {
return 'Guests can\'t read';
}
else {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_canview']) {
$tid = DB::table('for_threads')
->select('id')
->where('for_id', $request->for_id)
->get();
foreach ($tid as $t) {
$chk = DB::table('for_read')
->where('user_id', $check)
->where('top_id', $t->id)
->count();
if ($chk) {
$request->top_id = $t->id;
$this->readTopic($request);
}
else {
$getPost = DB::table('for_posts')
->select('post_date')
->where('top_id', $t->id)
->orderBy('post_date', 'desc')
->limit(1)
->first();
DB::table('for_read')
->insert([
'user_id' => $check,
'top_id' => $t->id,
'view_time' => $getPost->post_date
]);
}
}
return 'Done.';
}
else {
return 'Permission denied.';
}
}
}
public function readTopic(Request $request) { // /api/rpc/board/topic/read
$check = $this->objAuth->checkLegit($request->username, $request->password);
@ -120,7 +276,7 @@ class BoardController extends Controller {
->where('user_id', $check)
->where('top_id', $request->top_id)
->first();
$getPost = DB::table('for_posts')
->select('post_date')
->where('top_id', $request->top_id)
@ -135,10 +291,10 @@ class BoardController extends Controller {
->update([
'view_time' => $getPost->post_date
]);
return 'Read.';
}
return '';
}
else {

ファイルの表示

@ -42,6 +42,9 @@ Route::get('/api/rpc/board/topic/gettopiclock/{id}', 'BoardController@getTopicLo
Route::get('/api/rpc/board/topic/getforumidfromtopic/{top_id}', 'BoardController@getForumIdFromTopic');
Route::get('/api/rpc/board/topic/gettopicname/{id}', 'BoardController@getTopicName');
Route::post('/api/rpc/board/topic/markall', 'BoardController@markReadAll');
Route::post('/api/rpc/board/topic/markcat', 'BoardController@markReadCat');
Route::post('/api/rpc/board/topic/mark', 'BoardController@markRead');
Route::post('/api/rpc/board/topic/read', 'BoardController@readTopic');
Route::post('/api/rpc/board/topic/add', 'BoardController@addTopic');
Route::post('/api/rpc/board/topic/lock', 'BoardController@lockTopic');