ポストを削除機能性

このコミットが含まれているのは:
テクニカル諏訪子 2019-02-07 13:48:15 +09:00
コミット cc35f45aa7
1個のファイルの変更39行の追加22行の削除

ファイルの表示

@ -927,23 +927,40 @@ class BoardController extends Controller {
}
public function deletePost(Request $request) { // /api/rpc/board/post/delete
$check = $this->objAuth->checkLegit($request->username, $request->password);
$check = $this->objAuth->checkLegit($request->username, $request->password);
if ($check == 0) {
return 'Err!';
if ($check == 0) {
return 'Err!';
}
else {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_del'] == 1) {
$s = db::table('for_posts')
->select('delete')
->where('id', $request->id)
->first()->delete;
if ($s === 1) {
$request->delreason = '';
}
DB::table('for_posts')
->where('id', $request->id)
->update([
'delete' => ($s == 0 ? 1 : 0),
'delreason' => $request->delreason
]);
return array(
'delete' => ($s == 0 ? 1 : 0),
'delreason' => $request->delreason
);
}
else {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_del'] == 1) {
return DB::table('for_posts')
->where('id', $request->id)
->update([
'delete' => 1,
'delreason' => $request->delreason
]);
}
return 'Permission denied.';
}
}
}
public function lockTopic(Request $request) { // /api/rpc/board/topic/lock
@ -956,21 +973,21 @@ class BoardController extends Controller {
$valid = $this->objAuth->getPermissions($request->username, $request->password);
if ($valid['for_locky'] == 1) {
$s = DB::table('for_threads')
$s = db::table('for_threads')
->select('lock')
->where('id', $request->id)
->first();
->first()->lock;
DB::table('for_threads')
->where('id', $request->id)
->update([
'lock' => ($s->lock == 0 ? 1 : 0)
]);
DB::table('for_threads')
->where('id', $request->id)
->update([
'lock' => ($s == 0 ? 1 : 0)
]);
return ($s->lock == 0 ? 1 : 0);
return ($s == 0 ? 1 : 0);
}
else {
return 'Permission denied.';
return 'Permission denied.';
}
}
}