当前位置: 首页>>代码示例>>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;未经允许,请勿转载。