public static function destroy($id)
 {
     self::check_logged_in();
     $user = new User(array('id' => $id));
     $user->destroy();
     Redirect::to('/user', array('message' => 'The user has been removed successfully!'));
 }
 public function Eliminar($id)
 {
     $persona = User::find($id)->persona;
     User::destroy($id);
     Persona::destroy($persona->id);
     return Redirect::to('admi')->with('status', 'ok_delete');
 }
 public function userdelete($id)
 {
     $regno = USer::where('id', $id)->first();
     $data = $regno->regno;
     //        return $data;
     User::destroy($id);
     return Redirect::to('userlist')->with('deleted', $data . 'is deleted');
 }
 public static function destroy($id)
 {
     if (parent::is_admin() || parent::get_user_logged_in()->id == $id) {
         User::destroy($id);
         Redirect::to("/user", array('message' => "User was destroyed."));
     } else {
         Redirect::to("/", array('message' => "You are not an admin or user# " . $id));
     }
 }
Exemple #5
0
 /**
  * Remove the specified user from storage.
  *
  * @param  int $id
  * @return Response
  */
 public function destroy($id)
 {
     try {
         $this->users->destroy($id);
         return $this->redirect('users.index');
     } catch (ModelNotFoundException $e) {
         return $this->redirectNotFound();
     }
 }
Exemple #6
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Response();
     if (User::destroy($this->id)) {
         $res->success = true;
         $res->message = 'Destroyed User ' . $this->id;
     } else {
         $res->message = "Failed to destroy User";
     }
     return $res->to_json();
 }
Exemple #7
0
 public function testSaveOnNewRecordusingSetters()
 {
     $obj = new User();
     $obj->name = 'bob5000';
     $obj->my_int = 10000;
     $this->assertTrue($obj->save());
     $this->assertTrue(User::exists('name', 'bob5000'));
     $this->assertEquals($obj->name, 'bob5000');
     $this->assertEquals($obj->my_int, 10000);
     $obj->destroy();
 }
Exemple #8
0
 public function set_destroy_post()
 {
     $UserList = new ObjList();
     $UserList->construct_db(array('db_where_Arr' => array('status' => -1), 'db_where_deletenull_Bln' => TRUE, 'model_name_Str' => 'User', 'limitstart_Num' => 0, 'limitcount_Num' => 100));
     foreach ($UserList->obj_Arr as $key => $value_user) {
         $User = new User(['uid_Num' => $value_user->uid_Num]);
         $User->destroy();
     }
     if (!empty($UserList->obj_Arr)) {
         $this->load->model('Message');
         $this->Message->show(array('message' => '銷毀成功', 'url' => 'admin/base/user/set/set'));
     } else {
         $this->load->model('Message');
         $this->Message->show(array('message' => '已無可銷毀的項目', 'url' => 'admin/base/user/set/set'));
     }
 }
 public static function destroy($id)
 {
     self::check_logged_in();
     $destroyer = self::get_user_logged_in();
     $destroyerId = $destroyer->getId();
     //Kint::dump($destroyerId);
     if ($id == $destroyerId) {
         Redirect::to('/kayttaja/kayttajalista', array('message' => 'Et voi poistaa itseäsi!'));
     } else {
         //alustetaan User-olio annetulla id:llä
         $kayttaja = new User(array('kayttajaid' => $id));
         //kutsutaan User-luokan metodia destroy, joka poistaa kyselyn sen id:llä
         $kayttaja->destroy();
         Redirect::to('/kayttaja/kayttajalista', array('message' => 'Käyttäjä on poistettu onnistuneesti!'));
     }
 }
Exemple #10
0
 /**
  * Composes and sends email with provided data.
  * 
  * @param  string $view
  * @param  array  $data 
  * @param  string $email
  * @param  string $subject
  * @return void
  */
 public function send($view, $data, $email = null, $subject = null)
 {
     if (!$email) {
         $email = $data['email'];
     }
     if (!$subject) {
         $subject = $data['subject'];
     }
     try {
         Mail::send($view, $data, function ($message) use($data, $email, $subject) {
             $message->to($email)->subject($subject);
         });
     } catch (\Swift_TransportException $e) {
         \User::destroy($data['id']);
         throw new \Swift_TransportException($e->getMessage());
     }
 }
