Example #1
0
 public function update($id)
 {
     //get the json from the request.
     $updateModel = Input::json()->all();
     //update the user model based on the json data sent.
     $updateUser = User::find($id);
     $updateUser->position_id = $updateModel['position_id'];
     if (array_key_exists('phone', $updateModel)) {
         $updateUser->phone = UsersApiController::getAllNumbers($updateModel['phone']);
     } else {
         $updateUser->phone = NULL;
     }
     $updateUser->schedule_color = $updateModel['schedule_color'];
     $updateUser->acc_crud_assets = $updateModel['acc_crud_assets'];
     $updateUser->acc_room = $updateModel['acc_room'];
     $updateUser->acc_avlog = $updateModel['acc_avlog'];
     $updateUser->acc_inv = $updateModel['acc_inv'];
     $updateUser->acc_emp = $updateModel['acc_emp'];
     $updateUser->acc_useradm = $updateModel['acc_useradm'];
     $updateUser->acc_sysadm = $updateModel['acc_sysadm'];
     $updateUser->acc_crud_timesheet = $updateModel['acc_crud_timesheet'];
     $updateUser->acc_view_timesheet = $updateModel['acc_view_timesheet'];
     $updateUser->acc_gen_timesheet = $updateModel['acc_gen_timesheet'];
     $updateUser->acc_crud_schedule = $updateModel['acc_crud_schedule'];
     $updateUser->acc_notifications = $updateModel['acc_notifications'];
     $updateUser->acc_super_user = $updateModel['acc_super_user'];
     //save the updated user to the database
     $updateUser->save();
     //send the response
     return $updateUser->toJson();
 }
Example #2
0
 public function action_update($id)
 {
     // RESTful update from Backbone
     $officer = Officer::find($id);
     $json = Input::json(true);
     if (isset($json["command"])) {
         if (Auth::officer()->is_role_or_higher(Officer::ROLE_SUPER_ADMIN) && !$officer->is_role_or_higher(Officer::ROLE_SUPER_ADMIN) && Auth::officer()->id != $officer->id) {
             if ($json["command"] == "ban") {
                 $officer->ban();
             }
             if ($json["command"] == "unban") {
                 $officer->unban();
             }
             $officer->save();
             $officer = Officer::find($id);
         }
         return Response::json($officer->to_array());
     }
     // We can update the officer's role if we are an Admin or a Super Admin.
     // If we're a Super Admin, we can change the roles of other Super Admins.
     // Super Admins can never modify their own role.
     if (Auth::officer()->is_role_or_higher(Officer::ROLE_ADMIN)) {
         if (isset($json["role"]) && ($officer->role != Officer::ROLE_SUPER_ADMIN || Auth::officer()->is_role_or_higher(Officer::ROLE_SUPER_ADMIN)) && ($officer->role != Officer::ROLE_SUPER_ADMIN || Auth::officer()->id != $officer->id)) {
             $officer->role = $json["role"];
         }
     }
     $officer->save();
     return Response::json($officer->to_array());
 }
