Ejemplo n.º 1
0
 /**
  * Actions allowed to be used on reports
  *
  * @return array
  */
 public function getActions()
 {
     $actions = Cache::remember('system.adkats.reports.actions', 60 * 12, function () {
         return Command::whereIn('command_id', static::$allowedCommands)->lists('command_name', 'command_id');
     });
     return $actions;
 }
Ejemplo n.º 2
0
 public function edit($id)
 {
     try {
         $permissions = [];
         $role = Role::with('permissions', 'users')->findOrFail($id);
         Command::type('Active')->get()->each(function ($permission) use(&$permissions) {
             $command_id = $permission->command_id;
             $command_name = $permission->command_name;
             if ($permission->is_interactive) {
                 $group = 'Admin';
             } else {
                 $group = 'Public';
             }
             $permissions[$group][$command_id] = $command_name;
         });
         return View::make('admin.adkats.roles.edit', compact('permissions', 'role'))->with('page_title', Lang::get('navigation.admin.adkats.items.roles.items.edit.title'));
     } catch (ModelNotFoundException $e) {
         return Redirect::route('admin.adkats.roles.index')->withErrors([sprintf('No role found with ID #%s.', $id)]);
     }
 }
Ejemplo n.º 3
0
 /**
  * Logs action to database
  *
  * @param string|Player $target
  * @param string        $command
  * @param string        $message
  * @param int           $duration
  * @param bool|true     $sys
  *
  * @return \BFACP\Adkats\Record
  */
 private function log($target, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     $command = Command::where('command_key', $command)->first();
     if (!$command) {
         throw new RconException(500, 'Invalid command type');
     }
     if (!$target instanceof Player && is_string($target) && !in_array($command->command_key, ['server_nuke'])) {
         $target = Player::where('GameID', $this->gameID)->where('SoldierName', $target)->first();
     }
     if ($target instanceof Player) {
         $target_name = $target->SoldierName;
         $target_id = $target->PlayerID;
     } else {
         $target_name = is_null($target) ? 'Server' : $target;
         $target_id = null;
     }
     if ($this->admin instanceof Player) {
         $source_name = $this->admin->SoldierName;
         $source_id = $this->admin->PlayerID;
     } else {
         $source_name = $this->user->username;
         $source_id = null;
     }
     $data = [];
     if ($command->command_key == 'admin_say') {
         $data['chat'] = Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => $source_id, 'logSoldierName' => $source_name, 'logSubset' => 'Global']);
         if ($this->admin instanceof Player) {
             $data['chat']['player'] = $this->admin;
         }
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = $source_name;
     $record->source_id = $source_id;
     $record->target_name = $target_name;
     $record->target_id = $target_id;
     $record->save();
     $data['record'] = $record;
     return $data;
 }
Ejemplo n.º 4
0
 private function log($player, $command, $message = 'No Message', $duration = 0, $sys = true)
 {
     $timestamp = Carbon::now();
     if (!is_null($player)) {
         $player = Player::where('GameID', $this->gameID)->where('SoldierName', $player)->first();
     }
     $command = Command::where('command_key', $command)->first();
     if ($command == 'admin_say') {
         Chat::create(['ServerID' => $this->serverID, 'logDate' => $timestamp, 'logMessage' => $message, 'logPlayerID' => is_null($this->admin) ? null : $this->admin->PlayerID, 'logSoldierName' => is_null($this->admin) ? $this->user->username : $this->admin->SoldierName, 'logSubset' => 'Global']);
     }
     $record = new Record();
     $record->adkats_read = $sys ? 'Y' : 'N';
     $record->adkats_web = true;
     $record->command_action = $command->command_id;
     $record->command_type = $command->command_id;
     $record->command_numeric = $duration;
     $record->record_message = $message;
     $record->record_time = $timestamp;
     $record->server_id = $this->serverID;
     $record->source_name = is_null($this->admin) ? $this->user->username : $this->admin->SoldierName;
     $record->source_id = is_null($this->admin) ? null : $this->admin->PlayerID;
     $record->target_name = is_null($player) ? 'Server' : $player->SoldierName;
     $record->target_id = is_null($player) ? null : $player->PlayerID;
     $record->save();
     return $record;
 }