Beispiel #1
0
 function SetFeature($type, $id, $feature, $active, $featureName = false)
 {
     global $arSocNetAllowedEntityTypes, $APPLICATION;
     $type = Trim($type);
     if (StrLen($type) <= 0 || !in_array($type, $arSocNetAllowedEntityTypes)) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_ERROR_NO_ENTITY_TYPE"), "ERROR_EMPTY_TYPE");
         return false;
     }
     $id = IntVal($id);
     if ($id <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_EMPTY_ENTITY_ID"), "ERROR_EMPTY_ENTITY_ID");
         return false;
     }
     $feature = StrToLower(Trim($feature));
     if (StrLen($feature) <= 0) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_EMPTY_FEATURE_ID"), "ERROR_EMPTY_FEATURE_ID");
         return false;
     }
     $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures();
     if (!array_key_exists($feature, $arSocNetFeaturesSettings) || !in_array($type, $arSocNetFeaturesSettings[$feature]["allowed"])) {
         $GLOBALS["APPLICATION"]->ThrowException(GetMessage("SONET_GF_ERROR_NO_FEATURE_ID"), "ERROR_NO_FEATURE_ID");
         return false;
     }
     $active = $active ? "Y" : "N";
     $dbResult = CSocNetFeatures::GetList(array(), array("ENTITY_TYPE" => $type, "ENTITY_ID" => $id, "FEATURE" => $feature), false, false, array("ID", "ACTIVE"));
     if ($arResult = $dbResult->Fetch()) {
         $r = CSocNetFeatures::Update($arResult["ID"], array("FEATURE_NAME" => $featureName, "ACTIVE" => $active, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
     } else {
         $r = CSocNetFeatures::Add(array("ENTITY_TYPE" => $type, "ENTITY_ID" => $id, "FEATURE" => $feature, "FEATURE_NAME" => $featureName, "ACTIVE" => $active, "=DATE_UPDATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "=DATE_CREATE" => $GLOBALS["DB"]->CurrentTimeFunction()));
     }
     if (!$r) {
         $errorMessage = "";
         if ($e = $APPLICATION->GetException()) {
             $errorMessage = $e->GetString();
         }
         if (StrLen($errorMessage) <= 0) {
             $errorMessage = GetMessage("SONET_GF_ERROR_SET") . ".";
         }
         $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_SET_RECORD");
         return false;
     }
     return $r;
 }
<?php

if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) {
    die;
}
?>

<?php 
$pageId = "user_calendar";
include "util_menu.php";
include "util_profile.php";
$ownerId = $arResult["VARIABLES"]["user_id"];
if (isset($_GET['bx_enable_calendar']) && $_GET['bx_enable_calendar'] == 'Y') {
    $rsFeatures = CSocNetFeatures::GetList(array(), array("ENTITY_ID" => $ownerId, "ENTITY_TYPE" => SONET_ENTITY_USER, "FEATURE" => 'calendar'));
    if ($arFeature = $rsFeatures->Fetch()) {
        CSocNetFeatures::Update($arFeature['ID'], array('ACTIVE' => 'Y'));
        unset($GLOBALS['SONET_FEATURES_CACHE']);
    }
}
if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $ownerId, "calendar")) {
    $calendar2 = (!IsModuleInstalled("intranet") || COption::GetOptionString("intranet", "calendar_2", "N") == "Y") && CModule::IncludeModule("calendar");
    if ($calendar2) {
        $APPLICATION->IncludeComponent("bitrix:calendar.grid", "", array("CALENDAR_TYPE" => 'user', "OWNER_ID" => $ownerId, "ALLOW_SUPERPOSE" => $arParams['CALENDAR_ALLOW_SUPERPOSE'], "ALLOW_RES_MEETING" => $arParams["CALENDAR_ALLOW_RES_MEETING"], "SET_TITLE" => 'Y', "SET_NAV_CHAIN" => 'Y', 'NAME_TEMPLATE' => $arParams['NAME_TEMPLATE']), $component, array("HIDE_ICONS" => "Y"));
    } else {
        $APPLICATION->IncludeComponent("bitrix:intranet.event_calendar", ".default", array("IBLOCK_TYPE" => $arParams['CALENDAR_IBLOCK_TYPE'], "IBLOCK_ID" => $arParams['CALENDAR_USER_IBLOCK_ID'], "OWNER_ID" => $ownerId, "OWNER_TYPE" => 'USER', "INIT_DATE" => "", "WEEK_HOLIDAYS" => $arParams['CALENDAR_WEEK_HOLIDAYS'], "YEAR_HOLIDAYS" => $arParams['CALENDAR_YEAR_HOLIDAYS'], "LOAD_MODE" => "ajax", "USE_DIFFERENT_COLORS" => "Y", "EVENT_COLORS" => "", "ADVANCED_MODE_SETTINGS" => "Y", "SET_TITLE" => 'Y', "SET_NAV_CHAIN" => 'Y', "WORK_TIME_START" => $arParams['CALENDAR_WORK_TIME_START'], "WORK_TIME_END" => $arParams['CALENDAR_WORK_TIME_END'], "PATH_TO_USER" => $arResult["PATH_TO_USER"], "PATH_TO_USER_CALENDAR" => $arResult["PATH_TO_USER_CALENDAR"], "ALLOW_SUPERPOSE" => $arParams['CALENDAR_ALLOW_SUPERPOSE'], "SUPERPOSE_GROUPS_CALS" => $arParams['CALENDAR_SUPERPOSE_GROUPS_CALS'], "SUPERPOSE_USERS_CALS" => $arParams['CALENDAR_SUPERPOSE_USERS_CALS'], "SUPERPOSE_CUR_USER_CALS" => $arParams['CALENDAR_SUPERPOSE_CUR_USER_CALS'], "SUPERPOSE_CAL_IDS" => $arParams['CALENDAR_SUPERPOSE_CAL_IDS'], "SUPERPOSE_GROUPS_IBLOCK_ID" => $arParams['CALENDAR_SUPERPOSE_GROUPS_IBLOCK_ID'], "SUPERPOSE_USERS_IBLOCK_ID" => $arParams['CALENDAR_USER_IBLOCK_ID'], "USERS_IBLOCK_ID" => $arParams['CALENDAR_USER_IBLOCK_ID'], "ALLOW_RES_MEETING" => $arParams["CALENDAR_ALLOW_RES_MEETING"], "RES_MEETING_IBLOCK_ID" => $arParams["CALENDAR_RES_MEETING_IBLOCK_ID"], "PATH_TO_RES_MEETING" => $arParams["CALENDAR_PATH_TO_RES_MEETING"], "RES_MEETING_USERGROUPS" => $arParams["CALENDAR_RES_MEETING_USERGROUPS"], "REINVITE_PARAMS_LIST" => $arParams["CALENDAR_REINVITE_PARAMS_LIST"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "ALLOW_VIDEO_MEETING" => $arParams["CALENDAR_ALLOW_VIDEO_MEETING"], "VIDEO_MEETING_IBLOCK_ID" => $arParams["CALENDAR_VIDEO_MEETING_IBLOCK_ID"], "PATH_TO_VIDEO_MEETING" => $arParams["CALENDAR_PATH_TO_VIDEO_MEETING"], "PATH_TO_VIDEO_MEETING_DETAIL" => $arParams["CALENDAR_PATH_TO_VIDEO_MEETING_DETAIL"], "VIDEO_MEETING_USERGROUPS" => $arParams["CALENDAR_VIDEO_MEETING_USERGROUPS"]), $component, array("HIDE_ICONS" => "Y"));
    }
} elseif (strpos(POST_FORM_ACTION_URI, 'bx_enable_calendar=Y') === false) {
    $url = POST_FORM_ACTION_URI . (strpos(POST_FORM_ACTION_URI, '?') === false ? '?' : '&') . 'bx_enable_calendar=Y';
    echo GetMessage('SONET_U_CALENDAR_DIS_MES') . ' <a href="' . $url . '" title="' . GetMessage('SONET_U_CALENDAR_DIS_TITLE') . '">' . GetMessage('SONET_U_CALENDAR_TURN_ON') . '</a>';
}