Example #3
0
 public function action_update()
 {
     $deliverable = Config::get('deliverable');
     $deliverable->fill(Input::json(true));
     $deliverable->save();
     return Response::json($deliverable->to_array());
 }
 public function sendMail()
 {
     Mail::send('hello', array('mail_to' => Input::json('mail_to'), 'mail_subject' => Input::json('mail_subject')), function ($message) {
         $message->to(Input::json('mail_to'), 'John Smith')->subject(Input::json('mail_subject'));
     });
     return Response::json(array('flash' => 'Mail Sent Successfully!!!!!'));
 }
 public function login()
 {
     try {
         $user = Sentry::getUserProvider()->findByLogin(Input::json('email'));
         $throttle = Sentry::getThrottleProvider()->findByUserId($user->id);
         $throttle->setSuspensionTime(10);
         $throttle->setAttemptLimit(3);
         $throttle->check();
         $credentials = ['email' => Input::json('email'), 'password' => Input::json('password')];
         $user = Sentry::authenticate($credentials, false);
     } catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         return Response::json(array('flash' => 'Login field is required'), 500);
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         return Response::json(array('flash' => 'Password field is required'), 500);
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Response::json(array('flash' => 'Invalid username or password'), 500);
     } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
         return Response::json(array('flash' => 'This account is inactive'), 500);
     } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
         $time = $throttle->getSuspensionTime();
         return Response::json(array('flash' => 'This account is suspended for ' . $time . ' minutes'), 500);
     } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
         return Response::json(array('flash' => 'This account has been banned'), 500);
     }
     $user_details = User::join('users_groups', 'users.id', '=', 'users_groups.user_id')->join('groups', 'users_groups.group_id', '=', 'groups.id')->where('users.id', '=', $user->id)->select('users.id', 'users.email', 'users.first_name', 'users.last_name', 'groups.name as role', 'users.activated_at', 'users.last_login', 'users.created_at', 'users.updated_at')->get();
     return Response::json($user_details[0], 200);
 }
 public function update($id)
 {
     try {
         //get the json from the request.
         $updateModel = Input::json()->all();
         //select the vendor name of the new selected vendor
         $vendorQueryResult = Vendor::find($updateModel['vendor_id']);
         $newVendorName = $vendorQueryResult->name;
         //update the item model based on the json data sent.
         $updateItem = Item::find($id);
         $updateItem->description = $updateModel['description'];
         $updateItem->email_threshold = $updateModel['email_threshold'];
         $updateItem->item_url = $updateModel['item_url'];
         $updateItem->name = $updateModel['name'];
         $updateItem->on_order_quantity = $updateModel['on_order_quantity'];
         $updateItem->vendor_id = $updateModel['vendor_id'];
         $updateItem->quantity = $updateItem->quantity + $updateModel['adjustmentQty'];
         if ($updateItem->quantity < 0) {
             $updateItem->quantity = 0;
         }
         //save the updated item to the database
         $updateItem->save();
         //append the new vendor name to the model to send back in the response
         $updateItem->vendor_name = $newVendorName;
         $updateItem->adjustmentQty = 0;
         //send the response
         echo $updateItem->toJson();
     } catch (Exception $e) {
         return json_encode('{"error":{"text":' . $e->getMessage() . '}}');
     }
 }
 public function update($id)
 {
     //gets the input from Backbone
     $updateModel = Input::json()->all();
     //find the checkout that needs to be edited and sets the properties.
     $updateChecklist = OpenCloseChecklist::find($id);
     $updateChecklist->task_date = $updateModel['task_date'];
     $updateChecklist->cico_system_on = $updateModel['cico_system_on'];
     $updateChecklist->printers_on = $updateModel['printers_on'];
     $updateChecklist->print_stations_on = $updateModel['print_stations_on'];
     $updateChecklist->open_main_doors = $updateModel['open_main_doors'];
     $updateChecklist->open_side_doors = $updateModel['open_side_doors'];
     $updateChecklist->opened_by = $updateModel['opened_by'];
     $updateChecklist->cico_system_off = $updateModel['cico_system_off'];
     $updateChecklist->printers_off = $updateModel['printers_off'];
     $updateChecklist->print_stations_off = $updateModel['print_stations_off'];
     $updateChecklist->close_main_doors = $updateModel['close_main_doors'];
     $updateChecklist->close_side_doors = $updateModel['close_side_doors'];
     $updateChecklist->refill_printer_paper = $updateModel['refill_printer_paper'];
     $updateChecklist->push_in_chairs = $updateModel['push_in_chairs'];
     $updateChecklist->turn_off_machines = $updateModel['turn_off_machines'];
     $updateChecklist->recycle_prints = $updateModel['recycle_prints'];
     $updateChecklist->lock_cae_office_doors = $updateModel['lock_cae_office_doors'];
     $updateChecklist->closed_by = $updateModel['closed_by'];
     //save the updated checkout and returns it to Backbone
     $updateChecklist->save();
     return $updateChecklist->toJSON();
 }
