本文整理汇总了PHP中CSocNetGroup::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetGroup::Add方法的具体用法?PHP CSocNetGroup::Add怎么用?PHP CSocNetGroup::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetGroup
的用法示例。
在下文中一共展示了CSocNetGroup::Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: IntVal
$arGroupSubjectsId[$ind] = IntVal($idTmp);
} else {
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$errorMessage .= $e->GetString();
}
}
}
}
if (StrLen($errorMessage) <= 0) {
$pathToImages = WIZARD_SERVICE_ABSOLUTE_PATH . "/images/";
$arGroupsId = array(0 => 0, 1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0, 6 => 0, 7 => 0, 8 => 0, 9 => 0, 10 => 0);
$arGroups = array(0 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_0"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_0"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[1], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_0"), "IMAGE_ID" => array("name" => "0.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/0.jpg", "error" => "0", "size" => @filesize($pathToImages . "/0.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 1 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_1"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_1"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[0], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_1"), "IMAGE_ID" => array("name" => "1.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/1.jpg", "error" => "0", "size" => @filesize($pathToImages . "/1.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 2 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_2"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_2"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[0], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_2"), "IMAGE_ID" => array("name" => "2.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/2.jpg", "error" => "0", "size" => @filesize($pathToImages . "/2.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "E", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 3 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_3"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_3"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "Y", "SUBJECT_ID" => $arGroupSubjectsId[4], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_3"), "IMAGE_ID" => array("name" => "3.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/3.jpg", "error" => "0", "size" => @filesize($pathToImages . "/3.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "K", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 4 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_4"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_4"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[2], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_4"), "IMAGE_ID" => array("name" => "4.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/4.jpg", "error" => "0", "size" => @filesize($pathToImages . "/4.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "E", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 5 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_5"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_5"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[2], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_5"), "IMAGE_ID" => array("name" => "5.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/5.jpg", "error" => "0", "size" => @filesize($pathToImages . "/5.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 6 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_6"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_6"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "Y", "SUBJECT_ID" => $arGroupSubjectsId[4], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_6"), "IMAGE_ID" => array("name" => "6.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/6.jpg", "error" => "0", "size" => @filesize($pathToImages . "/6.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "SPAM_PERMS" => "N", "INITIATE_PERMS" => "K", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 7 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_7"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_7"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "Y", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[1], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_7"), "IMAGE_ID" => array("name" => "7.jpg", "type" => "image/jpeg", "tmp_name" => $pathToImages . "/7.jpg", "error" => "0", "size" => @filesize($pathToImages . "/7.jpg"), "MODULE_ID" => "socialnetwork"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "E", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 8 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_8"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_8"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_8"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 9 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_9"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_9"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_9"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()), 10 => array("SITE_ID" => WIZARD_SITE_ID, "NAME" => GetMessage("SONET_GROUP_NAME_10"), "DESCRIPTION" => GetMessage("SONET_GROUP_DESCRIPTION_10"), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "ACTIVE" => "Y", "VISIBLE" => "N", "OPENED" => "N", "SUBJECT_ID" => $arGroupSubjectsId[3], "OWNER_ID" => 1, "KEYWORDS" => GetMessage("SONET_GROUP_KEYWORDS_10"), "NUMBER_OF_MEMBERS" => 1, "INITIATE_PERMS" => "A", "SPAM_PERMS" => "N", "=DATE_ACTIVITY" => $GLOBALS["DB"]->CurrentTimeFunction()));
foreach ($arGroups as $ind => $arGroup) {
$dbSubject = CSocNetGroup::GetList(array(), array("NAME" => $arGroup["NAME"], "SITE_ID" => WIZARD_SITE_ID));
if (!$dbSubject->Fetch()) {
$idTmp = CSocNetGroup::Add($arGroup);
if ($idTmp) {
if (CModule::IncludeModule("disk")) {
\Bitrix\Disk\Driver::getInstance()->addGroupStorage($idTmp);
}
$arGroupsId[$ind] = IntVal($idTmp);
} else {
if ($e = $GLOBALS["APPLICATION"]->GetException()) {
$errorMessage .= $e->GetString();
}
}
}
}
}
if (StrLen($errorMessage) <= 0) {
foreach ($arGroupsId as $ind => $val) {
示例2: CreateGroup
function CreateGroup($ownerID, $arFields, $bAutoSubscribe = true)
{
global $APPLICATION, $DB;
$ownerID = IntVal($ownerID);
if ($ownerID <= 0) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_OWNERID") . ". ", "ERROR_OWNERID");
return false;
}
if (!isset($arFields) || !is_array($arFields)) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_UR_EMPTY_FIELDS") . ". ", "ERROR_FIELDS");
return false;
}
$DB->StartTransaction();
$arFields["=DATE_CREATE"] = $GLOBALS["DB"]->CurrentTimeFunction();
$arFields["=DATE_UPDATE"] = $GLOBALS["DB"]->CurrentTimeFunction();
$arFields["=DATE_ACTIVITY"] = $GLOBALS["DB"]->CurrentTimeFunction();
$arFields["ACTIVE"] = "Y";
$arFields["OWNER_ID"] = $ownerID;
if (!is_set($arFields, "SPAM_PERMS") || strlen($arFields["SPAM_PERMS"]) <= 0) {
$arFields["SPAM_PERMS"] = SONET_ROLES_OWNER;
}
$groupID = CSocNetGroup::Add($arFields);
if (!$groupID || IntVal($groupID) <= 0) {
$errorMessage = "";
if ($e = $APPLICATION->GetException()) {
$errorMessage = $e->GetString();
$errorID = $e->GetID();
if (StrLen($errorID) <= 0 && isset($e->messages) && is_array($e->messages) && is_array($e->messages[0]) && array_key_exists("id", $e->messages[0])) {
$errorID = $e->messages[0]["id"];
}
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_UR_ERROR_CREATE_GROUP") . ". ";
}
if (StrLen($errorID) <= 0) {
$errorID = "ERROR_CREATE_GROUP";
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, $errorID);
$DB->Rollback();
return false;
}
$arFields1 = array("USER_ID" => $ownerID, "GROUP_ID" => $groupID, "ROLE" => SONET_ROLES_OWNER, "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $ownerID, "MESSAGE" => false);
if (!CSocNetUserToGroup::Add($arFields1)) {
$errorMessage = "";
if ($e = $APPLICATION->GetException()) {
$errorMessage = $e->GetString();
}
if (StrLen($errorMessage) <= 0) {
$errorMessage = GetMessage("SONET_UR_ERROR_CREATE_U_GROUP") . ". ";
}
$GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_GROUP");
$DB->Rollback();
return false;
}
if ($bAutoSubscribe) {
CSocNetLogEvents::AutoSubscribe($ownerID, SONET_ENTITY_GROUP, $groupID);
}
CSocNetSubscription::Set($ownerID, "SG" . $groupID, "Y");
$DB->Commit();
return $groupID;
}