/** * 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'); } }
/** * Получить список преподавателей кафедры. * @param mixed $kaf один или массив ID кафедры * @param bool $named брать ли имена вместе с numst * @return array [id_kaf=>[numst=>name]] или [id_kaf=>[numst]] */ public static function prepsOfKaf($kaf, $named) { global $DB; $preps = array(); $kaf = RPU::arr($kaf); $MsSQL1 = RPDB::connect(); $STH = $MsSQL1->query("SELECT sh,id from kaf where id in(" . join(',', $kaf) . ")"); $kafs = array(); while ($row = $STH->fetch(PDO::FETCH_ASSOC)) { $kafs[$row['id']] = $row['sh']; } $MsSQL = RPDB::connect('iac'); if ($kafs) { foreach ($kafs as $_id => $kaf) { $STH = $MsSQL1->query("SELECT id_group from roles_groups where id_role='{$kaf}_pr'"); $gr_id = $STH->fetch(PDO::FETCH_ASSOC); if ($user_ids = CGroup::GetGroupUser($gr_id["id_group"])) { foreach ($user_ids as $user_id) { $rsUser = CUser::GetByID($user_id); $arUser = $rsUser->Fetch(); if ($arUser['ACTIVE'] == 'Y') { if (preg_match("/^[ut]?[0-9]{5,}/", trim($arUser['LOGIN']))) { $numst = trim($arUser['LOGIN'], "ut"); } else { $numst = -$user_id; } if ($named) { $preps[$_id][$numst] = trim($arUser['LAST_NAME']) . ' ' . trim($arUser['NAME']) . ' ' . trim($arUser['SECOND_NAME']); } else { $preps[$_id][$numst] = $numst; } } } } } $q = "select [Fam],[Name] as [Nam],[Otch],[Login] as [Numst],[NameEng] as gr FROM Students.dbo.RPK_Full_New "; $q_cond = array("[DepType]='Сотрудники'"); $q_cond[] = " [NameEng] IN('" . join("','", $kafs) . "')"; $q_cond[] = " [DepStatus]='У' "; if (count($q_cond) > 0) { $q .= " where " . join(' and ', $q_cond); } $q .= " order by [Fam],[Name],[Otch]"; if ($STH = $MsSQL->query($q)) { $kafs = array_flip($kafs); while ($temp = $STH->fetch(PDO::FETCH_ASSOC)) { $kaf = $kafs[$temp['gr']]; $numst = trim($temp['Numst']); if (!isset($preps[$kaf])) { $preps[$kaf] = array(); } if ($named) { $preps[$kaf][$numst] = trim($temp['Fam']) . ' ' . trim($temp['Nam']) . ' ' . trim($temp['Otch']); } else { $preps[$kaf][$numst] = $numst; } } } } return $preps; }
$this->AbortResultCache(); ShowError(GetMessage("IBLOCK_MODULE_NOT_INSTALLED")); return; } //Plug-in Blogs if (!CModule::IncludeModule("blog")) { $this->AbortResultCache(); ShowError(GetMessage("BLOG_MODULE_NOT_INSTALLED")); return; } //Get the number of participants $participantsCount = CUser::GetCount(); $arResult["PARTICIPANTS"] = $participantsCount; //Get the number of experts $groupId = $arParams["EXPERTS_GROUP"]; $arExperts = CGroup::GetGroupUser($groupId); //Alternative CGroup::GetList with SHOW_USERS_AMOUNT $arResult["EXPERTS"] = count($arExperts); //Get the number of questions $arFilter = array("IBLOCK_ID" => $arParams["QUESTIONS_IBLOCK_ID"], "ACTIVE" => "Y"); $arResult["QUESTIONS"] = CIBlockElement::GetList(array(), $arFilter, array(), false, array()); //Get the number of categoties $arFilter = array("IBLOCK_ID" => $arParams["CATEGORIES_IBLOCK_ID"], "ACTIVE" => "Y", "DEPTH_LEVEL" => 1); $arResult["CATEGORIES"] = CIBlockSection::GetCount($arFilter); //Get the number of work $arFilter = array("IBLOCK_ID" => $arParams["WORK_IBLOCK_ID"], "ACTIVE" => "Y"); $arResult["WORK"] = CIBlockElement::GetList(array(), $arFilter, array(), false, array()); //Get the number of comments $arFilter = array("BLOG_ID" => $arParams["BLOG_ID"]); $arResult["COMMENTS"] = CBlogComment::GetList(array(), $arFilter, array(), false, array()); //Plug-in tenplate