本文整理汇总了PHP中UserModel::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP UserModel::delete方法的具体用法?PHP UserModel::delete怎么用?PHP UserModel::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserModel
的用法示例。
在下文中一共展示了UserModel::delete方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delete
public function delete()
{
$id = request('id');
if (!$id) {
$this->error('缺少ID');
}
if (UserModel::delete($id)) {
$this->success('/admin/user');
} else {
$this->error('操作失败');
}
}
示例2: user_model_test
function user_model_test($delete)
{
$user = new UserModel("Not", "Here", "not.here@nowhere.com", "password", date("Y-m-d H:i:s"));
$user->save();
$user->print_fields();
$user->set("failed_login_attempts", 3);
$user->set("first_name", "User");
$user->set("last_name", "McUsage");
$user->save();
$user->print_fields();
if ($delete) {
$user->delete();
}
$um = UserModel::find(UserModel::first()->id);
$um->print_fields();
$um = UserModel::find(UserModel::last()->id);
$um->print_fields();
UserModel::find(999);
}
示例3: delete
/**
* Delete a user account.
*
* @since 2.0.0
* @access public
* @param int $UserID Unique ID.
* @param string $Method Type of deletion to do (delete, keep, or wipe).
*/
public function delete($UserID = '', $Method = '')
{
$this->permission('Garden.Users.Delete');
$Session = Gdn::session();
if ($Session->User->UserID == $UserID) {
trigger_error(errorMessage("You cannot delete the user you are logged in as.", $this->ClassName, 'FetchViewLocation'), E_USER_ERROR);
}
$this->addSideMenu('dashboard/user');
$this->title(t('Delete User'));
$RoleModel = new RoleModel();
$AllRoles = $RoleModel->getArray();
// By default, people with access here can freely assign all roles
$this->RoleData = $AllRoles;
$UserModel = new UserModel();
$this->User = $UserModel->getID($UserID);
try {
$CanDelete = true;
$this->EventArguments['CanDelete'] =& $CanDelete;
$this->EventArguments['TargetUser'] =& $this->User;
// These are all the 'effective' roles for this delete action. This list can
// be trimmed down from the real list to allow subsets of roles to be
// edited.
$this->EventArguments['RoleData'] =& $this->RoleData;
$UserRoleData = $UserModel->getRoles($UserID)->resultArray();
$RoleIDs = array_column($UserRoleData, 'RoleID');
$RoleNames = array_column($UserRoleData, 'Name');
$this->UserRoleData = ArrayCombine($RoleIDs, $RoleNames);
$this->EventArguments['UserRoleData'] =& $this->UserRoleData;
$this->fireEvent("BeforeUserDelete");
$this->setData('CanDelete', $CanDelete);
$Method = in_array($Method, array('delete', 'keep', 'wipe')) ? $Method : '';
$this->Method = $Method;
if ($Method != '') {
$this->View = 'deleteconfirm';
}
if ($this->Form->authenticatedPostBack() && $Method != '') {
$UserModel->delete($UserID, array('DeleteMethod' => $Method));
$this->View = 'deletecomplete';
}
} catch (Exception $Ex) {
$this->Form->addError($Ex);
}
$this->render();
}
示例4: users_delete
/**
* Deletes a user identified in the 'params' parameter
*
* @global Array $STRINGS
* @param Array $params
*/
public function users_delete($params)
{
global $STRINGS;
$result = false;
if (isset($params[0])) {
// delete the user data
$op1 = UserModel::delete($params[0]);
// delete the user activity
$op2 = ActivityModel::delete_all_by_user($params[0]);
$result = $op1 && $op2;
}
$result == true ? $alert = BootstrapHelper::alert('success', $STRINGS['event:success'], $STRINGS['user:delete:success']) : ($alert = BootstrapHelper::alert('error', $STRINGS['event:error'], $STRINGS['user:delete:failed']));
$this->_data->page = 0;
$this->_data->users = UserModel::find_page(0);
new AdminUsersView($this->_data, $alert);
}
示例5: delete
public function delete($id = null)
{
$this->load->model('UserModel');
$user = new UserModel();
if ($this->isLogged()) {
switch ($this->session->userdata('role')) {
case '1':
if ($this->session->userdata('userid') == $id) {
redirect(base_url('user/index/3'));
} else {
if ($user->delete($id)) {
redirect(base_url('user/index/4'));
}
}
break;
case '2':
$this->load->view('public/norole');
break;
}
}
}
示例6: del
public function del()
{
$user_id = I('id', 0);
if (0 < $user_id) {
$user = new UserModel();
if (false !== $user->delete($user_id)) {
$this->message('操作成功', __URL__ . '/index');
} else {
$this->message('操作失败:' . $user->getDbError());
}
} else {
$this->message('请选择删除用户', __URL__ . '/index');
}
}
示例7: delete
function delete()
{
// Refuse to delete a user with tickets
if ($this->tickets->count()) {
return false;
}
// Delete account record (if any)
if ($this->getAccount()) {
$this->getAccount()->delete();
}
// Delete emails.
$this->emails->expunge();
// Drop dynamic data
foreach ($this->getDynamicData() as $cd) {
$cd->delete();
}
// Delete user
return parent::delete();
}
示例8: del
/**
* 删除用户
*/
function del()
{
$del_id = $_POST['del_id'];
$ids = implode($del_id, ',');
//实例化
$users = new UserModel();
if ($users->delete($ids)) {
$this->assign('jumpUrl', __URL__ . '/index');
$this->success('用户删除成功');
} else {
$this->assign('jumpUrl', __URL__ . '/index');
$this->error('更新失败!!!' . $users->getDbError());
}
}
示例9: header
// TODO: data validation
// populate input from user
$user->setId($_POST['id']);
$user->setFirstName($_POST['first_name']);
$user->setLastName($_POST['last_name']);
$user->setUsername($_POST['username']);
$user->setPassword($_POST['password']);
// update database
if ($userModel->update($user)) {
header('location:../index.php?action=edit&status=success');
} else {
// TODO: populate last inputs to session
// return back to form : no rows affected
// header('location:../form.php?action=edit&id='.$_POST['id'].'&status=failed');
header('location:../index.php?action=edit&status=success');
}
break;
case 'delete':
// populate input from user
$user->setId($_POST['id']);
// delete from database
if ($userModel->delete($user)) {
header('location:../index.php?action=delete&status=success');
} else {
header('location:../index.php?action=delete&status=failed');
}
break;
default:
header('location:../index.php');
break;
}
示例10: delete
function delete()
{
// Refuse to delete a user with tickets
if ($this->tickets->count()) {
return false;
}
// Delete account record (if any)
if ($this->getAccount()) {
$this->getAccount()->delete();
}
// Delete emails.
$this->emails->expunge();
// Delete user
return parent::delete();
}
示例11: handleDeleteUser
function handleDeleteUser($id)
{
UserModel::delete($id);
$this['userTabella']->invalidateControl();
}
示例12: testDelete
/**
* Tests the delete method
*/
public function testDelete()
{
//create fake user
$user = new stdClass();
$user->id = '999997';
$user->identifier = 'tester3';
//store the fake user
UserModel::create($user);
//delete the fake user
UserModel::delete('999997');
//check that the user is gone
$this->assertFalse(UserModel::find('999997'));
}
示例13: delUser
public function delUser($id)
{
return $this->userDao->delete(['id' => $id]);
}