Example #8
0
 public function post_subscribe()
 {
     \Fuel\Core\Lang::load("global");
     $email = Input::json("email");
     if ($email !== null && preg_match("/^[a-zA-Z0-9.!#\$%&\"*+\\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+\$/", $email) === 1) {
         // Call API
         $api = new \Libraries\Api();
         $return = $api->executeAPIMethod("POST", "newsletters", array("email" => $email));
         // Success/error
         if ($return["code"] == 200) {
             // Success
             $this->jsonSuccess(\Fuel\Core\Lang::get("subscribe_to_newsletter.success"), array("apiReturn" => $return));
         } else {
             if ($return["code"] == 412) {
                 $this->jsonSuccess(\Fuel\Core\Lang::get("subscribe_to_newsletter.already_subscribed"));
             } else {
                 // Error...
                 $this->jsonError(\Fuel\Core\Lang::get("subscribe_to_newsletter.error"));
             }
         }
     } else {
         // Error, not valid...
         $this->jsonError(\Fuel\Core\Lang::get("subscribe_to_newsletter.error"));
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::json();
     $task = Task::find($id);
     $task->title = $input->get('title');
     $task->completed = $input->get('completed');
     $task->save();
 }
Example #10
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function login()
 {
     if (Auth::attempt(array('email' => Input::json('username'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => 'Invalid Username or Password Supplied'), 500);
     }
 }
Example #11
0
 protected function getRawRequest()
 {
     $json = \Input::json()->all();
     if (sizeof($json) == 0) {
         throw new ParseErrorException();
     }
     return $json;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $todo = $this->todo->findOrFail($id);
     $input = Input::json();
     $todo->update($input->get('todo'));
     $todo = $todo->toArray();
     return Response::json(compact('todo'));
 }
 public function login()
 {
     if (Auth::attempt(array('room' => Input::json('room'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => array('notification' => 'Invalid room or password', 'class' => 'alert')), 401);
     }
 }
 public function login()
 {
     if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => Lang::get('messages.auth_failed')), 401);
     }
 }
 public function store($notebookId, $noteId, $versionId)
 {
     $note = self::getNote($notebookId, $noteId, $versionId);
     if ($note->pivot->umask < PaperworkHelpers::UMASK_READWRITE) {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Permission Error'));
     }
     if (Input::hasFile('file') && Input::file('file')->isValid() || Input::json() != null && Input::json() != "") {
         $fileUpload = null;
         $newAttachment = null;
         if (Input::hasFile('file')) {
             $fileUpload = Input::file('file');
             $newAttachment = new Attachment(array('filename' => $fileUpload->getClientOriginalName(), 'fileextension' => $fileUpload->getClientOriginalExtension(), 'mimetype' => $fileUpload->getMimeType(), 'filesize' => $fileUpload->getSize()));
         } else {
             $fileUploadJson = Input::json();
             $fileUpload = base64_decode($fileUploadJson->get('file'));
             $newAttachment = new Attachment(array('filename' => $fileUploadJson->get('clientOriginalName'), 'fileextension' => $fileUploadJson->get('clientOriginalExtension'), 'mimetype' => $fileUploadJson->get('mimeType'), 'filesize' => count($fileUpload)));
         }
         $newAttachment->save();
         // Move file to (default) /app/storage/attachments/$newAttachment->id/$newAttachment->filename
         $destinationFolder = Config::get('paperwork.attachmentsDirectory') . '/' . $newAttachment->id;
         if (!File::makeDirectory($destinationFolder, 0700)) {
             $newAttachment->delete();
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Internal Error'));
         }
         // Get Version with versionId
         //$note = self::getNote($notebookId, $noteId, $versionId);
         $tmp = $note ? $note->version()->first() : null;
         $version = null;
         if (is_null($tmp)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version->first'));
         }
         while (!is_null($tmp)) {
             if ($tmp->id == $versionId || $versionId == 0) {
                 $version = $tmp;
                 break;
             }
             $tmp = $tmp->previous()->first();
         }
         if (is_null($version)) {
             $newAttachment->delete();
             File::deleteDirectory($destinationFolder);
             return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_NOTFOUND, array('message' => 'version'));
         }
         if (Input::hasFile('file')) {
             $fileUpload->move($destinationFolder, $fileUpload->getClientOriginalName());
         } else {
             file_put_contents($destinationFolder . '/' . $fileUploadJson->get('clientOriginalName'), $fileUpload);
         }
         $version->attachments()->attach($newAttachment);
         // Let's push that parsing job, which analyzes the document, converts it if needed and parses the crap out of it.
         Queue::push('DocumentParserWorker', array('user_id' => Auth::user()->id, 'document_id' => $newAttachment->id));
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_SUCCESS, $newAttachment);
     } else {
         return PaperworkHelpers::apiResponse(PaperworkHelpers::STATUS_ERROR, array('message' => 'Invalid input'));
     }
 }
 public function hasChannelRight()
 {
     $channel_id = Input::json('channel_id');
     $requested_ch_right = Input::json('channel_right');
     $usergroup = User::find(Auth::id())->usergroup()->first();
     //select form usergroup channel rights where the channel_id and usergroup_id and ch_right
     $Right_list = DB::select(DB::raw("SELECT ugchr.* FROM usergroupchannelrights ugchr, channelsrights chr\n\t\t\t\tWHERE ugchr.Channel_Id = " . $channel_id . " and ugchr.UserGroup_Id = " . $usergroup->UserGroup_Id . "\n\t\t\t\t\tand ugchr.Channel_Right_Id =  chr.ChannelRight_Id\n\t\t\t\t\tand chr.Channel_Right_Name = '" . $requested_ch_right . "'"));
     return Response::json(count($Right_list) > 0);
 }
