本文整理汇总了PHP中CSocNetUserToGroup::Add方法的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserToGroup::Add方法的具体用法?PHP CSocNetUserToGroup::Add怎么用?PHP CSocNetUserToGroup::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSocNetUserToGroup
的用法示例。
在下文中一共展示了CSocNetUserToGroup::Add方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: IntVal
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) {
CSocNetUserToGroup::Add(array("USER_ID" => 1, "GROUP_ID" => $val, "ROLE" => "A", "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => 1, "MESSAGE" => false));
}
}
if (StrLen($errorMessage) <= 0) {
// set EUV vor news
$dbResult = CSocNetEventUserView::GetList(array("ENTITY_ID" => "ASC"), array("ENTITY_TYPE" => "N"));
$arResult = $dbResult->Fetch();
if (!$arResult) {
CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
CSocNetEventUserView::Add(array("ENTITY_TYPE" => "N", "ENTITY_ID" => 0, "EVENT_ID" => "news_comment", "USER_ID" => 0, "USER_ANONYMOUS" => "N"));
}
$blogGroupID = 0;
if (CModule::IncludeModule("blog")) {
$dbRes = CBlogGroup::GetList(array("ID" => "DESC"), array("SITE_ID" => WIZARD_SITE_ID));
if ($arRes = $dbRes->Fetch()) {
$blogGroupID = $arRes["ID"];
示例3: 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) {
//.........这里部分代码省略.........
示例4: 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;
}
示例5: array
}
if (!$bError) {
$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => intval($arFields["OWNER_ID"]), "GROUP_ID" => $ID), false, false, array("ID"));
if ($arRelation = $dbRelation->Fetch()) {
$arUpdateFields = array("ROLE" => SONET_ROLES_OWNER, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => $GLOBALS["USER"]->GetID());
if (!CSocNetUserToGroup::Update($arRelation["ID"], $arUpdateFields)) {
$bError = true;
if ($ex = $APPLICATION->GetException()) {
$lAdmin->AddUpdateError($ex->GetString(), $ID);
} else {
$lAdmin->AddUpdateError(GetMessage("SONET_ERROR_UPDATE"), $ID);
}
}
} else {
$arAddFields = array("USER_ID" => intval($arFields["OWNER_ID"]), "GROUP_ID" => $ID, "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" => $GLOBALS["USER"]->GetID(), "MESSAGE" => false);
if (!CSocNetUserToGroup::Add($arAddFields)) {
$bError = true;
if ($ex = $APPLICATION->GetException()) {
$lAdmin->AddUpdateError($ex->GetString(), $ID);
} else {
$lAdmin->AddUpdateError(GetMessage("SONET_ERROR_UPDATE"), $ID);
}
}
}
}
if ($bError) {
$DB->Rollback();
}
}
$DB->Commit();
}
示例6: 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");
//.........这里部分代码省略.........
示例7: AddUserGroupClosedCommunity
function AddUserGroupClosedCommunity($Fields)
{
if ($Fields["USER_ID"] > 0 && $Fields["UF_YOU_HAVE_18"] == 1) {
if (CModule::IncludeModule("socialnetwork")) {
CSocNetUserToGroup::Add(array("USER_ID" => $Fields["USER_ID"], "GROUP_ID" => 6, "ROLE" => SONET_ROLES_USER, "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "INITIATED_BY_TYPE" => SONET_INITIATED_BY_USER, "INITIATED_BY_USER_ID" => 1, "MESSAGE" => false));
}
}
}