public function postEdit()
 {
     $rules = array('gangid' => 'required|numeric|exists:gangs,id', 'owner' => 'numeric', 'newmember' => 'numeric', 'maxmembers' => 'numeric', 'bank' => 'numeric', 'reason' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes() && Auth::user()->level >= 2) {
         $members = array();
         foreach (Input::all() as $key => $value) {
             if ($key != 'bank' && $key != '_token' && $key != 'gangid' && $key != 'active' && $key != 'maxmembers' && $key != 'owner' && $key != 'newmember' && $key != 'reason') {
                 $key = str_replace('member_', '', $key);
                 array_push($members, $key);
             }
         }
         if (Input::get('newmember')) {
             array_push($members, Input::get('newmember'));
         }
         $members = Auth::user()->encodeDBArray($members, true);
         $active = 0;
         if (Input::get('active') == 1) {
             $active = 1;
         }
         $gang = Gang::find(Input::get('gangid'));
         if (Auth::user()->level >= 3) {
             $log = new Adminlog();
             $log->type = 'gang';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('gangid');
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('owner' => $gang->owner, 'members' => $gang->members, 'maxmembers' => $gang->maxmembers, 'bank' => $gang->bank, 'active' => $gang->active), array('owner' => Input::get('owner'), 'members' => $members, 'maxmembers' => Input::get('maxmembers') * 1, 'bank' => Input::get('bank') * 1, 'active' => $active));
             $log->save();
             $gang->members = $members;
             $gang->maxmembers = Input::get('maxmembers');
             $gang->owner = Input::get('owner');
             $gang->bank = Input::get('bank');
             $gang->active = $active;
         } else {
             $log = new Adminlog();
             $log->type = 'gang';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('gangid');
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('members' => $gang->members, 'maxmembers' => $gang->maxmembers), array('members' => $members, 'maxmembers' => Input::get('maxmembers') * 1));
             $log->save();
             $gang->members = $members;
             $gang->maxmembers = Input::get('maxmembers');
         }
         $gang->save();
         return Redirect::to('/gangs')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } else {
         return Redirect::to('/gangs')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger'));
     }
 }
