Ejemplo n.º 1
0
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('Api_Users');
     $api_user = Model_Api_User::find($id);
     $val = Model_Api_User::validate('edit');
     if ($val->run()) {
         $api_user->id = Input::post('id');
         $api_user->key = Input::post('key');
         $api_user->status = Input::post('status');
         $api_user->description = Input::post('description');
         $api_user->ip = Input::post('ip');
         if ($api_user->save()) {
             Session::set_flash('success', 'Updated api_user #' . $id);
             Response::redirect('api/users');
         } else {
             Session::set_flash('error', 'Could not update api_user #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $api_user->id = $val->validated('id');
             $api_user->key = $val->validated('key');
             $api_user->status = $val->validated('status');
             $api_user->description = $val->validated('description');
             $api_user->ip = $val->validated('ip');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('api_user', $api_user, false);
     }
     $this->template->title = "Api_users";
     $this->template->content = View::forge('api/users/edit');
 }