Example #17
0
 /**
  * Add Todos
  * @return JSON
  */
 public function postTodos()
 {
     //Get the user id of the currently logged in user
     $userId = (int) \Sentry::getUser()->id;
     //Get Data
     $data = \Input::json()->all();
     //Add Todos
     $result = $this->todo->postTodos($data, $userId);
     return \Response::json(array('id' => $result['id'], 'status' => $result['status'], 'text' => $result['text']), 200);
 }
 /**
  * Update the specified resource in storage.
  *
  * @return Response
  */
 public function update($id)
 {
     $contact = Contact::find($id);
     $input = Input::json();
     $contact->first_name = $input->first_name;
     $contact->last_name = $input->last_name;
     $contact->description = $input->description;
     $contact->email_address = $input->email_address;
     $contact->save();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $input = \Input::json();
     $reading = new Reading();
     $reading->value = $input->get('value');
     $reading->readingtype_id = Readingtype::where('type', $input->get('readingtype'))->lists('id')->first();
     $reading->created_at = $input->get('created_at');
     $reading->user_id = $input->get('user_id');
     $reading->save();
     return response($reading, 201);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $input = Input::json();
     $contact = Contact::find($id);
     $contact->name = $input->get('name');
     $contact->surname = $input->get('surname');
     $contact->email = $input->get('email');
     $contact->phone = $input->get('phone');
     $contact->description = $input->get('description');
     $contact->save();
 }
Example #21
0
 public function login()
 {
     if (Auth::attempt(array('email' => Input::json('email'), 'password' => Input::json('password')))) {
         Session::put('entryStarted', false);
         Auth::user()->last_login = date('Y-m-d H:i:s');
         Auth::user()->save();
         return Response::json(Auth::user());
     } else {
         return Response::json(array('flash' => 'Invalid username or password!'), 500);
     }
 }
 /**
  * Update the specified resource in storage
  * PUT /accommodation/{id}
  * @Get("/search-accommodation")
  * @param  int $id
  * @return Response
  */
 public function update($id)
 {
     //
     $input = \Input::json();
     $accommodation = Accommodation::findOrFail($id);
     $accommodation->name = $input->get('name');
     $accommodation->description = $input->get('description');
     $accommodation->location_id = $input->get('location_id');
     $accommodation->save();
     return response($accommodation, 200)->header('Content-Type', 'application/json');
 }
