public static function createGroup($arFields) { if (!is_array($arFields)) { throw new Exception('Incorrect input data'); } foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "~" || substr($key, 0, 1) == "=") { unset($arFields[$key]); } } if (isset($arFields["IMAGE_ID"])) { unset($arFields["IMAGE_ID"]); } if (!is_set($arFields, "SITE_ID") || strlen($arFields["SITE_ID"]) <= 0) { $arFields["SITE_ID"] = array(SITE_ID); } if (!is_set($arFields, "SUBJECT_ID") || intval($arFields["SUBJECT_ID"]) <= 0) { $rsSubject = CSocNetGroupSubject::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arFields["SITE_ID"]), false, false, array("ID")); if ($arSubject = $rsSubject->Fetch()) { $arFields["SUBJECT_ID"] = $arSubject["ID"]; } } $groupID = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arFields, false); if ($groupID <= 0) { throw new Exception('Cannot create group'); } return $groupID; }
public static function createGroup($arFields) { if (!is_set($arFields, "SITE_ID") || strlen($arFields["SITE_ID"]) <= 0) $arFields["SITE_ID"] = array(SITE_ID); if (!is_set($arFields, "SUBJECT_ID") || intval($arFields["SUBJECT_ID"]) <= 0) { $rsSubject = CSocNetGroupSubject::GetList( array("SORT" => "ASC"), array("SITE_ID" => SITE_ID), false, false, array("ID") ); if ($arSubject = $rsSubject->Fetch()) $arFields["SUBJECT_ID"] = $arSubject["ID"]; } $groupID = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arFields, false); if($groupID <= 0) throw new Exception('Cannot create group'); return $groupID; }
public function Execute() { if (!CModule::IncludeModule("socialnetwork")) { return CBPActivityExecutionStatus::Closed; } $rootActivity = $this->GetRootActivity(); $documentId = $rootActivity->GetDocumentId(); $ownerId = CBPHelper::ExtractUsers($this->OwnerId, $documentId, true); $users = array_unique(CBPHelper::ExtractUsers($this->Users, $documentId, false)); $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => SITE_ID), false, false, array("ID")); $row = $dbSubjects->fetch(); if (!$row) { $this->WriteToTrackingService(GetMessage("BPCWG_ERROR_SUBJECT_ID")); return CBPActivityExecutionStatus::Closed; } $subjectId = $row['ID']; unset($dbSubjects, $row); $options = array("SITE_ID" => SITE_ID, "NAME" => $this->GroupName, "VISIBLE" => "Y", "OPENED" => "N", "CLOSED" => "N", "SUBJECT_ID" => $subjectId, "INITIATE_PERMS" => SONET_ROLES_OWNER, "SPAM_PERMS" => SONET_ROLES_USER); $groupId = CSocNetGroup::CreateGroup($ownerId, $options); if (!$groupId) { $this->WriteToTrackingService(GetMessage("BPCWG_ERROR_CREATE_GROUP")); return CBPActivityExecutionStatus::Closed; } $this->GroupId = $groupId; foreach ($users as $user) { if ($user == $ownerId) { continue; } CSocNetUserToGroup::Add(array("USER_ID" => $user, "GROUP_ID" => $groupId, "ROLE" => SONET_ROLES_USER, "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_GROUP, "INITIATED_BY_USER_ID" => $ownerId, "MESSAGE" => false)); } return CBPActivityExecutionStatus::Closed; }
function Add($arFields) { global $DB, $CACHE_MANAGER; $arFields1 = array(); foreach ($arFields as $key => $value) { if (substr($key, 0, 1) == "=") { $arFields1[substr($key, 1)] = $value; unset($arFields[$key]); } } if (!CSocNetGroupSubject::CheckFields("ADD", $arFields)) { return false; } else { $arSiteID = array(); if (array_key_exists("SITE_ID", $arFields)) { if (is_array($arFields["SITE_ID"])) { foreach ($arFields["SITE_ID"] as $site_id) { $arSiteID[$site_id] = $DB->ForSQL($site_id); } } else { $arSiteID[$arFields["SITE_ID"]] = $DB->ForSQL($arFields["SITE_ID"]); } } } if (empty($arSiteID)) { unset($arFields["SITE_ID"]); } else { $arFields["SITE_ID"] = end($arSiteID); } $arInsert = $DB->PrepareInsert("b_sonet_group_subject", $arFields); foreach ($arFields1 as $key => $value) { if (strlen($arInsert[0]) > 0) { $arInsert[0] .= ", "; } $arInsert[0] .= $key; if (strlen($arInsert[1]) > 0) { $arInsert[1] .= ", "; } $arInsert[1] .= $value; } $ID = false; if (strlen($arInsert[0]) > 0) { $strSql = "INSERT INTO b_sonet_group_subject(" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")"; $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__); $ID = IntVal($DB->LastID()); if ($ID > 0 && !empty($arSiteID)) { $DB->Query("\n\t\t\t\t\tDELETE FROM b_sonet_group_subject_site WHERE SUBJECT_ID = " . $ID . "\n\t\t\t\t", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); $DB->Query("\n\t\t\t\t\tINSERT INTO b_sonet_group_subject_site(SUBJECT_ID, SITE_ID)\n\t\t\t\t\tSELECT " . $ID . ", LID\n\t\t\t\t\tFROM b_lang\n\t\t\t\t\tWHERE LID IN ('" . implode("', '", $arSiteID) . "')\n\t\t\t\t", false, "FILE: " . __FILE__ . "<br> LINE: " . __LINE__); } if (CACHED_b_sonet_group_subjects != false) { $CACHE_MANAGER->CleanDir("b_sonet_group_subjects"); } } return $ID; }
} if (WIZARD_INSTALL_DEMO_DATA || WIZARD_FIRST_INSTAL !== "Y") { $arGroupSubjects = array(); $arGroupSubjectsId = array(); for ($i = 0; $i < 5; $i++) { $arGroupSubjects[$i] = array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_SUBJECT_" . $i)); $arGroupSubjectsId[$i] = 0; } $errorMessage = ""; foreach ($arGroupSubjects as $ind => $arGroupSubject) { $rsSocNetGroupSubject = CSocNetGroupSubject::GetList(array(), $arGroupSubject); $idTmp = false; if ($arSocNetGroupSubject = $rsSocNetGroupSubject->Fetch()) { $arGroupSubjectsId[$ind] = $arSocNetGroupSubject["ID"]; } else { $idTmp = CSocNetGroupSubject::Add($arGroupSubject); if ($idTmp) { $arGroupSubjectsId[$ind] = IntVal($idTmp); } else { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $errorMessage .= $e->GetString(); } } } } if (StrLen($errorMessage) <= 0) { $pathToImages = WIZARD_SERVICE_ABSOLUTE_PATH . "/images/"; $arGroupsId = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0); $arGroups = array(0 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_0"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_0"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[1], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_0"), "IMAGE_ID" => array("name" => "0.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/0.jpg", "error" => "0", "size" => @filesize($pathToImages . "/0.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 1 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_1"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_1"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[0], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_1"), "IMAGE_ID" => array("name" => "1.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/1.jpg", "error" => "0", "size" => @filesize($pathToImages . "/1.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 2 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_2"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_2"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[0], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_2"), "IMAGE_ID" => array("name" => "2.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/2.jpg", "error" => "0", "size" => @filesize($pathToImages . "/2.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "E", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 3 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_3"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_3"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "Y", "SUBJECT_ID" => $arGroupSubjectsId[4], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_3"), "IMAGE_ID" => array("name" => "3.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/3.jpg", "error" => "0", "size" => @filesize($pathToImages . "/3.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "K", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 4 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_4"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_4"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[2], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_4"), "IMAGE_ID" => array("name" => "4.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/4.jpg", "error" => "0", "size" => @filesize($pathToImages . "/4.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "E", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 5 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_5"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_5"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[2], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_5"), "IMAGE_ID" => array("name" => "5.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/5.jpg", "error" => "0", "size" => @filesize($pathToImages . "/5.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 6 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_6"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_6"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "Y", "SUBJECT_ID" => $arGroupSubjectsId[4], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_6"), "IMAGE_ID" => array("name" => "6.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/6.jpg", "error" => "0", "size" => @filesize($pathToImages . "/6.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "K", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 7 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_7"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_7"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[1], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_7"), "IMAGE_ID" => array("name" => "7.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/7.jpg", "error" => "0", "size" => @filesize($pathToImages . "/7.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 8 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_8"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_8"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_8"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 9 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_9"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_9"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_9"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 10 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_10"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_10"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_10"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction())); foreach ($arGroups as $ind => $arGroup) { $dbSubject = CSocNetGroup::GetList(array(), array("NAME" => $arGroup["NAME"], "SITE_ID" => WIZARD_SITE_ID));
$arResult["FatalError"] = GetMessage("SONET_C36_NO_USER_ID") . ". "; } elseif ($user2Request == $user4Groups) { $arResult["FatalError"] = GetMessage("SONET_C36_SELF") . ". "; } } } if (strlen($arResult["FatalError"]) <= 0) { if ($arParams["PAGE"] == "groups_list") { $arResult["Subjects"] = array(); $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => SITE_ID), false, false, array("ID", "NAME")); while ($arSubject = $dbSubjects->GetNext()) { $arResult["Subjects"][$arSubject["ID"]] = $arSubject["NAME"]; } } elseif ($arParams["PAGE"] == "groups_subject" && intval($arResult["filter_subject_id"]) > 0) { $arResult["Subjects"] = array(); $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => SITE_ID, "ID" => intval($arResult["filter_subject_id"])), false, false, array("ID", "NAME")); if ($arSubject = $dbSubjects->GetNext()) { $arResult["Subject"] = $arSubject; } } } if (StrLen($arResult["FatalError"]) <= 0 && intval($user4Groups) > 0) { $dbUser = CUser::GetByID($user4Groups); $arResult["User"] = $dbUser->GetNext(); if (!is_array($arResult["User"])) { $arResult["FatalError"] = GetMessage("SONET_P_USER_NO_USER") . ". "; } if (CModule::IncludeModule('extranet') && !CExtranet::IsProfileViewable($arResult["User"])) { return false; } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } if (CModule::IncludeModule("socialnetwork")) { $arSubjects = array(); $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => SITE_ID), false, false, array("ID", "NAME")); while ($arSubjectTmp = $dbSubjects->GetNext()) { $arSubjects[$arSubjectTmp["ID"]] = $arSubjectTmp["NAME"]; } ?> <div class="rounded-block"> <div class="corner left-top"></div><div class="corner right-top"></div> <div class="block-content"> <h3>Quick Search</h3> <div class="filter-box filter-people"> <form method="get" action="#SITE_DIR#groups/" class="bx-selector-form filter-form"> <input type="hidden" name="page" value="group_search"> <?php if ($_REQUEST["how"] == "d") { ?> <input type="hidden" name="how" value="d"> <?php } ?> <div class="filter-item filter-name"> <label for="filter-name"><span class="required-field">*</span>Search:</label> <input type="text" id="filter-name" name="q" class="filter-textbox" value="<?php echo htmlspecialcharsbx(trim($_REQUEST["q"])); ?>
/** * <p>Возвращает параметры темы. Не порождает запросов к базе данных.</p> * * * @param int $id Код темы.</bod * * @return array <p>Массив параметров темы. Массив имеет ключи:<br><b>ID</b> - код * темы,<br><b>SITE_ID</b> - код сайта,<br><b>NAME</b> - название. </p> <br><br> * * @static * @link http://dev.1c-bitrix.ru/api_help/socialnetwork/classes/csocnetgroupsubject/GetByID.php * @author Bitrix */ public static function GetByID($ID) { global $DB; if (!CSocNetGroup::__ValidateID($ID)) { return false; } $ID = IntVal($ID); $dbResult = CSocNetGroupSubject::GetList(array(), array("ID" => $ID)); if ($arResult = $dbResult->GetNext()) { return $arResult; } return False; }
function CheckFields($ACTION, &$arFields, $ID = 0) { global $DB, $arSocNetAllowedInitiatePerms, $arSocNetAllowedSpamPerms; if ($ACTION != "ADD" && IntVal($ID) <= 0) { $GLOBALS["APPLICATION"]->ThrowException("System error 870164", "ERROR"); return false; } if ($ID === 0 && !is_set($arFields, "SITE_ID") || is_set($arFields, "SITE_ID") && (is_array($arFields["SITE_ID"]) && count($arFields["SITE_ID"]) <= 0 || !is_array($arFields["SITE_ID"]) && strlen($arFields["SITE_ID"]) <= 0)) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GG_EMPTY_SITE_ID"), "EMPTY_SITE_ID"); return false; } elseif (is_set($arFields, "SITE_ID")) { if (!is_array($arFields["SITE_ID"])) { $arFields["SITE_ID"] = array($arFields["SITE_ID"]); } foreach ($arFields["SITE_ID"] as $v) { $r = CSite::GetByID($v); if (!$r->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $v, GetMessage("SONET_GG_ERROR_NO_SITE")), "ERROR_NO_SITE"); return false; } } } if ((is_set($arFields, "NAME") || $ACTION == "ADD") && strlen($arFields["NAME"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_NAME"), "EMPTY_NAME"); return false; } if (is_set($arFields, "DATE_CREATE") && !$DB->IsDate($arFields["DATE_CREATE"], false, LANG, "FULL")) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_CREATE"), "EMPTY_DATE_CREATE"); return false; } if (is_set($arFields, "DATE_UPDATE") && !$DB->IsDate($arFields["DATE_UPDATE"], false, LANG, "FULL")) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_UPDATE"), "EMPTY_DATE_UPDATE"); return false; } if (is_set($arFields, "DATE_ACTIVITY") && !$DB->IsDate($arFields["DATE_ACTIVITY"], false, LANG, "FULL")) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_DATE_ACTIVITY"), "EMPTY_DATE_ACTIVITY"); return false; } if ((is_set($arFields, "OWNER_ID") || $ACTION == "ADD") && IntVal($arFields["OWNER_ID"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_OWNER_ID"), "EMPTY_OWNER_ID"); return false; } elseif (is_set($arFields, "OWNER_ID")) { $dbResult = CUser::GetByID($arFields["OWNER_ID"]); if (!$dbResult->Fetch()) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_ERROR_NO_OWNER_ID"), "ERROR_NO_OWNER_ID"); return false; } } if ((is_set($arFields, "SUBJECT_ID") || $ACTION == "ADD") && IntVal($arFields["SUBJECT_ID"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_EMPTY_SUBJECT_ID"), "EMPTY_SUBJECT_ID"); return false; } elseif (is_set($arFields, "SUBJECT_ID")) { $arResult = CSocNetGroupSubject::GetByID($arFields["SUBJECT_ID"]); if ($arResult == false) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GB_ERROR_NO_SUBJECT_ID"), "ERROR_NO_SUBJECT_ID"); return false; } } if ((is_set($arFields, "ACTIVE") || $ACTION == "ADD") && $arFields["ACTIVE"] != "Y" && $arFields["ACTIVE"] != "N") { $arFields["ACTIVE"] = "Y"; } if ((is_set($arFields, "VISIBLE") || $ACTION == "ADD") && $arFields["VISIBLE"] != "Y" && $arFields["VISIBLE"] != "N") { $arFields["VISIBLE"] = "Y"; } if ((is_set($arFields, "OPENED") || $ACTION == "ADD") && $arFields["OPENED"] != "Y" && $arFields["OPENED"] != "N") { $arFields["OPENED"] = "N"; } if ((is_set($arFields, "CLOSED") || $ACTION == "ADD") && $arFields["CLOSED"] != "Y" && $arFields["CLOSED"] != "N") { $arFields["CLOSED"] = "N"; } if ((is_set($arFields, "INITIATE_PERMS") || $ACTION == "ADD") && strlen($arFields["INITIATE_PERMS"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_EMPTY_INITIATE_PERMS"), "EMPTY_INITIATE_PERMS"); return false; } elseif (is_set($arFields, "INITIATE_PERMS") && !in_array($arFields["INITIATE_PERMS"], $arSocNetAllowedInitiatePerms)) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["INITIATE_PERMS"], GetMessage("SONET_UG_ERROR_NO_INITIATE_PERMS")), "ERROR_NO_INITIATE_PERMS"); return false; } if ((is_set($arFields, "SPAM_PERMS") || $ACTION == "ADD") && strlen($arFields["SPAM_PERMS"]) <= 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UG_EMPTY_SPAM_PERMS"), "EMPTY_SPAM_PERMS"); return false; } elseif (is_set($arFields, "SPAM_PERMS") && !in_array($arFields["SPAM_PERMS"], $arSocNetAllowedSpamPerms)) { $GLOBALS["APPLICATION"]->ThrowException(str_replace("#ID#", $arFields["SPAM_PERMS"], GetMessage("SONET_UG_ERROR_NO_SPAM_PERMS")), "ERROR_NO_SPAM_PERMS"); return false; } if (is_set($arFields, "IMAGE_ID") && strlen($arFields["IMAGE_ID"]["name"]) <= 0 && (strlen($arFields["IMAGE_ID"]["del"]) <= 0 || $arFields["IMAGE_ID"]["del"] != "Y")) { unset($arFields["IMAGE_ID"]); } if (is_set($arFields, "IMAGE_ID")) { $arResult = CFile::CheckImageFile($arFields["IMAGE_ID"], 0, 0, 0); if (strlen($arResult) > 0) { $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GP_ERROR_IMAGE_ID") . ": " . $arResult, "ERROR_IMAGE_ID"); return false; } } if (!$GLOBALS["USER_FIELD_MANAGER"]->CheckFields("SONET_GROUP", $ID, $arFields)) { return false; } return True; }
$DB->Commit(); break; } } } $dbResultList = CSocNetGroup::GetList(array($by => $order), $arFilter, false, false, array("ID", "SUBJECT_ID", "NAME", "SITE_ID", "OWNER_ID")); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->AddHeaders($arHeaders); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SONET_GROUP_NAV"))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); $arSubjects = array(); $arSubjectsBySite = array(); $dbSitesList = CSite::GetList($b = "sort", $o = "asc"); while ($arSite = $dbSitesList->Fetch()) { $dbSubjectsList = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "ID" => "DESC"), array("SITE_ID" => $arSite["LID"])); while ($arSubject = $dbSubjectsList->Fetch()) { $str = "[" . $arSite["LID"] . "] " . $arSubject["NAME"]; $arSubjectsBySite[$arSite["LID"]][$arSubject["ID"]] = $str; if (!array_key_exists($arSubject["ID"], $arSubjects)) { $arSubjects[$arSubject["ID"]] = $str; } } } while ($arGroup = $dbResultList->NavNext(true, "f_")) { $arMembers = array(); $arResult["Users"] = false; $dbRequests = CSocNetUserToGroup::GetList(array("USER_LAST_NAME" => "ASC", "USER_NAME" => "ASC"), array("GROUP_ID" => $arGroup["ID"], "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("ID", "USER_ID", "ROLE", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN")); while ($arRequests = $dbRequests->Fetch()) { $arTmpUser = array("ID" => $arRequests["USER_ID"], "NAME" => $arRequests["USER_NAME"], "LAST_NAME" => $arRequests["USER_LAST_NAME"], "LOGIN" => $arRequests["USER_LOGIN"]); $arMembers[$arRequests["USER_ID"]] = CUser::FormatName(GetMessage("USER_NAME_TEMPLATE"), $arTmpUser, true, false);
public static function RequestToSonetGroups($arUserId, $arGroupCode, $arGroupName, $bExtranetUser = false) { $arGroupToAdd = array(); $strError = false; if (!is_array($arUserId)) { $arUserId = array($arUserId); } if (is_array($arGroupCode) && !empty($arGroupCode) && CModule::IncludeModule("socialnetwork")) { foreach ($arGroupCode as $group_code) { if ($bExtranetUser && preg_match('/^(SGN\\d+)$/', $group_code, $match) && is_array($arGroupName) && isset($arGroupName[$match[1]]) && strlen($arGroupName[$match[1]]) > 0 && CModule::IncludeModule("extranet") && (CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false) || $GLOBALS["APPLICATION"]->GetGroupRight("socialnetwork", false, "Y", "Y", array(CExtranet::GetExtranetSiteID(), false)) >= "K")) { // check and create group, for extranet only $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => CExtranet::GetExtranetSiteID()), false, false, array("ID")); if ($arSubject = $dbSubjects->GetNext()) { $arSocNetGroupFields = array("NAME" => $arGroupName[$match[1]], "DESCRIPTION" => "", "VISIBLE" => "N", "OPENED" => "N", "CLOSED" => "N", "SUBJECT_ID" => $arSubject["ID"], "INITIATE_PERMS" => "E", "SPAM_PERMS" => "K", "SITE_ID" => array($SITE_ID, CExtranet::GetExtranetSiteID())); if ($group_id = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arSocNetGroupFields, false)) { $arGroupToAdd[] = $group_id; } elseif ($e = $GLOBALS["APPLICATION"]->GetException()) { $strError = $e->GetString(); } } } elseif (preg_match('/^SG(\\d+)$/', $group_code, $match)) { $group_id = $match[1]; if (($arGroup = CSocNetGroup::GetByID($group_id)) && ($arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arGroup, CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false))) && $arCurrentUserPerms["UserCanInitiate"] && $arGroup["CLOSED"] != "Y") { $arGroupToAdd[] = $group_id; } } } if (!$strError) { foreach ($arGroupToAdd as $group_id) { foreach ($arUserId as $user_id) { if (!CSocNetUserToGroup::SendRequestToJoinGroup($GLOBALS["USER"]->GetID(), $user_id, $group_id, "", false)) { if ($e = $GLOBALS["APPLICATION"]->GetException()) { $strError .= $e->GetString(); } } } } } } return $strError; }
} require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_after.php"; ClearVars("str_"); $str_SORT = "100"; $arSubjectSites = array(); if ($ID > 0) { $arSubject = CSocNetGroupSubject::GetByID($ID); if (!$arSubject) { if ($socialnetworkModulePermissions < "W") { $errorMessage .= GetMessage("SONETE_NO_PERMS2ADD") . ". "; } $ID = 0; } else { $str_NAME = $arSubject["NAME"]; $str_SORT = $arSubject["SORT"]; $rsSubjectSite = CSocNetGroupSubject::GetSite($ID); while ($arSubjectSite = $rsSubjectSite->Fetch()) { $arSubjectSites[] = $arSubjectSite["LID"]; } } } if ($bVarsFromForm) { $DB->InitTableVarsForEdit("b_sonet_group_subject", "", "str_"); } ?> <?php $aMenu = array(array("TEXT" => GetMessage("SONETE_2FLIST"), "ICON" => "btn_list", "LINK" => "/bitrix/admin/socnet_subject.php?lang=" . LANG . "&" . GetFilterParams("filter_", false))); if ($ID > 0 && $socialnetworkModulePermissions >= "W") { $aMenu[] = array("SEPARATOR" => "Y"); $aMenu[] = array("TEXT" => GetMessage("SONETE_NEW_SUBJECT"), "ICON" => "btn_new", "LINK" => "/bitrix/admin/socnet_subject_edit.php?lang=" . LANG . "&" . GetFilterParams("filter_", false));
$lAdmin->AddGroupError(GetMessage("SONET_DELETE_ERROR"), $ID); } } $DB->Commit(); break; } } } $dbResultList = CSocNetGroup::GetList(array($by => $order), $arFilter, false, false, array("ID", "SUBJECT_ID", "NAME", "SITE_ID", "OWNER_ID")); $dbResultList = new CAdminResult($dbResultList, $sTableID); $dbResultList->NavStart(); $lAdmin->NavText($dbResultList->GetNavPrint(GetMessage("SONET_GROUP_NAV"))); $lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "NAME", "content" => GetMessage("SONET_GROUP_NAME"), "sort" => "NAME", "default" => true), array("id" => "SUBJECT_ID", "content" => GetMessage('SONET_GROUP_SUBJECT_ID'), "sort" => "SUBJECT_ID", "default" => true), array("id" => "OWNER_ID", "content" => GetMessage('SONET_GROUP_OWNER_ID'), "sort" => "OWNER_ID", "default" => true))); $arVisibleColumns = $lAdmin->GetVisibleHeaderColumns(); $arSubjects = array(); $dbSubjectsList = CSocNetGroupSubject::GetList(); while ($arSubject = $dbSubjectsList->Fetch()) { $arSubjects[$arSubject["SITE_ID"]][$arSubject["ID"]] = "[" . $arSubject["SITE_ID"] . "] " . $arSubject["NAME"]; } while ($arGroup = $dbResultList->NavNext(true, "f_")) { $arMembers = array(); $arResult["Users"] = false; $dbRequests = CSocNetUserToGroup::GetList(array("USER_LAST_NAME" => "ASC", "USER_NAME" => "ASC"), array("GROUP_ID" => $arGroup["ID"], "<=ROLE" => SONET_ROLES_USER, "USER_ACTIVE" => "Y"), false, false, array("ID", "USER_ID", "ROLE", "USER_NAME", "USER_LAST_NAME", "USER_LOGIN")); while ($arRequests = $dbRequests->Fetch()) { $arTmpUser = array("ID" => $arRequests["USER_ID"], "NAME" => $arRequests["USER_NAME"], "LAST_NAME" => $arRequests["USER_LAST_NAME"], "LOGIN" => $arRequests["USER_LOGIN"]); $arMembers[$arRequests["USER_ID"]] = CUser::FormatName(GetMessage("USER_NAME_TEMPLATE"), $arTmpUser, true, false); } $row =& $lAdmin->AddRow($f_ID, $arGroup); $row->AddField("ID", $f_ID); $row->AddInputField("NAME", array("size" => "35")); $row->AddSelectField("SUBJECT_ID", $arSubjects[$arGroup["SITE_ID"]], array());