本文整理汇总了PHP中CUser类的典型用法代码示例。如果您正苦于以下问题:PHP CUser类的具体用法?PHP CUser怎么用?PHP CUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CUser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
/**
* Delete
* @param $CODE
* @return array
* @throws \Exception
*/
public static function Delete($CODE)
{
$group = new \CGroup();
$user = new \CUser();
if (!empty($CODE)) {
$by = "ID";
$order = "asc";
$dbGroup = $group->GetList($by, $order, array('STRING_ID' => $CODE));
if ($arGroup = $dbGroup->Fetch()) {
$arReturn = $arGroup;
}
} else {
throw new BimException('Empty group code');
}
if (intval($arReturn['ID']) > 0) {
$arUsers = $group->GetGroupUser($arReturn['ID']);
foreach ($arUsers as $UserID) {
$arGroup = $user->GetUserGroup($UserID);
$arGroup[] = "3";
$user->SetUserGroup($UserID, $arGroup);
}
$res = $group->Delete($arReturn['ID']);
if (is_object($res)) {
return $arReturn['ID'];
} else {
throw new BimException($group->LAST_ERROR);
}
} else {
throw new BimException('Group not found');
}
}
示例2: loadUsers
/**
* Load multiple users at a same time to save up on the queries.
* @return boolean True upon success
* @param Array $userIds An array of user ids to be loaded.
*/
public function loadUsers($userIds)
{
if (empty($userIds)) {
return;
}
$ids = implode(",", $userIds);
$db =& JFactory::getDBO();
$query = "SELECT " . "\ta.`userid` as _userid , " . "\ta.`status` as _status , " . "\ta.`points`\tas _points, " . "\ta.`posted_on` as _posted_on, " . "\ta.`avatar`\tas _avatar , " . "\ta.`thumb`\tas _thumb , " . "\ta.`invite`\tas _invite, " . "\ta.`params`\tas _cparams, " . "\ta.`view`\tas _view, " . " a.`friendcount` as _friendcount, " . " a.`alias`\tas _alias, " . " a.`profile_id` as _profile_id, " . " a.`friendcount` as _friendcount, " . " a.`storage` as _storage, " . " a.`watermark_hash` as _watermark_hash, " . "s.`userid` as _isonline, u.* " . " FROM #__community_users as a " . " LEFT JOIN #__users u " . " ON u.`id`=a.`userid` " . " LEFT OUTER JOIN #__session s " . " ON s.`userid`=a.`userid` " . "WHERE a.`userid` IN ({$ids})";
$db->setQuery($query);
$objs = $db->loadObjectList();
foreach ($objs as $obj) {
$user = new CUser($obj->_userid);
$isNewUser = $user->init($obj);
$user->getThumbAvatar();
// technically, we should not fetch any new user here
if ($isNewUser) {
// New user added to jomSocial database
// trigger event onProfileInit
$appsLib = CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] = $user;
$appsLib->triggerEvent('onProfileCreate', $args);
}
CFactory::getUser($obj->_userid, $user);
}
}
示例3: registerUser
function registerUser($userInfo)
{
$errors = array();
$result = '';
if (empty($userInfo['name'])) {
$errors[] = 'Вы не ввели имя';
}
if (empty($userInfo['email'])) {
$errors[] = 'Вы не ввели email';
}
if (empty($userInfo['phone'])) {
$errors[] = 'Вы не ввели телефон';
}
if (empty($errors)) {
$user = new CUser();
$password = make_password(8);
$arFields = array("NAME" => $userInfo['name'], "EMAIL" => $userInfo['email'], "LOGIN" => $userInfo['email'], "ACTIVE" => "Y", "GROUP_ID" => array(6), "PASSWORD" => $password, "CONFIRM_PASSWORD" => $password, "PERSONAL_PHONE" => $userInfo['phone']);
$ID = $user->Add($arFields);
if (intval($ID) > 0) {
$result = "Вы успешно зарегистрированы.";
$arEventField = array("NAME" => $userInfo['name'], "EMAIL" => $userInfo['email'], "PASSWORD" => $password);
CEvent::SendImmediate("NEW_REG", "s1", $arEventField);
unset($_POST['user']);
global $USER;
global $APPLICATION;
$USER->Authorize($ID);
LocalRedirect($APPLICATION->GetCurPageParam('', array('user[name]', 'user[email]', 'ELEMENT_CODE', 'code')));
} else {
$errors[] = $user->LAST_ERROR;
}
}
return $errors;
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->writeln("Install bitrix...");
global $DB, $DBType, $DBHost, $DBLogin, $DBPassword, $DBName, $DBDebug, $DBDebugToFile, $APPLICATION, $USER, $arWizardConfig, $MESS;
$bitrixRoot = $this->projectPath;
$_SERVER["DOCUMENT_ROOT"] = $bitrixRoot;
$_SERVER["REQUEST_URI"] = "/index.php";
$_SERVER["QUERY_STRING"] = "";
define("B_PROLOG_INCLUDED", true);
ob_start();
require_once "{$bitrixRoot}/bitrix/modules/main/install/wizard/wizard.php";
ob_end_clean();
$output->writeln("Step 1. Create database:");
$wizard = new \CWizardBase("nonlux.createDb.wizard", null);
$dbName = time() . "_db";
$output->writeln("database name: {$dbName}");
$data = $this->getConfig(array("agree_license", "user", "password", "database", "utf8", "dbType", "host", "create_user", "create_database", "root_user", "root_password", 'file_access_perms', 'folder_access_perms', 'bitrixRoot'));
foreach ($data as $key => $value) {
$wizard->SetVar($key, $value);
}
$step = new \CreateDBStep();
$wizard->AddStep($step);
$step->OnPostForm();
$output->writeln("Done");
require_once $bitrixRoot . '/bitrix/php_interface/dbconn.php';
$output->writeln("Step 2. Install modules:");
$wizard = new \CWizardBase("nonlux.installModules.wizard", null);
$data = array_merge(array("nextStep" => "main", "nextStepStage" => "utf8"), $this->getConfig(array('bitrixRoot', "user", "password", "utf8")));
$step = new CreateModulesStep();
$wizard->AddStep($step);
foreach ($data as $key => $value) {
$wizard->SetVar($key, $value);
}
do {
$output->writeln("Install " . $wizard->GetVar("nextStep") . " " . $wizard->GetVar("nextStepStage"));
$step->OnPostForm();
if ($wizard->GetVar("nextStep") === 'main' && $wizard->GetVar("nextStepStage") === 'files') {
$HttpApplication = \Bitrix\Main\HttpApplication::getInstance();
$HttpApplication->initializeBasicKernel();
$HttpApplication->getCache()->clearCache(true);
$GLOBALS['CACHE_MANAGER']->Clean('b_option');
Option::clearOptions("main");
}
} while ($wizard->GetVar('nextStep') != '__finish');
$output->writeln("Done");
$USER = new \CUser();
$policy = $USER->GetSecurityPolicy();
$output->writeln("Step 3. Create admin:");
$data = $this->getConfig(array('email', 'login', 'admin_password_confirm', 'admin_password', 'user_name', "utf8", 'user_surname'));
foreach ($data as $key => $value) {
$wizard->SetVar($key, $value);
}
$wizard = new \CWizardBase("nonlux.admin.wizard", null);
$step = new \CreateAdminStep();
$wizard->AddStep($step);
$step->OnPostForm();
$output->writeln("Done");
$step = new \FinishStep();
$step->ShowStep();
}
示例5: __construct
/**
* Constructor
*
*/
public function __construct($url, $dbOptions)
{
$user = new CUser($dbOptions);
$content = new CContent($dbOptions);
$filter = new CTextFilter();
$res = $content->getContentByUrl($url);
if (isset($res[0])) {
$c = $res[0];
} else {
die('Misslyckades: det finns inget innehåll.');
}
// Sanitize content before using it.
$title = htmlentities($c->title, null, 'UTF-8');
$data = $filter->doFilter(htmlentities($c->data, null, 'UTF-8'), $c->filter);
// Prepare content and store it all in variables in the Anax container.
$this->title = $title;
$editLink = $user->isAuthenticated() ? "<a href='content_edit.php?id={$c->id}'>Uppdatera sidan</a>\n <a href='content_delete.php?id={$c->id}'>Radera sidan</a>" : null;
$this->main = <<<EOD
<article>
<header>
<h1>{$title}</h1>
</header>
{$data}
<footer>
<p>(Skriven av {$c->owner}. Publicerad {$c->pubdate})</p>
{$editLink}
</footer
</article>
EOD;
}
示例6: loadUsers
/**
* Load multiple users at a same time to save up on the queries.
* @return boolean True upon success
* @param Array $userIds An array of user ids to be loaded.
*/
public static function loadUsers($userIds)
{
$userIds = array_diff_key($userIds, self::$instances);
if (empty($userIds)) {
return;
}
$ids = implode(",", $userIds);
$db = JFactory::getDBO();
$query = 'SELECT ' . ' a.' . $db->quoteName('userid') . ' as _userid ,' . ' a.' . $db->quoteName('status') . ' as _status , ' . ' a.' . $db->quoteName('points') . ' as _points, ' . ' a.' . $db->quoteName('posted_on') . ' as _posted_on, ' . ' a.' . $db->quoteName('avatar') . ' as _avatar , ' . ' a.' . $db->quoteName('thumb') . ' as _thumb , ' . ' a.' . $db->quoteName('invite') . ' as _invite, ' . ' a.' . $db->quoteName('params') . ' as _cparams, ' . ' a.' . $db->quoteName('view') . ' as _view, ' . ' a.' . $db->quoteName('friends') . ' as _friends, ' . ' a.' . $db->quoteName('groups') . ' as _groups, ' . ' a.' . $db->quoteName('events') . ' as _events, ' . ' a.' . $db->quoteName('alias') . ' as _alias, ' . ' a.' . $db->quoteName('profile_id') . ' as _profile_id, ' . ' a.' . $db->quoteName('friendcount') . ' as _friendcount, ' . ' a.' . $db->quoteName('storage') . ' as _storage, ' . ' a.' . $db->quoteName('watermark_hash') . ' as _watermark_hash, ' . ' a.' . $db->quoteName('search_email') . ' AS _search_email, ' . ' s.' . $db->quoteName('userid') . ' as _isonline, u.* ' . ' FROM ' . $db->quoteName('#__community_users') . ' as a ' . ' LEFT JOIN ' . $db->quoteName('#__users') . ' u ' . ' ON u.' . $db->quoteName('id') . '=a.' . $db->quoteName('userid') . ' LEFT OUTER JOIN ' . $db->quoteName('#__session') . 's ' . ' ON s.' . $db->quoteName('userid') . '=a.' . $db->quoteName('userid') . ' WHERE a.' . $db->quoteName('userid') . ' IN (' . $ids . ')';
$db->setQuery($query);
$objs = $db->loadObjectList();
foreach ($objs as $obj) {
$user = new CUser($obj->_userid);
$isNewUser = $user->init($obj);
$user->getThumbAvatar();
// technically, we should not fetch any new user here
if ($isNewUser) {
// New user added to jomSocial database
// trigger event onProfileInit
$appsLib = CAppPlugins::getInstance();
$appsLib->loadApplications();
$args = array();
$args[] = $user;
$appsLib->triggerEvent('onProfileCreate', $args);
}
CFactory::getUser($obj->_userid, $user);
}
}
示例7: executeEditPhones
private static function executeEditPhones(&$error)
{
global $USER_FIELD_MANAGER;
$userId = intval($_REQUEST['USER_ID']);
$obUser = new CUser();
$arFields = array("UF_VI_BACKPHONE" => $_REQUEST["UF_VI_BACKPHONE"], "UF_PHONE_INNER" => $_REQUEST["UF_PHONE_INNER"]);
$viUser = new CVoximplantUser();
if (isset($_REQUEST["UF_VI_PHONE"])) {
if ($_REQUEST["UF_VI_PHONE"] == 'N') {
$viUser->UpdateUserPassword($_REQUEST['USER_ID'], CVoxImplantUser::MODE_PHONE);
unset($_REQUEST["UF_VI_PHONE_PASSWORD"]);
}
$viUser->SetPhoneActive($_REQUEST['USER_ID'], $_REQUEST["UF_VI_PHONE"] == "Y" ? true : false);
}
if (isset($_REQUEST["UF_VI_PHONE_PASSWORD"]) && trim($_REQUEST["UF_VI_PHONE_PASSWORD"])) {
$pass = $viUser->UpdateUserPassword($_REQUEST['USER_ID'], CVoxImplantUser::MODE_PHONE, $_REQUEST["UF_VI_PHONE_PASSWORD"]);
if (!$pass) {
$error = $viUser->GetError()->msg;
}
}
$USER_FIELD_MANAGER->EditFormAddFields("USER", $arFields);
if (!$obUser->Update($userId, $arFields, true)) {
$error = $obUser->LAST_ERROR;
}
$arUser = CUser::GetList($by = "ID", $order = "ASC", array('ID' => $userId), array('FIELDS' => array('ID', 'LOGIN', 'NAME', 'SECOND_NAME', 'LAST_NAME', "UF_PHONE_INNER", "UF_VI_BACKPHONE", "UF_VI_PHONE", "UF_VI_PHONE_PASSWORD"), 'SELECT' => array("UF_PHONE_INNER", "UF_VI_BACKPHONE", "UF_VI_PHONE", "UF_VI_PHONE_PASSWORD")))->fetch();
return array('UF_VI_BACKPHONE' => $arUser['UF_VI_BACKPHONE'], 'UF_PHONE_INNER' => $arUser["UF_PHONE_INNER"], 'UF_VI_PHONE' => $arUser["UF_VI_PHONE"], 'UF_VI_PHONE_PASSWORD' => $arUser["UF_VI_PHONE_PASSWORD"]);
}
示例8: onUserLoginExternal
public function onUserLoginExternal(&$arParams)
{
if (!$this->useOfficeAuth()) {
return null;
}
$login = new UserLogin($arParams['LOGIN']);
$password = $arParams['PASSWORD'];
if ($this->isAuthorized($login->getOfficeLogin(), $password, $this->officeAuthUrl())) {
$fields = array("LOGIN" => $login->getBitrixLogin(), "NAME" => $login->getOfficeLogin(), "PASSWORD" => $password, "EMAIL" => $login->getEmail(), "ACTIVE" => "Y", "EXTERNAL_AUTH_ID" => "Office", "LID" => SITE_ID);
$user = new \CUser();
$existedUser = \CUser::GetList($by = "timestamp_x", $order = "desc", array("LOGIN_EQUAL_EXACT" => $login->getBitrixLogin(), "EXTERNAL_AUTH_ID" => "Office"))->Fetch();
if (!$existedUser) {
$id = $user->Add($fields);
} else {
$id = $existedUser["ID"];
$user->Update($id, $fields);
}
if ($id > 0) {
$groups = \CUser::GetUserGroup($id);
if (!in_array(1, $groups)) {
$groups[] = 1;
\CUser::SetUserGroup($id, $groups);
}
$arParams["store_password"] = "N";
return $id;
}
}
return null;
}
示例9: swapPratIds
/**
* Change prat usernames to prat ids
*
* @return bool
*/
protected function swapPratIds()
{
$ds = CSQLDataSource::get("std");
CApp::setTimeLimit(1800);
$user = new CUser();
// Changement des chirurgiens
$query = "SELECT id_chir\r\n FROM plagesop\r\n GROUP BY id_chir";
$listPlages = $ds->loadList($query);
foreach ($listPlages as $plage) {
$where["user_username"] = "= '" . $plage["id_chir"] . "'";
$user->loadObject($where);
if ($user->user_id) {
$query = "UPDATE plagesop\r\n SET chir_id = '{$user->user_id}'\r\n WHERE id_chir = '{$user->user_username}'";
$ds->exec($query);
$ds->error();
}
}
//Changement des anesthésistes
$query = "SELECT id_anesth\r\n FROM plagesop\r\n GROUP BY id_anesth";
$listPlages = $ds->loadList($query);
foreach ($listPlages as $plage) {
$where["user_username"] = "= '" . $plage["id_anesth"] . "'";
$user->loadObject($where);
if ($user->user_id) {
$query = "UPDATE plagesop\r\n SET anesth_id = '{$user->user_id}'\r\n WHERE id_anesth = '{$user->user_username}'";
$ds->exec($query);
$ds->error();
}
}
return true;
}
示例10: getSecurityContextByUser
/**
* Gets security context (access provider) for user.
* Attention! File/Folder can use anywhere and SecurityContext have to check rights anywhere (any module).
* @param mixed $user User which use for check rights.
* @return SecurityContext
*/
public function getSecurityContextByUser($user)
{
if ($this->isCurrentUser($user)) {
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
if (Loader::includeModule('socialnetwork') && \CSocnetUser::isCurrentUserModuleAdmin()) {
return new FakeSecurityContext($user);
}
if (UserModel::isCurrentUserAdmin()) {
return new FakeSecurityContext($user);
}
} else {
$userId = UserModel::resolveUserId($user);
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
if ($userId && Loader::includeModule('socialnetwork') && \CSocnetUser::isUserModuleAdmin($userId)) {
return new FakeSecurityContext($user);
}
try {
if ($userId && ModuleManager::isModuleInstalled('bitrix24') && Loader::includeModule('bitrix24') && \CBitrix24::isPortalAdmin($userId)) {
return new FakeSecurityContext($user);
} elseif ($userId) {
//Check user group 1 ('Admins')
$tmpUser = new \CUser();
$arGroups = $tmpUser->getUserGroup($userId);
if (in_array(1, $arGroups)) {
return new FakeSecurityContext($user);
}
}
} catch (\Exception $e) {
}
}
return new DiskSecurityContext($user);
}
示例11: run
public function run($id)
{
$userId = Yii::app()->user->id;
if (Yii::app()->request->isAjaxRequest) {
$user = new CUser();
$result = $user->like($userId, $id);
echo CJSON::encode($result);
}
}
示例12: getUsersId
public static function getUsersId()
{
$cUser = new CUser();
$sort_by = "ID";
$sort_ord = "ASC";
$arFilter = array("ACTIVE" => 'Y');
$dbUsers = $cUser->GetList($sort_by, $sort_ord, $arFilter);
$dbUsers->NavStart(8);
return $dbUsers;
}
示例13: run
public function run($id)
{
if (Yii::app()->request->isAjaxRequest) {
$user = new CUser();
$result = $user->liked($id);
if ($result['code'] == 200) {
echo CJOSN::encode($result);
}
}
}
示例14: OnSalePayOrderHandler
/**
* Обработчик события подтверждения оплаты товара
*/
function OnSalePayOrderHandler($id, $val)
{
$currentUserId = $GLOBALS['USER']->GetID();
//Идентификатор текущего пользователя, по идее администратор
$idRatingGroup = 5;
//группа акции
$curTo = "UAH";
//тип гривневой цены
$arOrder = CSaleOrder::GetByID($id);
//информация о заказе
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["SUM_PAID"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//стоимость заказа
$userId = intval($arOrder["USER_ID"]);
//пользователь, который оплатил заказ
$arUserData = CUser::GetByID($userId)->Fetch();
//Информация о пользователе
$userGroups = CUser::GetUserGroup($userId);
//ИД групп, к которым принадлежит пользователь
//Если пользователя нет в акционной группе, и он совершил заказ более чем на 900 грн, то добавить его в группу
if (!in_array($idRatingGroup, $userGroups)) {
if ($price >= 900 && $price <= 4000 && $val === 'Y') {
$userGroups[] = $idRatingGroup;
CUser::SetUserGroup($userId, $userGroups);
}
}
$points = $price * 5;
$payedUser = new CUser();
//Если оплата подтверждается, то добавить баллы
if ($val === 'Y' && in_array($idRatingGroup, $userGroups)) {
$points = intval($arUserData['UF_ACTION_POINTS']) + $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points, "UF_DATE_LAST_BUY" => $arOrder["DATE_UPDATE_FORMAT"]));
} else {
if ($val === 'N') {
$price = CCurrencyRates::ConvertCurrency(floatval($arOrder["PRICE"]), $arOrder["CURRENCY"], $curTo);
$price = intval(ceil($price));
//вычитаем полную стоимость
$points = $price * 5;
if ($arUserData['UF_ACTION_POINTS'] >= $points) {
$points = intval($arUserData['UF_ACTION_POINTS']) - $points;
$payedUser->Update($userId, array("UF_ACTION_POINTS" => $points));
//Если очков стало меньше 4500, то исключаем пользователя из группы участников
if (in_array($idRatingGroup, $userGroups) && $points < 4500) {
$indexGroup = array_search($idRatingGroup, $userGroups);
if (isset($userGroups[$indexGroup])) {
unset($userGroups[$indexGroup]);
CUser::SetUserGroup($userId, $userGroups);
}
}
}
}
}
unset($payedUser);
}
示例15: CheckAuthorization
function CheckAuthorization($user, $password)
{
$UserAuthTry = new CUser();
$authTry = $UserAuthTry->Login($user, $password);
if ($authTry === true) {
$unode = $UserAuthTry->GetByLogin($user);
$uinfo = $unode->Fetch();
return $uinfo;
}
return new CSOAPFault('Server Error', 'Unable to authorize user.');
}