Example #23
0
 /**
  * Manage Users
  * @param int
  * @return JSON
  */
 public function manageUsers($userId)
 {
     //Get all data
     $data = \Input::json()->all();
     $result = $this->user->manageUsers($data);
     //Display Appropriate Notification
     if ($result) {
         return \Response::json(array('error' => false), 200);
     } else {
         return \Response::json(array('error' => true), 500);
     }
 }
 public function deleteDestroy()
 {
     $modelArray = array();
     $deleteModels = Input::json('models');
     foreach ($deleteModels as $model) {
         $deleteAdminSchedule = AdminSchedule::find($model['id']);
         $deleteAdminSchedule->delete();
         array_push($modelArray, $deleteAdminSchedule);
         $returnModels = BaseCollection::make($modelArray);
     }
     echo $returnModels->toJson();
 }
 public function deleteDestroy()
 {
     $modelArray = array();
     $deleteModels = Input::json('models');
     foreach ($deleteModels as $model) {
         $deleteComputerClassroom = ComputerClassroom::find($model['id']);
         $deleteComputerClassroom->delete();
         array_push($modelArray, $deleteComputerClassroom);
         $returnModels = BaseCollection::make($modelArray);
     }
     echo $returnModels->toJson();
 }
Example #26
0
 public function update($id)
 {
     try {
         $updateModel = Input::json()->all();
         $updateVendor = Vendor::find($id);
         $updateVendor->name = $updateModel['name'];
         $updateVendor->url = $updateModel['url'];
         $updateVendor->save();
     } catch (Exception $e) {
         return json_encode('{"error":{"text":' . $e->getMessage() . '}}');
     }
 }
Example #27
0
 public function create()
 {
     $apiKey = new ApiKey();
     $apiKey->key = $apiKey->generateKey();
     $apiKey->user_id = \Input::json('user_id', 0);
     $apiKey->level = \Input::json('level', 10);
     $apiKey->ignore_limits = \Input::json('ignore_limits', 1);
     if ($apiKey->save() === false) {
         return $this->response->errorInternalError("Failed to save API key to the database.");
     }
     $this->response->setStatusCode(201);
     return $this->response->withItem($apiKey, new ApiKeyTransformer());
 }
Example #28
0
 /**
  * Update the specific tag by ID
  * 
  * @param mixed $id The ID.
  *
  * @access public
  *
  * @return mixed Value.
  */
 public function put_update($id)
 {
     $tag = Slendertag::find($id);
     $input = Input::json();
     if ($tag !== null) {
         $tag->contents = $input->contents;
         $tag->enabled = $input->enabled;
         $tag->alt = $input->alt;
         $tag->save();
     } else {
         return;
     }
 }
 public function update($id)
 {
     $role = Auth::user()->role;
     $user = User::find($id);
     $user->name = Input::json('name');
     $user->role = Input::json('role');
     try {
         $user->save();
         $users = $this->users();
         return Response::json($users);
     } catch (Exception $e) {
         return Response::json(array('flash' => "Error occured while updating"), 500);
     }
 }
Example #30
0
 public function post_delete_module()
 {
     $content = Input::json();
     $all = (array) $content;
     // return var_dump($all);
     $group = Group::find($all['group_id']);
     $delete_group_module = $group->modules()->detach($all['module_id']);
     // return var_dump($delete_group_module);
     if ($delete_group_module) {
         return Response::json(array('response' => true));
     } else {
         return Response::json(array('response' => false));
     }
 }