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


PHP CUser::SearchUserByName方法代码示例

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


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

示例1: SearchUserByName

 private function SearchUserByName($user)
 {
     $user = trim($user);
     if (strlen($user) <= 0) {
         return array();
     }
     $userId = 0;
     if ($user . "|" == intval($user) . "|") {
         $userId = intval($user);
     }
     if ($userId <= 0) {
         $arMatches = array();
         if (preg_match("#\\[(\\d+)\\]#i", $user, $arMatches)) {
             $userId = intval($arMatches[1]);
         }
     }
     $arResult = array();
     $dbUsers = false;
     if ($userId > 0) {
         $arFilter = array("ID_EQUAL_EXACT" => $userId);
         $dbUsers = CUser::GetList($by = "LAST_NAME", $order = "asc", $arFilter, array("NAV_PARAMS" => false));
     } else {
         $userLogin = "";
         $arMatches = array();
         if (preg_match("#\\((.+?)\\)#i", $user, $arMatches)) {
             $userLogin = $arMatches[1];
             $user = trim(str_replace("(" . $userLogin . ")", "", $user));
         }
         $userEmail = "";
         $arMatches = array();
         if (preg_match("#<(.+?)>#i", $user, $arMatches)) {
             if (check_email($arMatches[1])) {
                 $userEmail = $arMatches[1];
                 $user = Trim(Str_Replace("<" . $userEmail . ">", "", $user));
             }
         }
         $arUser = array();
         $arUserTmp = Explode(" ", $user);
         foreach ($arUserTmp as $s) {
             $s = Trim($s);
             if (StrLen($s) > 0) {
                 $arUser[] = $s;
             }
         }
         if (strlen($userLogin) > 0) {
             $arUser[] = $userLogin;
         }
         $dbUsers = CUser::SearchUserByName($arUser, $userEmail, true);
     }
     if ($dbUsers) {
         while ($arUsers = $dbUsers->GetNext()) {
             $arResult[] = $arUsers["ID"];
         }
     }
     return $arResult;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:56,代码来源:helper.php

示例2: SearchUser

 /**
  * <p>Метод ищет пользователя по его имени или коду.</p>
  *
  *
  *
  *
  * @param string $user  Имя или код пользователя. Если параметр является числом или
  * строкой, в которой содержится число в квадратных скобках, то это
  * число рассматривается как код пользователя. В противном случае
  * параметр рассматривается как строка, содержащая ФИО
  * пользователя.
  *
  *
  *
  * @param bool $bIntranet = false Флаг, определяющий, осуществляется ли работа в рамках решения
  * интранет. Необязательный параметр. По умолчанию равен false.
  *
  *
  *
  * @return array <p>Массив пользователей, удовлетворяющих условию поиска.</p> <br><br>
  *
  * @static
  * @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/CSocNetUser/searchuser.php
  * @author Bitrix
  */
 public static function SearchUser($user, $bIntranet = false)
 {
     $user = Trim($user);
     if (StrLen($user) <= 0) {
         return false;
     }
     $userID = 0;
     if ($user . "|" == IntVal($user) . "|") {
         $userID = IntVal($user);
     }
     if ($userID <= 0) {
         $arMatches = array();
         if (preg_match("#\\[(\\d+)\\]#i", $user, $arMatches)) {
             $userID = IntVal($arMatches[1]);
         }
     }
     $dbUsers = false;
     if ($userID > 0) {
         $arFilter = array("ID_EQUAL_EXACT" => $userID);
         $dbUsers = CUser::GetList($by = "LAST_NAME", $order = "asc", $arFilter, array("NAV_PARAMS" => false));
     } else {
         $email = "";
         $arMatches = array();
         if (preg_match("#<(.+?)>#i", $user, $arMatches)) {
             if (check_email($arMatches[1])) {
                 $email = $arMatches[1];
                 $user = Trim(Str_Replace("<" . $email . ">", "", $user));
             }
         }
         $arUser = array();
         $arUserTmp = Explode(" ", $user);
         foreach ($arUserTmp as $s) {
             $s = Trim($s);
             if (StrLen($s) > 0) {
                 $arUser[] = $s;
             }
         }
         if (count($arUser) <= 0 && strlen($email) > 0) {
             $arFilter = array("ACTIVE" => "Y", "EMAIL" => $email);
             $dbUsers = CUser::GetList($by = "id", $order = "asc", $arFilter);
         } else {
             $dbUsers = CUser::SearchUserByName($arUser, $email);
         }
     }
     if ($dbUsers) {
         $arResult = array();
         while ($arUsers = $dbUsers->GetNext()) {
             $arResult[$arUsers["ID"]] = CSocNetUser::FormatNameEx($arUsers["NAME"], $arUsers["SECOND_NAME"], $arUsers["LAST_NAME"], $arUsers["LOGIN"], $bIntranet ? $arUsers["EMAIL"] : "", $arUsers["ID"]);
         }
         return $arResult;
     }
     return false;
 }
开发者ID:rasuldev,项目名称:torino,代码行数:78,代码来源:user.php

示例3: SearchUsers

 public static function SearchUsers($search, $nameTemplate = "", $bSelf = true, $bEmployeesOnly = false)
 {
     CUtil::JSPostUnescape();
     $bIntranetEnable = IsModuleInstalled('intranet');
     $bExtranetEnable = IsModuleInstalled('extranet');
     $bBitrix24Enable = IsModuleInstalled('bitrix24');
     $arUsers = array();
     $arTmpUsers = array();
     $arExtranetTestUsers = array();
     $search = trim($search);
     if (strlen($search) <= 0) {
         return $arUsers;
     }
     $strUserIDs = '';
     $arUserSearch = explode(' ', urldecode($search));
     if (empty($arUserSearch)) {
         return $arUsers;
     }
     $dbRes = CUser::SearchUserByName($arUserSearch, '', true);
     while ($arRes = $dbRes->Fetch()) {
         if (!$bSelf && is_object($GLOBALS["USER"]) && $GLOBALS["USER"]->GetID() == $arRes['ID']) {
             continue;
         }
         $strUserIDs .= ($strUserIDs == '' ? '' : '|') . $arRes['ID'];
     }
     $arFilter = array("ACTIVE" => "Y", "NAME_SEARCH" => $search, "ID" => $strUserIDs);
     if ($bEmployeesOnly || $bBitrix24Enable && !$bExtranetEnable) {
         $arFilter["!UF_DEPARTMENT"] = false;
     }
     $arExtParams = array("FIELDS" => array("ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "PERSONAL_PHOTO", "WORK_POSITION", "PERSONAL_PROFESSION"));
     if ($bIntranetEnable) {
         $arExtParams['SELECT'] = array('UF_DEPARTMENT');
     }
     $dbUsers = CUser::GetList($sort_by = array('last_name' => 'asc', 'IS_ONLINE' => 'desc'), $dummy = '', $arFilter, $arExtParams);
     $dbUsers->NavStart(20);
     while ($arUser = $dbUsers->NavNext(false)) {
         if (!$bSelf && is_object($GLOBALS["USER"]) && $GLOBALS["USER"]->GetID() == $arUser['ID']) {
             continue;
         }
         $arTmpUsers[$arUser["ID"]] = $arUser;
         if ($bIntranetEnable && $bExtranetEnable && (!is_array($arUser["UF_DEPARTMENT"]) || empty($arUser["UF_DEPARTMENT"]))) {
             $arExtranetTestUsers[$arUser["ID"]] = $arUser["ID"];
         }
     }
     if (!empty($arExtranetTestUsers) && CModule::IncludeModule('extranet') && CExtranet::IsIntranetUser()) {
         global $USER;
         $arUserSocNetGroups = array();
         $rsGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), array("USER_ID" => $USER->GetID(), "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => SITE_ID, "GROUP_ACTIVE" => "Y", "!GROUP_CLOSED" => "Y"), false, array("nPageSize" => 500, "bDescPageNumbering" => false), array("ID", "GROUP_ID"));
         while ($arGroup = $rsGroups->Fetch()) {
             $arUserSocNetGroups[] = $arGroup["GROUP_ID"];
         }
         if (count($arUserSocNetGroups) > 0) {
             $dbUsersInGroup = CSocNetUserToGroup::GetList(array(), array("GROUP_ID" => $arUserSocNetGroups, "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("ID", "USER_ID", "GROUP_ID"));
             while ($ar = $dbUsersInGroup->GetNext(true, false)) {
                 $arSelect[$ar["USER_ID"]] = $ar["USER_ID"];
             }
             foreach ($arExtranetTestUsers as $userId) {
                 if (!isset($arSelect[$userId])) {
                     unset($arTmpUsers[$userId]);
                 }
             }
         } else {
             foreach ($arExtranetTestUsers as $userId) {
                 unset($arTmpUsers[$userId]);
             }
         }
     }
     foreach ($arTmpUsers as $arUser) {
         $sName = CUser::FormatName(empty($nameTemplate) ? CSite::GetNameFormat(false) : $nameTemplate, $arUser, true, false);
         $arFileTmp = CFile::ResizeImageGet($arUser["PERSONAL_PHOTO"], array('width' => 32, 'height' => 32), BX_RESIZE_IMAGE_EXACT, false);
         $arUsers['U' . $arUser["ID"]] = array('id' => 'U' . $arUser["ID"], 'entityId' => $arUser["ID"], 'name' => $sName, 'avatar' => empty($arFileTmp['src']) ? '' : $arFileTmp['src'], 'desc' => $arUser['WORK_POSITION'] ? $arUser['WORK_POSITION'] : ($arUser['PERSONAL_PROFESSION'] ? $arUser['PERSONAL_PROFESSION'] : '&nbsp;'));
     }
     return $arUsers;
 }
开发者ID:k-kalashnikov,项目名称:geekcon_new,代码行数:74,代码来源:log_destination.php

示例4: unset

 if (empty($arLocalPath[0])) {
     unset($arLocalPath[0]);
 }
 if (sizeof($arLocalPath) > 0) {
     $userName = $arLocalPath[0];
     $userFilter = array();
     if (strpos($userName, '(') !== false) {
         $userFilter = array('LOGIN_EQUAL' => trim($userName, '()'));
         $dbUser = CUser::GetList($by, $order, $userFilter);
     } else {
         //$userFilter = array('NAME' => $userName);
         $arName = explode(' ', $userName);
         foreach ($arName as &$namePart) {
             $namePart = trim(trim($namePart), ".,-");
         }
         $dbUser = CUser::SearchUserByName($arName, '', false);
     }
     if ($dbUser !== false && ($arUser = $dbUser->Fetch())) {
         $userID = $arUser['ID'];
         $userLogin = $arUser['LOGIN'];
     } else {
         CHTTP::SetStatus('404 Not Found');
         ShowError(GetMessage("WD_USER_NOT_FOUND"));
         return 0;
     }
     $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_USER_ID"], "SOCNET_GROUP_ID" => false, "SECTION_ID" => 0, "CHECK_PERMISSIONS" => "N", "CREATED_BY" => $userID);
     $dbSection = CIBlockSection::GetList(array(), $arFilter, false, array('ID'));
     if ($arUserSection = $dbSection->Fetch()) {
         $sectionID = $arUserSection['ID'];
     } else {
         CHTTP::SetStatus('404 Not Found');
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:31,代码来源:component.php


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