本文整理汇总了PHP中CSocNetGroup::CreateGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetGroup::CreateGroup方法的具体用法?PHP CSocNetGroup::CreateGroup怎么用?PHP CSocNetGroup::CreateGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetGroup
的用法示例。
在下文中一共展示了CSocNetGroup::CreateGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGroup
public static function createGroup($arFields)
{
if (!is_set($arFields, "SITE_ID") || strlen($arFields["SITE_ID"]) <= 0)
$arFields["SITE_ID"] = array(SITE_ID);
if (!is_set($arFields, "SUBJECT_ID") || intval($arFields["SUBJECT_ID"]) <= 0)
{
$rsSubject = CSocNetGroupSubject::GetList(
array("SORT" => "ASC"),
array("SITE_ID" => SITE_ID),
false,
false,
array("ID")
);
if ($arSubject = $rsSubject->Fetch())
$arFields["SUBJECT_ID"] = $arSubject["ID"];
}
$groupID = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arFields, false);
if($groupID <= 0)
throw new Exception('Cannot create group');
return $groupID;
}
示例2: createGroup
public static function createGroup($arFields)
{
if (!is_array($arFields)) {
throw new Exception('Incorrect input data');
}
foreach ($arFields as $key => $value) {
if (substr($key, 0, 1) == "~" || substr($key, 0, 1) == "=") {
unset($arFields[$key]);
}
}
if (isset($arFields["IMAGE_ID"])) {
unset($arFields["IMAGE_ID"]);
}
if (!is_set($arFields, "SITE_ID") || strlen($arFields["SITE_ID"]) <= 0) {
$arFields["SITE_ID"] = array(SITE_ID);
}
if (!is_set($arFields, "SUBJECT_ID") || intval($arFields["SUBJECT_ID"]) <= 0) {
$rsSubject = CSocNetGroupSubject::GetList(array("SORT" => "ASC"), array("SITE_ID" => $arFields["SITE_ID"]), false, false, array("ID"));
if ($arSubject = $rsSubject->Fetch()) {
$arFields["SUBJECT_ID"] = $arSubject["ID"];
}
}
$groupID = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arFields, false);
if ($groupID <= 0) {
throw new Exception('Cannot create group');
}
return $groupID;
}
示例3: Execute
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;
}
$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;
}
示例4: elseif
$arFields["OPENED"] = "N";
}
} elseif (CModule::IncludeModule("extranet") && CExtranet::IsExtranetSite()) {
$arFields["SITE_ID"] = array(SITE_ID, CSite::GetDefSite());
}
foreach ($arResult["GROUP_PROPERTIES"] as $field => $arUserField) {
if (array_key_exists($field, $_POST)) {
$arFields[$field] = $_POST[$field];
}
}
$USER_FIELD_MANAGER->EditFormAddFields("SONET_GROUP", $arFields);
if ($arParams["GROUP_ID"] <= 0) {
if (CModule::IncludeModule("extranet") && CExtranet::IsExtranetSite()) {
$arFields["SITE_ID"][] = CSite::GetDefSite();
}
$arResult["GROUP_ID"] = CSocNetGroup::CreateGroup($USER->GetID(), $arFields, $bAutoSubscribe);
if (!$arResult["GROUP_ID"]) {
if ($e = $APPLICATION->GetException()) {
$errorMessage .= $e->GetString();
$errorID = $e->GetID();
if (strlen($errorID) > 0) {
$arResult["ErrorFields"][] = $errorID;
}
}
} else {
$bFirstStepSuccess = true;
}
} else {
$arFields["=DATE_UPDATE"] = $DB->CurrentTimeFunction();
$arFields["=DATE_ACTIVITY"] = $DB->CurrentTimeFunction();
$arResult["GROUP_ID"] = CSocNetGroup::Update($arParams["GROUP_ID"], $arFields, $bAutoSubscribe);
示例5: RequestToSonetGroups
public static function RequestToSonetGroups($arUserId, $arGroupCode, $arGroupName, $bExtranetUser = false)
{
$arGroupToAdd = array();
$strError = false;
if (!is_array($arUserId)) {
$arUserId = array($arUserId);
}
if (is_array($arGroupCode) && !empty($arGroupCode) && CModule::IncludeModule("socialnetwork")) {
foreach ($arGroupCode as $group_code) {
if ($bExtranetUser && preg_match('/^(SGN\\d+)$/', $group_code, $match) && is_array($arGroupName) && isset($arGroupName[$match[1]]) && strlen($arGroupName[$match[1]]) > 0 && CModule::IncludeModule("extranet") && (CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false) || $GLOBALS["APPLICATION"]->GetGroupRight("socialnetwork", false, "Y", "Y", array(CExtranet::GetExtranetSiteID(), false)) >= "K")) {
// check and create group, for extranet only
$dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => CExtranet::GetExtranetSiteID()), false, false, array("ID"));
if ($arSubject = $dbSubjects->GetNext()) {
$arSocNetGroupFields = array("NAME" => $arGroupName[$match[1]], "DESCRIPTION" => "", "VISIBLE" => "N", "OPENED" => "N", "CLOSED" => "N", "SUBJECT_ID" => $arSubject["ID"], "INITIATE_PERMS" => "E", "SPAM_PERMS" => "K", "SITE_ID" => array($SITE_ID, CExtranet::GetExtranetSiteID()));
if ($group_id = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arSocNetGroupFields, false)) {
$arGroupToAdd[] = $group_id;
} elseif ($e = $GLOBALS["APPLICATION"]->GetException()) {
$strError = $e->GetString();
}
}
} elseif (preg_match('/^SG(\\d+)$/', $group_code, $match)) {
$group_id = $match[1];
if (($arGroup = CSocNetGroup::GetByID($group_id)) && ($arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arGroup, CSocNetUser::IsCurrentUserModuleAdmin(SITE_ID, false))) && $arCurrentUserPerms["UserCanInitiate"] && $arGroup["CLOSED"] != "Y") {
$arGroupToAdd[] = $group_id;
}
}
}
if (!$strError) {
foreach ($arGroupToAdd as $group_id) {
foreach ($arUserId as $user_id) {
if (!CSocNetUserToGroup::SendRequestToJoinGroup($GLOBALS["USER"]->GetID(), $user_id, $group_id, "", false)) {
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$strError .= $e->GetString();
}
}
}
}
}
}
return $strError;
}
示例6: foreach
if (CModule::IncludeModule("extranet") && !CExtranet::IsExtranetSite() && $_POST["IS_EXTRANET_GROUP"] == "Y") {
$arFields["SITE_ID"][] = CExtranet::GetExtranetSiteID();
$arFields["VISIBLE"] = "N";
$arFields["OPENED"] = "N";
}
foreach ($arResult["GROUP_PROPERTIES"] as $field => $arUserField) {
if (array_key_exists($field, $_POST)) {
$arFields[$field] = $_POST[$field];
}
}
$GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_GROUP", $arFields);
if ($arParams["GROUP_ID"] <= 0) {
if (CModule::IncludeModule("extranet") && CExtranet::IsExtranetSite()) {
$arFields["SITE_ID"][] = CSite::GetDefSite();
}
$arResult["MEW_GROUP_ID"] = CSocNetGroup::CreateGroup($GLOBALS["USER"]->GetID(), $arFields, $bAutoSubscribe);
if (!$arResult["MEW_GROUP_ID"]) {
if ($e = $APPLICATION->GetException()) {
$errorMessage .= $e->GetString();
}
} else {
$bCreate = true;
}
} else {
$arFields["=DATE_UPDATE"] = $GLOBALS["DB"]->CurrentTimeFunction();
$arFields["=DATE_ACTIVITY"] = $GLOBALS["DB"]->CurrentTimeFunction();
$arResult["MEW_GROUP_ID"] = CSocNetGroup::Update($arParams["GROUP_ID"], $arFields, $bAutoSubscribe);
if (!$arResult["MEW_GROUP_ID"] && ($e = $APPLICATION->GetException())) {
$errorMessage .= $e->GetString();
} else {
$rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y"));