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


PHP CSocNetGroup::GetDefaultSiteId方法代碼示例

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


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

示例1: SetOwner

 function SetOwner($userID, $groupID, $arGroup = false)
 {
     global $DB, $APPLICATION, $USER;
     if (!$arGroup) {
         $arGroup = CSocNetGroup::GetByID($groupID);
     }
     if (!$arGroup) {
         return false;
     }
     $DB->StartTransaction();
     // setting relations for the old owner
     $dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $arGroup["OWNER_ID"], "GROUP_ID" => $groupID), false, false, array("ID"));
     if ($arRelation = $dbRelation->Fetch()) {
         $arFields = array("ROLE" => SONET_ROLES_USER, "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID());
         if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields)) {
             $errorMessage = "";
             if ($e = $APPLICATION->GetException()) {
                 $errorMessage = $e->GetString();
             }
             if (StrLen($errorMessage) <= 0) {
                 $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_CURRENT_OWNER");
             }
             $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
             $DB->Rollback();
             return false;
         }
     } else {
         $errorMessage = "";
         if ($e = $APPLICATION->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) <= 0) {
             $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_GET_CURRENT_OWNER_RELATION");
         }
         $APPLICATION->ThrowException($errorMessage, "ERROR_GET_USER2GROUP");
         $DB->Rollback();
         return false;
     }
     // delete requests to the old owner
     if (strlen($errorMessage) <= 0) {
         CSocNetUserToGroup::__SpeedFileDelete($arGroup["OWNER_ID"]);
     }
     if (strlen($errorMessage) <= 0) {
         // setting relations for the new owner
         $dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $userID, "GROUP_ID" => $groupID), false, false, array("ID"));
         if ($arRelation = $dbRelation->Fetch()) {
             $arFields = array("ROLE" => SONET_ROLES_OWNER, "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID());
             if (!CSocNetUserToGroup::Update($arRelation["ID"], $arFields)) {
                 $errorMessage = "";
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage = $e->GetString();
                 }
                 if (StrLen($errorMessage) <= 0) {
                     $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_NEW_OWNER_RELATION");
                 }
                 $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_USER2GROUP");
                 $DB->Rollback();
                 return false;
             }
         } else {
             $arFields = array("USER_ID" => $userID, "GROUP_ID" => $groupID, "ROLE" => SONET_ROLES_OWNER, "=DATE_CREATE" => $DB->CurrentTimeFunction(), "=DATE_UPDATE" => $DB->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $USER->GetID(), "MESSAGE" => false);
             if (!CSocNetUserToGroup::Add($arFields)) {
                 $errorMessage = "";
                 if ($e = $APPLICATION->GetException()) {
                     $errorMessage = $e->GetString();
                 }
                 if (StrLen($errorMessage) <= 0) {
                     $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_ADD_NEW_OWNER_RELATION");
                 }
                 $APPLICATION->ThrowException($errorMessage, "ERROR_ADD_USER2GROUP");
                 $DB->Rollback();
                 return false;
             }
         }
     }
     if (strlen($errorMessage) <= 0) {
         $GROUP_ID = CSocNetGroup::Update($groupID, array("OWNER_ID" => $userID));
         if (!$GROUP_ID || IntVal($GROUP_ID) <= 0) {
             $errorMessage = "";
             if ($e = $APPLICATION->GetException()) {
                 $errorMessage = $e->GetString();
             }
             if (StrLen($errorMessage) <= 0) {
                 $errorMessage = GetMessage("SONET_UG_ERROR_CANNOT_UPDATE_GROUP");
             }
             $APPLICATION->ThrowException($errorMessage, "ERROR_UPDATE_GROUP");
             $DB->Rollback();
             return false;
         }
     }
     if (CModule::IncludeModule("im")) {
         $bIMIncluded = true;
         $groupSiteId = CSocNetGroup::GetDefaultSiteId($groupID, $arGroup["SITE_ID"]);
         $workgroupsPage = COption::GetOptionString("socialnetwork", "workgroups_page", "/workgroups/", $groupSiteId);
         $groupUrlTemplate = COption::GetOptionString("socialnetwork", "group_path_template", "/workgroups/group/#group_id#/", $groupSiteId);
         $groupUrlTemplate = "#GROUPS_PATH#" . substr($groupUrlTemplate, strlen($workgroupsPage), strlen($groupUrlTemplate) - strlen($workgroupsPage));
         $groupUrl = str_replace(array("#group_id#", "#GROUP_ID#"), $groupID, $groupUrlTemplate);
     }
     // send message to the old owner
     if ($bIMIncluded) {
//.........這裏部分代碼省略.........
開發者ID:DarneoStudio,項目名稱:bitrix,代碼行數:101,代碼來源:user_group.php


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