Exemple #11
0
//3. возможность добавить нового пользователя;
//можно сделать разными способами
// 1ый: создать объект юзера и вызвать метод save()
echo '<h3> 3 </h3>';
$params = array('name' => 'new user 1', 'birth' => '1991-07-25');
$user_1 = new User($params);
$user_1->save();
// 2ой: вызвать статический метод класса User create()
$params['name'] = 'new user 2';
$user_2 = User::create($params);
$result = DB::query('SELECT * FROM users_tbl WHERE id=' . $user_1->id . ';');
echo 'Try to find first created user:<br/>num rows:' . $result->num_rows;
$result = DB::query('SELECT * FROM users_tbl WHERE id=' . $user_2->id . ';');
echo '<br/>Try to find second created user:<br/>num rows:' . $result->num_rows;
//4. возможность добавить для пользователя номер мобильного телефона;
echo '<h3> 4 </h3>';
$user->add_phone_number('380953326461');
echo 'Users\'s telephones:<ul>';
foreach ($user->phones as $phone) {
    echo '<li>' . $phone->formated_phone . '</li>';
}
echo '</ul>';
//5. возможность удалить всю информацию о пользователе вместе с номерами телефонов;
echo '<h3> 5 </h3>';
$user->destroy();
$user_1->destroy();
$user_2->destroy();
$result = DB::query('SELECT * FROM users_tbl WHERE id=' . $id);
echo 'Try find deleted user:<br/>num rows: ' . $result->num_rows;
$result = DB::query('SELECT * FROM phones_tbl WHERE user_id=' . $id);
echo '<br/>Try find deleted user\'s phone numbers:<br/>num rows: ' . $result->num_rows;
 /**
  * ELimina el estudiante especificado de la base de datos
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($admin, $id)
 {
     $user = User::findOrFail($id);
     if (User::destroy($id)) {
         $this->log_action('Estudiante Eliminado', 'El Estudiante "' . $user->name . '" ha sido eliminado.');
         Session::flash('msj', 'El estudiante ha sido eliminado exitosamente');
         return Redirect::route('admin.users.index', ['admin' => $admin]);
     } else {
         Session::flash('msj', 'Hubo un error y el Estudiante no pudo ser eliminado');
         Session::flash('msj_fallido', 'Hubo un error y el Estudiante no pudo ser eliminado');
         return Redirect::route('admin.users.index', ['admin' => $admin]);
     }
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     if ($id == Auth::user()->id) {
         return Redirect::back()->with('message', 'Could not delete own account')->with('alert-class', 'danger');
     }
     User::destroy($id);
     return Redirect::route('users.index')->with('message', 'Deleted user')->with('alert-class', 'success');
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     User::destroy($id);
     return Redirect::route('users.index');
 }
Exemple #15
0
    public function destroy($id)
    {
        //Message that's returned
        $msg = '<div class="alert alert-warning alert-dismissible col-md-12" role="alert">
					  <button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
					 	User Deleted!
				</div>';
        //Delete userinfo with that user's data
        Userinfo::deleteUser($id);
        //Delete user
        User::findOrFail($id);
        User::destroy($id);
        return Redirect::to('admin')->with('message', $msg);
    }
Exemple #16
0
 public function destroy($id)
 {
     // Check apakah user yang di hapus sama dengan user yang sedang login
     if ($id == Auth::user()->id) {
         $message = 'Maaf tidak bisa menghapus user yang sedang digunakan';
     } elseif ($id !== '1') {
         User::destroy($id);
         $message = 'Data berhasil dihapus';
     } else {
         $message = 'Maaf user ini tidak dapat dihapus';
     }
     return Redirect::route('admin.users.index')->with('message', $message);
 }
 /**
  * Remove the specified resource from storage.
  * DELETE /users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $status = User::destroy($id);
     return $status ? ['status' => true] : ['status' => false];
 }
Exemple #18
0
 public function destroy($id)
 {
     User::find($id)->roles()->detach();
     User::destroy($id);
     return Redirect::route('admin.users.index');
 }
Exemple #19
0
 public function destroy($id)
 {
     User::destroy($id);
     return Redirect::action('UsersController@index')->with('notice', 'The user has been deleted successfully.');
 }
 /**
  * Delete user
  *
  * @return json
  */
 public function delete($id)
 {
     $user = User::where('id', '=', $id)->first();
     if ($user == null) {
         return Response::make(null, 404);
     }
     User::destroy($id);
     return Response::make(null, 202);
 }
