本文整理汇总了PHP中CSocNetUserToGroup类的典型用法代码示例。如果您正苦于以下问题:PHP CSocNetUserToGroup类的具体用法?PHP CSocNetUserToGroup怎么用?PHP CSocNetUserToGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CSocNetUserToGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getRelatedGroup
function getRelatedGroup($relationID)
{
$arRel = CSocNetUserToGroup::GetByID($relationID);
if ($arRel) {
return $arRel["GROUP_NAME"];
} else {
return false;
}
}
示例3: _socnet_type_check
protected static function _socnet_type_check($USER, $iblock_type_id, $socnet_group_id)
{
if ($iblock_type_id === COption::GetOptionString("lists", "socnet_iblock_type_id")) {
$socnet_role = CSocNetUserToGroup::GetUserRole($USER->GetID(), $socnet_group_id);
if ($socnet_role == "A") {
return CListPermissions::IS_ADMIN;
} else {
return CListPermissions::CAN_READ;
}
} else {
return CListPermissions::WRONG_IBLOCK_TYPE;
}
}
示例4: getUserGroups
public static function getUserGroups($userId, $force = false)
{
static $cache = array();
if (!$force && isset($cache[$userId])) {
return $cache[$userId];
}
$cache[$userId] = array();
if (!CModule::IncludeModule('socialnetwork')) {
return $cache[$userId];
}
$userGroupFilter = array('USER_ID' => (int) $userId, '<=ROLE' => SONET_ROLES_USER);
$dbUserGroups = CSocNetUserToGroup::GetList(array('GROUP_NAME' => 'ASC'), $userGroupFilter, false, false, array('GROUP_NAME', 'GROUP_ID'));
while ($row = $dbUserGroups->GetNext()) {
$cache[$userId][] = $row;
}
return $cache[$userId];
}
示例5: OnUserInitialize
function OnUserInitialize($user_id, $arFields = array())
{
if (intval($user_id) <= 0) {
return false;
}
if (CModule::IncludeModule("im")) {
$bIM = true;
}
$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $user_id, "ROLE" => SONET_ROLES_REQUEST, "INITIATED_BY_TYPE" => SONET_INITIATED_BY_GROUP), false, false, array("ID", "GROUP_ID"));
while ($arRelation = $dbRelation->Fetch()) {
if (CSocNetUserToGroup::UserConfirmRequestToBeMember($user_id, $arRelation["ID"], false) && defined("BX_COMP_MANAGED_CACHE")) {
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_user2group_G" . $arRelation["GROUP_ID"]);
$GLOBALS["CACHE_MANAGER"]->ClearByTag("sonet_user2group_U" . $user_id);
if ($bIM) {
CIMNotify::DeleteByTag("SOCNET|INVITE_GROUP|" . $user_id . "|" . intval($arRelation["ID"]));
}
}
}
}
示例6: getUserGroupWithStorage
protected function getUserGroupWithStorage()
{
if (!\CBXFeatures::isFeatureEnabled("Workgroups")) {
return array();
}
if (!Loader::includeModule('socialnetwork')) {
return array();
}
$userId = $this->getUser()->getId();
$currentPossibleUserGroups = $currentUserGroups = array();
$cache = Cache::createInstance();
$cacheTtl = defined('BX_COMP_MANAGED_CACHE') ? 3153600 : 3600 * 4;
$cachePath = "/disk/uf/{$userId}";
if ($cache->initCache($cacheTtl, 'group_storage_list_' . SITE_ID . '_' . $userId, $cachePath)) {
list($currentUserGroups) = $cache->getVars();
} else {
$cache->startDataCache();
$taggedCache = Application::getInstance()->getTaggedCache();
$taggedCache->startTagCache($cachePath);
$diskSecurityContext = new DiskSecurityContext($userId);
$storages = Storage::getReadableList($diskSecurityContext, array('filter' => array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className())));
foreach ($storages as $storage) {
$currentPossibleUserGroups[$storage->getEntityId()] = $storage;
}
unset($storage);
$query = \CSocNetUserToGroup::getList(array('GROUP_NAME' => 'ASC'), array('USER_ID' => $userId, 'GROUP_ID' => array_keys($currentPossibleUserGroups)), false, false, array('GROUP_ID', 'GROUP_NAME', 'GROUP_ACTIVE', 'GROUP_CLOSED', 'ROLE'));
while ($row = $query->getNext()) {
if ($row['GROUP_ACTIVE'] == 'Y' && $row['GROUP_CLOSED'] == 'N' && $row['ROLE'] != SONET_ROLES_BAN && $row['ROLE'] != SONET_ROLES_REQUEST && isset($currentPossibleUserGroups[$row['GROUP_ID']])) {
$taggedCache->registerTag("sonet_features_G_{$row['GROUP_ID']}");
$taggedCache->registerTag("sonet_group_{$row['GROUP_ID']}");
$currentUserGroups[$row['GROUP_ID']] = array('STORAGE' => $currentPossibleUserGroups[$row['GROUP_ID']], 'NAME' => $row['GROUP_NAME']);
}
}
$taggedCache->registerTag("sonet_user2group_U{$userId}");
$taggedCache->endTagCache();
$cache->endDataCache(array($currentUserGroups));
}
return $currentUserGroups;
}
示例7: getUserGroupWithStorage
protected function getUserGroupWithStorage()
{
if (!\CBXFeatures::isFeatureEnabled("Workgroups")) {
return array();
}
if (!Loader::includeModule('socialnetwork')) {
return array();
}
$userId = $this->getUser()->getId();
$currentPossibleUserGroups = $currentUserGroups = array();
$diskSecurityContext = new DiskSecurityContext($this->getUser()->getId());
$storages = Storage::getReadableList($diskSecurityContext, array('filter' => array('STORAGE.ENTITY_TYPE' => ProxyType\Group::className())));
foreach ($storages as $storage) {
$currentPossibleUserGroups[$storage->getEntityId()] = $storage;
}
unset($storage);
$query = \CSocNetUserToGroup::getList(array('GROUP_NAME' => 'ASC'), array('USER_ID' => $userId, 'GROUP_ID' => array_keys($currentPossibleUserGroups)), false, false, array('GROUP_ID', 'GROUP_NAME', 'GROUP_ACTIVE', 'GROUP_CLOSED', 'ROLE'));
while ($row = $query->getNext()) {
if ($row['GROUP_ACTIVE'] == 'Y' && $row['GROUP_CLOSED'] == 'N' && $row['ROLE'] != SONET_ROLES_BAN && $row['ROLE'] != SONET_ROLES_REQUEST && isset($currentPossibleUserGroups[$row['GROUP_ID']])) {
$currentUserGroups[$row['GROUP_ID']] = array('STORAGE' => $currentPossibleUserGroups[$row['GROUP_ID']], 'NAME' => $row['GROUP_NAME']);
}
}
return $currentUserGroups;
}
示例8: getUserGroups
public static function getUserGroups($arFields, $n, $server)
{
global $USER;
$dbRes = CSocNetUserToGroup::GetList(
array('ID' => 'ASC'),
array(
'USER_ID' => $USER->GetID(),
'<=ROLE' => SONET_ROLES_USER
), false, false, array('GROUP_ID', 'GROUP_NAME', 'ROLE')
);
$res = array();
while ($arRes = $dbRes->Fetch())
{
$res[] = $arRes;
}
return $res;
}
示例9: array
if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
$arFilter["SITE_ID"] = SITE_ID;
} else {
$arFilter["SITE_ID"] = array(SITE_ID, false);
}
$cnt = 0;
$dbEvents = CSocNetLog::GetList(array("LOG_DATE" => "DESC"), $arFilter, false, false, array("MIN_ID_JOIN" => true));
while ($arEvents = $dbEvents->GetNext()) {
if (intval($arParams["LOG_CNT"]) > 0 && $cnt >= $arParams["LOG_CNT"]) {
break;
}
if ($arResult["Events"] == false) {
$arResult["Events"] = array();
}
if ($arEvents["ENTITY_TYPE"] == SONET_ENTITY_GROUP) {
$arCurrentUserPerms = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), array("ID" => $arEvents["ENTITY_ID"], "OWNER_ID" => $arEvents["GROUP_OWNER_ID"], "INITIATE_PERMS" => $arEvents["GROUP_INITIATE_PERMS"], "VISIBLE" => $arEvents["GROUP_VISIBLE"], "OPENED" => $arEvents["GROUP_OPENED"]), $bCurrentUserIsAdmin);
if ($arEvents["EVENT_ID"] == "system") {
if (!$arCurrentUserPerms["UserIsMember"]) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_post") {
if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_post_micro") {
if (!array_key_exists("microblog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) {
continue;
}
} elseif ($arEvents["EVENT_ID"] == "blog_comment") {
if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvents["ENTITY_ID"], "blog", "view_comment", $bCurrentUserIsAdmin)) {
continue;
示例10: OnSearchCheckPermissions
function OnSearchCheckPermissions($FIELD)
{
global $DB, $USER;
$user_id = intval($USER->GetID());
$arResult = array();
if ($user_id > 0) {
$arResult[] = "SU" . $user_id . "_Z";
$rsFriends = CSocNetUserRelations::GetList(array(), array("USER_ID" => $user_id, "RELATION" => SONET_RELATIONS_FRIEND), false, false, array("ID", "FIRST_USER_ID", "SECOND_USER_ID", "DATE_CREATE", "DATE_UPDATE", "INITIATED_BY"));
while ($arFriend = $rsFriends->Fetch()) {
if ($arFriend["FIRST_USER_ID"] != $user_id) {
$arResult[] = "SU" . $arFriend["FIRST_USER_ID"] . "_M";
}
if ($arFriend["SECOND_USER_ID"] != $user_id) {
$arResult[] = "SU" . $arFriend["SECOND_USER_ID"] . "_M";
}
}
}
$rsGroups = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $user_id), false, false, array("GROUP_ID", "ROLE"));
while ($arGroup = $rsGroups->Fetch()) {
$arResult[] = "SG" . $arGroup["GROUP_ID"] . "_" . $arGroup["ROLE"];
}
return $arResult;
}
示例11: GetMessage
$arResult["Group"] = $arGroup;
$arResult["CurrentUserPerms"] = CSocNetUserToGroup::InitUserPerms($GLOBALS["USER"]->GetID(), $arResult["Group"], CSocNetUser::IsCurrentUserModuleAdmin());
if (!$arResult["CurrentUserPerms"] || !$arResult["CurrentUserPerms"]["UserCanViewGroup"] || !$arResult["CurrentUserPerms"]["UserCanSpamGroup"]) {
$arResult["FatalError"] = GetMessage("SONET_CHAT_GROUP_ACESS");
} else {
$arResult["Urls"]["Group"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_GROUP"], array("group_id" => $arResult["Group"]["ID"]));
if ($arParams["SET_TITLE"] == "Y") {
$APPLICATION->SetTitle($arResult["Group"]["NAME"] . ": " . GetMessage("SONET_CHAT_GROUP_TITLE"));
}
if (intval($arResult["Group"]["IMAGE_ID"]) <= 0) {
$arResult["Group"]["IMAGE_ID"] = COption::GetOptionInt("socialnetwork", "default_group_picture", false, SITE_ID);
}
$arImage = CSocNetTools::InitImage($arResult["Group"]["IMAGE_ID"], 50, "/bitrix/images/socialnetwork/nopic_group_50.gif", 50, $arResult["Urls"]["Group"], true, 'target="_blank"');
$arResult["Group"]["IMAGE_ID_FILE"] = $arImage["FILE"];
$arResult["Group"]["IMAGE_ID_IMG"] = $arImage["IMG"];
$dbRequests = CSocNetUserToGroup::GetList(array("USER_LAST_NAME" => "ASC", "USER_NAME" => "ASC"), array("GROUP_ID" => $arResult["Group"]["ID"], "<=ROLE" => SONET_ROLES_USER), false, false, array("ID", "USER_ID", "ROLE", "DATE_CREATE", "DATE_UPDATE", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "USER_IS_ONLINE"));
if ($dbRequests) {
$arResult["Users"] = array();
$arResult["Users"]["List"] = false;
while ($arRequests = $dbRequests->GetNext()) {
if ($arResult["UserSelf"]["ID"] == $arRequests["USER_ID"]) {
continue;
}
if ($arResult["Users"]["List"] == false) {
$arResult["Users"]["List"] = array();
}
$pu = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arRequests["USER_ID"]));
$canViewProfile = CSocNetUserPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arRequests["USER_ID"], "viewprofile", CSocNetUser::IsCurrentUserModuleAdmin());
$arTmpUser = array("NAME" => htmlspecialcharsback($arRequests["USER_NAME"]), "LAST_NAME" => htmlspecialcharsback($arRequests["USER_LAST_NAME"]), "SECOND_NAME" => htmlspecialcharsback($arRequests["USER_SECOND_NAME"]), "LOGIN" => htmlspecialcharsback($arRequests["USER_LOGIN"]));
$strNameFormatted = CUser::FormatName($arParams['NAME_TEMPLATE'], $arTmpUser, $bUseLogin);
$arResult["Users"]["List"][] = array("ID" => $arRequests["ID"], "USER_ID" => $arRequests["USER_ID"], "USER_NAME" => $arRequests["USER_NAME"], "USER_LAST_NAME" => $arRequests["USER_LAST_NAME"], "USER_SECOND_NAME" => $arRequests["USER_SECOND_NAME"], "USER_LOGIN" => $arRequests["USER_LOGIN"], "USER_NAME_FORMATTED" => $strNameFormatted, "USER_PROFILE_URL" => $pu, "SHOW_PROFILE_LINK" => $canViewProfile, "PATH_TO_MESSAGES_CHAT" => str_replace("#user_id#", $arRequests["USER_ID"], $arParams["PATH_TO_MESSAGES_CHAT"]), "IS_ONLINE" => $arRequests["USER_IS_ONLINE"] == "Y", "IS_MODERATOR" => $arRequests["ROLE"] != SONET_ROLES_USER);
示例12: AllowToSend
public static function AllowToSend($arParams)
{
$bResult = false;
if (isset($arParams['TO_USER_ID']))
{
$toUserId = intval($arParams['TO_USER_ID']);
$bResult = true;
if(IsModuleInstalled('intranet') && CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser())
{
$bResult = false;
if (CModule::IncludeModule("socialnetwork"))
{
global $USER, $CACHE_MANAGER;
if(defined("BX_COMP_MANAGED_CACHE"))
$ttl = 2592000;
else
$ttl = 600;
$cache_id = 'im_user_sg_'.$USER->GetID();
$obSGCache = new CPHPCache;
$cache_dir = '/bx/imc/sonet';
if($obSGCache->InitCache($ttl, $cache_id, $cache_dir))
{
$tmpVal = $obSGCache->GetVars();
$bResult = in_array($toUserId, $tmpVal['EXTRANET_USERS']);
}
else
{
if(defined("BX_COMP_MANAGED_CACHE"))
$CACHE_MANAGER->StartTagCache($cache_dir);
$dbUsersInGroup = CSocNetUserToGroup::GetList(
array(),
array(
"USER_ID" => $USER->GetID(),
"<=ROLE" => SONET_ROLES_USER,
"GROUP_SITE_ID" => CExtranet::GetExtranetSiteID(),
"GROUP_ACTIVE" => "Y",
"GROUP_CLOSED" => "N"
),
false,
false,
array("ID", "GROUP_ID", "GROUP_NAME")
);
$arUserSocNetGroups = Array();
$arUserSG = Array();
while ($ar = $dbUsersInGroup->GetNext(true, false))
{
$arUserSocNetGroups[] = $ar["GROUP_ID"];
$arUserSG['SG'.$ar['GROUP_ID']] = array(
'id' => 'SG'.$ar['GROUP_ID'],
'status' => 'close',
'name' => GetMessage('IM_CL_GROUP_SG').$ar['GROUP_NAME']
);
if(defined("BX_COMP_MANAGED_CACHE"))
{
$CACHE_MANAGER->RegisterTag('sonet_group_'.$ar['GROUP_ID']);
$CACHE_MANAGER->RegisterTag('sonet_user2group_G'.$ar['GROUP_ID']);
}
}
$arExtranetUsers = Array();
$arUserInGroup = Array();
$arWoUserInGroup = Array();
if (count($arUserSocNetGroups) > 0)
{
$dbUsersInGroup = CSocNetUserToGroup::GetList(
array(),
array(
"GROUP_ID" => $arUserSocNetGroups,
"<=ROLE" => SONET_ROLES_USER,
"USER_ACTIVE" => "Y"
),
false,
false,
array("ID", "USER_ID", "GROUP_ID")
);
while ($ar = $dbUsersInGroup->GetNext(true, false))
{
if($USER->GetID() != $ar["USER_ID"])
{
$arExtranetUsers[$ar["USER_ID"]] = $ar["USER_ID"];
if (isset($arUserInGroup["SG".$ar["GROUP_ID"]]))
$arUserInGroup["SG".$ar["GROUP_ID"]]['users'][] = $ar["USER_ID"];
else
$arUserInGroup["SG".$ar["GROUP_ID"]] = Array('id' => "SG".$ar["GROUP_ID"], 'users' => Array($ar["USER_ID"]));
if (isset($arWoUserInGroup["extranet"]))
$arWoUserInGroup["extranet"]['users'][] = $ar["USER_ID"];
else
$arWoUserInGroup["extranet"] = Array('id' => "extranet", 'users' => Array($ar["USER_ID"]));
}
}
if (isset($arWoUserInGroup['extranet']) && isset($arWoUserInGroup['extranet']['users']))
//.........这里部分代码省略.........
示例13: GetMessage
if ($arParams["SET_NAV_CHAIN"] != "N") {
$APPLICATION->AddChainItem($arResult["Group"]["NAME"], $arResult["Urls"]["Group"]);
$APPLICATION->AddChainItem(GetMessage("SONET_C37_PAGE_TITLE"));
}
if ($arResult["CurrentUserPerms"]["UserIsOwner"]) {
$arResult["FatalError"] = GetMessage("SONET_C37_IS_OWNER") . ". ";
} elseif (!$arResult["CurrentUserPerms"]["UserIsMember"]) {
$arResult["FatalError"] = GetMessage("SONET_C37_NOT_MEMBER") . ". ";
} else {
if ($arParams["SET_TITLE"] == "Y") {
$APPLICATION->SetTitle($arResult["Group"]["NAME"] . ": " . GetMessage("SONET_C37_PAGE_TITLE"));
}
$arResult["ShowForm"] = "Input";
if ($_SERVER["REQUEST_METHOD"] == "POST" && strlen($_POST["save"]) > 0 && check_bitrix_sessid()) {
$errorMessage = "";
if (strlen($errorMessage) <= 0) {
if (!CSocNetUserToGroup::DeleteRelation($GLOBALS["USER"]->GetID(), $arResult["Group"]["ID"]) && ($e = $APPLICATION->GetException())) {
$errorMessage .= $e->GetString();
}
}
if (strlen($errorMessage) > 0) {
$arResult["ErrorMessage"] = $errorMessage;
} else {
$arResult["ShowForm"] = "Confirm";
}
}
}
}
}
}
$this->IncludeComponentTemplate();
示例14: GetSocnetGroup
public static function GetSocnetGroup($arParams = array())
{
global $USER;
$userId = intval($USER->GetID());
$arSocnetGroups = array();
$arSelect = array();
if (isset($arParams['id'])) {
if (empty($arParams['id'])) {
return $arSocnetGroups;
} else {
foreach ($arParams['id'] as $value) {
$arSelect[] = intval($value);
}
}
}
if (isset($arParams['site_id']) && strlen($arParams['site_id']) > 0) {
$siteId = $arParams['site_id'];
} else {
$siteId = SITE_ID;
}
$arFilter = array("USER_ID" => $userId, "ID" => $arSelect, "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => $siteId, "GROUP_ACTIVE" => "Y");
if (isset($arParams['GROUP_CLOSED'])) {
$arFilter['GROUP_CLOSED'] = $arParams['GROUP_CLOSED'];
}
$arSocnetGroupsTmp = array();
$rsGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arFilter, false, array("nTopCount" => 500), array("ID", "GROUP_ID", "GROUP_NAME", "GROUP_DESCRIPTION", "GROUP_IMAGE_ID"));
while ($arGroup = $rsGroups->Fetch()) {
$arGroupTmp = array("id" => $arGroup["GROUP_ID"], "entityId" => $arGroup["GROUP_ID"], "name" => htmlspecialcharsbx($arGroup["GROUP_NAME"]), "desc" => htmlspecialcharsbx($arGroup["GROUP_DESCRIPTION"]));
if ($arGroup["GROUP_IMAGE_ID"]) {
$imageFile = CFile::GetFileArray($arGroup["GROUP_IMAGE_ID"]);
if ($imageFile !== false) {
$arFileTmp = CFile::ResizeImageGet($imageFile, array("width" => intval($arParams["THUMBNAIL_SIZE_WIDTH"]) > 0 ? $arParams["THUMBNAIL_SIZE_WIDTH"] : 30, "height" => intval($arParams["THUMBNAIL_SIZE_HEIGHT"]) > 0 ? $arParams["THUMBNAIL_SIZE_HEIGHT"] : 30), BX_RESIZE_IMAGE_PROPORTIONAL, false);
$arGroupTmp["avatar"] = $arFileTmp["src"];
}
}
$arSocnetGroupsTmp[$arGroupTmp['id']] = $arGroupTmp;
}
if (isset($arParams['features']) && !empty($arParams['features'])) {
self::GetSocnetGroupFilteredByFeaturePerms($arSocnetGroupsTmp, $arParams['features']);
}
foreach ($arSocnetGroupsTmp as $value) {
$value['id'] = 'SG' . $value['id'];
$arSocnetGroups[$value['id']] = $value;
}
return $arSocnetGroups;
}
示例15: 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;
}