本文整理汇总了PHP中Services::getUserManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Services::getUserManager方法的具体用法?PHP Services::getUserManager怎么用?PHP Services::getUserManager使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Services
的用法示例。
在下文中一共展示了Services::getUserManager方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < $this->bot->getNeededAccess($target, $this->originalName)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
if (count($messageEx) == 2) {
// check target access
if ($access < $this->bot->getAccess($target, Services::getUserManager()->getUserByNick($messageEx[1])->accountname)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
} else {
Services::getConnection()->getProtocol()->sendKick($this->bot->getUuid(), $target, $messageEx[1], $user->getNick());
}
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
unset($messageEx[0]);
$username = $messageEx[1];
unset($messageEx[1]);
// check target access
// todo: abort when target has no account
if ($access < $this->bot->getAccess($target, Services::getUserManager()->getUserByNick($username)->accountname)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
} else {
Services::getConnection()->getProtocol()->sendKick($this->bot->getUuid(), $target, $username, $user->getNick() . ': ' . implode(' ', $messageEx));
}
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
}
}
示例2: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
if (!$this->bot->isRegistered($target)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.notRegistered'));
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < 500) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
$sql = "SELECT\n\t\t\t\tunregistercode\n\t\t\tFROM\n\t\t\t\tchanserv_channels\n\t\t\tWHERE\n\t\t\t\tchannel = '" . escapeString($target) . "'";
$row = Services::getDB()->getFirstRow($sql);
$code = $row['unregistercode'];
if (isset($messageEx[1])) {
if ($code != trim($messageEx[1])) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.codeWrong', $target));
}
// TODO: Validate unregistercode
$this->bot->unregister($target);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success', $target));
} else {
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.code', $code));
}
}
示例3: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < $this->bot->getNeededAccess($target, $this->originalName)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
if (count($messageEx) == 1) {
$sql = "SELECT\n\t\t\t\t\t*\n\t\t\t\tFROM\n\t\t\t\t\tchanserv_channel_accessLevel\n\t\t\t\tWHERE\n\t\t\t\t\tchannel = '" . escapeString($target) . "'\n\t\t\t\tORDER BY \n\t\t\t\t\taccessLevel DESC";
$result = Services::getDB()->sendQuery($sql);
while ($row = Services::getDB()->fetchArray($result)) {
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.' . $row['function']) . ': ' . $row['accessLevel']);
}
} else {
if (count($messageEx) == 3) {
if ($access < $messageEx[2]) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.tooHigh'));
}
if (!$this->bot->getNeededAccess($target, $messageEx[1])) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.unknown'));
}
$sql = "UPDATE\n\t\t\t\t\t\tchanserv_channel_accessLevel\n\t\t\t\t\tSET\n\t\t\t\t\t\taccessLevel = " . $messageEx[2] . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tfunction = '" . escapeString($messageEx[1]) . "'";
Services::getDB()->sendQuery($sql);
} else {
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
}
示例4: setAccount
/**
* Sets the accountname for the given uuid
*
* @param string $uuid
* @param string $accountname
* @retuen void
*/
public function setAccount($uuid, $accountname)
{
Services::getUserManager()->getUser($uuid)->accountname = $accountname;
if (isset($this->accountToUser[$accountname])) {
$this->accountToUser[$accountname][] = $uuid;
} else {
$this->accountToUser[$accountname] = array($uuid);
}
// set umode +r
Services::getConnection()->getProtocol()->sendMode($this->getUuid(), $uuid, '+r');
}
示例5: handleKick
/**
* Handles an incoming KICK event
* @param array $data
*/
public function handleKick($data)
{
// get chanserv
$chanserv = Services::getModuleManager()->lookupModule('ChanServ');
// ignore unregistered channels
if (call_user_func(array($chanserv, 'isRegistered'), $data['target'])) {
// check permissions
if (call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['issuer'])->accountname) < call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['victim'])->accountname) || call_user_func(array($chanserv, 'getAccess'), $data['target'], Services::getUserManager()->getUser($data['issuer'])->accountname) < call_user_func(array($chanserv, 'kick'), $data['target'])) {
// rejoin victim if needed
Services::getConnection()->getProtocol()->sendSvsjoin($data['victim'], $data['target']);
}
}
}
示例6: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if (count($messageEx) == 2) {
$email = $messageEx[1];
if (!$this->bot->isAuthed($user->getUuid())) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.notAuthed'));
}
$this->bot->email(Services::getUserManager()->getUser($user->getUuid())->accountname, $email);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
// send syntax hint
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
示例7: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if (count($messageEx) == 3) {
$oldPassword = $messageEx[1];
$newPassword = $messageEx[2];
if (!$this->bot->isAuthed($user->getUuid())) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.notAuthed'));
}
if (!$this->bot->checkCredentials($accountname, $oldPassword)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.auth.invalidCredentials'));
}
$this->bot->pass(Services::getUserManager()->getUser($user->getUuid())->accountname, $newPassword);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
// send syntax hint
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
示例8: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < $this->bot->getNeededAccess($target, 'access')) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
if (count($messageEx) == 3) {
if ($messageEx[2] >= $access) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.tooHigh'));
} else {
if ($messageEx[2] > 500) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.tooHigh'));
}
}
if ($access <= $this->bot->getAccess($target, Services::getUserManager()->getUserByNick($messageEx[1])->accountname)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
$authServ = Services::getModuleManager()->lookupModule('AuthServ');
$userID = call_user_func(array($authServ, 'getUserID'), $messageEx[1]);
if (!$userID) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.invalidUser'));
}
if ($messageEx[0] < 1) {
$sql = "DELETE FROM chanserv_channels_to_users WHERE channel = '" . escapeString($target) . "' AND userID = " . $userID;
} else {
$sql = "INSERT INTO chanserv_channels_to_users (channel, userID, accessLevel)\n\t\t\t\t\tVALUES ('" . escapeString($target) . "', " . $userID . ", " . intval($messageEx[2]) . ")\n\t\t\t\t\tON DUPLICATE KEY UPDATE accessLevel = VALUES(accessLevel)";
}
Services::getDB()->sendQuery($sql);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
示例9: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < $this->bot->getNeededAccess($target, $this->originalName)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
if (count($messageEx) == 1) {
$this->bot->setStandardModes($target);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
unset($messageEx[0]);
$modeString = implode(' ', $messageEx);
Services::getConnection()->getProtocol()->sendMode($this->bot->getUuid(), $target, str_replace(array('q', 'r', 'a', 'v', 'o', 'b', 'h', 'A', 'O', 'e', 'P'), '', $modeString));
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
}
}
示例10: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
$access = $this->bot->getAccess($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
if ($access < $this->bot->getNeededAccess($target, 'access')) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.permissionDenied'));
}
if (count($messageEx) == 1) {
$sql = "SELECT\n\t\t\t\t\tc.*,\n\t\t\t\t\ta.accountname\n\t\t\t\tFROM\n\t\t\t\t\tchanserv_channels_to_users c\n\t\t\t\t\tLEFT JOIN\n\t\t\t\t\t\tauthserv_users a\n\t\t\t\t\t\tON c.userID = a.userID\n\t\t\t\tWHERE\n\t\t\t\t\tchannel = '" . escapeString($target) . "'\n\t\t\t\tORDER BY \n\t\t\t\t\tc.accessLevel DESC";
$result = Services::getDB()->sendQuery($sql);
while ($row = Services::getDB()->fetchArray($result)) {
$this->bot->sendMessage($user->getUuid(), $row['accountname'] . ': ' . $row['accessLevel']);
}
} else {
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
示例11: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if (count($messageEx) == 2) {
$password = $messageEx[1];
if (!$this->bot->isAuthed($user->getUuid())) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.notAuthed'));
}
$accountname = Services::getUserManager()->getUser($user->getUuid())->accountname;
if (!$this->bot->checkCredentials($accountname, $password)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.auth.invalidCredentials'));
}
$userID = $this->bot->getUserID($accountname);
$this->bot->delete($accountname);
// TODO: Kill user to log him out
$sql = "DELETE FROM chanserv_channels_to_users WHERE userID = " . $userID;
Services::getDB()->sendQuery($sql);
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success'));
} else {
// send syntax hint
$this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.syntaxHint'));
}
}
示例12: execute
/**
* @see lib/modules/CommandModule::execute()
*/
public function execute($user, $target, $message)
{
// split message
$messageEx = explode(' ', $message);
if ($target[0] != '#') {
$target = $messageEx[1];
unset($messageEx[1]);
$messageEx = array_values($messageEx);
}
if ($this->bot->isRegistered($target)) {
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.alreadyRegistered'));
}
$users = Services::getChannelManager()->getChannel($target)->getUserList();
foreach ($users as $channelUser) {
if ($channelUser['user']->getUuid() == $user->getUuid()) {
if (stripos($channelUser['mode'], 'o')) {
$this->bot->register($target, Services::getUserManager()->getUser($user->getUuid())->accountname);
Services::getConnection()->getProtocol()->sendMode($this->bot->getUuid(), $target, '+q ' . $user->getNick());
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.success', $target));
}
}
}
return $this->bot->sendMessage($user->getUuid(), Services::getLanguage()->get($user->languageID, 'command.' . $this->originalName . '.noOp'));
}
示例13: UID
/**
* Handles an UID line from server
*
* @param string $input
* @param array<string> $inputEx
* @return void
*/
public static function UID($input, $inputEx)
{
// get mode string
$modes = '';
$activeIndex = 10;
while ($inputEx[$activeIndex][0] != ':') {
if (!empty($modes)) {
$modes .= " ";
}
$modes .= $inputEx[$activeIndex];
$activeIndex++;
}
// add user to manager
Services::getUserManager()->introduceUser($inputEx[3], $inputEx[4], $inputEx[5], $inputEx[6], $inputEx[7], $inputEx[8], $inputEx[9], $modes, substr($input, stripos($input, ':') + 1), $inputEx[2]);
// send debug message
if (defined('DEBUG')) {
print "Added user " . $inputEx[2] . "\n";
}
}