本文整理汇总了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) {
//.........这里部分代码省略.........