Browse permissions for store.

このコミットが含まれているのは:
テクニカル諏訪子 2018-03-06 21:34:53 +09:00
コミット f0e27920dd
2個のファイルの変更64行の追加0行の削除

ファイルの表示

@ -7,6 +7,14 @@ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
class StoreController extends Controller {
private $objUser;
private $objPermission;
public function __construct() {
$this->objUser = new UserController();
$this->objPermission = new PermissionController();
}
// Game
public function getGames() { // /api/rpc/store/game/getgames
return DB::table('str_games')
@ -479,4 +487,57 @@ class StoreController extends Controller {
->where('id', $request->id)
->update(['isApproved' => 0]);
}
public function browsePermissions($uid) {
// Get user ID.
$perm = $this->objUser->getUser($uid);
// Does the user ID exist? Grand the appropriate rights. Otherwise, use guest.
if ($uid != 0) {
// Store permissions.
$grouppermstr = $this->objPermission->getPermissionGroup('str', $perm[0]->perm_id);
$userpermstr = $this->objPermission->getPermissionUser('str', $uid);
// User permissions.
$grouppermusr = $this->objPermission->getPermissionGroup('usr', $perm[0]->perm_id);
$userpermusr = $this->objPermission->getPermissionUser('usr', $uid);
// Now provide an array of user overwritten permissions if it exists. Otherwise, give its group permissions.
$strarr = array();
$usrarr = array();
if (!empty($userpermstr[0])) {
$strarr = (array)$userpermstr[0];
}
else {
$strarr = (array)$grouppermstr[0];
}
if (!empty($userpermusr[0])) {
$usrarr = (array)$userpermusr[0];
}
else {
$usrarr = (array)$grouppermusr[0];
}
$merge = array();
$merge = array_merge($strarr, $usrarr);
return $merge;
}
else {
// Store permissions.
$grouppermstr = $this->objPermission->getPermissionGroup('str', 6);
// User permissions.
$grouppermusr = $this->objPermission->getPermissionGroup('usr', 6);
// Since guests don't have user overwritten permissions, simply return the group permissions.
$merge = array();
$merge = array_merge((array)$grouppermstr[0], (array)$grouppermusr[0]);
return $merge;
}
}
}

ファイルの表示

@ -56,3 +56,6 @@ Route::post('/api/rpc/store/entry/upload', 'StoreController@uploadEntry');
Route::post('/api/rpc/store/entry/update', 'StoreController@updateEntry');
Route::post('/api/rpc/store/entry/restore', 'StoreController@restoreEntry');
Route::post('/api/rpc/store/entry/remove', 'StoreController@removeEntry');
// Compiled routes.
Route::get('/api/rpc/store/browse/browsepermissions/{uid}', 'StoreController@browsePermissions');