本文整理汇总了PHP中CBXFeatures类的典型用法代码示例。如果您正苦于以下问题:PHP CBXFeatures类的具体用法?PHP CBXFeatures怎么用?PHP CBXFeatures使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CBXFeatures类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Add
/** Add new store in table b_catalog_store,
* @static
* @param $arFields
* @return bool|int
*/
static function Add($arFields)
{
/** @global CDataBase $DB */
global $DB;
if (!CBXFeatures::IsFeatureEnabled('CatMultiStore')) {
$dbResultList = CCatalogStore::GetList(array());
if ($arResult = $dbResultList->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("CS_ALREADY_HAVE_STORE"));
return false;
}
}
if (array_key_exists('DATE_CREATE', $arFields)) {
unset($arFields['DATE_CREATE']);
}
if (array_key_exists('DATE_MODIFY', $arFields)) {
unset($arFields['DATE_MODIFY']);
}
$arFields['~DATE_MODIFY'] = $DB->GetNowFunction();
$arFields['~DATE_CREATE'] = $DB->GetNowFunction();
if (!self::CheckFields('ADD', $arFields)) {
return false;
}
$arInsert = $DB->PrepareInsert("b_catalog_store", $arFields);
$strSql = "INSERT INTO b_catalog_store (" . $arInsert[0] . ") " . "VALUES(" . $arInsert[1] . ")";
$res = $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!$res) {
return false;
}
$lastId = intval($DB->LastID());
return $lastId;
}
示例2: SPRegisterUpdatedItem
public static function SPRegisterUpdatedItem($arFields)
{
if (CBXFeatures::IsFeatureEnabled('intranet_sharepoint')) {
if (CIntranetSharepoint::$bUpdateInProgress) {
return;
}
$dbRes = CIntranetSharepoint::GetByID($arFields['IBLOCK_ID']);
if ($arRes = $dbRes->Fetch()) {
CIntranetSharepoint::AddToUpdateLog($arFields);
}
}
}
示例3: DoInstall
function DoInstall()
{
global $DB, $DBType, $DOCUMENT_ROOT, $APPLICATION;
$APPLICATION->ResetException();
if (!CBXFeatures::IsFeatureEditable("Extranet")) {
$this->errors = array(GetMessage("MAIN_FEATURE_ERROR_EDITABLE"));
$APPLICATION->ThrowException(implode("<br>", $this->errors));
$GLOBALS["errors"] = $this->errors;
} else {
if ($this->InstallDB()) {
$this->InstallEvents();
$this->InstallFiles();
}
$APPLICATION->IncludeAdminFile(GetMessage("EXTRANET_INSTALL_TITLE"), $DOCUMENT_ROOT . "/bitrix/modules/extranet/install/step1.php");
}
}
示例4: 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;
}
示例5: Add
/** Add new store in table b_catalog_store,
* @static
* @param $arFields
* @return bool|int
*/
static function Add($arFields)
{
/** @global CDataBase $DB */
global $DB;
if (!CBXFeatures::IsFeatureEnabled('CatMultiStore')) {
$dbResultList = CCatalogStore::GetList(array(), array(), false, array('NAV_PARAMS' => array("nTopCount" => "1")), array("ID"));
if ($arResult = $dbResultList->Fetch()) {
$GLOBALS["APPLICATION"]->ThrowException(GetMessage("CS_ALREADY_HAVE_STORE"));
return false;
}
}
foreach (GetModuleEvents("catalog", "OnBeforeCatalogStoreAdd", true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array(&$arFields)) === false) {
return false;
}
}
if (array_key_exists('DATE_CREATE', $arFields)) {
unset($arFields['DATE_CREATE']);
}
if (array_key_exists('DATE_MODIFY', $arFields)) {
unset($arFields['DATE_MODIFY']);
}
$arFields['~DATE_MODIFY'] = $DB->GetNowFunction();
$arFields['~DATE_CREATE'] = $DB->GetNowFunction();
if (!self::CheckFields('ADD', $arFields)) {
return false;
}
$arInsert = $DB->PrepareInsert("b_catalog_store", $arFields);
$strSql = "INSERT INTO b_catalog_store (" . $arInsert[0] . ") VALUES(" . $arInsert[1] . ")";
$res = $DB->Query($strSql, False, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!$res) {
return false;
}
$lastId = intval($DB->LastID());
foreach (GetModuleEvents("catalog", "OnCatalogStoreAdd", true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($lastId, $arFields));
}
return $lastId;
}
示例6: 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;
}
示例7:
if ($gadget["COMPANY_PHOTO_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("CompanyPhoto")) {
continue;
}
if ($gadget["COMPANY_CALENDAR_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("CompanyCalendar")) {
continue;
}
if ($gadget["CALENDAR_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("Calendar")) {
continue;
}
if ($gadget["COMPANY_VIDEO_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("CompanyVideo")) {
continue;
}
if ($gadget["WORKGROUPS_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("Workgroups")) {
continue;
}
if ($gadget["FRIENDS_ONLY"] == true && !CBXFeatures::IsFeatureEnabled("Friends")) {
continue;
}
if ($USER->IsAuthorized() && $arResult["PERMISSION"] < "W" && $gadget["SELF_PROFILE_ONLY"] == true && $arParams["MODE"] == "SU" && intval($arParams["USER_ID"]) > 0 && $arParams["USER_ID"] != $USER->GetID()) {
continue;
}
if ($gadget["BLOG_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "blog")) {
continue;
}
if ($gadget["BLOG_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog")) {
continue;
}
if ($gadget["FORUM_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "forum")) {
continue;
}
if ($gadget["FORUM_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum")) {
示例8: array
?><a href="/bitrix/admin/event_log.php?lang=<? echo LANGUAGE_ID; ?>&set_filter=Y<? echo CCatalogEvent::GetYandexAgentFilter(); ?>"><? echo Loc::getMessage('CAT_AGENT_EVENT_LOG_SHOW_ERROR')?></a>
</td></tr>
<?
$systemTabControl->BeginNextTab();
?><tr><td align="left"><?
$firstTop = ' style="margin-top: 0;"';
if (!$useSaleDiscountOnly)
{
?>
<h4<? echo $firstTop; ?>><? echo Loc::getMessage('CAT_PROC_REINDEX_DISCOUNT'); ?></h4>
<input class="adm-btn-save" type="button" id="discount_reindex" value="<? echo Loc::getMessage('CAT_PROC_REINDEX_DISCOUNT_BTN'); ?>">
<p><? echo Loc::getMessage('CAT_PROC_REINDEX_DISCOUNT_ALERT'); ?></p><?
$firstTop = '';
}
if (CBXFeatures::IsFeatureEnabled('CatCompleteSet') && CCatalogProductSetAvailable::getAllCounter() > 0)
{
?><h4<? echo $firstTop; ?>><? echo Loc::getMessage('CAT_PROC_REINDEX_SETS_AVAILABLE'); ?></h4>
<input class="adm-btn-save" type="button" id="sets_reindex" value="<? echo Loc::getMessage('CAT_PROC_REINDEX_SETS_AVAILABLE_BTN'); ?>">
<p><? echo Loc::getMessage('CAT_PROC_REINDEX_SETS_AVAILABLE_ALERT'); ?></p><?
$firstTop = '';
}
?>
</td></tr><?
if ($strUseStoreControl === 'N' && !empty($arCatalogList))
{
$userListID = array();
$strQuantityUser = '';
$strQuantityReservedUser = '';
$strStoreUser = '';
$strClearQuantityDate = '';
示例9: GetMessage
<input type="hidden" name="CAT_ROW_COUNTER" id="CAT_ROW_COUNTER" value="<?php
echo $ind;
?>
">
<input type="button" value="<?php
echo GetMessage("C2IT_MORE");
?>
" OnClick="ClonePriceSections()">
</td>
</tr>
<script type="text/javascript">
arCatalogGroups = [];
catalogGroupsInd = 0;
</script>
<?php
if (CBXFeatures::IsFeatureEnabled('CatMultiPrice')) {
$dbCatalogGroups = CCatalogGroup::GetList(array("SORT" => "ASC", "NAME" => "ASC", "ID" => "ASC"), array("!BASE" => "Y"));
while ($arCatalogGroup = $dbCatalogGroups->Fetch()) {
?>
<script type="text/javascript">
arCatalogGroups[catalogGroupsInd] = <?php
echo $arCatalogGroup["ID"];
?>
;
catalogGroupsInd++;
</script>
<tr>
<td valign="top" align="right">
<?php
echo GetMessage("C2IT_PRICE_TYPE");
?>
示例10: array
$strUseStoreControl = '';
$strSaveWithoutPrice = '';
$boolCatalogRead = false;
$boolCatalogPrice = false;
$boolCatalogPurchasInfo = false;
$boolCatalogSet = false;
$arProductTypeList = array();
$showCatalogWithOffers = false;
if ($bCatalog)
{
$strUseStoreControl = COption::GetOptionString("catalog", "default_use_store_control");
$strSaveWithoutPrice = COption::GetOptionString('catalog','save_product_without_price','N');
$boolCatalogRead = $USER->CanDoOperation('catalog_read');
$boolCatalogPrice = $USER->CanDoOperation('catalog_price');
$boolCatalogPurchasInfo = $USER->CanDoOperation('catalog_purchas_info');
$boolCatalogSet = CBXFeatures::IsFeatureEnabled('CatCompleteSet');
$arCatalog = CCatalogSKU::GetInfoByIBlock($arIBlock["ID"]);
if (empty($arCatalog))
{
$bCatalog = false;
}
else
{
if (CCatalogSKU::TYPE_PRODUCT == $arCatalog['CATALOG_TYPE'] || CCatalogSKU::TYPE_FULL == $arCatalog['CATALOG_TYPE'])
{
if (CIBlockRights::UserHasRightTo($arCatalog['IBLOCK_ID'], $arCatalog['IBLOCK_ID'], "iblock_admin_display"))
{
$boolSKU = true;
$strSKUName = GetMessage('IBLIST_A_OFFERS');
}
}
示例11: array
if ($arResult["IBLOCK"]["BIZPROC"] == "Y" && $arParams["CAN_EDIT_BIZPROC"]) {
$arToolbar[] = array("TEXT" => GetMessage("CT_BLL_TOOLBAR_BIZPROC"), "TITLE" => GetMessage("CT_BLL_TOOLBAR_BIZPROC_TITLE"), "LINK" => $arResult["BIZPROC_WORKFLOW_ADMIN_URL"], "ICON" => "btn-list-bizproc");
}
if ($arParams["IBLOCK_TYPE_ID"] == COption::GetOptionString("lists", "livefeed_iblock_type_id")) {
$text = GetMessage("CT_BLL_TOOLBAR_PROCESS");
$title = GetMessage("CT_BLL_TOOLBAR_PROCESS_TITLE");
} else {
$text = GetMessage("CT_BLL_TOOLBAR_LIST");
$title = GetMessage("CT_BLL_TOOLBAR_LIST_TITLE");
}
$arToolbar[] = array("TEXT" => $text, "TITLE" => $title, "LINK" => $arResult["LIST_EDIT_URL"], "ICON" => "btn-edit-list");
}
if ($arResult["CAN_READ"]) {
$arToolbar[] = array("TEXT" => GetMessage("CT_BLL_EXPORT_EXCEL"), "TITLE" => GetMessage("CT_BLL_EXPORT_EXCEL_TITLE"), "LINK" => CHTTP::urlAddParams(strpos($APPLICATION->GetCurPageParam(), "?") == false ? $arResult["EXPORT_EXCEL_URL"] : $arResult["EXPORT_EXCEL_URL"] . substr($APPLICATION->GetCurPageParam(), strpos($APPLICATION->GetCurPageParam(), "?")), array("ncc" => "y")), "ICON" => "btn-list-excel");
}
if (IsModuleInstalled('intranet') && CBXFeatures::IsFeatureEnabled('intranet_sharepoint')) {
if ($arIcons = $APPLICATION->IncludeComponent('bitrix:sharepoint.link', '', array('IBLOCK_ID' => $arParams['IBLOCK_ID'], 'OUTPUT' => 'N'), null, array('HIDE_ICONS' => 'Y'))) {
if (count($arIcons['LINKS']) > 0) {
$arMenu = array();
foreach ($arIcons['LINKS'] as $link) {
$arMenu[] = array('TEXT' => $link['TEXT'], 'ONCLICK' => $link['ONCLICK'], 'ICONCLASS' => $link['ICON']);
}
$arToolbar[] = array('TEXT' => 'SharePoint', 'ICON' => 'bx-sharepoint', 'MENU' => $arMenu);
}
}
}
if (count($arToolbar)) {
$APPLICATION->IncludeComponent("bitrix:main.interface.toolbar", "", array("BUTTONS" => $arToolbar), $component, array("HIDE_ICONS" => "Y"));
}
$arActions = array();
if (!empty($arResult["ELEMENTS_CAN_DELETE"])) {
示例12: array
$asset->addString('<link rel="stylesheet" type="text/css" media="print" href="' . SITE_TEMPLATE_PATH . '/print.css" />', false, \Bitrix\Main\Page\AssetLocation::AFTER_CSS);
$asset->addString('<link rel="alternate stylesheet" type="text/css" media="screen,projection" href="' . SITE_TEMPLATE_PATH . '/print.css" title="print" />', false, \Bitrix\Main\Page\AssetLocation::AFTER_CSS);
$asset->addString('<link rel="stylesheet" type="text/css" href="' . SITE_TEMPLATE_PATH . '/colors.css"/>', false, \Bitrix\Main\Page\AssetLocation::AFTER_CSS);
$asset->addJs(SITE_TEMPLATE_PATH . '/script.js');
?>
<title><?php
$APPLICATION->ShowTitle();
?>
</title>
</head>
<body class="<?php
$APPLICATION->ShowProperty("BodyClass");
?>
">
<?php
if (IsModuleInstalled("im") && CBXFeatures::IsFeatureEnabled('WebMessenger')) {
$APPLICATION->IncludeComponent("bitrix:im.messenger", "", array("PATH_TO_SONET_EXTMAIL" => SITE_DIR . "company/personal/mail/"));
}
?>
<div id="page-wrapper">
<div id="panel"><?php
$APPLICATION->ShowPanel();
?>
</div>
<div id="page-inner">
<div id="site-selector">
<div id="site-selector-inner">
<div id="site-selector-menus">
示例13: IncludeModuleLangFile
<?php
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_admin_before.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/include.php";
require_once $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/sale/prolog.php";
IncludeModuleLangFile(__FILE__);
$saleModulePermissions = $APPLICATION->GetGroupRight("sale");
if ($saleModulePermissions == "D") {
$APPLICATION->AuthForm(GetMessage("BUYER_PE_ACCESS_DENIED"));
}
if (!CBXFeatures::IsFeatureEnabled('SaleAccounts')) {
require $DOCUMENT_ROOT . "/bitrix/modules/main/include/prolog_admin_after.php";
ShowError(GetMessage("SALE_FEATURE_NOT_ALLOW"));
require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_admin.php";
die;
}
ClearVars();
$ID = IntVal($_REQUEST["id"]);
$arErrors = array();
if ($arProfile = CSaleOrderUserProps::GetByID($ID)) {
$USER_ID = IntVal($arProfile["USER_ID"]);
$PERSON_TYPE = IntVal($arProfile["PERSON_TYPE_ID"]);
$profileName = $arProfile["NAME"];
} else {
$arErrors[] = GetMessage("BUYER_PE_NO_PROFILE");
}
/*****************************************************************************/
/**************************** SAVE PROFILE ***********************************/
/*****************************************************************************/
if ($REQUEST_METHOD == "POST" && $saleModulePermissions >= "U" && check_bitrix_sessid() && !empty($arProfile)) {
$CODE_PROFILE_NAME = trim($_REQUEST["CODE_PROFILE_NAME"]);
示例14: GetUserGroups
static function GetUserGroups($userID = 0, $bGetFolders = true)
{
static $oCache = null;
static $CACHE_PATH = "/webdav/sonet_user_groups/";
if (!CBXFeatures::IsFeatureEnabled("Workgroups")) {
return array();
}
$userID = intval($userID);
if (intval($userID) <= 0) {
$userID = $GLOBALS['USER']->GetID();
}
//$currentUserGroups = CWebDavBase::CustomDataCache($CACHE_PATH, $userID);
//if (!$currentUserGroups)
//{
$currentUserGroups = array();
$db_res = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), array("USER_ID" => $userID), false, false, array("GROUP_ID", "GROUP_NAME", "GROUP_ACTIVE", "GROUP_CLOSED", "ROLE"));
while ($res = $db_res->GetNext()) {
if ($res['GROUP_ACTIVE'] == 'Y' && $res['GROUP_CLOSED'] == 'N' && $res['ROLE'] != SONET_ROLES_BAN && $res['ROLE'] != SONET_ROLES_REQUEST) {
$currentUserGroups[$res["GROUP_ID"]] = $res;
}
}
$arGroupID = array_keys($currentUserGroups);
if (is_array($arGroupID) && sizeof($arGroupID) > 0) {
$arFeatures = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arGroupID, 'files');
foreach ($arFeatures as $groupID => $enabled) {
if (!$enabled) {
unset($currentUserGroups[$groupID]);
}
}
}
if ($bGetFolders) {
$groupIBlock = CWebDavIblock::LibOptions('group_files', false, SITE_ID);
if ($groupIBlock && isset($groupIBlock['id']) && intval($groupIBlock['id']) > 0) {
$arFilter = array("IBLOCK_ID" => intval($groupIBlock['id']), "SECTION_ID" => 0, "CHECK_PERMISSIONS" => "N");
$dbSection = CIBlockSection::GetList(array(), $arFilter, false, array('ID', 'SOCNET_GROUP_ID'));
while ($arGroupSection = $dbSection->Fetch()) {
if (isset($currentUserGroups[$arGroupSection['SOCNET_GROUP_ID']])) {
$currentUserGroups[$arGroupSection['SOCNET_GROUP_ID']]['SECTION_ID'] = $arGroupSection['ID'];
}
}
//CWebDavBase::CustomDataCache($CACHE_PATH, $userID, $currentUserGroups, 'wd_socnet, iblock_id_'.intval($groupIBlock['id'])); // do not save to cache if LibOptions('group_files') is empty
}
}
//}
return $currentUserGroups;
}
示例15: InitUserPerms
function InitUserPerms($userID, $arGroup, $bCurrentUserIsAdmin)
{
global $arSocNetAllowedInitiatePerms;
global $arSocNetAllowedSpamPerms;
$arReturn = array();
$userID = IntVal($userID);
$groupID = IntVal($arGroup["ID"]);
$groupOwnerID = IntVal($arGroup["OWNER_ID"]);
$groupInitiatePerms = Trim($arGroup["INITIATE_PERMS"]);
$groupVisible = Trim($arGroup["VISIBLE"]);
$groupOpened = Trim($arGroup["OPENED"]);
$groupSpamPerms = Trim($arGroup["SPAM_PERMS"]);
if ($groupID <= 0 || $groupOwnerID <= 0 || !in_array($groupInitiatePerms, $arSocNetAllowedInitiatePerms)) {
return false;
}
$arReturn["Operations"] = array();
if (!in_array($groupSpamPerms, $arSocNetAllowedSpamPerms)) {
$groupSpamPerms = "K";
}
// UserRole - User role in group. False if user is not group member.
// UserIsMember - True in user is group member.
// UserIsOwner - True if user is group owner.
// UserCanInitiate - True if user can invite friends to group.
// UserCanViewGroup - True if user can view group.
// UserCanAutoJoinGroup - True if user can join group automatically.
// UserCanModifyGroup - True if user can modify group.
// UserCanModerateGroup - True if user can moderate group.
if ($userID <= 0) {
$arReturn["UserRole"] = false;
$arReturn["UserIsMember"] = false;
$arReturn["UserIsOwner"] = false;
$arReturn["UserCanInitiate"] = false;
$arReturn["UserCanViewGroup"] = $groupVisible == "Y";
$arReturn["UserCanAutoJoinGroup"] = false;
$arReturn["UserCanModifyGroup"] = false;
$arReturn["UserCanModerateGroup"] = false;
$arReturn["UserCanSpamGroup"] = false;
$arReturn["InitiatedByType"] = false;
$arReturn["Operations"]["viewsystemevents"] = false;
} else {
$arReturn["UserRole"] = CSocNetUserToGroup::GetUserRole($userID, $groupID);
$arReturn["UserIsMember"] = $arReturn["UserRole"] && in_array($arReturn["UserRole"], array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR, SONET_ROLES_USER));
$arReturn["InitiatedByType"] = false;
if ($arReturn["UserRole"] == SONET_ROLES_REQUEST) {
$dbRelation = CSocNetUserToGroup::GetList(array(), array("USER_ID" => $userID, "GROUP_ID" => $groupID), false, false, array("INITIATED_BY_TYPE"));
if ($arRelation = $dbRelation->Fetch()) {
$arReturn["InitiatedByType"] = $arRelation["INITIATED_BY_TYPE"];
}
}
$arReturn["UserIsOwner"] = $userID == $groupOwnerID;
if ($bCurrentUserIsAdmin) {
$arReturn["UserCanInitiate"] = true;
$arReturn["UserCanViewGroup"] = true;
$arReturn["UserCanAutoJoinGroup"] = true;
$arReturn["UserCanModifyGroup"] = true;
$arReturn["UserCanModerateGroup"] = true;
$arReturn["UserCanSpamGroup"] = true;
$arReturn["Operations"]["viewsystemevents"] = true;
} else {
if ($arReturn["UserIsMember"]) {
$arReturn["UserCanInitiate"] = $groupInitiatePerms == SONET_ROLES_OWNER && $arReturn["UserIsOwner"] || $groupInitiatePerms == SONET_ROLES_MODERATOR && in_array($arReturn["UserRole"], array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR)) || $groupInitiatePerms == SONET_ROLES_USER && $arReturn["UserIsMember"];
$arReturn["UserCanViewGroup"] = true;
$arReturn["UserCanAutoJoinGroup"] = false;
$arReturn["UserCanModifyGroup"] = $arReturn["UserIsOwner"];
$arReturn["UserCanModerateGroup"] = in_array($arReturn["UserRole"], array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR));
$arReturn["UserCanSpamGroup"] = $groupSpamPerms == SONET_ROLES_OWNER && $arReturn["UserIsOwner"] || $groupSpamPerms == SONET_ROLES_MODERATOR && in_array($arReturn["UserRole"], array(SONET_ROLES_OWNER, SONET_ROLES_MODERATOR)) || $groupSpamPerms == SONET_ROLES_USER && $arReturn["UserIsMember"] || $groupSpamPerms == SONET_ROLES_ALL;
$arReturn["Operations"]["viewsystemevents"] = true;
} else {
$arReturn["UserCanInitiate"] = false;
$arReturn["UserCanViewGroup"] = $groupVisible == "Y";
$arReturn["UserCanAutoJoinGroup"] = $arReturn["UserCanViewGroup"] && $groupOpened == "Y";
$arReturn["UserCanModifyGroup"] = false;
$arReturn["UserCanModerateGroup"] = false;
$arReturn["UserCanSpamGroup"] = $groupSpamPerms == SONET_ROLES_ALL;
$arReturn["Operations"]["viewsystemevents"] = false;
}
}
}
if (CModule::IncludeModule('extranet') && CExtranet::IsExtranetSite()) {
$arReturn["UserCanSpamGroup"] = true;
}
if (!CBXFeatures::IsFeatureEnabled("WebMessenger")) {
$arReturn["UserCanSpamGroup"] = false;
}
return $arReturn;
}