本文整理汇总了PHP中CUser类的典型用法代码示例。如果您正苦于以下问题:PHP CUser类的具体用法?PHP CUser怎么用?PHP CUser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CUser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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');
}
}
开发者ID:cjp2600,项目名称:bim-core,代码行数:37,代码来源:GroupIntegrate.php
示例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);
}
}
开发者ID:bizanto,项目名称:Hooked,代码行数:32,代码来源:core.php
示例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;
}
开发者ID:ASDAFF,项目名称:mp,代码行数:33,代码来源:registration.php
示例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();
}
开发者ID:ASDAFF,项目名称:bitapp,代码行数:60,代码来源:BitrixInstallCommand.php
示例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;
}
开发者ID:britec,项目名称:branac-base,代码行数:36,代码来源:CPage.php
示例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);
}
}
开发者ID:joshjim27,项目名称:jobsglobal,代码行数:33,代码来源:core.php
示例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"]);
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:27,代码来源:ajax.php
示例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;
}
开发者ID:techart,项目名称:bitrix.tao,代码行数:29,代码来源:auth.php
示例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;
}
开发者ID:fbone,项目名称:mediboard4,代码行数:36,代码来源:setup.php
示例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);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:38,代码来源:disk.php
示例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);
}
}
开发者ID:itliuchang,项目名称:test,代码行数:9,代码来源:LikeAction.php
示例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;
}
开发者ID:CheBurashka334,项目名称:zakrepi,代码行数:10,代码来源:cUserAddress.php
示例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);
}
}
}
开发者ID:itliuchang,项目名称:test,代码行数:10,代码来源:likedAction.php
示例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);
}
开发者ID:lenchv,项目名称:estore_additionl_work,代码行数:57,代码来源:rarus_event.php
示例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.');
}
开发者ID:sharapudinov,项目名称:lovestore.top,代码行数:11,代码来源:component.php
示例16: __construct
/**
* Creates new instance of SecurityContext specific by user.
* @param \CUser|int $user User.
*/
public function __construct($user)
{
$this->userId = static::GUEST_USER;
if ($user instanceof \CUser) {
if ($user->isAuthorized()) {
$this->userId = $user->getId();
}
} elseif ((int) $user > 0) {
$this->userId = (int) $user;
}
$this->errorCollection = new ErrorCollection();
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:16,代码来源:securitycontext.php
示例17: ManagerUserSession
private function ManagerUserSession($objRequestArr)
{
$objUser = new CUser();
if ($objRequestArr->RequestType == 'NU') {
if ($objUser->InsertUser($objRequestArr) == false) {
return false;
}
} elseif ($objRequestArr->RequestType == 'AU') {
} elseif ($objRequestArr->RequestType == 'LU') {
}
return true;
}
开发者ID:4000Eyes,项目名称:myres,代码行数:12,代码来源:CSiteFactory.class.php
示例18: OnAfterUserAuthorizeHandler
function OnAfterUserAuthorizeHandler(&$arFields)
{
$f = fopen($_SERVER['DOCUMENT_ROOT'] . '/bitrix/php_interface/md/log.txt', 'a+');
global $USER;
$rsUser = CUser::GetByID($USER->GetId());
$arUser = $rsUser->Fetch();
fwrite($f, "---start\n");
if ($arUser['ID'] > 0 && $arUser['EXTERNAL_AUTH_ID'] == 'Facebook' && $arUser['UF_RULES'] != '1') {
$facebook = new Facebook_Facebook(array('appId' => '447579571927341', 'secret' => '2f2cf9cd60f9e98d6cf3309e6b7bde5d'));
$id = $arUser["XML_ID"];
$user_info = $facebook->api('/' . $id . '?fields=id,name,first_name,middle_name,last_name,gender,birthday,email,picture');
$props = array();
if (!$arUser['PERSONAL_GENDER']) {
if (isset($user_info['gender']) && $user_info['gender']) {
$props['PERSONAL_GENDER'] = $user_info['gender'] == 'male' ? 'M' : 'F';
}
}
if (!empty($props)) {
$user = new CUser();
$user->Update($arUser["ID"], $props);
}
CModule::IncludeModule("blog");
$blogUser = CBlogUser::GetByID($USER->GetId(), BLOG_BY_USER_ID);
$props = array();
if (!$blogUser['AVATAR']) {
if (isset($user_info['picture']) && $user_info['picture']) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://graph.facebook.com/{$id}/picture?type=large");
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
$output = curl_exec($ch);
if ($output) {
$fileName = md5($user_info['picture']);
$fullPath = $_SERVER['DOCUMENT_ROOT'] . "/bitrix/cache/social_pictures/{$fileName}.jpg";
if (file_put_contents($fullPath, $output) !== false) {
$picture = CFile::MakeFileArray($fullPath);
$props['AVATAR'] = $picture;
$user = new CBlogUser();
$user->Update($blogUser["ID"], $props);
unlink($fullPath);
}
}
}
}
}
fwrite($f, "---finish\n");
fclose($f);
}
开发者ID:irotaev,项目名称:vector-vip.server,代码行数:50,代码来源:init.php
示例19: actionEdit
public function actionEdit()
{
$query = new CQuery();
$query->select("user.*")->from(TABLE_USERS . " as user")->order("user.FIO asc");
$users = array();
foreach ($query->execute()->getItems() as $ar) {
$user = new CUser(new CActiveRecord($ar));
$users[$user->getId()] = $user->FIO;
}
$quest = CQuestionManager::getQuestion(CRequest::getInt("id"));
$this->setData("users", $users);
$this->setData("quest", $quest);
$this->renderView("__public/_question_add/edit.tpl");
}
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:14,代码来源:CQuestionAddController.class.php
示例20: CheckFields
function CheckFields($ACTION, &$arFields, $ID = 0)
{
if ((is_set($arFields, "USER_ID") || $ACTION == "ADD") && IntVal($arFields["USER_ID"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("Empty user field", "EMPTY_USER_ID");
return false;
}
if ((is_set($arFields, "ITEM") || $ACTION == "ADD") && strlen($arFields["ITEM"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("Empty item field", "EMPTY_ITEM");
return false;
}
if ((is_set($arFields, "ITEM_MD5") || $ACTION == "ADD") && strlen($arFields["ITEM_MD5"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("Empty item md5 field", "EMPTY_ITEM_MD5");
return false;
}
if ((is_set($arFields, "DATE_INSERT") || $ACTION == "ADD") && strlen($arFields["DATE_INSERT"]) <= 0) {
$GLOBALS["APPLICATION"]->ThrowException("Empty date insert field", "EMPTY_DATE_INSERT");
return false;
}
if (is_set($arFields, "ITEM_MD5")) {
$arFields["ITEM_MD5"] = md5($arFields["ITEM_MD5"]);
}
if (is_set($arFields, "USER_ID")) {
$dbUser = CUser::GetByID($arFields["USER_ID"]);
if (!$dbUser->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["USER_ID"], GetMessage("SGMA_NO_USER")), "ERROR_NO_USER_ID");
return false;
}
}
return True;
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:30,代码来源:auxiliary.php
注:本文中的CUser类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论