當前位置: 首頁>>代碼示例>>PHP>>正文


PHP CSocNetFeaturesPerms::Add方法代碼示例

本文整理匯總了PHP中CSocNetFeaturesPerms::Add方法的典型用法代碼示例。如果您正苦於以下問題:PHP CSocNetFeaturesPerms::Add方法的具體用法?PHP CSocNetFeaturesPerms::Add怎麽用?PHP CSocNetFeaturesPerms::Add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CSocNetFeaturesPerms的用法示例。


在下文中一共展示了CSocNetFeaturesPerms::Add方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: SetPerm

 function SetPerm($featureID, $operation, $perm)
 {
     $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
     $featureID = IntVal($featureID);
     $operation = Trim($operation);
     $perm = Trim($perm);
     $dbResult = CSocNetFeaturesPerms::GetList(array(), array("FEATURE_ID" => $featureID, "OPERATION_ID" => $operation), false, false, array("ID", "FEATURE_ENTITY_TYPE", "FEATURE_ENTITY_ID", "FEATURE_FEATURE", "OPERATION_ID", "ROLE"));
     if ($arResult = $dbResult->Fetch()) {
         $r = CSocNetFeaturesPerms::Update($arResult["ID"], array("ROLE" => $perm));
     } else {
         $r = CSocNetFeaturesPerms::Add(array("FEATURE_ID" => $featureID, "OPERATION_ID" => $operation, "ROLE" => $perm));
     }
     if (!$r) {
         $errorMessage = "";
         if ($e = $GLOBALS["APPLICATION"]->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) <= 0) {
             $errorMessage = GetMessage("SONET_GF_ERROR_SET") . ".";
         }
         $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_SET_RECORD");
         return false;
     } else {
         if (!$arResult) {
             $arFeature = CSocNetFeatures::GetByID($featureID);
             $entity_type = $arFeature["ENTITY_TYPE"];
             $entity_id = $arFeature["ENTITY_ID"];
             $feature = $arFeature["FEATURE"];
         } else {
             $entity_type = $arResult["FEATURE_ENTITY_TYPE"];
             $entity_id = $arResult["FEATURE_ENTITY_ID"];
             $feature = $arResult["FEATURE_FEATURE"];
         }
         if (empty($arResult) || $arResult["ROLE"] != $perm) {
             if ($arResult && $arResult["ROLE"] != $perm) {
                 CSocNetSearch::SetFeaturePermissions($entity_type, $entity_id, $feature, $arResult["OPERATION_ID"], $perm);
             } else {
                 CSocNetSearch::SetFeaturePermissions($entity_type, $entity_id, $feature, $operation, $perm);
             }
         }
         if (!in_array($feature, array("tasks", "files", "blog")) && is_array($arSocNetFeaturesSettings[$feature]["subscribe_events"])) {
             $arEventsTmp = array_keys($arSocNetFeaturesSettings[$feature]["subscribe_events"]);
             $rsLog = CSocNetLog::GetList(array(), array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => $arEventsTmp), false, false, array("ID", "EVENT_ID"));
             while ($arLog = $rsLog->Fetch()) {
                 CSocNetLogRights::DeleteByLogID($arLog["ID"]);
                 CSocNetLogRights::SetForSonet($arLog["ID"], $entity_type, $entity_id, $feature, $arSocNetFeaturesSettings[$feature]["subscribe_events"][$arLog["EVENT_ID"]]["OPERATION"]);
             }
         }
     }
     return $r;
 }
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:51,代碼來源:group_features_perms.php


注:本文中的CSocNetFeaturesPerms::Add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。