当前位置: 首页>>代码示例>>PHP>>正文


PHP CUser::getById方法代码示例

本文整理汇总了PHP中CUser::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP CUser::getById方法的具体用法?PHP CUser::getById怎么用?PHP CUser::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUser的用法示例。


在下文中一共展示了CUser::getById方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setOccurAsUserId

 public static function setOccurAsUserId($userId = 'get key')
 {
     static $key = null;
     if ($key === null) {
         $key = 'occurAs_key:' . md5(mt_rand(1000, 999999) . '-' . mt_rand(1000, 999999));
         if ($userId !== 'get key') {
             CTasksPerHitOption::set('tasks', $key, false);
         }
     }
     if ($userId !== 'get key') {
         CTaskAssert::assertLaxIntegers($userId);
         $userId = (int) $userId;
         /** @noinspection PhpDynamicAsStaticMethodCallInspection */
         $rs = CUser::getById($userId);
         if (!($rs && $rs->fetch())) {
             throw new TasksException('User not found', TasksException::TE_ITEM_NOT_FOUND_OR_NOT_ACCESSIBLE);
         }
         CTasksPerHitOption::set('tasks', $key, $userId);
     }
     return $key;
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:21,代码来源:tasktools.php

示例2: Authorize

    public function Authorize()
    {
        global $APPLICATION;
        $APPLICATION->RestartBuffer();
        $authError = SOCSERV_AUTHORISATION_ERROR;
        if (isset($_REQUEST["code"]) && $_REQUEST["code"] != '' && CSocServAuthManager::CheckUniqueKey()) {
            $redirect_uri = CSocServUtil::ServerName() . '/bitrix/tools/oauth/bitrix24net.php';
            if ($this->getEntityOAuth($_REQUEST["code"])->GetAccessToken($redirect_uri) !== false) {
                $arB24NetUser = $this->entityOAuth->GetCurrentUser();
                if ($arB24NetUser) {
                    if (isset($_REQUEST['checkword']) && $arB24NetUser['PROFILE_ID'] > 0) {
                        $profileId = $arB24NetUser['PROFILE_ID'];
                        $checkword = trim($_REQUEST['checkword']);
                        $dbRes = CUser::getById($profileId);
                        $arUser = $dbRes->fetch();
                        if ($arUser && !$arUser['LAST_LOGIN']) {
                            if ($arUser['CONFIRM_CODE'] == $checkword) {
                                $arUserFields = array('XML_ID' => $arB24NetUser['ID'], 'EXTERNAL_AUTH_ID' => 'socservices');
                                if ($arUser['NAME'] == '' && $arUser['LAST_NAME'] == '') {
                                    $arUserFields['NAME'] = $arB24NetUser['NAME'];
                                    $arUserFields['LAST_NAME'] = $arB24NetUser['LAST_NAME'];
                                    if (strlen($arB24NetUser['PERSONAL_PHOTO']) > 0 && self::CheckPhotoURI($arB24NetUser['PERSONAL_PHOTO'])) {
                                        $arUserFields['PERSONAL_PHOTO'] = CFile::MakeFileArray($arB24NetUser['PERSONAL_PHOTO']);
                                    }
                                }
                                $obUser = new CUser();
                                if ($obUser->update($profileId, $arUserFields)) {
                                    foreach (GetModuleEvents("main", "OnUserInitialize", true) as $arEvent) {
                                        ExecuteModuleEventEx($arEvent, array($profileId, $arUserFields));
                                    }
                                }
                            }
                        }
                    }
                    $arFields = array('EXTERNAL_AUTH_ID' => self::ID, 'XML_ID' => $arB24NetUser["ID"], 'LOGIN' => "B24_" . $arB24NetUser["ID"], 'NAME' => $arB24NetUser["NAME"], 'LAST_NAME' => $arB24NetUser["LAST_NAME"], 'EMAIL' => $arB24NetUser["EMAIL"], 'PERSONAL_WWW' => $arB24NetUser["PROFILE"], 'OATOKEN' => $this->entityOAuth->getToken(), 'REFRESH_TOKEN' => $this->entityOAuth->getRefreshToken(), 'OATOKEN_EXPIRES' => $this->entityOAuth->getAccessTokenExpires());
                    if (IsModuleInstalled('bitrix24')) {
                        $arFields['LOGIN'] = $arFields['EMAIL'];
                    }
                    if (strlen(SITE_ID) > 0) {
                        $arFields["SITE_ID"] = SITE_ID;
                    }
                    $authError = $this->AuthorizeUser($arFields);
                }
            }
        }
        $bSuccess = $authError === true;
        $aRemove = array("logout", "auth_service_error", "auth_service_id", "code", "error_reason", "error", "error_description", "check_key", "current_fieldset", "checkword");
        $url = $APPLICATION->GetCurDir() == "/login/" ? "" : $APPLICATION->GetCurDir();
        $mode = 'page';
        if (isset($_REQUEST["state"])) {
            $arState = array();
            parse_str($_REQUEST["state"], $arState);
            if (isset($arState['backurl']) || isset($arState['redirect_url'])) {
                $parseUrl = parse_url(isset($arState['redirect_url']) ? $arState['redirect_url'] : $arState['backurl']);
                $urlPath = $parseUrl["path"];
                $arUrlQuery = explode('&', $parseUrl["query"]);
                foreach ($arUrlQuery as $key => $value) {
                    foreach ($aRemove as $param) {
                        if (strpos($value, $param . "=") === 0) {
                            unset($arUrlQuery[$key]);
                            break;
                        }
                    }
                }
                $url = !empty($arUrlQuery) ? $urlPath . '?' . implode("&", $arUrlQuery) : $urlPath;
            }
            if (isset($arState['mode'])) {
                $mode = $arState['mode'];
            }
        }
        if (strlen($url) <= 0 || preg_match("'^(http://|https://|ftp://|//)'i", $url)) {
            $url = CSocServUtil::ServerName() . '/';
        }
        $url = CUtil::JSEscape($url);
        if ($bSuccess) {
            unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
        } else {
            if (IsModuleInstalled('bitrix24')) {
                if (isset($_SESSION['B24_NETWORK_REDIRECT_TRY'])) {
                    unset($_SESSION['B24_NETWORK_REDIRECT_TRY']);
                    $url = self::getUrl();
                    $url .= (strpos($url, '?') >= 0 ? '&' : '?') . 'skip_redirect=1';
                } else {
                    $_SESSION['B24_NETWORK_REDIRECT_TRY'] = true;
                    $url = '/';
                }
            } else {
                if ($authError === SOCSERV_REGISTRATION_DENY) {
                    $url = preg_match("/\\?/", $url) ? $url . '&' : $url . '?';
                    $url .= 'auth_service_id=' . self::ID . '&auth_service_error=' . $authError;
                } elseif ($bSuccess !== true) {
                    $url = isset($urlPath) ? $urlPath . '?auth_service_id=' . self::ID . '&auth_service_error=' . $authError : $GLOBALS['APPLICATION']->GetCurPageParam('auth_service_id=' . self::ID . '&auth_service_error=' . $authError, $aRemove);
                }
            }
        }
        if (CModule::IncludeModule("socialnetwork") && strpos($url, "current_fieldset=") === false) {
            $url .= (strpos($url, "?") === false ? '?' : '&') . "current_fieldset=SOCSERV";
        }
        $location = $mode == "popup" ? 'if(window.opener) window.opener.location = \'' . $url . '\'; window.close();' : 'window.location = \'' . $url . '\';';
        ?>
//.........这里部分代码省略.........
开发者ID:rasuldev,项目名称:torino,代码行数:101,代码来源:bitrix24net.php

示例3: array

$GLOBALS['APPLICATION']->AddHeadScript("/bitrix/js/tasks/task-iframe-popup.js");
$GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/intranet/intranet-common.css");
$GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/main/core/css/core_popup.css");
$GLOBALS['APPLICATION']->SetAdditionalCSS("/bitrix/js/tasks/css/tasks.css");
$GLOBALS["APPLICATION"]->IncludeComponent('bitrix:main.calendar', '', array('SILENT' => 'Y'), null, array('HIDE_ICONS' => 'Y'));
$arPaths = array("PATH_TO_TASKS_TASK" => $arParams["PATH_TO_TASKS_TASK"], "PATH_TO_USER_PROFILE" => $arParams["PATH_TO_USER_PROFILE"]);
$loggedInUser = $USER->getId();
$createUrl = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_TASKS_TASK"], array("task_id" => 0, "action" => "edit"));
$createSubtaskUrl = $createUrl . (strpos($createUrl, "?") === false ? "?" : "&") . "PARENT_ID=" . $arResult["TASK"]["ID"];
$APPLICATION->IncludeComponent("bitrix:tasks.iframe.popup", ".default", array("ON_TASK_ADDED" => "onPopupTaskAdded", "ON_TASK_CHANGED" => "onPopupTaskChanged", "ON_TASK_DELETED" => "onPopupTaskDeleted"), null, array("HIDE_ICONS" => "Y"));
if (!defined('TASKS_MUL_INCLUDED')) {
    $APPLICATION->IncludeComponent("bitrix:main.user.link", '', array("AJAX_ONLY" => "Y", "PATH_TO_SONET_USER_PROFILE" => $arParams["~PATH_TO_USER_PROFILE"], "PATH_TO_SONET_MESSAGES_CHAT" => $arParams["~PATH_TO_MESSAGES_CHAT"], "DATE_TIME_FORMAT" => $arParams["~DATE_TIME_FORMAT"], "SHOW_YEAR" => $arParams["SHOW_YEAR"], "NAME_TEMPLATE" => $arParams["~NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "PATH_TO_CONPANY_DEPARTMENT" => $arParams["~PATH_TO_CONPANY_DEPARTMENT"], "PATH_TO_VIDEO_CALL" => $arParams["~PATH_TO_VIDEO_CALL"]), false, array("HIDE_ICONS" => "Y"));
    define('TASKS_MUL_INCLUDED', 1);
}
$loggedInUserWorkPosition = '';
if ($rs = CUser::getById($loggedInUser)) {
    if ($arUserData = $rs->fetch()) {
        $loggedInUserWorkPosition = $arUserData['WORK_POSITION'];
    }
}
$loggedInUserFormattedName = CUser::FormatName($arParams['~NAME_TEMPLATE'], array('NAME' => $USER->GetFirstName(), 'LAST_NAME' => $USER->GetLastName(), 'SECOND_NAME' => $USER->GetSecondName(), 'LOGIN' => $USER->GetLogin()), true, $bEscapeSpecChars = false);
?>
<script type="text/javascript">
BX.message({
	TASKS_PRIORITY : '<?php 
echo CUtil::JSEscape(GetMessage("TASKS_PRIORITY"));
?>
',
	TASKS_APPLY : '<?php 
echo CUtil::JSEscape(GetMessage("TASKS_APPLY"));
?>
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:template.php

示例4: getRootSectionIdForUser

 public static function getRootSectionIdForUser($iblockId, $userId)
 {
     global $USER_FIELD_MANAGER;
     global $UF_USE_BP;
     $result = CIBlockWebdavSocnet::getSectionId($iblockId, 'user', $userId);
     if (($result = intval($result)) > 0) {
         return $result;
     }
     $fields = array('IBLOCK_ID' => $iblockId, 'ACTIVE' => 'Y', 'SOCNET_GROUP_ID' => false, 'IBLOCK_SECTION_ID' => 0, 'UF_USE_BP' => 'N', 'UF_USE_EXT_SERVICES' => CWebDavIblock::resolveDefaultUseExtServices());
     $user = CUser::getById($userId)->fetch();
     if (empty($user)) {
         return false;
     }
     $fields['NAME'] = trim($user['LAST_NAME'] . ' ' . $user['FIRST_NAME']);
     $fields['NAME'] = trim(!empty($fields["NAME"]) ? $fields['NAME'] : $user['LOGIN']);
     $fields['CREATED_BY'] = $user['ID'];
     $fields['MODIFIED_BY'] = $user['ID'];
     if (CIBlock::GetArrayByID($iblockId, "RIGHTS_MODE") === "E") {
         $tasks = CWebDavIblock::GetTasks();
         $fields['RIGHTS'] = array('n0' => array('GROUP_CODE' => 'U' . $userId, 'TASK_ID' => $tasks['X']));
     }
     $UF_USE_BP = $fields['UF_USE_BP'];
     $USER_FIELD_MANAGER->editFormAddFields('IBLOCK_' . $iblockId . '_SECTION', $fields);
     $section = new CIBlockSection();
     $sectionId = $section->add($fields);
     if (!$sectionId) {
         return false;
     }
     WDClearComponentCache(array('webdav.element.edit', 'webdav.element.hist', 'webdav.element.upload', 'webdav.element.view', 'webdav.menu', 'webdav.section.edit', 'webdav.section.list'));
     return $sectionId;
 }
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:iblock.php

示例5: sendNotify

 public static function sendNotify(array $folderInvite)
 {
     $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
     if (empty($folderInvite['IS_DELETED']) && !empty($folderInvite['IS_APPROVED']) && $folderInvite['USER_ID'] != $folderInvite['INVITE_USER_ID'] && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME'))->fetch();
         if (empty($sectionToShare['NAME'])) {
             return;
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         $uriShow = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'];
         $uriDisconnect = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'] . '#disconnect';
         $notifyFields['NOTIFY_MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_APPROVE_N1', array('#FOLDERNAME#' => '<a href="' . $uriShow . '">' . $sectionToShare['NAME'] . '</a>', '#DISCONNECT_LINK#' => '<a href="' . $uriDisconnect . '">' . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . '</a>', '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: ''));
         $notifyFields['NOTIFY_MESSAGE_OUT'] = GetMessage('WD_SYMLINK_INVITE_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'] . " ({$uriShow})", '#DISCONNECT_LINK#' => "\n\n" . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . ': ' . $serverName . $uriDisconnect, '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: ''));
         \CIMNotify::Add($notifyFields);
     } elseif (empty($folderInvite['IS_DELETED']) && $folderInvite['USER_ID'] == $folderInvite['INVITE_USER_ID'] && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME', 'SOCNET_GROUP_ID'))->fetch();
         if (empty($sectionToShare['NAME']) || empty($sectionToShare['SOCNET_GROUP_ID'])) {
             return;
         }
         if (\Bitrix\Main\Loader::includeModule('socialnetwork')) {
             $group = CSocNetGroup::GetList(array(), array('ID' => $sectionToShare['SOCNET_GROUP_ID']), false, false, array('NAME'))->fetch();
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         $uriShow = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('group', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'];
         $uriDisconnect = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'] . '#disconnect';
         if (\CWebDavTools::allowAutoconnectShareGroupFolder()) {
             $notifyFields['NOTIFY_MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: '', '#GROUPNAME#' => '<a href="' . $uriShow . '">' . $group['NAME'] . '</a>', '#DISCONNECT_LINK#' => '<a href="' . $uriDisconnect . '">' . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . '</a>'));
             $notifyFields['NOTIFY_MESSAGE_OUT'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: '', '#GROUPNAME#' => $group['NAME'], '#DISCONNECT_LINK#' => "\n\n" . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . ': ' . $serverName . $uriDisconnect));
         } elseif (empty($folderInvite['IS_APPROVED'])) {
             $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_CONFIRM;
             $notifyFields['NOTIFY_BUTTONS'] = array(array('TITLE' => GetMessage('WD_SYMLINK_INVITE_APPROVE_Y'), 'VALUE' => 'Y', 'TYPE' => 'accept'), array('TITLE' => GetMessage('WD_SYMLINK_INVITE_APPROVE_N'), 'VALUE' => 'N', 'TYPE' => 'cancel'));
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_CONFIRM_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#GROUPNAME#' => $group['NAME']));
         }
         \CIMNotify::Add($notifyFields);
     } elseif (!empty($folderInvite['IS_DELETED']) && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME'))->fetch();
         if (empty($sectionToShare['NAME'])) {
             return;
         }
         $inviteUser = \CUser::getById($folderInvite['INVITE_USER_ID']);
         if ($inviteUser) {
             $inviteUser = $inviteUser->fetch();
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         if (CWebDavTools::getUserGender($inviteUser['PERSONAL_GENDER']) == 'F') {
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_F', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#USERNAME#' => CWebDavTools::getUserName($inviteUser)));
         } else {
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_M', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#USERNAME#' => CWebDavTools::getUserName($inviteUser)));
         }
         \CIMNotify::Add($notifyFields);
     }
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:73,代码来源:symlinkhelper.php

示例6: getUserFromForum

 private static function getUserFromForum($userId)
 {
     if ($userId > 0 && !array_key_exists($userId, self::$users)) {
         self::$users[$userId] = \CForumUser::getListEx(array(), array("USER_ID" => $userId))->fetch();
         if (!self::$users[$userId]) {
             self::$users[$userId] = \CUser::getById($userId)->fetch();
             self::$users[$userId]["SHOW_NAME"] = \COption::getOptionString("forum", "USER_SHOW_NAME", "Y");
         }
     }
     return self::$users[$userId];
 }
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:11,代码来源:baseobject.php


注:本文中的CUser::getById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。