Example #1
0
 public function GetFormHtml($arParams = false)
 {
     global $USER;
     if (is_array($arParams["socnetgroups"]) && $arParams["socnetgroups"]["disabled"] == "true") {
         return false;
     }
     $currElements = '';
     if (is_array($arParams[$this->id]) && ($group_id = intval($arParams[$this->id]["group_id"])) > 0) {
         $arFinderParams = array("PROVIDER" => $this->id, "TYPE" => 4);
         $arFilter = array("ID" => $group_id, "ACTIVE" => "Y");
         if (!CSocNetUser::IsCurrentUserModuleAdmin($arParams["SITE_ID"])) {
             $arFilter["CHECK_PERMISSIONS"] = $USER->GetID();
         }
         $rsGroups = CSocNetGroup::GetList(array(), $arFilter);
         if ($arGroup = $rsGroups->Fetch()) {
             $arItem = array("ID" => "SG" . $arGroup['ID'], "AVATAR" => '/bitrix/js/main/core/images/access/avatar-user-everyone.png', "NAME" => $arGroup['NAME'], "DESC" => $arGroup['DESCRIPTION'], "OPEN" => "Y", "CHECKBOX" => array("#ID#_A" => GetMessage("authprov_sg_a"), "#ID#_E" => GetMessage("authprov_sg_e"), "#ID#_K" => GetMessage("authprov_sg_k")));
             if ($arGroup["IMAGE_ID"]) {
                 $imageFile = CFile::GetFileArray($arGroup["IMAGE_ID"]);
                 if ($imageFile !== false) {
                     $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 30, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                     $arItem["AVATAR"] = $arFileTmp["src"];
                 }
             }
             $currElements .= CFinder::GetFinderItem($arFinderParams, $arItem);
         }
     }
     $elements = "";
     $arFinderParams = array("PROVIDER" => $this->id, "TYPE" => 3);
     $arLRU = CAccess::GetLastRecentlyUsed($this->id);
     if (!empty($arLRU)) {
         $arLast = array();
         $arLastID = array();
         $arElements = array();
         foreach ($arLRU as $val) {
             if (preg_match('/^SG([0-9]+)_([A-Z])/', $val, $match)) {
                 $arLast[$match[2]][$match[1]] = $match[1];
                 $arLastID[$match[1]] = $match[1];
             }
         }
         if (!empty($arLastID)) {
             $arFilter = array("ID" => $arLastID, "ACTIVE" => "Y");
             if ($arParams["SITE_ID"] != '') {
                 $arFilter["SITE_ID"] = $arParams["SITE_ID"];
             }
             if (!CSocNetUser::IsCurrentUserModuleAdmin($arParams["SITE_ID"])) {
                 $arFilter["CHECK_PERMISSIONS"] = $USER->GetID();
             }
             $rsGroups = CSocNetGroup::GetList(array("NAME" => "ASC"), $arFilter);
             while ($arGroup = $rsGroups->Fetch()) {
                 $arItem = array("ID" => $arGroup['ID'], "AVATAR" => '/bitrix/js/main/core/images/access/avatar-user-everyone.png', "NAME" => $arGroup['NAME'], "DESC" => $arGroup['DESCRIPTION']);
                 if ($arGroup["IMAGE_ID"]) {
                     $imageFile = CFile::GetFileArray($arGroup["IMAGE_ID"]);
                     if ($imageFile !== false) {
                         $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 30, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                         $arItem["AVATAR"] = $arFileTmp["src"];
                     }
                 }
                 $arElements[$arItem['ID']] = $arItem;
             }
             foreach ($arLRU as $val) {
                 if (preg_match('/^SG([0-9]+)_([A-Z])/', $val, $match)) {
                     $arItem = $arElements[$match[1]];
                     if ($match[2] == 'K') {
                         $arItem['ID'] = 'SG' . $arElements[$match[1]]['ID'] . '_K';
                         $arItem['NAME'] = $arElements[$match[1]]['NAME'] . ': ' . GetMessage("authprov_sg_k");
                     } else {
                         if ($match[2] == 'E') {
                             $arItem['ID'] = 'SG' . $arElements[$match[1]]['ID'] . '_E';
                             $arItem['NAME'] = $arElements[$match[1]]['NAME'] . ': ' . GetMessage("authprov_sg_e");
                         } else {
                             if ($match[2] == 'A') {
                                 $arItem['ID'] = 'SG' . $arElements[$match[1]]['ID'] . '_A';
                                 $arItem['NAME'] = $arElements[$match[1]]['NAME'] . ': ' . GetMessage("authprov_sg_a");
                             }
                         }
                     }
                     $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
                 }
             }
         }
     }
     $arFinderParams = array("PROVIDER" => $this->id, "TYPE" => 4);
     $arFilter = array("USER_ID" => $USER->GetID(), "<=ROLE" => SONET_ROLES_USER, "GROUP_ACTIVE" => "Y");
     if ($arParams["SITE_ID"] != '') {
         $arFilter["GROUP_SITE_ID"] = $arParams["SITE_ID"];
     }
     $rsGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arFilter, false, array(), array("ID", "GROUP_ID", "GROUP_NAME", "GROUP_DESCRIPTION", "GROUP_IMAGE_ID"));
     $myElements = '';
     while ($arGroup = $rsGroups->Fetch()) {
         $arItem = array("ID" => "SG" . $arGroup['GROUP_ID'], "AVATAR" => $arGroup['GROUP_IMAGE_ID'], "NAME" => $arGroup['GROUP_NAME'], "DESC" => $arGroup['GROUP_DESCRIPTION'], "CHECKBOX" => array("#ID#_A" => GetMessage("authprov_sg_a"), "#ID#_E" => GetMessage("authprov_sg_e"), "#ID#_K" => GetMessage("authprov_sg_k")));
         if ($arGroup["GROUP_IMAGE_ID"]) {
             $imageFile = CFile::GetFileArray($arGroup["GROUP_IMAGE_ID"]);
             if ($imageFile !== false) {
                 $arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => 30, "height" => 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
                 $arItem["AVATAR"] = $arFileTmp["src"];
             }
         }
         $myElements .= CFinder::GetFinderItem($arFinderParams, $arItem);
     }
     $arPanels = array();
     if ($currElements != '') {
         $arPanels[] = array("NAME" => GetMessage("authprov_sg_current"), "ELEMENTS" => $currElements);
     }
     $arPanels[] = array("NAME" => GetMessage("authprov_sg_panel_last"), "ELEMENTS" => $elements);
     $arPanels[] = array("NAME" => GetMessage("authprov_sg_panel_my_group"), "ELEMENTS" => $myElements);
     $arPanels[] = array("NAME" => GetMessage("authprov_sg_panel_search"), "ELEMENTS" => CFinder::GetFinderItem(array("TYPE" => "text"), array("TEXT" => GetMessage("authprov_sg_panel_search_text"))), "SEARCH" => "Y");
     $html = CFinder::GetFinderAppearance($arFinderParams, $arPanels);
     return array("HTML" => $html, "SELECTED" => $currElements != '');
 }
