Пример #1
0
 function GetDepartmentManagerOld($arDepartments, $skipUserId = false, $bRecursive = false)
 {
     if (!is_array($arDepartments) || empty($arDepartments)) {
         return array();
     }
     $arManagers = array();
     $dbSections = CIBlockSection::GetList(array('SORT' => 'ASC'), array('ID' => $arDepartments, 'IBLOCK_ID' => COption::GetOptionInt('intranet', 'iblock_structure', 0)), false, array('ID', 'UF_HEAD', 'IBLOCK_SECTION_ID'));
     while ($arSection = $dbSections->Fetch()) {
         $bFound = false;
         if ($arSection["UF_HEAD"] > 0) {
             $dbUser = CUser::GetByID($arSection["UF_HEAD"]);
             $arUser = $dbUser->GetNext();
             if ($arUser) {
                 if ($arUser["ID"] != $skipUserId) {
                     $arManagers[$arUser["ID"]] = $arUser;
                     $bFound = true;
                 }
             }
         }
         if (!$bFound && $bRecursive && $arSection['IBLOCK_SECTION_ID'] > 0) {
             $ar = CIntranetUtils::GetDepartmentManagerOld(array($arSection['IBLOCK_SECTION_ID']), $skipUserId, $bRecursive);
             $arManagers = $arManagers + $ar;
         }
     }
     return $arManagers;
 }