Пример #2
0
 public static function createLog($comment, $poderId, $subclase, $actorId, $objeto, $tipoObj = null)
 {
     $log = new Adminlog();
     $log->descripcion = $comment;
     $log->subclase = $subclase;
     $log->poder_id = $poderId;
     $log->actor_id = $actorId;
     if (is_null($tipoObj)) {
         $log->objeto()->associate($objeto);
     } else {
         $log->objeto_id = $objeto;
         $log->objeto_type = $tipoObj;
     }
     $log->save();
     return $log;
 }
 public function postEdit()
 {
     $rules = array('vehicleid' => 'required|numeric|exists:vehicles,id', 'playerid' => 'required|numeric|exists:players,playerid', 'reason' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes() && Auth::user()->canEditVehicle(Input::get('playerid'))) {
         $alive = 0;
         if (Input::get('alive') == 1) {
             $alive = 1;
         }
         $active = 0;
         if (Input::get('active') == 1) {
             $active = 1;
         }
         $delete = 0;
         if (Input::get('delete') == 1) {
             $delete = 1;
         }
         if ($delete) {
             $log = new Adminlog();
             $log->type = 'vehicle';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('vehicleid');
             $log->playerid = DB::table('players')->where('playerid', Input::get('playerid'))->first()->uid;
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('deleted' => 0), array('deleted' => 1));
             $log->save();
             DB::table('vehicles')->where('id', Input::get('vehicleid'))->delete();
         } else {
             $vehicle = Vehicle::find(Input::get('vehicleid'));
             $log = new Adminlog();
             $log->type = 'vehicle';
             $log->editor = Auth::user()->id;
             $log->objectid = Input::get('vehicleid');
             $log->playerid = DB::table('players')->where('playerid', Input::get('playerid'))->first()->uid;
             $log->reason = Input::get('reason');
             $log->difference = $log->getDifference(array('alive' => $vehicle->alive, 'active' => $vehicle->active), array('alive' => $alive, 'active' => $active));
             $log->save();
             $vehicle->alive = $alive;
             $vehicle->active = $active;
             $vehicle->save();
         }
         return Redirect::to('/vehicles')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } else {
         return Redirect::to('/vehicles')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger'));
     }
 }
 public function postAdd()
 {
     $rules = array('playerid' => 'required|numeric|exists:players,playerid', 'donatoramount' => 'numeric|required', 'donatorduration' => 'numeric|required', 'donatordate' => 'required', 'reason' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes() && Auth::user()->canEditPlayerAdmin(Input::get('playerid'))) {
         $player = Player::where('playerid', Input::get('playerid'))->first();
         $log = new Adminlog();
         $log->type = 'player';
         $log->editor = Auth::user()->id;
         $log->objectid = $player->uid;
         $log->reason = Input::get('reason');
         $log->difference = $log->getDifference(array('donatorlvl' => $player->donatorlvl, 'donatordate' => $player->donatordate, 'donatoramount' => $player->donatoramount, 'donatorduration' => $player->donatorduration), array('donatorlvl' => 5, 'donatordate' => Input::get('donatordate'), 'donatoramount' => Input::get('donatoramount') * 1, 'donatorduration' => Input::get('donatorduration')));
         $log->save();
         $player->donatorlvl = 5;
         $player->donatordate = Input::get('donatordate');
         $player->donatoramount = Input::get('donatoramount') * 1;
         $player->donatorduration = Input::get('donatorduration');
         $player->save();
         return Redirect::to('/donators')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } else {
         return Redirect::to('/donators')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger'));
     }
 }
 public function postEdit()
 {
     $rules = array('uid' => 'required|numeric|exists:players,uid', 'playerid' => 'required|numeric|exists:players,playerid', 'cash' => 'numeric', 'bankacc' => 'numeric', 'coplevel' => 'numeric|min:0|max:11', 'mediclevel' => 'numeric|min:0|max:5', 'adaclevel' => 'numeric|min:0|max:5', 'adminlevel' => 'numeric|min:0|max:3', 'reason' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     $civ_licenses = array(array('license_civ_sec', 0), array('license_civ_donator', 0), array('license_civ_home', 0), array('license_civ_rebel', 0), array('license_civ_bm', 0), array('license_civ_gun', 0), array('license_civ_driver', 0), array('license_civ_truck', 0), array('license_civ_air', 0), array('license_civ_boat', 0), array('license_civ_dive', 0), array('license_civ_heroin', 0), array('license_civ_coke', 0), array('license_civ_marijuana', 0), array('license_civ_oil', 0), array('license_civ_diamond', 0), array('license_civ_copper', 0), array('license_civ_iron', 0), array('license_civ_sand', 0), array('license_civ_salt', 0), array('license_civ_cement', 0), array('license_civ_brauer', 0), array('license_civ_wein', 0), array('license_civ_zigaretten', 0), array('license_civ_zucker', 0), array('license_civ_whiskey', 0), array('license_civ_zigarren', 0), array('license_civ_rum', 0), array('license_civ_holz', 0), array('license_civ_schwefel', 0), array('license_civ_silber', 0), array('license_civ_zinn', 0), array('license_civ_gusseisen', 0), array('license_civ_bronze', 0), array('license_civ_schmuck', 0), array('license_civ_good', 0), array('license_civ_bus', 0), array('license_civ_taxi', 0), array('license_civ_hunting', 0));
     $cop_licenses = array(array('license_cop_air', 0), array('license_cop_sek', 0), array('license_cop_cg', 0));
     $med_licenses = array(array('license_med_air', 0), array('license_med_mohawk', 0));
     $adac_licenses = array(array('license_adac_car', 0), array('license_adac_air', 0));
     if ($validator->passes() && Auth::user()->canEditPlayerAdmin(Input::get('playerid'))) {
         foreach (Input::all() as $str_key => $value) {
             $subStr = substr($str_key, 0, 12);
             if ($subStr == 'license_civ_') {
                 foreach ($civ_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $civ_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_cop_') {
                 foreach ($cop_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $cop_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_med_') {
                 foreach ($med_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $med_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_adac') {
                 foreach ($adac_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $adac_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
         }
         $civ_licenses = Auth::user()->encodeDBArray($civ_licenses);
         $cop_licenses = Auth::user()->encodeDBArray($cop_licenses);
         $med_licenses = Auth::user()->encodeDBArray($med_licenses);
         $adac_licenses = Auth::user()->encodeDBArray($adac_licenses);
         $player = Player::find(Input::get('uid'));
         $log = new Adminlog();
         $log->type = 'player';
         $log->editor = Auth::user()->id;
         $log->objectid = Input::get('uid');
         $log->reason = Input::get('reason');
         $log->difference = $log->getDifference(array('cash' => $player->cash, 'bankacc' => $player->bankacc, 'coplevel' => $player->coplevel, 'mediclevel' => $player->mediclevel, 'adaclevel' => $player->adaclevel, 'civ_licenses' => $player->civ_licenses, 'cop_licenses' => $player->cop_licenses, 'med_licenses' => $player->med_licenses, 'adac_licenses' => $player->adac_licenses, 'adminlevel' => $player->adminlevel), array('cash' => Input::get('cash') * 1, 'bankacc' => Input::get('bankacc') * 1, 'coplevel' => Input::get('coplevel') * 1, 'mediclevel' => Input::get('mediclevel') * 1, 'adaclevel' => Input::get('adaclevel') * 1, 'civ_licenses' => $civ_licenses, 'cop_licenses' => $cop_licenses, 'med_licenses' => $med_licenses, 'adac_licenses' => $adac_licenses, 'adminlevel' => Input::get('adminlevel')));
         $log->save();
         $player->cash = Input::get('cash');
         $player->bankacc = Input::get('bankacc');
         $player->coplevel = Input::get('coplevel');
         $player->mediclevel = Input::get('mediclevel');
         $player->adaclevel = Input::get('adaclevel');
         $player->civ_licenses = $civ_licenses;
         $player->cop_licenses = $cop_licenses;
         $player->med_licenses = $med_licenses;
         $player->adac_licenses = $adac_licenses;
         $player->adminlevel = Input::get('adminlevel');
         $player->save();
         return Redirect::to('/players')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } elseif ($validator->passes() && Auth::user()->canEditPlayerMoney(Input::get('playerid'))) {
         foreach (Input::all() as $str_key => $value) {
             $subStr = substr($str_key, 0, 12);
             if ($subStr == 'license_civ_') {
                 foreach ($civ_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $civ_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_cop_') {
                 foreach ($cop_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $cop_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_med_') {
                 foreach ($med_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $med_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_adac') {
                 foreach ($adac_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $adac_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
         }
         $civ_licenses = Auth::user()->encodeDBArray($civ_licenses);
         $cop_licenses = Auth::user()->encodeDBArray($cop_licenses);
         $med_licenses = Auth::user()->encodeDBArray($med_licenses);
         $adac_licenses = Auth::user()->encodeDBArray($adac_licenses);
         $player = Player::find(Input::get('uid'));
         $log = new Adminlog();
         $log->type = 'player';
         $log->editor = Auth::user()->id;
         $log->objectid = Input::get('uid');
         $log->reason = Input::get('reason');
         $log->difference = $log->getDifference(array('cash' => $player->cash, 'bankacc' => $player->bankacc, 'coplevel' => $player->coplevel, 'mediclevel' => $player->mediclevel, 'adaclevel' => $player->adaclevel, 'civ_licenses' => $player->civ_licenses, 'cop_licenses' => $player->cop_licenses, 'med_licenses' => $player->med_licenses, 'adac_licenses' => $player->adac_licenses), array('cash' => Input::get('cash') * 1, 'bankacc' => Input::get('bankacc') * 1, 'coplevel' => Input::get('coplevel') * 1, 'mediclevel' => Input::get('mediclevel') * 1, 'adaclevel' => Input::get('adaclevel') * 1, 'civ_licenses' => $civ_licenses, 'cop_licenses' => $cop_licenses, 'med_licenses' => $med_licenses, 'adac_licenses' => $adac_licenses));
         $log->save();
         $player->cash = Input::get('cash');
         $player->bankacc = Input::get('bankacc');
         $player->coplevel = Input::get('coplevel');
         $player->mediclevel = Input::get('mediclevel');
         $player->adaclevel = Input::get('adaclevel');
         $player->civ_licenses = $civ_licenses;
         $player->cop_licenses = $cop_licenses;
         $player->med_licenses = $med_licenses;
         $player->adac_licenses = $adac_licenses;
         $player->save();
         return Redirect::to('/players')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } elseif ($validator->passes() && Auth::user()->canEditPlayerLicenses(Input::get('playerid'))) {
         foreach (Input::all() as $str_key => $value) {
             $subStr = substr($str_key, 0, 12);
             if ($subStr == 'license_civ_') {
                 foreach ($civ_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $civ_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_cop_') {
                 foreach ($cop_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $cop_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_med_') {
                 foreach ($med_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $med_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
             if ($subStr == 'license_adac_') {
                 foreach ($adac_licenses as $int_key => $array) {
                     if ($array[0] == $str_key) {
                         $adac_licenses[$int_key][1] = $value * 1;
                     }
                 }
             }
         }
         $civ_licenses = Auth::user()->encodeDBArray($civ_licenses);
         $cop_licenses = Auth::user()->encodeDBArray($cop_licenses);
         $med_licenses = Auth::user()->encodeDBArray($med_licenses);
         $adac_licenses = Auth::user()->encodeDBArray($adac_licenses);
         $player = Player::find(Input::get('uid'));
         $log = new Adminlog();
         $log->type = 'player';
         $log->editor = Auth::user()->id;
         $log->objectid = Input::get('uid');
         $log->reason = Input::get('reason');
         $log->difference = $log->getDifference(array('coplevel' => $player->coplevel, 'mediclevel' => $player->mediclevel, 'adaclevel' => $player->adaclevel, 'civ_licenses' => $player->civ_licenses, 'cop_licenses' => $player->cop_licenses, 'med_licenses' => $player->med_licenses, 'adac_licenses' => $player->adac_licenses), array('coplevel' => Input::get('coplevel') * 1, 'mediclevel' => Input::get('mediclevel') * 1, 'adaclevel' => Input::get('adaclevel') * 1, 'civ_licenses' => $civ_licenses, 'cop_licenses' => $cop_licenses, 'med_licenses' => $med_licenses, 'adac_licenses' => $adac_licenses));
         $log->save();
         $player->coplevel = Input::get('coplevel');
         $player->mediclevel = Input::get('mediclevel');
         $player->adaclevel = Input::get('adaclevel');
         $player->civ_licenses = $civ_licenses;
         $player->cop_licenses = $cop_licenses;
         $player->med_licenses = $med_licenses;
         $player->adac_licenses = $adac_licenses;
         $player->save();
         return Redirect::to('/players')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } elseif ($validator->passes() && Auth::user()->canEditPlayerLevel(Input::get('playerid'))) {
         $player = Player::find(Input::get('playerid'));
         $log = new Adminlog();
         $log->type = 'player';
         $log->editor = Auth::user()->id;
         $log->objectid = Input::get('uid');
         $log->reason = Input::get('reason');
         $log->difference = $log->getDifference(array('coplevel' => $player->coplevel, 'mediclevel' => $player->mediclevel, 'adaclevel' => $player->adaclevel), array('coplevel' => Input::get('coplevel') * 1, 'mediclevel' => Input::get('mediclevel') * 1, 'adaclevel' => Input::get('adaclevel') * 1));
         $log->save();
         $player->coplevel = Input::get('coplevel');
         $player->mediclevel = Input::get('mediclevel');
         $player->adaclevel = Input::get('adaclevel');
         $player->save();
         return Redirect::to('/players')->with(array('message' => 'Die Änderung wurde erfolgreich übernommen.', 'type' => 'success'));
     } else {
         return Redirect::to('/players')->with(array('message' => 'Leider ist ein Fehler aufgetreten, die Änderung wurde verworfen.', 'type' => 'danger'));
     }
 }