Example #2
0
 public function GetFormHtml($arParams = false)
 {
     global $USER;
     if (is_array($arParams["other"]) && $arParams["other"]["disabled"] == "true") {
         return false;
     }
     $elements = "";
     $arFinderParams = array("PROVIDER" => "other", "TYPE" => 3);
     $arItem = array("ID" => "U" . $USER->GetID(), "AVATAR" => "/freetrix/js/main/core/images/access/avatar-user-auth.png", "NAME" => ($s = trim($USER->GetFormattedName(false, false))) != '' ? $s : $USER->GetLogin(), "DESC" => GetMessage("authprov_user_curr"));
     $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
     if (!is_array($arParams["other"]) || $arParams["other"]["disabled_cr"] != "true") {
         $arItem = array("ID" => "CR", "AVATAR" => "/freetrix/js/main/core/images/access/avatar-user-author.png", "NAME" => GetMessage("authprov_author"), "DESC" => GetMessage("authprov_author_desc"));
         $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
     }
     if (!is_array($arParams["other"]) || $arParams["other"]["disabled_g2"] != "true") {
         $arItem = array("ID" => "G2", "AVATAR" => "/freetrix/js/main/core/images/access/avatar-user-everyone.png", "NAME" => GetMessage("authprov_all"), "DESC" => GetMessage("authprov_all_desc"));
         $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
     }
     if (!is_array($arParams["other"]) || $arParams["other"]["disabled_au"] != "true") {
         $arItem = array("ID" => "AU", "AVATAR" => "/freetrix/js/main/core/images/access/avatar-user-auth.png", "NAME" => GetMessage("authprov_authorized"), "DESC" => GetMessage("authprov_authorized_desc"));
         $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
     }
     $arPanels = array(array("NAME" => GetMessage("authprov_other"), "ELEMENTS" => $elements, "SELECTED" => "Y"));
     $html = CFinder::GetFinderAppearance($arFinderParams, $arPanels);
     return array("HTML" => $html);
 }
