public function delete() { $user = User::getData(); if (!empty($user->avatar)) { @unlink(Url::resource($user->avatar)); } $userFlag = UserModel::delete('id = ?', [$user->id]); $perFlag = PermissionModel::delete('user_id = ?', [$user->id]); $msgFlag = MessageModel::delete('user_id = ?', [$user->id]); $compFlag = ComplainModel::delete('user_id = ?', [$user->id]); $status = $userFlag && $perFlag && $msgFlag && $compFlag; if ($status) { $u = new User(); $u->logout(); } Response::json(['status' => $status]); }
public function actionDelete($id) { UserModel::delete($id); FL::redirectTo('/admin/user'); return true; }
public function delete($id) { $current = User::getData(); $admin = PermissionModel::findBy(['user_id' => $current->id, 'permission' => 'admin']); $userFlag = $perFlag = $msgFlag = $compFlag = FALSE; if ($current->id != $id && $admin) { $avatar = UserModel::id($id)->avatar; if (!empty($avatar)) { @unlink(Url::resource($avatar)); } $userFlag = UserModel::delete('id = ?', [$id]); $perFlag = PermissionModel::delete('user_id = ?', [$id]); $msgFlag = MessageModel::delete('user_id = ?', [$id]); $compFlag = ComplainModel::delete('user_id = ?', [$id]); } Response::json(['status' => $userFlag && $perFlag && $msgFlag && $compFlag]); }