Exemple #21
0
 public function testDestroyShouldFailWithoutErrorsKey()
 {
     $invalid_status = Config::get('response.http_status.invalid');
     //setup our creation mocks, expected results etc
     $this->setupIndividualTest($this->getSaveErrorTestOptions(), [], $invalid_status);
     $u = new User();
     $u->id = 1;
     $result = $u->destroy();
     //get objects to assert on
     $history = $this->getHttpClientHistory();
     $request = $history->getLastRequest();
     $response = $history->getLastResponse();
     $this->assertFalse($result, 'Expected destroy() to return false');
     $this->assertEquals($invalid_status, $response->getStatusCode(), "Expected different response code");
     $this->assertCount(2, $u->errors(), 'Expected 2 errors');
 }
Exemple #22
0
 public function delete($id)
 {
     return User::destroy((int) $id) > 0 ? 1 : 0;
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     User::destroy($id);
     return Redirect::to('/backend/user');
 }
 public function testDestroy()
 {
     $user = new User();
     $user->name = 'John Doe';
     $user->title = 'admin';
     $user->age = 35;
     $user->save();
     User::destroy((string) $user->_id);
     $this->assertEquals(0, User::count());
 }
Exemple #25
0
 /**
  * Completely deletes a database, on $user's word.
  */
 public function destroy(User $user = null)
 {
     $con = $this->config;
     // assert non-null user
     if ($user == null) {
         throw new InvalidArgumentException('Method requires an user.');
     }
     // assert admin user
     $security_doc = $this->get_security_doc();
     if (!in_array($user->get_name(), $security_doc['admins']['names']) && count($security_doc['admins']['names']) == 1) {
         throw new InvalidArgumentException('User must be group admin.');
     }
     /*
      * Your papers check out sir, deleting database.
      */
     $data = array("create_target" => true, "source" => $con->group_db_name($this->name, "main"), "target" => $con->deleted_db_name($this->name));
     // stash a copy
     $post_response = h\Request::post($con->db_url("_replicate", "main"))->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->sendsJson()->body(json_encode($data))->send();
     $delete_response_raw = h\Request::delete($con->group_db_url($this->name, "main"))->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->send();
     $delete_response = json_decode($delete_response_raw, true);
     // If the database was deleted, remove user's references to it
     if (!isset($delete_response['error'])) {
         $this->isExtant = false;
         $user_categories = array($security_doc['admins']['names'], $security_doc['members']['names']);
         foreach ($user_categories as $category) {
             foreach ($category as $user) {
                 $notify_user = new User(array("name" => $user, "admin" => true));
                 $notify_user->remove_group($this);
             }
         }
         // Remove the uploader user
         $uploader_user = new User(array("name" => "uploader-" . $this->get_name(), "admin" => true));
         $uploader_user->destroy();
         /*
          * remove the backup entry in _replicator
          */
         $backup_name = $con->constants->SERVER_NICKNAME . "_" . $this->name . "_" . $con->constants->BACKUP_SUFFIX;
         $replicator_response = json_decode(h\Request::get($con->doc_url($backup_name, "_replicator", "backup", true))->send(), true);
         $rev = "?rev=" . $replicator_response['_rev'];
         $delete_response_raw = h\Request::delete($con->doc_url($backup_name, "_replicator", "backup", true) . $rev)->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->send();
     }
     return $delete_response;
 }
