public function cmdDel() { if (($login = ArgsHolder::get()->shiftCommand()) === false) { return io::out('Incorrect param count', IO::MESSAGE_FAIL) | 1; } if (IO::YES != io::dialog('Do You really want to delete user ~RED~' . $login . '~~~?', IO::NO | IO::YES, IO::NO)) { return io::out('Cancelled ', IO::MESSAGE_FAIL) | 2; } try { if (ArgsHolder::get()->getOption('confirm')) { if (OneTimeTokenAuth::exists($user_id = User::findIdBy('login', $login))) { io::out('Deleting User... ', false); OneTimeTokenAuth::deleteByUserId($user_id); return io::done(); } else { return io::out('There is no user ~WHITE~' . $login . '~~~', IO::MESSAGE_FAIL) | 2; } } if ($user = User::findBy("login", $login)) { io::out('Deleting user ', false); $user->delete(); io::done(); } else { return io::out('There is no user ~WHITE~' . $login . '~~~', IO::MESSAGE_FAIL) | 2; } } catch (UserException $e) { return io::out($e->getMessage(), IO::MESSAGE_FAIL) | 127; } }