public function deleteAction() { $app = App::getInstance(); $id = (int) $app->getUrlParam('id'); User::delete($id); $app->redirect(__HOME__ . '/user/'); }
/** * @param \User $user * * @return mixed */ public function getNestData(\User $user) { // start, return is false: $data = false; $count = 0; while ($data === false && $count < 5) { \Log::debug('Attempt #' . ($count + 1)); // try to get the data: $URL = 'https://developer-api.nest.com/?auth=' . $user->accessToken; $client = new Client(); try { $response = $client->get($URL); } catch (RingException $e) { \Log::error('GuzzleHttp\\Ring\\Exception\\ConnectException for user ' . $user->id . '! ' . $e->getMessage()); sleep(5); return false; } catch (ConnectException $e) { \Log::error('GuzzleHttp\\Exception\\ConnectException for user ' . $user->id . '!! ' . $e->getMessage()); sleep(5); return false; } catch (\Exception $e) { \Log::error('General exception (' . get_class($e) . ') for user ' . $user->id . '! ' . $e->getMessage()); if ($e->getCode() == 401) { \Log::warning('This is unauthorized! Delete the user!'); $user->delete(); } sleep(5); return false; } $body = $response->getBody()->getContents(); $data = json_decode($body); $count++; } return $data; }
public function actionRegister() { $model = new RegisterForm(); if (isset($_POST['ajax']) && $_POST['ajax'] === 'register-form') { echo CActiveForm::validate($model, array('username', 'password', 'new_password', 'password_confirm', 'verify_code')); Yii::app()->end(); } if (isset($_POST['RegisterForm'])) { $model->attributes = $_POST['RegisterForm']; if ($model->validate(array('email', 'username', 'new_password', 'password_confirm', 'verify_code'))) { $user = new User(); $user->email = $_POST['RegisterForm']['email']; $user->username = $_POST['RegisterForm']['username']; $user->password = $_POST['RegisterForm']['new_password']; if ($user->save()) { //send email activation key has been generated on beforeValidate function in User class $activation_url = $this->createAbsoluteUrl('/site/activate', array('key' => $user->activation_key, 'email' => $user->email)); if (sendHtmlEmail($user->email, Yii::app()->name . ' Administrator', null, Yii::t('register', 'Account activation'), array('username' => $user->username, 'activation_url' => $activation_url), 'activation', 'main2')) { $msg = Yii::t('register', 'Please check your email inbox for the activation link.It is valid for 24 hours.'); Yii::app()->user->setFlash('success', $msg); $this->redirect(bu() . '/site/login'); } else { $user->delete(); $msg = Yii::t('register', 'Error.Activation email could not be sent.Please register again.'); Yii::app()->user->setFlash('danger', $msg); $this->redirect(bu() . '/site/register'); } } } } $this->render('register', array('model' => $model)); }
public static function delete_users() { if (Auth::check()) { $id = $_POST['id']; if (isset($id)) { $strpos = strpos($id, ","); if ($strpos === false) { $ob = new User($id); $ob->delete(); echo "ok"; } else { $array_id = explode(",", $id); $ob = null; foreach ($array_id as $value) { $ob = new User($value); $ob->delete(); } echo "ok"; } } else { echo "Error while contacting server, please try again"; } } else { $redirection = Config::get('app.base_url') . Config::get('panel.route'); header("Location: {$redirection}"); } }
public function test_belongs_to() { MemoryStore::flush(); Page::delete_all(); User::delete_all(); $user = new User(); $user->email = "*****@*****.**"; $user->first_name = "Ben"; $user->last_name = "Copsey"; $user->password = "******"; $user->accepted_terms_and_conditions = true; $user->registration_date = new Date(); $user->first_name = "Ben"; $user->save(); $page1 = new Page(); $page1->title = "This is page 1"; $page1->last_modified = new Date(); $page1->body = "This is the content"; $page1->url = "page-1"; $page1->author = $user; $page1->save(); FuzzyTest::assert_equal($page1->author_id, $user->id, "Author not set correctly"); $user->delete(); $page = Page::find_by_url('page-1'); FuzzyTest::assert_true(isset($page), "Page deleted when it should have been preserved"); FuzzyTest::assert_equal($page->author_id, 0, "Page deleted when it should have been preserved"); $user->save(); $page->author = $user; $page->save(); $matches = $user->pages; FuzzyTest::assert_equal(count($matches), 1, "Page count should be 1"); }
protected function cleanUpTestUser() { if (!$this->user) { $this->user = User::model()->findByAttributes(array('username' => 'autotestapi')); if (!$this->user) { return; } } // clear out all the data we've touched, and the user foreach (array_merge(array('Audit', 'OEModule\\PASAPI\\models\\PasApiAssignment', 'Patient', 'Address', 'Contact'), $this->additional_clean_up_models) as $cls) { $cls::model()->deleteAllByAttributes(array('created_user_id' => $this->user->id)); } Audit::model()->deleteAllByAttributes(array('user_id' => $this->user->id)); $this->user->saveRoles(array()); $this->user->delete(); }
function delete() { $translator = new Translator(); $user = new User(); try { $id = array_shift($this->param); $user->delete($id, $data); echo <<<EOF <div class="container"> <div class="page-header"> <h1>{$translator->User_updated}</h1> </div> <p class="lead">{$translator->User_updated_Desc}</p> <p >{$translator->Error_Backusers}</p> </div> <script type="text/javascript"> window.location.href='/admin_users'; </script> EOF; } catch (Exception $e) { echo <<<EOF <div class="container"> <div class="page-header"> <h1>{$translator->User_error}</h1> </div> <p class="lead">{$translator->User_error_Desc}</p> <p >{$translator->Error_Backusers}</p> </div> EOF; } }
/** * Delete user * * @param void * @return null */ function delete() { if ($this->active_user->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND, null, true, $this->request->isApiCall()); } // if if (!$this->active_user->canDelete($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN, null, true, $this->request->isApiCall()); } // if if ($this->request->isSubmitted()) { $delete = $this->active_user->delete(); if ($delete && !is_error($delete)) { if ($this->request->isApiCall()) { $this->httpOk(); } else { flash_success('User ":name" has been deleted', array('name' => $this->active_user->getDisplayName())); $this->redirectToUrl($this->active_company->getViewUrl()); } // if } else { if ($this->request->isApiCall()) { $this->serveData($delete); } else { flash_error('Failed to delete ":name"', array('name' => $this->active_user->getDisplayName())); $this->redirectToUrl($this->active_company->getViewUrl()); } // if } // if } else { $this->httpError(HTTP_ERR_BAD_REQUEST, null, true, $this->request->isApiCall()); } // if }
function delete($id = FALSE) { $u = new User($id); $u->delete(); $this->session->set_flashdata('msg', '<div class="alert alert-success">User was succesfully deleted.</div>'); redirect($this->agent->referrer()); }
static function uninstall() { global $DB; CronTask::Unregister('fusioninventory'); PluginFusioninventoryProfile::uninstallProfile(); $pfSetup = new PluginFusioninventorySetup(); $user = new User(); if (class_exists('PluginFusioninventoryConfig')) { $fusioninventory_config = new PluginFusioninventoryConfig(); $users_id = $fusioninventory_config->getValue('users_id'); $user->delete(array('id' => $users_id), 1); } if (file_exists(GLPI_PLUGIN_DOC_DIR . '/fusioninventory')) { $pfSetup->rrmdir(GLPI_PLUGIN_DOC_DIR . '/fusioninventory'); } $query = "SHOW TABLES;"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (strstr($data[0], "glpi_plugin_fusioninventory_") or strstr($data[0], "glpi_plugin_fusinvsnmp_") or strstr($data[0], "glpi_plugin_fusinvinventory_") or strstr($data[0], "glpi_dropdown_plugin_fusioninventory") or strstr($data[0], "glpi_plugin_tracker") or strstr($data[0], "glpi_dropdown_plugin_tracker")) { $query_delete = "DROP TABLE `" . $data[0] . "`;"; $DB->query($query_delete) or die($DB->error()); } } $query = "DELETE FROM `glpi_displaypreferences`\n WHERE `itemtype` LIKE 'PluginFusioninventory%';"; $DB->query($query) or die($DB->error()); // Delete rules $Rule = new Rule(); $Rule->deleteByCriteria(array('sub_type' => 'PluginFusioninventoryInventoryRuleImport')); //Remove informations related to profiles from the session (to clean menu and breadcrumb) PluginFusioninventoryProfile::removeRightsFromSession(); return TRUE; }
public function testUserCRUD() { $user = new User(); try { $user->load('gaurav'); } catch (PAException $e) { if ($e->getMessage() == "No such user") { $user = new User(); $user->first_name = 'Gaurav'; $user->last_name = 'Bhatnagar'; $user->homepage = 'http://www.newdelhitimes.org'; $user->login_name = 'gaurav'; $user->password = md5('password1'); $user->email = '*****@*****.**'; $user->save(); } else { throw $e; } } $newuser = new User(); $newuser->load('gaurav'); $this->assertTrue($newuser->first_name == 'Gaurav'); $newuser->delete(); $this->assertTrue($newuser->is_active == FALSE); }
function delete($id = FALSE) { $user = new User($id); $user->delete(); set_notify('success', 'ลบข้อมูลเรียบร้อยแล้วค่ะ'); redirect($_SERVER['HTTP_REFERER']); }
function onMessage(WeChat $object, $messageType, $content, $arg1, $arg2) { $user = new User($object->fromUser); //创建一个用户 //处理subscribe和unsubscribe消息 switch ($messageType) { case "subscribe": //当用户关注 global $wm_welcome; $object->addNews($wm_welcome, "", "", ""); $object->addNews(WM_MESSAGE, "", "", ""); $object->sendNews(); break; case "unsubscribe": //当用户取消关注 $user->delete(); break; case "text": $keyword = strtolower(trim($content)); switch ($keyword) { case "n": $articles = query("n"); foreach ($articles as $v) { $object->addNews($v['0'], $v['1'], $v['2'], $v['3']); } $object->sendNews(); break; case "h": $articles = query("h"); foreach ($articles as $v) { $object->addNews($v['0'], $v['1'], $v['2'], $v['3']); } $object->sendNews(); break; case "r": $articles = query("r"); foreach ($articles as $v) { $object->addNews($v['0'], $v['1'], $v['2'], $v['3']); } $object->sendNews(); break; case "help": case "?": case "?": global $wm_welcome; $object->addNews($wm_welcome, "", "", ""); $object->addNews(WM_MESSAGE, "", "", ""); $object->sendNews(); break; default: switchFunc($object, $keyword); break; } break; default: $object->sendText("暂无设置此功能,你可以到我们的<a href='http://wx.wsq.qq.com/177325859'>微社区</a>提交相关问题"); //否则,显示出错信息 } }
public function testSimpleObject() { $user = new User(); $user->name = 'Foo'; $user->save(); $reload = new User(array('name' => 'Foo')); $reload->delete(); }
function delete() { if ($this->f3->exists('PARAMS.id')) { $user = new User($this->db); $user->delete($this->f3->get('PARAMS.id')); } $this->f3->reroute('/useradmin'); }
public function delete() { if ($this->f3->exists('PARAMS.id')) { $user = new User($this->db); $user->delete($this->f3->get('PARAMS.id')); } $this->f3->reroute('/success/User Deleted'); }
public function delete() { if ($this->f3->exists('PARAMS.id')) { $user = new User($this->db); $user->delete($this->f3->get('PARAMS.id')); } // go back to home page after delete $this->f3->reroute('/'); }
public function delete($id) { if ($id) { $user = new User($id); $user->delete(); set_notify('success', lang('delete_data_complete')); } redirect($_SERVER['HTTP_REFERER']); }
public function delete($id) { if ($id) { $user = new User($id); $user->delete(); set_notify('success', lang('delete_data_complete')); } redirect('users/admin/users'); }
function delete($id = FALSE) { if ($id) { $user = new User($id); $user->delete(); set_notify('success', lang('delete_data_complete')); } redirect('officer'); }
/** * testExists function * @return void */ public function testExists() { $this->loadFixtures('User'); $TestModel = new User(); $this->assertTrue($TestModel->exists(1)); $TestModel->id = 2; $this->assertTrue($TestModel->exists()); $TestModel->delete(); $this->assertFalse($TestModel->exists()); $this->assertFalse($TestModel->exists(2)); }
function actionDelete() { $user = new User(); // 删除uid为3的行 $uid = 3; // 与insert,update等类似,delete也是输入条件数组 $this->result = $user->delete(array("uid" => $uid)); // delete也是返回影响行数,没有匹配的结果会返回0 $this->findall = $user->findAll(); $this->display("db/delete.html"); }
public function removeUserAction() { // action body $delId = $this->_getParam('id'); $userInfo = Zend_Auth::getInstance()->getStorage()->read(); $userId = $userInfo->id; if ($delId != $userId) { $user = new User($delId); $this->view->entries = $user->delete(); } }
/** * Delete a user */ public function delete() { $this->setState('DELETING_USER'); //Get Username $username = $this->getActiveRequest(); //Include the User Library include_once "core/lib/User.php"; //Setup user class $u = new User(); //Delete u $u->delete($username); }
public function delete() { $url = Registry::getUrl(); $id = $_REQUEST["id"] ? $_REQUEST["id"] : $url->vars[0]; $user = new User($id); if ($user->id) { if ($user->delete()) { Registry::addMessage("Usuario eliminado satisfactoriamente", "success"); } } Url::redirect(Url::site("users")); }
function doDelete() { @($id = $_POST['selector']); $key = count($id); //multi delete using checkbox as a selector for ($i = 0; $i < $key; $i++) { $user = new User(); $user->delete($id[$i]); } message("User already Deleted!", "info"); redirect('index.php'); }
function test_delete() { $user = new User(); $rand = md5(rand()); $user->username = '******' . $rand; $user->fullname = 'This is the name'; $user->email = "{$rand}@email.com"; $user->save(); $this->assertNotNull(User::by_username($user->username)); $user->delete(); $this->assertNull(User::by_username($user->username)); }
/** * Deleta um registro e redireciona para 'users/list' * Caso não seja informado nenhum ID pela url, * o usuário será redirecionado para 'users' * * @return void */ public function deleteAction() { // verificamos se realmente foi informado algum ID if ( $this->_hasParam('id') == false ) { $this->_redirect('users'); } $id = (int) $this->_getParam('id'); $where = $this->_model->getAdapter()->quoteInto('id = ?', $id); $this->_model->delete($where); $this->_redirect('users/list'); }
public function display() { $userlist = new Template(); $userlist->load("user_list"); $userlist->assign_var("URL", $this->page->GetUrl()); if (isset($_POST['insert'])) { $user = new User(); $user->name = $_POST['name']; $user->role = $_POST['new_user_role']; $user->email = $_POST['email']; if (!$user->insert($_POST['password'])) { $userlist->assign_var("MSG", Language::DirectTranslateHtml("USER_NOT_CREATED")); } } if (isset($_GET['delete'])) { $user = new User(); $user->id = $_GET['delete']; if (!$user->delete()) { $userlist->assign_var("MSG", Language::DirectTranslateHtml("USER_NOT_DELETED")); } } $userlist->assign_var("MSG", ""); Cache::clear("tables", "userlist"); $table = new Table(); $id = new TableColumn("id", Language::DirectTranslate("ID")); $id->autoWidth = true; $name = new TableColumn("name", Language::DirectTranslate("NAME")); $role = new TableColumn("role", Language::DirectTranslate("ROLE"), "IFNULL((SELECT name FROM {'dbprefix'}roles WHERE id = {'dbprefix'}user.role),'')"); $email = new TableColumn("email", Language::DirectTranslate("EMAIL")); $created = new TableColumn("create_timestamp", Language::DirectTranslate("CREATED_ON")); $created->autoWidth = true; $access = new TableColumn("last_access_timestamp", Language::DirectTranslate("LAST_ACCESS")); $access->autoWidth = true; $table->columns->add($id); $table->columns->add($name); $table->columns->add($role); $table->columns->add($email); $table->columns->add($created); $table->columns->add($access); $table->name = "{'dbprefix'}user"; $table->actions = "userlist"; $table->orderBy = "name"; $table->cacheName = "userlist"; $userlist->assign_var("TABLE", $table->getCode()); $roles = new RoleSelector(); $roles->hideSpecialRoles = true; $roles->name = "new_user_role"; $userlist->assign_var("ROLES", $roles->getCode()); $userlist->output(); }
public function post() { $post = Input::all(); $validator = User::validate($post); $userId = $post['id']; if ($validator->fails()) { return Redirect::to('usuarios/' . $userId)->withErrors($validator)->withInput(); } else { $user = self::__checkExistence($userId); if (!$userId) { $user = new User(); } $user->name = $post['name']; $user->last_name = $post['last_name']; $user->display_name = $post['display_name']; $user->is_approved = $post['approved'] == '' ? null : ($post['approved'] == 'approved' ? true : false); $user->profile_type = $post['profile_type']; $user->email = $post['email']; $user->mobile = $post['mobile']; $sendMail = false; if (!$user->id) { //new user $passwordText = str_random(8); $passwordHashed = Hash::make($passwordText); $sendMail = true; $user->password = $passwordHashed; $user->is_approved = true; } //save user data $user->save(); if ($post['status'] == 'inactive') { $user->delete(); } else { if ($user->trashed()) { $user->restore(); } } if ($sendMail) { $mailView = 'emails.newPassword'; $subject = 'Bienvenido a CloudInventory'; Mail::send($mailView, array('user' => $user->email, 'password' => $passwordText), function ($message) use($user, $subject) { $message->to($user->email, $user->display_name)->subject($subject); }); Session::flash('warning', 'Su contraseña fue enviada a su correo electrónico.'); } Session::flash('success', 'Usuario guardado correctamente.'); return Redirect::to('usuarios'); } }