Exemple #26
0
 /**
  * Test whether a second BelongsTO assignment does change the attribute
  * (Check if BelongsTo cache is properly updated)
  *
  * @return null
  */
 public function testBelongsDoubleAttribution()
 {
     $user1 = new User();
     $user1->name = "Belongs first attribution from where and other class";
     $user1->email = "*****@*****.**";
     $user1->code = "01011";
     $user1->level = 1;
     $this->assertTrue($user1->save());
     $user2 = new User();
     $user2->name = "Belongs second attribution from where and other class";
     $user2->email = "*****@*****.**";
     $user2->code = "01012";
     $user2->level = 1;
     $this->assertTrue($user2->save());
     $uid1 = $user1->id;
     $uname1 = $user1->name;
     $uid2 = $user2->id;
     $uname2 = $user2->name;
     $users = [$user1->code, $user2->code];
     $ticket = new Ticket();
     $ticket->description = "Test";
     $ticket->user = $user1;
     $this->assertEquals($uname1, $ticket->user->name);
     $ticket->user = $user2;
     $this->assertEquals($uname2, $ticket->user->name);
     $this->assertTrue($ticket->save());
     $this->assertNotEquals(self::$user->id, $uid1);
     $this->assertNotEquals(self::$user->id, $uid2);
     $this->assertNotNull($uid1);
     $this->assertNotNull($uid2);
     $this->assertEquals($ticket->user->id, $uid2);
     $this->assertTrue($user1->destroy());
     $this->assertTrue($user2->destroy());
     $this->assertTrue($ticket->destroy());
 }
Exemple #27
0
 /**
  * destroy
  */
 public function destroy()
 {
     $res = new Response();
     if (is_array($this->params)) {
         $destroyed = array();
         foreach ($this->params as $id) {
             if ($rec = User::destroy($id)) {
                 array_push($destroyed, $rec);
             }
         }
         $res->success = true;
         $res->message = 'Destroyed ' . count($destroyed) . ' records';
     } else {
         if ($rec = User::destroy($this->params)) {
             $res->message = "Destroyed User";
             $res->success = true;
         } else {
             $res->message = "Failed to Destroy user";
         }
     }
     return $res->to_json();
 }
 /**
  * Remove the specified karyawan from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     User::destroy($id);
     return Redirect::route('admin.karyawan.index')->with('successMessage', 'Karyawan berhasil dihapus. ');
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     User::destroy($id);
     return Redirect::action('HomeController@showIndex');
 }
@extends('layout')
@section('content')
<h1 id="page-header"><div class="container">Delete Account</div></h1>
<div class="container">
    <div id="page-spacer"></div>
    <?php 
if (Input::has('deleteConfirm') && Input::get('deleteConfirm') == 'DELETE') {
    $id = Auth::user()->id;
    Auth::logout();
    User::destroy($id);
    ?>
        <h3>Your account has been successfully deleted.</h3>
        <p>We hope that you've enjoyed your time here, and wish you the best for the future.</p>
      <?php 
} else {
    ?>
    <form action="#" id="deleteForm" method="post">
        <p><strong>Are you sure you want to delete your account? You will lose EVERYTHING on this site (that's a lot of stuff) FOREVER (that's a very long time) and it cannot be undone.</strong></p>
        <p>Type "<strong>DELETE</strong>" in capitals below to confirm deletion</p>
        <div class="ui input fluid">
            <input type="text" ng-model="deleteForm" name="deleteConfirm">
        </div>
        <div class="ui divider"></div>
        <a class="ui button" href="{{PageController::getUrlPath($lang, 'dashboard');}}">Cancel</a>
        <button class="ui button negative" ng-show="deleteForm == 'DELETE'" id="delete-account-button">Delete Account Permanently (no going back after this)</button>
        <div class="spacer"></div>
    </form>
    <?php 
}
?>
</div>