Example #3
0
 public function GetFormHtml($arParams = false)
 {
     global $USER;
     if (!$USER->IsAuthorized()) {
         return false;
     }
     $elements = '';
     $arElement = array();
     $arElements = array();
     $arLRU = CAccess::GetLastRecentlyUsed($this->id);
     if (!empty($arLRU)) {
         $arFinderParams = array('PROVIDER' => $this->id, 'TYPE' => 3);
         $arLast = array();
         $arLastID = array();
         foreach ($arLRU as $val) {
             if (substr($val, 0, 2) == 'DR') {
                 $id = substr($val, 2);
                 $arLast['DR'][] = $id;
                 $arLastID[$id] = $id;
             } else {
                 if (substr($val, 0, 1) == 'D') {
                     $id = substr($val, 1);
                     $arLast['D'][] = $id;
                     $arLastID[$id] = $id;
                 } else {
                     if (substr($val, 0, 2) == 'IU') {
                         $arLast['U'][] = substr($val, 2);
                     }
                 }
             }
         }
         $dbRes = CIBlockSection::GetList(array('ID' => 'ASC'), array('IBLOCK_ID' => COption::GetOptionInt('intranet', 'iblock_structure'), 'ID' => $arLastID), false, array('ID', 'NAME'));
         while ($arSection = $dbRes->Fetch()) {
             $arElement[$arSection['ID']] = $arSection;
         }
         if (!empty($arLast['DR'])) {
             foreach ($arLast['DR'] as $value) {
                 $arItem = array("ID" => 'DR' . $arElement[$value]['ID'], "NAME" => $arElement[$value]['NAME'] . ': ' . GetMessage("authprov_check_dr"), "AVATAR" => '/bitrix/js/main/core/images/access/avatar-user-everyone.png');
                 $arElements['DR' . $value] = CFinder::GetFinderItem($arFinderParams, $arItem);
             }
         }
         if (!empty($arLast['D'])) {
             foreach ($arLast['D'] as $value) {
                 $arItem = array("ID" => 'D' . $arElement[$value]['ID'], "NAME" => $arElement[$value]['NAME'] . ': ' . GetMessage("authprov_check_d"), "AVATAR" => '/bitrix/js/main/core/images/access/avatar-user-everyone.png');
                 $arElements['D' . $value] = CFinder::GetFinderItem($arFinderParams, $arItem);
             }
         }
         if (!empty($arLast['U'])) {
             //be careful with field list because of CUser::FormatName()
             $res = CUser::GetList($by = "LAST_NAME", $order = "asc", array("ID" => implode("|", $arLast['U'])), array("FIELDS" => array('ID', 'NAME', 'LAST_NAME', 'SECOND_NAME', 'LOGIN', 'EMAIL', 'PERSONAL_PHOTO', 'PERSONAL_GENDER', 'WORK_POSITION', 'PERSONAL_PROFESSION')));
             while ($arUser = $res->Fetch()) {
                 $arPhoto = array('IMG' => '');
                 if (!$arUser['PERSONAL_PHOTO']) {
                     switch ($arUser['PERSONAL_GENDER']) {
                         case "M":
                             $suffix = "male";
                             break;
                         case "F":
                             $suffix = "female";
                             break;
                         default:
                             $suffix = "unknown";
                     }
                     $arUser['PERSONAL_PHOTO'] = COption::GetOptionInt("socialnetwork", "default_user_picture_" . $suffix, false, SITE_ID);
                 }
                 if ($arUser['PERSONAL_PHOTO'] > 0) {
                     $arPhoto = CIntranetUtils::InitImage($arUser['PERSONAL_PHOTO'], 30);
                 }
                 $arItem = array("ID" => "IU" . $arUser["ID"], "NAME" => CUser::FormatName(CSite::GetNameFormat(false), $arUser, true, false), "AVATAR" => $arPhoto['CACHE']['src'], "DESC" => $arUser['WORK_POSITION'] ? $arUser['WORK_POSITION'] : $arUser['PERSONAL_PROFESSION']);
                 $elements .= CFinder::GetFinderItem($arFinderParams, $arItem);
             }
         }
         foreach ($arLRU as $val) {
             $elements .= $arElements[$val];
         }
     }
     $arFinderParams = array('PROVIDER' => 'intranet', 'TYPE' => 'structure');
     $obCache = new CPHPCache();
     $IBlockID = COption::GetOptionInt('intranet', 'iblock_structure');
     $arSecFilter = array('IBLOCK_ID' => $IBlockID);
     $arStructure = array();
     $arSections = array();
     if (!CModule::IncludeModule('extranet') || CExtranet::IsIntranetUser()) {
         $cache_id = md5(serialize($arSecFilter));
         $cacheDir = '/intranet';
         if ($obCache->InitCache(30 * 86400, $cache_id, $cacheDir)) {
             $vars = $obCache->GetVars();
             $arSections = $vars["SECTIONS"];
             $arStructure = $vars["STRUCTURE"];
         } elseif ($obCache->StartDataCache()) {
             global $CACHE_MANAGER;
             $CACHE_MANAGER->StartTagCache($cacheDir);
             $CACHE_MANAGER->RegisterTag("iblock_id_" . $IBlockID);
             $dbRes = CIBlockSection::GetTreeList($arSecFilter);
             while ($arRes = $dbRes->Fetch()) {
                 $iblockSectionID = intval($arRes['IBLOCK_SECTION_ID']);
                 if (!is_array($arStructure[$iblockSectionID])) {
                     $arStructure[$iblockSectionID] = array($arRes['ID']);
                 } else {
                     $arStructure[$iblockSectionID][] = $arRes['ID'];
                 }
                 $arSections[$arRes['ID']] = $arRes;
             }
             $CACHE_MANAGER->EndTagCache();
             $obCache->EndDataCache(array("SECTIONS" => $arSections, "STRUCTURE" => $arStructure));
         }
     }
     if ((!is_array($arParams["extranet"]) || $arParams["extranet"]["disabled"] != "true") && CModule::IncludeModule('extranet')) {
         $arStructure[0][] = "extranet";
         $arSections["extranet"] = array("ID" => "extranet", "NAME" => GetMessage("authprov_group_extranet"));
     }
     $arItem = self::InEmployeeDrawStructure($arStructure, $arSections, 0);
     $elementsStructure = CFinder::GetFinderItem($arFinderParams, $arItem);
     $arPanels = array(array("NAME" => GetMessage("authprov_panel_last"), "ELEMENTS" => $elements), array("NAME" => GetMessage("authprov_panel_group"), "ELEMENTS" => $elementsStructure), array("NAME" => GetMessage("authprov_panel_search"), "ELEMENTS" => CFinder::GetFinderItem(array("TYPE" => "text"), array("TEXT" => GetMessage("authprov_panel_search_text"))), "SEARCH" => "Y"));
     $html = CFinder::GetFinderAppearance($arFinderParams, $arPanels);
     return array("HTML" => $html);
 }