/** * @SWG\Api( * path="/update", * @SWG\Operation( * method="POST", * summary="Update Protected Application by ID", * notes="", * type="void", * authorizations={}, * @SWG\Parameter( * name="id", * description="ID of Protected Application.", * required=true, * type="integer", * paramType="form" * ), * @SWG\Parameter( * name="name", * description="Application Name.", * required=false, * type="string", * paramType="form" * ), * @SWG\Parameter( * name="enabled", * description="Is this Application Enabled?", * required=true, * type="boolean", * paramType="form" * ), * @SWG\ResponseMessage(code=200, message="Successfull Updated."), * @SWG\ResponseMessage(code=400, message="Invalid ID supplied."), * @SWG\ResponseMessage(code=404, message="Item not found."), * @SWG\ResponseMessage(code=405, message="Invalid Input.") * ) * ) */ public function update() { $this->load->model("protection_model", "lProtectionModel"); $lId = $this->input->post('id'); $lName = $this->input->post('name'); if ($lName == "") { $lProtections = $this->lProtectionModel->get($lId, Item::BY_ID); foreach ($lProtections as $lProtection) { $lName = $lProtection[database_fields::COLUMN_NAME]; } } $lProtections = protection_item::update($lId, $lName, $this->input->post('enabled') == Protection::BOOL_TRUE ? 1 : 0); if (count($lProtections) == 0) { http_response_code(ResponseCodes::InvalidInput); } else { $this->lProtectionModel->update($lProtections); echo protection_item::get($lProtections); } }