Пример #1
0
 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;
     }
     $features = array();
     $allowedFeatures = CSocNetAllowed::GetAllowedFeatures();
     foreach ($allowedFeatures as $feature => $arFeature) {
         if (is_array($arFeature["allowed"]) && in_array(SONET_ENTITY_GROUP, $arFeature["allowed"])) {
             $features[] = $feature;
         }
     }
     foreach ($features as $feature) {
         CSocNetFeatures::SetFeature(SONET_ENTITY_GROUP, $groupId, $feature, true);
     }
     $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;
 }
Пример #2
0
            $APPLICATION->RestartBuffer();
            ?>
<script type="text/javascript">
				top.BX.reload();
			</script><?php 
            die;
        } else {
            echo $errorMessage;
            die;
        }
    } elseif ($_SERVER['REQUEST_METHOD'] == 'POST' && array_key_exists("sm_action", $_REQUEST) && $_REQUEST["sm_action"] == "add" && check_bitrix_sessid()) {
        if (array_key_exists($_REQUEST["feature"], $arSocNetFeaturesSettings) && in_array($arParams["ENTITY_TYPE"], $arSocNetFeaturesSettings[$_REQUEST["feature"]]["allowed"]) || in_array($_REQUEST['feature'], $arStaticTabs)) {
            $dbResultTmp = CSocNetFeatures::GetList(array(), array("ENTITY_ID" => $arParams['ENTITY_ID'], "ENTITY_TYPE" => $arParams['ENTITY_TYPE'], "FEATURE" => $_REQUEST['feature']));
            $arResultTmp = $dbResultTmp->Fetch();
            if ($arResultTmp) {
                CSocNetFeatures::SetFeature($arParams['ENTITY_TYPE'] == SONET_ENTITY_GROUP ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams['ENTITY_ID'], $_REQUEST["feature"], true, $arResultTmp["FEATURE_NAME"]);
            }
            $arUserOptions = CUserOptions::GetOption("socialnetwork", "~menu_" . $arParams["ENTITY_TYPE"] . "_" . $arParams["ENTITY_ID"], false, 0);
            if (is_array($arUserOptions)) {
                $arUserOptions["FEATURES"][$_REQUEST["feature"]]["INDEX"] = count($arUserOptions["FEATURES"]);
            }
            CUserOptions::SetOption("socialnetwork", "~menu_" . $arParams["ENTITY_TYPE"] . "_" . $arParams["ENTITY_ID"], $arUserOptions, false, 0);
        } else {
            $errorMessage = GetMessage("SONET_SM_FEATURE_INCORRECT");
        }
        if (!$errorMessage) {
            $APPLICATION->RestartBuffer();
            ?>
<script type="text/javascript">
				top.BX.reload();
			</script><?php 
Пример #3
0
     }
 }
 if (strlen($errorMessage) <= 0 && array_key_exists("TAB", $arResult) && $arResult["TAB"] != "edit") {
     $arResult["GROUP_ID"] = $arParams["GROUP_ID"];
 }
 if (strlen($arImageID["tmp_name"]) > 0) {
     CFile::ResizeImageDeleteCache($arImageID);
 }
 if (strlen($errorMessage) > 0) {
     $arResult["ErrorMessage"] = $errorMessage;
     $arResult["bVarsFromForm"] = true;
 } elseif ($arResult["GROUP_ID"] > 0) {
     /* features */
     if (!array_key_exists("TAB", $arResult) || $arResult["TAB"] == "edit") {
         foreach ($arResult["POST"]["FEATURES"] as $feature => $arFeature) {
             $idTmp = CSocNetFeatures::SetFeature(SONET_ENTITY_GROUP, $arResult["GROUP_ID"], $feature, $_POST[$feature . "_active"] == "Y" ? true : false, strlen($arFeature["FeatureName"]) > 0 ? $arFeature["FeatureName"] : false);
             if (!$idTmp) {
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage .= $e->GetString();
                 }
             } else {
                 $bSecondStepSuccess = true;
             }
         }
     }
     /* invite */
     if (strlen($errorMessage) <= 0 && (!array_key_exists("TAB", $arResult) || $arResult["TAB"] == "invite")) {
         if (CModule::IncludeModule('extranet') && CModule::IncludeModule('intranet')) {
             if ($_POST["EXTRANET_INVITE_ACTION"] == "invite" && strlen($_POST["EMAILS"]) > 0) {
                 $arEmail = array();
                 $arIntranetUsersEmails = array();
Пример #4
0
     if ($arParams["PAGE_ID"] == "group_features") {
         $APPLICATION->AddChainItem($arResult["Group"]["NAME"], $arResult["Urls"]["Group"]);
         $APPLICATION->AddChainItem(GetMessage("SONET_C3_GROUP_SETTINGS"));
     } else {
         $APPLICATION->AddChainItem($strTitleFormatted, $arResult["Urls"]["User"]);
         $APPLICATION->AddChainItem(GetMessage("SONET_C3_USER_SETTINGS"));
     }
 }
 $arResult["ShowForm"] = "Input";
 if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["save"]) > 0 && check_bitrix_sessid()) {
     $errorMessage = "";
     foreach ($arResult["Features"] as $feature => $arFeature) {
         if ($feature == "blog" && $arParams["PAGE_ID"] != "group_features") {
             $_REQUEST["blog_active"] = "Y";
         }
         $idTmp = CSocNetFeatures::SetFeature($arParams["PAGE_ID"] == "group_features" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER, $arParams["PAGE_ID"] == "group_features" ? $arResult["Group"]["ID"] : $arResult["User"]["ID"], $feature, $_REQUEST[$feature . "_active"] == "Y" ? true : false, StrLen($_REQUEST[$feature . "_name"]) > 0 ? $_REQUEST[$feature . "_name"] : false);
         if ($idTmp && $_REQUEST[$feature . "_active"] == "Y" && (!array_key_exists("hide_operations_settings", $GLOBALS["arSocNetFeaturesSettings"][$feature]) || !$GLOBALS["arSocNetFeaturesSettings"][$feature]["hide_operations_settings"])) {
             foreach ($arFeature["Operations"] as $operation => $perm) {
                 if (!array_key_exists("restricted", $GLOBALS["arSocNetFeaturesSettings"][$feature]["operations"][$operation]) || !in_array($key, $GLOBALS["arSocNetFeaturesSettings"][$feature]["operations"][$operation]["restricted"][$arParams["PAGE_ID"] == "group_features" ? SONET_ENTITY_GROUP : SONET_ENTITY_USER])) {
                     $id1Tmp = CSocNetFeaturesPerms::SetPerm($idTmp, $operation, $_REQUEST[$feature . "_" . $operation . "_perm"]);
                     if (!$id1Tmp && ($e = $APPLICATION->GetException())) {
                         $errorMessage .= $e->GetString();
                     }
                 }
             }
         } elseif ($e = $APPLICATION->GetException()) {
             $errorMessage .= $e->GetString();
         }
     }
     if (strlen($errorMessage) > 0) {
         $arResult["ErrorMessage"] = $errorMessage;