function filterByFeaturePerms(&$arGroups, $arFeaturePerms) { $arGroupsIDs = array(); foreach ($arGroups as $value) { $arGroupsIDs[] = $value["ID"]; } if (sizeof($arGroupsIDs) > 0) { $feature = $arFeaturePerms[0]; $operations = $arFeaturePerms[1]; if (!is_array($operations)) { $operations = explode(",", $operations); } $arGroupsPerms = array(); foreach ($operations as $operation) { $tmpOps = CSocNetFeaturesPerms::CurrentUserCanPerformOperation(SONET_ENTITY_GROUP, $arGroupsIDs, $feature, $operation); if (is_array($tmpOps)) { foreach ($tmpOps as $key => $val) { if (!$arGroupsPerms[$key]) { $arGroupsPerms[$key] = $val; } } } } $arGroupsActive = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arGroupsIDs, $arFeaturePerms[0]); foreach ($arGroups as $key => $group) { if (!$arGroupsActive[$group["ID"]] || !$arGroupsPerms[$group["ID"]]) { unset($arGroups[$key]); } } } $arGroups = array_values($arGroups); }
static function Init($SOCNET_GROUP_ID, $IBLOCK_ID) { if (self::$bInit) { return self::$bInit; } if (!self::IsEnabledSocnet()) { return false; } self::$iSocNetId = intVal($SOCNET_GROUP_ID); // detect work group $arFilter = array(); $arFilter['IBLOCK_ID'] = $IBLOCK_ID; $arFilter['SOCNET_GROUP_ID'] = self::$iSocNetId; $arFilter['CHECK_PERMISSIONS'] = 'N'; $rsSection = CIBlockSection::GetList(array($by => $order), $arFilter, true); $obSection = $rsSection->GetNextElement(); if ($obSection !== false) { $arResult = $obSection->GetFields(); self::$iCatId = $arResult['ID']; self::$iCatLeftBorder = $arResult['LEFT_MARGIN']; self::$iCatRightBorder = $arResult['RIGHT_MARGIN']; } else { $arWorkGroup = CSocNetGroup::GetById(self::$iSocNetId); $arFields = array('ACTIVE' => 'Y', 'IBLOCK_ID' => $IBLOCK_ID, 'SOCNET_GROUP_ID' => self::$iSocNetId, 'CHECK_PERMISSIONS' => 'N', 'NAME' => $arWorkGroup['NAME']); $CIB_S = new CIBlockSection(); self::$iCatId = $CIB_S->Add($arFields); if (self::$iCatId == false) { self::$bInit = false; return false; } $rsSection = CIBlockSection::GetList(array($by => $order), $arFilter, true); $obSection = $rsSection->GetNextElement(); if ($obSection == false) { self::$bInit = false; return false; } $arResult = $obSection->GetFields(); self::$iCatLeftBorder = $arResult['LEFT_MARGIN']; self::$iCatRightBorder = $arResult['RIGHT_MARGIN']; } self::$bInit = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, self::$iSocNetId, 'wiki'); return self::$bInit; }
public static function CheckAccess($USER, $iblock_type_id, $iblock_id = false, $socnet_group_id = 0) { if ($socnet_group_id > 0 && CModule::IncludeModule('socialnetwork')) { if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $socnet_group_id, "group_lists")) { if ($iblock_id !== false) { return CListPermissions::_socnet_check($USER, $iblock_type_id, $iblock_id, intval($socnet_group_id)); } else { return CListPermissions::_socnet_type_check($USER, $iblock_type_id, $socnet_group_id); } } else { return CListPermissions::LISTS_FOR_SONET_GROUP_DISABLED; } } else { if ($iblock_id !== false) { return CListPermissions::_lists_check($USER, $iblock_type_id, $iblock_id); } else { return CListPermissions::_lists_type_check($USER, $iblock_type_id); } } }
function IsTasksFeatureActive($taskType, $ownerId) { $taskType = strtolower($taskType); if (!in_array($taskType, array("group", "user"))) { $taskType = "user"; } $ownerId = intval($ownerId); if ($ownerId <= 0) { $taskType = "user"; $ownerId = $GLOBALS["USER"]->GetID(); } $ownerId = intval($ownerId); if ($ownerId <= 0) { return false; } return CSocNetFeatures::IsActiveFeature($taskType == 'user' ? SONET_ENTITY_USER : SONET_ENTITY_GROUP, $ownerId, "tasks"); }
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")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "search")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "search")) { continue; } if ($gadget["WIKI_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki") || !CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki", "view", CSocNetUser::IsCurrentUserModuleAdmin()))) { continue; } if ($gadget["GROUP"]["ID"] == "") { $gadget["GROUP"]["ID"] = "other"; } if (!isset($gadget["TOTALLY_FIXED"]) || !$gadget["TOTALLY_FIXED"]) { if (!is_array($gadget["GROUP"]["ID"])) { $arGroups[$gadget["GROUP"]["ID"]]["GADGETS"][] = $gadget["ID"]; } else { foreach ($gadget["GROUP"]["ID"] as $group_id) { if (in_array($arParams["MODE"], array("SU", "SG")) && $group_id != "sonet" || !in_array($arParams["MODE"], array("SU", "SG")) && $group_id == "sonet" || $arParams["MODE"] == "AI" && $group_id != "admin" || $arParams["MODE"] != "AI" && $group_id == "admin") { continue; } $arGroups[$group_id]["GADGETS"][] = $gadget["ID"]; }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $pageId = "group_calendar"; include "util_group_menu.php"; include "util_group_profile.php"; $ownerId = $arResult["VARIABLES"]["group_id"]; if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $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" => 'group', "OWNER_ID" => $ownerId, "ALLOW_SUPERPOSE" => $arParams['CALENDAR_ALLOW_SUPERPOSE'], "ALLOW_RES_MEETING" => $arParams["CALENDAR_ALLOW_RES_MEETING"], "SET_TITLE" => 'Y', "SET_NAV_CHAIN" => 'Y'), $component, array("HIDE_ICONS" => "Y")); } else { $APPLICATION->IncludeComponent("bitrix:intranet.event_calendar", ".default", array("IBLOCK_TYPE" => $arParams['CALENDAR_IBLOCK_TYPE'], "IBLOCK_ID" => $arParams['CALENDAR_GROUP_IBLOCK_ID'], "OWNER_ID" => $ownerId, "OWNER_TYPE" => 'GROUP', "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" => $arParams["PATH_TO_USER"], "PATH_TO_USER_CALENDAR" => $arResult["PATH_TO_USER_CALENDAR"], "PATH_TO_GROUP" => $arResult["PATH_TO_GROUP"], "PATH_TO_GROUP_CALENDAR" => $arResult["PATH_TO_GROUP_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_GROUP_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"]), $component, array("HIDE_ICONS" => "Y")); } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $pageId = "group_tasks"; include "util_group_menu.php"; include "util_group_profile.php"; if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "tasks")) { ?> <?php if (COption::GetOptionString("intranet", "use_tasks_2_0", "N") == "Y") { $APPLICATION->IncludeComponent($arResult["VARIABLES"]["action"] == "edit" ? "bitrix:tasks.task.edit" : "bitrix:tasks.task.detail", ".default", array("GROUP_ID" => $arResult["VARIABLES"]["group_id"], "PAGE_VAR" => $arResult["ALIASES"]["page"], "GROUP_VAR" => $arResult["ALIASES"]["group_id"], "VIEW_VAR" => $arResult["ALIASES"]["view_id"], "TASK_VAR" => $arResult["ALIASES"]["task_id"], "ACTION_VAR" => $arResult["ALIASES"]["action"], "ACTION" => $arResult["VARIABLES"]["action"], "TASK_ID" => $arResult["VARIABLES"]["task_id"], "PATH_TO_GROUP_TASKS" => $arResult["PATH_TO_GROUP_TASKS"], "PATH_TO_GROUP_TASKS_TASK" => $arResult["PATH_TO_GROUP_TASKS_TASK"], "PATH_TO_GROUP_TASKS_VIEW" => $arResult["PATH_TO_GROUP_TASKS_VIEW"], "PATH_TO_USER_TASKS_TEMPLATES" => $arParams["PATH_TO_USER_TASKS_TEMPLATES"], "PATH_TO_USER_TEMPLATES_TEMPLATE" => $arParams["PATH_TO_USER_TEMPLATES_TEMPLATE"], "PATH_TO_USER_PROFILE" => $arParams["PATH_TO_USER"], "SHOW_RATING" => $arParams["SHOW_RATING"], "RATING_TYPE" => $arParams["RATING_TYPE"], "PATH_TO_GROUP" => $arResult["PATH_TO_GROUP"], "PATH_TO_MESSAGES_CHAT" => $arParams["PATH_TO_MESSAGES_CHAT"], "PATH_TO_VIDEO_CALL" => $arParams["PATH_TO_VIDEO_CALL"], "PATH_TO_CONPANY_DEPARTMENT" => $arParams["PATH_TO_CONPANY_DEPARTMENT"], "PATH_TO_FORUM_SMILE" => $arParams["PATH_TO_FORUM_SMILE"], "TASKS_FIELDS_SHOW" => $arParams["TASKS_FIELDS_SHOW"], "SET_NAV_CHAIN" => $arResult["SET_NAV_CHAIN"], "SET_TITLE" => $arResult["SET_TITLE"], "FORUM_ID" => $arParams["TASK_FORUM_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => $arResult["DATE_TIME_FORMAT"], "SHOW_YEAR" => $arParams["SHOW_YEAR"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "THUMBNAIL_LIST_SIZE" => 30), $component, array("HIDE_ICONS" => "Y")); } else { $APPLICATION->IncludeComponent("bitrix:intranet.tasks.menu", ".default", array("IBLOCK_ID" => $arParams["TASK_IBLOCK_ID"], "OWNER_ID" => $arResult["VARIABLES"]["group_id"], "TASK_TYPE" => 'group', "PAGE_VAR" => $arResult["ALIASES"]["page"], "GROUP_VAR" => $arResult["ALIASES"]["group_id"], "VIEW_VAR" => $arResult["ALIASES"]["view_id"], "TASK_VAR" => $arResult["ALIASES"]["task_id"], "ACTION_VAR" => $arResult["ALIASES"]["action"], "ACTION" => $arResult["VARIABLES"]["action"], "TASK_ID" => $arResult["VARIABLES"]["task_id"], "PATH_TO_GROUP_TASKS" => $arResult["PATH_TO_GROUP_TASKS"], "PATH_TO_GROUP_TASKS_TASK" => $arResult["PATH_TO_GROUP_TASKS_TASK"], "PATH_TO_GROUP_TASKS_VIEW" => $arResult["PATH_TO_GROUP_TASKS_VIEW"], "PAGE_ID" => "group_tasks_task"), $component, array("HIDE_ICONS" => "Y")); $zzz = $APPLICATION->IncludeComponent("bitrix:intranet.tasks.create", ".default", array("IBLOCK_ID" => $arParams["TASK_IBLOCK_ID"], "OWNER_ID" => $arResult["VARIABLES"]["group_id"], "TASK_TYPE" => 'group', "PAGE_VAR" => $arResult["ALIASES"]["page"], "GROUP_VAR" => $arResult["ALIASES"]["group_id"], "VIEW_VAR" => $arResult["ALIASES"]["view_id"], "TASK_VAR" => $arResult["ALIASES"]["task_id"], "ACTION_VAR" => $arResult["ALIASES"]["action"], "ACTION" => $arResult["VARIABLES"]["action"], "TASK_ID" => $arResult["VARIABLES"]["task_id"], "PATH_TO_GROUP_TASKS" => $arResult["PATH_TO_GROUP_TASKS"], "PATH_TO_GROUP_TASKS_TASK" => $arResult["PATH_TO_GROUP_TASKS_TASK"], "PATH_TO_GROUP_TASKS_VIEW" => $arResult["PATH_TO_GROUP_TASKS_VIEW"], "PATH_TO_USER" => $arParams["PATH_TO_USER"], "PATH_TO_GROUP" => $arResult["PATH_TO_GROUP"], "PATH_TO_MESSAGES_CHAT" => $arParams["PATH_TO_MESSAGES_CHAT"], "PATH_TO_VIDEO_CALL" => $arParams["PATH_TO_VIDEO_CALL"], "PATH_TO_CONPANY_DEPARTMENT" => $arParams["PATH_TO_CONPANY_DEPARTMENT"], "TASKS_FIELDS_SHOW" => $arParams["TASKS_FIELDS_SHOW"], "SET_NAV_CHAIN" => $arResult["SET_NAV_CHAIN"], "SET_TITLE" => $arResult["SET_TITLE"], "FORUM_ID" => $arParams["TASK_FORUM_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => $arResult["DATE_TIME_FORMAT"], "SHOW_YEAR" => $arParams["SHOW_YEAR"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "THUMBNAIL_LIST_SIZE" => 30), $component, array("HIDE_ICONS" => "Y")); if ($zzz && IntVal($arResult["VARIABLES"]["task_id"]) > 0 && $arResult["VARIABLES"]["action"] == "view") { ?> <br /><br /> <?php $APPLICATION->IncludeComponent("bitrix:forum.topic.reviews", "", array("CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "MESSAGES_PER_PAGE" => $arParams["ITEM_DETAIL_COUNT"], "USE_CAPTCHA" => "N", "PREORDER" => "Y", "PATH_TO_SMILE" => $arParams["PATH_TO_FORUM_SMILE"], "FORUM_ID" => $arParams["TASK_FORUM_ID"], "URL_TEMPLATES_READ" => $arParams["URL_TEMPLATES_READ"], "SHOW_LINK_TO_FORUM" => "N", "ELEMENT_ID" => $arResult["VARIABLES"]["task_id"]), $component, array("HIDE_ICONS" => "Y")); } } }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $pageId = "user_tasks"; include "util_menu.php"; include "util_profile.php"; if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "tasks") && COption::GetOptionString("intranet", "use_tasks_2_0", "N") == "Y") { $APPLICATION->IncludeComponent("bitrix:tasks.templates.list", ".default", array("USER_ID" => $arResult["VARIABLES"]["user_id"], "ITEMS_COUNT" => $arParams["ITEM_DETAIL_COUNT"], "PAGE_VAR" => $arResult["ALIASES"]["page"], "USER_VAR" => $arResult["ALIASES"]["user_id"], "VIEW_VAR" => $arResult["ALIASES"]["view_id"], "TASK_VAR" => $arResult["ALIASES"]["task_id"], "TEMPLATE_VAR" => $arResult["ALIASES"]["template_id"], "ACTION_VAR" => $arResult["ALIASES"]["action"], "PATH_TO_USER_PROFILE" => $arResult["PATH_TO_USER"], "PATH_TO_MESSAGES_CHAT" => $arResult["PATH_TO_MESSAGES_CHAT"], "PATH_TO_CONPANY_DEPARTMENT" => $arParams["PATH_TO_CONPANY_DEPARTMENT"], "PATH_TO_VIDEO_CALL" => $arResult["PATH_TO_VIDEO_CALL"], "PATH_TO_USER_TASKS" => $arResult["PATH_TO_USER_TASKS"], "PATH_TO_USER_TASKS_TASK" => $arResult["PATH_TO_USER_TASKS_TASK"], "PATH_TO_USER_TASKS_VIEW" => $arResult["PATH_TO_USER_TASKS_VIEW"], "PATH_TO_USER_TASKS_REPORT" => $arResult["PATH_TO_USER_TASKS_REPORT"], "PATH_TO_USER_TASKS_TEMPLATES" => $arResult["PATH_TO_USER_TASKS_TEMPLATES"], "PATH_TO_USER_TEMPLATES_TEMPLATE" => $arResult["PATH_TO_USER_TEMPLATES_TEMPLATE"], "PATH_TO_GROUP_TASKS" => $arParams["PATH_TO_GROUP_TASKS"], "PATH_TO_GROUP_TASKS_TASK" => $arParams["PATH_TO_GROUP_TASKS_TASK"], "PATH_TO_GROUP_TASKS_VIEW" => $arParams["PATH_TO_GROUP_TASKS_VIEW"], "PATH_TO_GROUP_TASKS_REPORT" => $arParams["PATH_TO_GROUP_TASKS_REPORT"], "TASKS_FIELDS_SHOW" => $arParams["TASKS_FIELDS_SHOW"], "SET_NAV_CHAIN" => $arResult["SET_NAV_CHAIN"], "SET_TITLE" => $arResult["SET_TITLE"], "FORUM_ID" => $arParams["TASK_FORUM_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "DATE_TIME_FORMAT" => $arResult["DATE_TIME_FORMAT"], "SHOW_YEAR" => $arParams["SHOW_YEAR"], "CACHE_TYPE" => $arParams["CACHE_TYPE"], "CACHE_TIME" => $arParams["CACHE_TIME"], "USE_THUMBNAIL_LIST" => "N", "INLINE" => "Y"), $component, array("HIDE_ICONS" => "Y")); }
function SocnetEMailMessageAdd($arMessageFields, $ACTION_VARS) { if (!is_array($arMessageFields["FORUM_EMAIL_FILTER"])) { return false; } if (!CModule::IncludeModule("socialnetwork")) { return false; } $arParams = $arMessageFields["FORUM_EMAIL_FILTER"]; if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum")) { return false; } // Найдем кто отправитель $message_email = strlen($arMessageFields["FIELD_REPLY_TO"]) > 0 ? $arMessageFields["FIELD_REPLY_TO"] : $arMessageFields["FIELD_FROM"]; $message_email_addr = strtolower(CMailUtil::ExtractMailAddress($message_email)); $o = "LAST_LOGIN"; $b = "DESC"; $res = CUser::GetList($o, $b, array("ACTIVE" => "Y", "EMAIL" => $message_email_addr)); if (($arUser = $res->Fetch()) && strtolower(CMailUtil::ExtractMailAddress($arUser["EMAIL"])) == $message_email_addr) { $AUTHOR_USER_ID = $arUser["ID"]; } elseif ($arParams["NOT_MEMBER_POST"] == "Y") { $AUTHOR_USER_ID = false; } else { CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR1") . ": " . $message_email_addr)); return false; } if ($arParams["NOT_MEMBER_POST"] != "Y") { // Проверим права доступа if (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "full")) { $PERMISSION = "Y"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "newtopic")) { $PERMISSION = "M"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($AUTHOR_USER_ID, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "answer")) { $PERMISSION = "I"; } else { CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR2") . " " . $arUser["LOGIN"] . " [" . $AUTHOR_USER_ID . "] (" . $message_email_addr . ")")); return false; } } $body = $arMessageFields["BODY"]; //$body = preg_replace("/(\r\n)+/", "\r\n", $body); $p = strpos($body, "\r\nFrom:"); if ($p > 0) { $body = substr($body, 0, $p) . "\r\n[CUT]" . substr($body, $p) . "[/CUT]"; } $subject = $arMessageFields["SUBJECT"]; // обрежем все RE и FW $subject = trim(preg_replace('#^\\s*((RE[0-9\\[\\]]*:\\s*)|(FW:\\s*))+(.*)$#i', '\\4', $subject)); if ($subject == '') { $subject = GetMessage("FORUM_MAIL_EMPTY_TOPIC_TITLE") . " " . rand(); } // Найдем какая тема $arFields = array(); $FORUM_ID = IntVal($arParams["FORUM_ID"]); $SOCNET_GROUP_ID = IntVal($arParams["SOCNET_GROUP_ID"]); $TOPIC_ID = 0; global $DB; if ($arMessageFields["IN_REPLY_TO"] != '') { $dbTopic = $DB->Query("SELECT FT.ID FROM b_forum_topic FT INNER JOIN b_forum_message FM ON FM.TOPIC_ID=FT.ID WHERE FM.XML_ID='" . $DB->ForSQL($arMessageFields["IN_REPLY_TO"], 255) . "' AND FT.FORUM_ID=" . $FORUM_ID . " AND FT.SOCNET_GROUP_ID=" . $SOCNET_GROUP_ID); if ($arTopic = $dbTopic->Fetch()) { $TOPIC_ID = $arTopic["ID"]; } } if ($arParams["USE_SUBJECT"] == "Y" && $TOPIC_ID <= 0) { $dbTopic = $DB->Query("SELECT ID FROM b_forum_topic WHERE TITLE='" . $DB->ForSQL($subject, 255) . "' AND FORUM_ID=" . $FORUM_ID . " AND SOCNET_GROUP_ID=" . $SOCNET_GROUP_ID); // ограничить по старости? if ($arTopic = $dbTopic->Fetch()) { $TOPIC_ID = $arTopic["ID"]; } } if ($AUTHOR_USER_ID > 0) { if ($TOPIC_ID < 0 && $PERMISSION <= "I") { CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR3") . " " . $arUser["LOGIN"] . " [" . $AUTHOR_USER_ID . "] (" . $message_email_addr . ")")); return false; } $bSHOW_NAME = true; $res = CForumUser::GetByUSER_ID($AUTHOR_USER_ID); if ($res) { $bSHOW_NAME = $res["SHOW_NAME"] == "Y"; } if ($bSHOW_NAME) { $AUTHOR_NAME = $arUser["NAME"] . (strlen($arUser["NAME"]) <= 0 || strlen($arUser["LAST_NAME"]) <= 0 ? "" : " ") . $arUser["LAST_NAME"]; } if (strlen(Trim($AUTHOR_NAME)) <= 0) { $AUTHOR_NAME = $arUser["LOGIN"]; } } else { $AUTHOR_NAME = $arMessageFields["FIELD_FROM"]; $arFields["AUTHOR_EMAIL"] = $arMessageFields["FIELD_FROM"]; } $arFields["NEW_TOPIC"] = "N"; if ($PERMISSION >= "Q") { $arFields["APPROVED"] = "Y"; } else { $arFields["APPROVED"] = $arParams["MODERATION"] == "Y" ? "N" : "Y"; } // Добавим новую тему if ($TOPIC_ID <= 0) { $arTopicFields = array("TITLE" => $subject, "FORUM_ID" => $FORUM_ID, "USER_START_ID" => $AUTHOR_USER_ID, "OWNER_ID" => $AUTHOR_USER_ID, "SOCNET_GROUP_ID" => $SOCNET_GROUP_ID); $arTopicFields["XML_ID"] = $arMessageFields["MSG_ID"]; $arTopicFields["APPROVED"] = $arFields['APPROVED']; $arTopicFields["USER_START_NAME"] = $AUTHOR_NAME; $arTopicFields["LAST_POSTER_NAME"] = $AUTHOR_NAME; $TOPIC_ID = CForumTopic::Add($arTopicFields); if (IntVal($TOPIC_ID) <= 0) { CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR4"))); return false; } $arFields["NEW_TOPIC"] = "Y"; } // Добавим сообщение $arFields["POST_MESSAGE"] = $body; // Аттаченные файлы $arFILES = array(); $rsAttach = CMailAttachment::GetList(array(), array("MESSAGE_ID" => $arMessageFields["ID"])); while ($arAttach = $rsAttach->Fetch()) { $filename = CTempFile::GetFileName(md5(uniqid("")) . ".tmp"); CheckDirPath($filename); if (file_put_contents($filename, $arAttach["FILE_DATA"]) !== false) { $arFile = array("name" => $arAttach["FILE_NAME"], "type" => $arAttach["CONTENT_TYPE"], "size" => @filesize($filename), "tmp_name" => $filename, "MODULE_ID" => "forum"); $arFilter = array("FORUM_ID" => $FORUM_ID); $arFiles = array($arFile); if (CForumFiles::CheckFields($arFiles, $arFilter)) { $arFILES[] = $arFiles[0]; } else { $oError = $GLOBALS["APPLICATION"]->GetException(); CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR6") . " (" . $arAttach["FILE_NAME"] . "): " . ($oError && $oError->GetString() ? $oError->GetString() : ""))); } } } if (count($arFILES) > 0) { $arFields["FILES"] = $arFILES; } $arFields["AUTHOR_NAME"] = $AUTHOR_NAME; $arFields["AUTHOR_ID"] = $AUTHOR_USER_ID; $arFields["FORUM_ID"] = $FORUM_ID; $arFields["TOPIC_ID"] = $TOPIC_ID; $arFields["XML_ID"] = $arMessageFields["MSG_ID"]; $arFields["SOURCE_ID"] = "EMAIL"; $arRes = array(); if (!empty($arMessageFields["FIELD_FROM"])) { $arRes[] = "From: " . $arMessageFields["FIELD_FROM"]; } if (!empty($arMessageFields["FIELD_TO"])) { $arRes[] = "To: " . $arMessageFields["FIELD_TO"]; } if (!empty($arMessageFields["FIELD_CC"])) { $arRes[] = "Cc: " . $arMessageFields["FIELD_CC"]; } if (!empty($arMessageFields["FIELD_BCC"])) { $arRes[] = "Bcc: " . $arMessageFields["FIELD_BCC"]; } $arRes[] = "Subject: " . $arMessageFields["SUBJECT"]; $arRes[] = "Date: " . $arMessageFields["FIELD_DATE"]; $arFields["MAIL_HEADER"] = implode("\r\n", $arRes); preg_match_all('#Received:\\s+from\\s+(.*)by.*#i', $arMessageFields["HEADER"], $regs); if (is_array($regs) && is_array($regs[1])) { $arFields["AUTHOR_IP"] = $arFields["AUTHOR_REAL_IP"] = '<email: ' . $regs[1][count($regs[1]) - 1] . '>'; } else { $arFields["AUTHOR_IP"] = $arFields["AUTHOR_REAL_IP"] = '<email: no address>'; } /* $AUTHOR_IP = ForumGetRealIP(); $AUTHOR_IP_tmp = $AUTHOR_IP; $AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR']; if (COption::GetOptionString("forum", "FORUM_GETHOSTBYADDR", "N") == "Y") { $AUTHOR_IP = @gethostbyaddr($AUTHOR_IP); if ($AUTHOR_IP_tmp==$AUTHOR_REAL_IP) $AUTHOR_REAL_IP = $AUTHOR_IP; else $AUTHOR_REAL_IP = @gethostbyaddr($AUTHOR_REAL_IP); } $arFields["AUTHOR_IP"] = ($AUTHOR_IP!==False) ? $AUTHOR_IP : "<no address>"; $arFields["AUTHOR_REAL_IP"] = ($AUTHOR_REAL_IP!==False) ? $AUTHOR_REAL_IP : "<no address>"; */ $strErrorMessage = ''; $MESSAGE_ID = CForumMessage::Add($arFields, false); if (intVal($MESSAGE_ID) <= 0) { $str = $GLOBALS['APPLICATION']->GetException(); if ($str && $str->GetString()) { $strErrorMessage .= "[" . $str->GetString() . "]"; } if ($arFields["NEW_TOPIC"] == 'Y') { CForumTopic::Delete($TOPIC_ID); } CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_ERROR", "MESSAGE" => GetMessage("FORUM_MAIL_ERROR5") . " " . $strErrorMessage)); } if ($MESSAGE_ID > 0) { CMailLog::AddMessage(array("MAILBOX_ID" => $arMessageFields["MAILBOX_ID"], "MESSAGE_ID" => $arMessageFields["ID"], "FILTER_ID" => $arParams["MAIL_FILTER_ID"], "LOG_TYPE" => "FILTER_COMPLETE", "MESSAGE" => GetMessage("FORUM_MAIL_OK") . " " . $MESSAGE_ID . " (TID#" . $TOPIC_ID . ")")); CForumMessage::SendMailMessage($MESSAGE_ID, array(), false, "NEW_FORUM_MESSAGE"); $dbSite = CSite::GetById($arMessageFields["LID"]); if ($arSite = $dbSite->Fetch()) { $lang = $arSite['LANGUAGE_ID']; } else { $lang = $LANGUAGE_ID; } $parser = new forumTextParser(); $arForum = CForumNew::GetByID($FORUM_ID); $arAllow = array("HTML" => "N", "ANCHOR" => "N", "BIU" => "N", "IMG" => "N", "LIST" => "N", "QUOTE" => "N", "CODE" => "N", "FONT" => "N", "SMILES" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => "N", "TABLE" => "N", "ALIGN" => "N"); if ($arFields["NEW_TOPIC"] == "Y") { $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $AUTHOR_NAME, CForumEmail::GetLangMessage("FORUM_MAIL_SOCNET_TITLE_TOPIC", $lang)), "TITLE" => $subject, "MESSAGE" => $parser->convert($body, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($body), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $AUTHOR_USER_ID, "FID" => $FORUM_ID, "TID" => $TOPIC_ID, "MID" => $MESSAGE_ID)), "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $TOPIC_ID)))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $MESSAGE_ID, "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => intval($TOPIC_ID)); if (intVal($AUTHOR_USER_ID) > 0) { $arFieldsForSocnet["USER_ID"] = $AUTHOR_USER_ID; } $logID = CSocNetLog::Add($arFieldsForSocnet, false); if (intval($logID) > 0) { CSocNetLog::Update($logID, array("TMP_ID" => $logID)); CSocNetLogRights::SetForSonet($logID, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true); CSocNetLog::SendEvent($logID, "SONET_NEW_EVENT", $logID); } } else { $dbForumMessage = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $TOPIC_ID)); if ($arForumMessage = $dbForumMessage->Fetch()) { $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "forum", "SOURCE_ID" => $arForumMessage["ID"]), false, false, array("ID", "TMP_ID")); if ($arRes = $dbRes->Fetch()) { $log_id = $arRes["TMP_ID"]; } else { $dbFirstMessage = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $arForumMessage["TOPIC_ID"]), false, 1); if ($arFirstMessage = $dbFirstMessage->Fetch()) { $arTopic = CForumTopic::GetByID($arFirstMessage["TOPIC_ID"]); $sFirstMessageText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arFirstMessage["POST_MESSAGE_FILTER"] : $arFirstMessage["POST_MESSAGE"]; $sFirstMessageURL = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $arFirstMessage["AUTHOR_ID"], "FID" => $arFirstMessage["FORUM_ID"], "TID" => $arFirstMessage["TOPIC_ID"], "MID" => $arFirstMessage["ID"])); $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "LOG_DATE" => $arFirstMessage["POST_DATE"], "LOG_UPDATE" => $arFirstMessage["POST_DATE"], "TITLE_TEMPLATE" => str_replace("#AUTHOR_NAME#", $arFirstMessage["AUTHOR_NAME"], GetMessage("SONET_FORUM_LOG_TOPIC_TEMPLATE")), "TITLE" => $arTopic["TITLE"], "MESSAGE" => $parser->convert($sFirstMessageText, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($sFirstMessageText), "URL" => $sFirstMessageURL, "PARAMS" => serialize(array("PATH_TO_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("TID" => $arFirstMessage["TOPIC_ID"])))), "MODULE_ID" => false, "CALLBACK_FUNC" => false, "SOURCE_ID" => $arFirstMessage["ID"], "RATING_TYPE_ID" => "FORUM_TOPIC", "RATING_ENTITY_ID" => intval($arFirstMessage["TOPIC_ID"])); if (intVal($arFirstMessage["AUTHOR_ID"]) > 0) { $arFieldsForSocnet["USER_ID"] = $arFirstMessage["AUTHOR_ID"]; } $log_id = CSocNetLog::Add($arFieldsForSocnet, false); if (intval($log_id) > 0) { CSocNetLog::Update($log_id, array("TMP_ID" => $log_id)); CSocNetLogRights::SetForSonet($log_id, $arFieldsForSocnet["ENTITY_TYPE"], $arFieldsForSocnet["ENTITY_ID"], "forum", "view", true); } } } if (intval($log_id) > 0) { $arFieldsForSocnet = array("ENTITY_TYPE" => SONET_ENTITY_GROUP, "ENTITY_ID" => $SOCNET_GROUP_ID, "EVENT_ID" => "forum", "LOG_ID" => $log_id, "=LOG_DATE" => $GLOBALS["DB"]->CurrentTimeFunction(), "MESSAGE" => $parser->convert($body, $arAllow), "TEXT_MESSAGE" => $parser->convert4mail($body), "URL" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("UID" => $AUTHOR_USER_ID, "FID" => $FORUM_ID, "TID" => $TOPIC_ID, "MID" => $MESSAGE_ID)), "MODULE_ID" => false, "SOURCE_ID" => $MESSAGE_ID, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => intval($MESSAGE_ID)); if (intVal($AUTHOR_USER_ID) > 0) { $arFieldsForSocnet["USER_ID"] = $AUTHOR_USER_ID; } CSocNetLogComments::Add($arFieldsForSocnet); } } } } }
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")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "search")) { continue; } if ($gadget["SEARCH_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "search")) { continue; } if ($gadget["GROUP"]["ID"] == "") { $gadget["GROUP"]["ID"] = "other"; } if (!is_array($gadget["GROUP"]["ID"])) { $arGroups[$gadget["GROUP"]["ID"]]["GADGETS"][] = $gadget["ID"]; } else { foreach ($gadget["GROUP"]["ID"] as $group_id) { if (($arParams["MODE"] == "SU" || $arParams["MODE"] == "SG") && $group_id != "sonet") { continue; } elseif ($arParams["MODE"] != "SU" && $arParams["MODE"] != "SG" && $group_id == "sonet") { continue; } elseif ($arParams["MODE"] == "AI" && $group_id != "admin") { continue;
} } } if ($arParams["SET_TITLE"] == "Y" && !empty($strTitle)) { $APPLICATION->SetTitle($strTitle); if ($componentPage == "user_photo") $arParams["SET_TITLE"] = "N"; elseif ($componentPage == "user_photo_gallery" && empty($arResult["VARIABLES"]["section_id"])) $arParams["SET_TITLE"] = "N"; } /************** Navigation/*****************************************/ /******************************************************************** Fatal errors ********************************************************************/ if (($object == "user" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "photo")) || ($object == "group" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "photo"))) { $arParams["ERROR_MESSAGE"] = GetMessage("SONET_PHOTO_IS_NOT_ACTIVE"); return 0; } elseif (!CModule::IncludeModule("photogallery")) { $arParams["ERROR_MESSAGE"] = GetMessage("SONET_P_MODULE_IS_NOT_INSTALLED"); return 0; } elseif (!CModule::IncludeModule("iblock")) { $arParams["ERROR_MESSAGE"] = GetMessage("SONET_IB_MODULE_IS_NOT_INSTALLED"); return 0; } elseif (($object == "user" && $arParams["PHOTO_USER_IBLOCK_ID"] <= 0) || ($object == "group" && $arParams["PHOTO_GROUP_IBLOCK_ID"] <= 0))
} else { $arParams["CACHE_TIME"] = 0; } $arParams["CACHE_TAGS"] = !empty($arParams["CACHE_TAGS"]) ? $arParams["CACHE_TAGS"] : array(); //$arParams["CACHE_TIME"] = 0; /******************************************************************** /Input params ********************************************************************/ global $CACHE_MANAGER; $cache_path = CComponentEngine::MakeComponentPath("bitrix:socialnetwork.blog.blog"); $bGroupMode = $arParams["SOCNET_GROUP_ID"] > 0; $feature = "blog"; $user_id = intval($USER->GetID()); $arResult["ERROR_MESSAGE"] = array(); $arResult["OK_MESSAGE"] = array(); if (!($bGroupMode && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], $feature) || CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], $feature))) { $arResult["ERROR_MESSAGE"][] = array("id" => "SONET_MODULE_NOT_AVAIBLE", "text" => GetMessage("BLOG_SONET_MODULE_NOT_AVAIBLE")); } else { if (!($arParams["USER_ID"] > 0 || $bGroupMode)) { $arResult["ERROR_MESSAGE"][] = array("id" => "NO_BLOG", "text" => GetMessage("BLOG_BLOG_BLOG_NO_BLOG")); CHTTP::SetStatus("404 Not Found"); } else { $arResult["perms"] = BLOG_PERMS_DENY; $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); if ($bGroupMode) { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "full_post", $bCurrentUserIsAdmin) || $APPLICATION->GetGroupRight("blog") >= "W") { $arResult["perms"] = BLOG_PERMS_FULL; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "moderate_post", $bCurrentUserIsAdmin)) { $arResult["perms"] = BLOG_PERMS_MODERATE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "write_post", $bCurrentUserIsAdmin)) { $arResult["perms"] = BLOG_PERMS_WRITE;
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $pageId = "group_calendar"; include "util_group_menu.php"; include "util_group_profile.php"; $ownerId = $arResult["VARIABLES"]["group_id"]; if (CSocNetGroup::GetByID($ownerId) && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $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" => 'group', "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'], 'PATH_TO_USER' => $arParams['PATH_TO_USER'], 'PATH_TO_COMPANY_DEPARTMENT' => $arParams['PATH_TO_CONPANY_DEPARTMENT'], 'HIDE_OWNER_IN_TITLE' => $arParams['HIDE_OWNER_IN_TITLE']), $component, array("HIDE_ICONS" => "Y")); } else { $APPLICATION->IncludeComponent("bitrix:intranet.event_calendar", ".default", array("IBLOCK_TYPE" => $arParams['CALENDAR_IBLOCK_TYPE'], "IBLOCK_ID" => $arParams['CALENDAR_GROUP_IBLOCK_ID'], "OWNER_ID" => $ownerId, "OWNER_TYPE" => 'GROUP', "MULTIPLE_MODE" => 'Y', "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" => $arParams["PATH_TO_USER"], "PATH_TO_USER_CALENDAR" => $arResult["PATH_TO_USER_CALENDAR"], "PATH_TO_GROUP" => $arResult["PATH_TO_GROUP"], "PATH_TO_GROUP_CALENDAR" => $arResult["PATH_TO_GROUP_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_GROUP_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"], "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")); } }
$arParams["PATH_TO_USER"] = htmlspecialcharsbx($APPLICATION->GetCurPage() . "?" . $arParams["PAGE_VAR"] . "=user&" . $arParams["USER_VAR"] . "=#user_id#"); } $arParams["PATH_TO_SMILE"] = strlen(trim($arParams["PATH_TO_SMILE"])) <= 0 ? false : trim($arParams["PATH_TO_SMILE"]); $arParams["IMAGE_MAX_WIDTH"] = IntVal($arParams["IMAGE_MAX_WIDTH"]); $arParams["IMAGE_MAX_HEIGHT"] = IntVal($arParams["IMAGE_MAX_HEIGHT"]); $arParams["ALLOW_POST_CODE"] = $arParams["ALLOW_POST_CODE"] !== "N"; $user_id = IntVal($USER->GetID()); if ($arParams["SET_TITLE"] == "Y") { $APPLICATION->SetTitle(GetMessage("BLOG_MOD_TITLE")); } $bGroupMode = false; if (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { $bGroupMode = true; } if (IntVal($arParams["SOCNET_GROUP_ID"]) > 0 || IntVal($arParams["USER_ID"]) > 0 && $user_id == $arParams["USER_ID"]) { if ($bGroupMode && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog") || IntVal($arParams["USER_ID"]) > 0) { $arResult["ERROR_MESSAGE"] = array(); $arResult["OK_MESSAGE"] = array(); $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); $arResult["perms"] = BLOG_PERMS_DENY; if (!$bGroupMode) { $arResult["perms"] = BLOG_PERMS_FULL; } else { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "full_post", $bCurrentUserIsAdmin) || $APPLICATION->GetGroupRight("blog") >= "W") { $arResult["perms"] = BLOG_PERMS_FULL; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "moderate_post", $bCurrentUserIsAdmin)) { $arResult["perms"] = BLOG_PERMS_MODERATE; } } if ($arResult["perms"] >= BLOG_PERMS_MODERATE) { //Message delete
if (intval($arParams["PHOTO_COUNT"]) <= 0) $arParams["PHOTO_COUNT"] = 6; if (intval($arParams["PHOTO_THUMBNAIL_SIZE"]) <= 0) $arParams["PHOTO_THUMBNAIL_SIZE"] = 48; if( IntVal($GLOBALS["USER"]->GetID()) > 0 && ( ( $arParams["ENTITY_TYPE"] != SONET_ENTITY_GROUP && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $GLOBALS["USER"]->GetID(), "blog") ) || ( $arParams["ENTITY_TYPE"] == SONET_ENTITY_GROUP && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog") ) ) ) $arResult["MICROBLOG_USER_ID"] = $GLOBALS["USER"]->GetID(); $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); $arResult["TZ_OFFSET"] = CTimeZone::GetOffset(); $GLOBALS["arExtranetGroupID"] = array(); $GLOBALS["arExtranetUserID"] = array(); if($GLOBALS["USER"]->IsAuthorized()) { if(defined("BX_COMP_MANAGED_CACHE"))
public static function GetSuperposedList($Params = array()) { global $DB; $checkPermissions = $Params['checkPermissions'] !== false; $checkSocnetPermissions = $Params['checkSocnetPermissions'] !== false; $userId = isset($Params['userId']) ? intVal($Params['userId']) : self::$userId; $arResult = array(); $arSectionIds = array(); $sqlSearch = ""; // Common types $strTypes = ""; if (isset($Params['TYPES']) && is_array($Params['TYPES'])) { foreach ($Params['TYPES'] as $type) { $strTypes .= ",'" . CDatabase::ForSql($type) . "'"; } $strTypes = trim($strTypes, ", "); if ($strTypes != "") { $sqlSearch .= "(CS.CAL_TYPE in (" . $strTypes . "))"; } } // Group's calendars $strGroups = "0"; if (is_array($Params['GROUPS']) && count($Params['GROUPS']) > 0) { foreach ($Params['GROUPS'] as $ownerId) { if (IntVal($ownerId) > 0) { $strGroups .= "," . IntVal($ownerId); } } if ($strGroups != "0") { if ($sqlSearch != "") { $sqlSearch .= " OR "; } $sqlSearch .= "(CS.OWNER_ID in (" . $strGroups . ") AND CS.CAL_TYPE='group')"; } } if ($sqlSearch != "") { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tCT.NAME AS TYPE_NAME, CT.DESCRIPTION AS TYPE_DESC\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_calendar_type CT ON (CS.CAL_TYPE=CT.XML_ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCT.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t(\n\t\t\t\t\t\t{$sqlSearch}\n\t\t\t\t\t))"; $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); while ($arRes = $res->Fetch()) { $arSectionIds[] = $arRes['ID']; $arResult[] = $arRes; } } // User's calendars $strUsers = "0"; if (is_array($Params['USERS']) && count($Params['USERS']) > 0) { foreach ($Params['USERS'] as $ownerId) { if (IntVal($ownerId) > 0) { $strUsers .= "," . IntVal($ownerId); } } if ($strUsers != "0") { $strSql = "\n\t\t\t\tSELECT\n\t\t\t\t\tCS.*,\n\t\t\t\t\tU.LOGIN AS USER_LOGIN, U.NAME AS USER_NAME, U.LAST_NAME AS USER_LAST_NAME, U.SECOND_NAME AS USER_SECOND_NAME\n\t\t\t\tFROM\n\t\t\t\t\tb_calendar_section CS\n\t\t\t\t\tLEFT JOIN b_user U ON (CS.OWNER_ID=U.ID)\n\t\t\t\tWHERE\n\t\t\t\t\t(\n\t\t\t\t\t\tCS.ACTIVE='Y'\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.OWNER_ID in (" . $strUsers . ")\n\t\t\t\t\tAND\n\t\t\t\t\t\tCS.CAL_TYPE='user'\n\t\t\t\t\t)"; $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); } while ($arRes = $res->Fetch()) { $arSectionIds[] = $arRes['ID']; $arResult[] = $arRes; } } if ($checkPermissions && count($arSectionIds) > 0) { if ($checkSocnetPermissions) { if (isset($Params['USERS']) && count($Params['USERS']) > 0) { $arFeaturesU = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $Params['USERS'], "calendar"); $arViewU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $Params['USERS'], "calendar", 'view'); $arWriteU = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['USERS'], "calendar", 'write'); } if (isset($Params['GROUPS']) && count($Params['GROUPS']) > 0) { $arFeaturesG = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar"); $arViewG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'view'); $arWriteG = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $Params['GROUPS'], "calendar", 'write'); } } CCalendarSect::GetArrayPermissions($arSectionIds); $res = array(); $sectIds = array(); foreach ($arResult as $sect) { $sectId = $sect['ID']; $ownerId = $sect['OWNER_ID']; if (self::CanDo('calendar_view_time', $sectId) && !in_array($sectId, $sectIds)) { if ($checkSocnetPermissions) { // Disabled in socialnetwork if ($sect['CAL_TYPE'] == 'group' && (!$arFeaturesG[$ownerId] || !$arViewG[$ownerId]) || $sect['CAL_TYPE'] == 'user' && (!$arFeaturesU[$ownerId] || !$arViewU[$ownerId])) { continue; } } $sect['PERM'] = array('view_time' => self::CanDo('calendar_view_time', $sectId), 'view_title' => self::CanDo('calendar_view_title', $sectId), 'view_full' => self::CanDo('calendar_view_full', $sectId), 'add' => self::CanDo('calendar_add', $sectId), 'edit' => self::CanDo('calendar_edit', $sectId), 'edit_section' => self::CanDo('calendar_edit_section', $sectId), 'access' => self::CanDo('calendar_edit_access', $sectId)); if ($checkSocnetPermissions) { if ($sect['CAL_TYPE'] == 'group' && !$arWriteG[$ownerId] || $sect['CAL_TYPE'] == 'user' && !$arWriteU[$ownerId]) { $sect['PERM']['add'] = false; $sect['PERM']['edit'] = false; $sect['PERM']['edit_section'] = false; $sect['PERM']['access'] = false; } } if ($sect['CAL_TYPE'] == 'user') { if (isset($sect['USER_NAME'], $sect['USER_LAST_NAME'])) { $sect['OWNER_NAME'] = CCalendar::GetUserName(array("NAME" => $sect['USER_NAME'], "LAST_NAME" => $sect['USER_LAST_NAME'], "LOGIN" => $sect['USER_LOGIN'], "ID" => $ownerId, "SECOND_NAME" => $sect['USER_SECOND_NAME'])); unset($sect['USER_LOGIN']); unset($sect['USER_LAST_NAME']); unset($sect['USER_SECOND_NAME']); unset($sect['USER_NAME']); } else { $sect['OWNER_NAME'] = CCalendar::GetUserName($ownerId); } } elseif ($sect['CAL_TYPE'] == 'group' && isset($Params['arGroups'])) { $sect['OWNER_NAME'] = $Params['arGroups'][$ownerId]['NAME']; } $res[] = $sect; $sectIds[] = $sectId; } } $arResult = $res; } return $arResult; }
$arParams["PERMISSION"] = $res["PERMISSION"]; $arParams["CHECK_CREATOR"] = $res["CHECK_CREATOR"]; $arParams["STR_TITLE"] = GetMessage("SONET_FILES"); $arParams["SHOW_WEBDAV"] = "Y"; /******************************************************************** /Input params ********************************************************************/ $arError = array(); /******************************************************************** Check Socnet Permission and Main Data ********************************************************************/ /************** Can View *******************************************/ if ($arParams["PERMISSION"] < "R") { $arError[] = array("id" => "access_denied", "text" => GetMessage("SONET_ACCESS_DENIED")); /************** Active Feature *************************************/ } elseif ($object == "user" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "files") || $object == "group" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "files")) { $arError[] = array("id" => "fiture_is_not_active", "text" => GetMessage("SONET_FILES_IS_NOT_ACTIVE")); /************** Check Iblock ID ************************************/ } elseif ($object == "user" && $arParams["FILES_USER_IBLOCK_ID"] <= 0 || $object == "group" && $arParams["FILES_GROUP_IBLOCK_ID"] <= 0) { $arError[] = array("id" => "iblock_id_empty", "text" => GetMessage("SONET_IBLOCK_ID_EMPTY")); } elseif ($arParams["USE_AUTH"] == "Y" && (CWebDavBase::IsDavHeaders() || $_SERVER['REQUEST_METHOD'] != "GET" && $_SERVER['REQUEST_METHOD'] != "POST") && !$USER->IsAuthorized()) { $APPLICATION->RestartBuffer(); CWebDavBase::SetAuthHeader(); header('Content-length: 0'); die; } /************** Set Page Title or Add Navigation *******************/ if ($arParams["SET_NAV_CHAIN"] == "Y" || $arParams["SET_TITLE"] == "Y") { $strTitle = ""; if ($object == "group") { $arResult["GROUP"] = $arGroup = CSocNetGroup::GetByID($arResult["VARIABLES"]["group_id"]);
} } $arPrevPageLogID = array_unique($arPrevPageLogID); } } if (strlen($arParams["PATH_TO_USER_BLOG_POST"]) > 0) { $arParams["PATH_TO_USER_MICROBLOG_POST"] = $arParams["PATH_TO_USER_BLOG_POST"]; } if (intval($arParams["PHOTO_COUNT"]) <= 0) { $arParams["PHOTO_COUNT"] = 5; } if (intval($arParams["PHOTO_THUMBNAIL_SIZE"]) <= 0) { $arParams["PHOTO_THUMBNAIL_SIZE"] = 76; } $GLOBALS["APPLICATION"]->SetPageProperty("BodyClass", $arParams["LOG_ID"] > 0 || $arParams["EMPTY_PAGE"] == "Y" ? "post-card" : "lenta-page"); if ($arParams["GROUP_ID"] <= 0 && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $GLOBALS["USER"]->GetID(), "blog") || $arParams["GROUP_ID"] > 0 && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog")) { $arResult["MICROBLOG_USER_ID"] = $GLOBALS["USER"]->GetID(); } $arResult["TZ_OFFSET"] = CTimeZone::GetOffset(); if ($arParams["EMPTY_PAGE"] != "Y") { CSocNetTools::InitGlobalExtranetArrays(); $arTmpEventsNew = array(); $arResult["Events"] = false; $arFilter = array(); if ($arParams["LOG_ID"] > 0) { $arFilter["ID"] = $arParams["LOG_ID"]; } elseif ($arResult["AJAX_CALL"] && intval($arParams["NEW_LOG_ID"]) > 0) { $arFilter["ID"] = $arParams["NEW_LOG_ID"]; } else { if ($arParams["DESTINATION"] > 0) { $arFilter["LOG_RIGHTS"] = $arParams["DESTINATION"];
public static function GetNearestEventsList($Params = array()) { global $USER; $type = $Params['bCurUserList'] ? 'user' : $Params['type']; // Get current user id if (!isset($Params['userId']) || $Params['userId'] <= 0) { $curUserId = CCalendar::GetCurUserId(); } else { $curUserId = intval($Params['userId']); } if (!CCalendarType::CanDo('calendar_type_view', $type, $curUserId)) { return 'access_denied'; } if ($Params['bCurUserList'] && ($curUserId <= 0 || class_exists('CSocNetFeatures') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $curUserId, "calendar"))) { return 'inactive_feature'; } $arFilter = array('CAL_TYPE' => $type, 'FROM_LIMIT' => $Params['fromLimit'], 'TO_LIMIT' => $Params['toLimit'], 'DELETED' => 'N'); if ($Params['bCurUserList']) { $arFilter['OWNER_ID'] = $curUserId; } if (isset($Params['sectionId']) && $Params['sectionId']) { $arFilter["SECTION"] = $Params['sectionId']; } if ($type == 'user') { unset($arFilter['CAL_TYPE']); } $arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => true, 'fetchAttendees' => true, 'userId' => $curUserId, 'fetchMeetings' => $type == 'user', 'preciseLimits' => true)); if (CCalendar::Date(time(), false) == $Params['fromLimit']) { $currentTime = time(); } else { $currentTime = CCalendar::Timestamp($Params['fromLimit']); } $arResult = array(); foreach ($arEvents as $event) { if ($event['IS_MEETING'] && $event['USER_MEETING']['STATUS'] == 'N') { continue; } if ($type == 'user' && !$event['IS_MEETING'] && $event['CAL_TYPE'] != 'user') { continue; } $toTs = $event['DT_TO_TS']; if ($event['DT_SKIP_TIME'] == 'Y') { $toTs += self::DAY_LENGTH; } if ($toTs < $currentTime) { continue; } $event['DATE_FROM'] = $event['DT_FROM']; $arResult[] = $event; } // Sort by DT_FROM_TS usort($arResult, array('CCalendar', '_NearestSort')); return $arResult; }
private static function GetSocnetGroupFilteredByFeaturePerms(&$arGroups, $arFeaturePerms) { $arGroupsIDs = array(); foreach($arGroups as $value) { $arGroupsIDs[] = $value["id"]; } if (sizeof($arGroupsIDs) > 0) { $feature = $arFeaturePerms[0]; $operations = $arFeaturePerms[1]; if (!is_array($operations)) $operations = explode(",", $operations); $arGroupsPerms = array(); foreach($operations as $operation) { $tmpOps = CSocNetFeaturesPerms::CurrentUserCanPerformOperation(SONET_ENTITY_GROUP, $arGroupsIDs, $feature, $operation); foreach($tmpOps as $key=>$val) if (!$arGroupsPerms[$key]) $arGroupsPerms[$key] = $val; } $arGroupsActive = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arGroupsIDs, $arFeaturePerms[0]); foreach ($arGroups as $key=>$group) if (!$arGroupsActive[$group["id"]] || !$arGroupsPerms[$group["id"]]) unset($arGroups[$key]); } }
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; }
function __InTaskCheckActiveFeature($taskType, $ownerId) { $taskType = StrToLower($taskType); if (!in_array($taskType, array("group", "user"))) { $taskType = "user"; } $ownerId = IntVal($ownerId); if ($ownerId <= 0) { $taskType = "user"; $ownerId = $GLOBALS["USER"]->GetID(); } $ownerId = IntVal($ownerId); if ($ownerId <= 0) { return false; } // added by me if ($taskType == 'group') { CModule::IncludeModule('socialnetwork'); } return CSocNetFeatures::IsActiveFeature($taskType == 'user' ? SONET_ENTITY_USER : SONET_ENTITY_GROUP, $ownerId, "tasks"); }
} else { $arParams["POST_ID"] = IntVal($arParams["POST_ID"]); } $bSoNet = false; $bGroupMode = false; if (CModule::IncludeModule("socialnetwork") && (IntVal($arParams["SOCNET_GROUP_ID"]) > 0 || IntVal($arParams["USER_ID"]) > 0)) { $bSoNet = true; if (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { $bGroupMode = true; } if ($bGroupMode) { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog")) { return; } } else { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "blog")) { return; } } } $arParams["BLOG_URL"] = preg_replace("/[^a-zA-Z0-9_-]/is", "", Trim($arParams["BLOG_URL"])); $arParams["RSS1"] = $arParams["RSS1"] != "N" ? "Y" : "N"; $arParams["RSS2"] = $arParams["RSS2"] != "N" ? "Y" : "N"; $arParams["ATOM"] = $arParams["ATOM"] != "N" ? "Y" : "N"; $arParams["MODE"] = trim($arParams["MODE"]); if (!is_array($arParams["PARAM_GROUP_ID"])) { $arParams["PARAM_GROUP_ID"] = array($arParams["PARAM_GROUP_ID"]); } foreach ($arParams["PARAM_GROUP_ID"] as $k => $v) { if (IntVal($v) <= 0) { unset($arParams["PARAM_GROUP_ID"][$k]);
public static function ConvertEntity($ownerType, $ownerId, $sectionId, $iblockId, $createdBy) { $eventsCount = 0; $sectCount = 0; $bs = new CIBlockSection(); $ent_id = "IBLOCK_" . $iblockId . "_SECTION"; $result = array('eventsCount' => 0, 'sectCount' => 0); $bSetAccessFromCalendar = true; $Access = array('G2' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied')); // CONVERT ACCESS: if ($ownerType == 'user') { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $ownerId, "calendar")) { return $result; } // Read $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'view'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'); if ($read == 'A') { // All users $Access['G2'] = $taskId; } elseif ($read == 'C') { // All autorized $Access['AU'] = $taskId; } elseif ($read == 'M' || $read == 'E') { // Friends $Access['SU' . $ownerId . '_F'] = $taskId; } elseif ($bSetAccessFromCalendar) { $bSetAccessFromCalendar = false; } // Write - will override read access $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $ownerId, "calendar", 'write'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'); if ($write == 'A') { // All users $Access['G2'] = $taskId; } elseif ($write == 'C') { // All autorized $Access['AU'] = $taskId; } elseif ($write == 'M' || $write == 'E') { // Friends $Access['SU' . $ownerId . '_F'] = $taskId; } } elseif ($ownerType == 'group') { if (!CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $ownerId, "calendar")) { return $result; } // Read $read = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'view'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'); if ($read == 'A') { // Group owner $Access['SG' . $ownerId . '_A'] = $taskId; } elseif ($read == 'E') { // Group moderator $Access['SG' . $ownerId . '_E'] = $taskId; } elseif ($read == 'K') { // User $Access['SG' . $ownerId . '_K'] = $taskId; } elseif ($read == 'L') { // Authorized $Access['AU'] = $taskId; } elseif ($read == 'N') { // Authorized $Access['G2'] = $taskId; } // Write - will override read access $write = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $ownerId, "calendar", 'write'); $taskId = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'); if ($write == 'A') { // Group owner $Access['SG' . $ownerId . '_A'] = $taskId; } elseif ($write == 'E') { // Group moderator $Access['SG' . $ownerId . '_E'] = $taskId; } elseif ($write == 'K') { // User $Access['SG' . $ownerId . '_K'] = $taskId; } elseif ($write == 'L') { // Authorized $Access['AU'] = $taskId; } elseif ($write == 'N') { // Authorized $Access['G2'] = $taskId; } } else { $arGroupPerm = CIBlock::GetGroupPermissions($iblockId); $taskByLetter = array('D' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'), 'R' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view'), 'W' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_edit'), 'X' => CCalendar::GetAccessTasksByName('calendar_section', 'calendar_access')); foreach ($arGroupPerm as $groupId => $letter) { $Access['G' . $groupId] = $taskByLetter[$letter]; } } // 1. Fetch sections $arUserSections = CEventCalendar::GetCalendarList(array($iblockId, $sectionId, 0, $ownerType)); $calendarIndex = array(); foreach ($arUserSections as $section) { $arUF = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields($ent_id, $section['ID']); if (isset($arUF["UF_CAL_CONVERTED"]) && strlen($arUF["UF_CAL_CONVERTED"]['VALUE']) > 0) { continue; } $SectionAccess = array(); if ($bSetAccessFromCalendar && $ownerType == 'user') { if ($section['PRIVATE_STATUS'] == 'private') { $deniedTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_denied'); $SectionAccess['G2'] = $deniedTask; } elseif ($section['PRIVATE_STATUS'] == 'time') { $viewTimeTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view_time'); $SectionAccess['G2'] = $viewTimeTask; } elseif ($section['PRIVATE_STATUS'] == 'title') { $viewTitleTask = CCalendar::GetAccessTasksByName('calendar_section', 'calendar_view_title'); $SectionAccess['G2'] = $viewTitleTask; } else { $SectionAccess = $Access; // nested from common access settings from socnet } } else { $SectionAccess = $Access; // G2 => denied } $new_sect_id = CCalendarSect::Edit(array('arFields' => array("CAL_TYPE" => $ownerType, "NAME" => $section['NAME'], "OWNER_ID" => $ownerId, "CREATED_BY" => $createdBy, "DESCRIPTION" => $section['DESCRIPTION'], "COLOR" => $section["COLOR"], "ACCESS" => $SectionAccess))); // Set converted property $bs->Update($section['ID'], array('UF_CAL_CONVERTED' => 1)); $calendarIndex[$section['ID']] = $new_sect_id; $sectCount++; } // 2. Create events $arEvents = CEventCalendar::GetCalendarEventsList(array($iblockId, $sectionId, 0), array()); foreach ($arEvents as $event) { if (!isset($calendarIndex[$event['IBLOCK_SECTION_ID']]) || $event['PROPERTY_PARENT'] > 0) { continue; } $arFields = array("CAL_TYPE" => $ownerType, "OWNER_ID" => $ownerId, "CREATED_BY" => $event["CREATED_BY"], "DT_FROM" => $event['ACTIVE_FROM'], "DT_TO" => $event['ACTIVE_TO'], 'NAME' => htmlspecialcharsback($event['NAME']), 'DESCRIPTION' => CCalendar::ParseHTMLToBB(htmlspecialcharsback($event['DETAIL_TEXT'])), 'SECTIONS' => array($calendarIndex[$event['IBLOCK_SECTION_ID']]), 'ACCESSIBILITY' => $event['PROPERTY_ACCESSIBILITY'], 'IMPORTANCE' => $event['PROPERTY_IMPORTANCE'], 'PRIVATE_EVENT' => $event['PROPERTY_PRIVATE'] && $event['PROPERTY_PRIVATE'] == 'true' ? '1' : '', 'RRULE' => array(), 'LOCATION' => array('NEW' => $event['PROPERTY_LOCATION'], 'RE_RESERVE' => 'N'), "REMIND" => array(), "IS_MEETING" => $event['PROPERTY_IS_MEETING'] == 'Y'); if (!empty($event['PROPERTY_REMIND_SETTINGS'])) { $ar = explode("_", $event["PROPERTY_REMIND_SETTINGS"]); if (count($ar) == 2) { $arFields["REMIND"][] = array('type' => $ar[1], 'count' => floatVal($ar[0])); } } if (isset($event["PROPERTY_PERIOD_TYPE"]) && in_array($event["PROPERTY_PERIOD_TYPE"], array("DAILY", "WEEKLY", "MONTHLY", "YEARLY"))) { $arFields['RRULE']['FREQ'] = $event["PROPERTY_PERIOD_TYPE"]; $arFields['RRULE']['INTERVAL'] = $event["PROPERTY_PERIOD_COUNT"]; if (!empty($event['PROPERTY_EVENT_LENGTH'])) { $arFields['DT_LENGTH'] = intval($event['PROPERTY_EVENT_LENGTH']); } if (!$arFields['DT_LENGTH']) { $arFields['DT_LENGTH'] = 86400; } if ($arFields['RRULE']['FREQ'] == "WEEKLY" && !empty($event['PROPERTY_PERIOD_ADDITIONAL'])) { $arFields['RRULE']['BYDAY'] = array(); $bydays = explode(',', $event['PROPERTY_PERIOD_ADDITIONAL']); foreach ($bydays as $day) { $day = CCalendar::WeekDayByInd($day); if ($day !== false) { $arFields['RRULE']['BYDAY'][] = $day; } } $arFields['RRULE']['BYDAY'] = implode(',', $arFields['RRULE']['BYDAY']); } $arFields['RRULE']['UNTIL'] = $event['ACTIVE_TO']; } if ($arFields['IS_MEETING']) { if ($event['PROPERTY_PARENT'] > 0) { continue; } $host = intVal($event['CREATED_BY']); $arFields['ATTENDEES'] = array(); if ($event['PROPERTY_HOST_IS_ABSENT'] == 'N') { $arFields['ATTENDEES'][] = $host; } $arGuests = CECEvent::GetGuests(self::$userIblockId, $event['ID']); $attendeesStatuses = array(); foreach ($arGuests as $userId => $ev) { $attendeesStatuses[$userId] = $ev['PROPERTY_VALUES']['CONFIRMED']; $arFields['ATTENDEES'][] = $userId; } $arFields['MEETING_HOST'] = $host; $arFields['MEETING'] = array('HOST_NAME' => CCalendar::GetUserName($host), 'TEXT' => is_array($event['PROPERTY_MEETING_TEXT']) && is_string($event['PROPERTY_MEETING_TEXT']['TEXT']) ? trim($event['PROPERTY_MEETING_TEXT']['TEXT']) : '', 'OPEN' => false, 'NOTIFY' => false, 'REINVITE' => false); } $new_event_id = CCalendar::SaveEvent(array('arFields' => $arFields, 'bAffectToDav' => false, 'attendeesStatuses' => $attendeesStatuses, 'bSendInvitations' => false)); $eventsCount++; } // 3. Set userfield $bs->Update($sectionId, array('UF_CAL_CONVERTED' => 1)); return array('eventsCount' => $eventsCount, 'sectCount' => $sectCount); }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $APPLICATION->IncludeComponent("bitrix:socialnetwork.user_menu", "", array("USER_VAR" => $arResult["ALIASES"]["user_id"], "PAGE_VAR" => $arResult["ALIASES"]["page"], "PATH_TO_USER" => $arResult["PATH_TO_USER"], "PATH_TO_USER_EDIT" => $arResult["PATH_TO_USER_PROFILE_EDIT"], "PATH_TO_USER_FRIENDS" => $arResult["PATH_TO_USER_FRIENDS"], "PATH_TO_USER_GROUPS" => $arResult["PATH_TO_USER_GROUPS"], "PATH_TO_USER_FRIENDS_ADD" => $arResult["PATH_TO_USER_FRIENDS_ADD"], "PATH_TO_USER_FRIENDS_DELETE" => $arResult["PATH_TO_USER_FRIENDS_DELETE"], "PATH_TO_MESSAGES_INPUT" => $arResult["PATH_TO_MESSAGES_INPUT"], "PATH_TO_MESSAGE_FORM" => $arResult["PATH_TO_MESSAGE_FORM"], "PATH_TO_USER_BLOG" => $arResult["PATH_TO_USER_BLOG"], "PATH_TO_USER_PHOTO" => $arResult["PATH_TO_USER_PHOTO"], "PATH_TO_USER_FORUM" => $arResult["PATH_TO_USER_FORUM"], "PATH_TO_USER_CALENDAR" => $arResult["PATH_TO_USER_CALENDAR"], "PATH_TO_USER_FILES" => $arResult["PATH_TO_USER_FILES"], "PATH_TO_USER_TASKS" => $arResult["PATH_TO_USER_TASKS"], "PATH_TO_USER_CONTENT_SEARCH" => $arResult["PATH_TO_USER_CONTENT_SEARCH"], "ID" => $arResult["VARIABLES"]["user_id"], "PAGE_ID" => "user_tasks", "USE_MAIN_MENU" => $arParams["USE_MAIN_MENU"], "MAIN_MENU_TYPE" => $arParams["MAIN_MENU_TYPE"]), $component); ?> <?php $APPLICATION->IncludeComponent("bitrix:socialnetwork.user_profile", "short", array("PATH_TO_USER" => $arResult["PATH_TO_USER"], "PATH_TO_USER_EDIT" => $arResult["PATH_TO_USER_PROFILE_EDIT"], "PATH_TO_USER_FRIENDS" => $arResult["PATH_TO_USER_FRIENDS"], "PATH_TO_USER_GROUPS" => $arResult["PATH_TO_USER_GROUPS"], "PATH_TO_USER_FRIENDS_ADD" => $arResult["PATH_TO_USER_FRIENDS_ADD"], "PATH_TO_USER_FRIENDS_DELETE" => $arResult["PATH_TO_USER_FRIENDS_DELETE"], "PATH_TO_MESSAGE_FORM" => $arResult["PATH_TO_MESSAGE_FORM"], "PATH_TO_MESSAGES_CHAT" => $arResult["PATH_TO_MESSAGES_CHAT"], "PATH_TO_MESSAGES_USERS_MESSAGES" => $arResult["PATH_TO_MESSAGES_USERS_MESSAGES"], "PATH_TO_USER_SETTINGS_EDIT" => $arResult["PATH_TO_USER_SETTINGS_EDIT"], "PATH_TO_GROUP" => $arParams["PATH_TO_GROUP"], "PATH_TO_GROUP_CREATE" => $arResult["PATH_TO_GROUP_CREATE"], "PATH_TO_USER_FEATURES" => $arResult["PATH_TO_USER_FEATURES"], "PATH_TO_USER_REQUESTS" => $arResult["PATH_TO_USER_REQUESTS"], "PAGE_VAR" => $arResult["ALIASES"]["page"], "USER_VAR" => $arResult["ALIASES"]["user_id"], "SET_TITLE" => "N", "USER_PROPERTY_MAIN" => $arResult["USER_PROPERTY_MAIN"], "USER_PROPERTY_CONTACT" => $arResult["USER_PROPERTY_CONTACT"], "USER_PROPERTY_PERSONAL" => $arResult["USER_PROPERTY_PERSONAL"], "USER_FIELDS_MAIN" => $arResult["USER_FIELDS_MAIN"], "USER_FIELDS_CONTACT" => $arResult["USER_FIELDS_CONTACT"], "USER_FIELDS_PERSONAL" => $arResult["USER_FIELDS_PERSONAL"], "DATE_TIME_FORMAT" => $arResult["DATE_TIME_FORMAT"], "SHORT_FORM" => "Y", "ITEMS_COUNT" => $arParams["ITEM_MAIN_COUNT"], "ID" => $arResult["VARIABLES"]["user_id"], "PATH_TO_GROUP_REQUEST_GROUP_SEARCH" => $arResult["PATH_TO_GROUP_REQUEST_GROUP_SEARCH"], "PATH_TO_CONPANY_DEPARTMENT" => $arParams["PATH_TO_CONPANY_DEPARTMENT"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "PATH_TO_VIDEO_CALL" => $arResult["PATH_TO_VIDEO_CALL"]), $component, array("HIDE_ICONS" => "Y")); ?> <?php if (CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "tasks")) { ?> <?php $APPLICATION->IncludeComponent("bitrix:tasks.report.construct", "", array("USER_ID" => $arResult["VARIABLES"]["user_id"], "REPORT_ID" => $arResult["VARIABLES"]["report_id"], "ACTION" => $arResult["VARIABLES"]["action"], "PATH_TO_USER_TASKS" => $arResult["PATH_TO_USER_TASKS"], "PATH_TO_USER_TASKS_TASK" => $arResult["PATH_TO_USER_TASKS_TASK"], "PATH_TO_USER_TASKS_VIEW" => $arResult["PATH_TO_USER_TASKS_VIEW"], "PATH_TO_TASKS_REPORT" => CComponentEngine::MakePathFromTemplate($arResult["PATH_TO_USER_TASKS_REPORT"], array('user_id' => $arResult["VARIABLES"]["user_id"])), "PATH_TO_TASKS_REPORT_CONSTRUCT" => CComponentEngine::MakePathFromTemplate($arResult["PATH_TO_USER_TASKS_REPORT_CONSTRUCT"], array('user_id' => $arResult["VARIABLES"]["user_id"])), "PATH_TO_TASKS_REPORT_VIEW" => CComponentEngine::MakePathFromTemplate($arResult["PATH_TO_USER_TASKS_REPORT_VIEW"], array('user_id' => $arResult["VARIABLES"]["user_id"])), "PATH_TO_USER_TASKS_TEMPLATES" => $arResult["PATH_TO_USER_TASKS_TEMPLATES"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"]), false); }
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")) continue; if ($gadget["SEARCH_ONLY"] == true && $gadget["SU_ONLY"] == true && intval($arParams["USER_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "search")) continue; if ($gadget["SEARCH_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "search")) continue; if ( $gadget["WIKI_ONLY"] == true && $gadget["SG_ONLY"] == true && intval($arParams["SOCNET_GROUP_ID"]) > 0 && CModule::IncludeModule('socialnetwork') && ( !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki") || !CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "wiki", "view", CSocNetUser::IsCurrentUserModuleAdmin()) ) ) { continue; } if($gadget["GROUP"]["ID"] == "") { $gadget["GROUP"]["ID"] = "other"; } if ( !isset($gadget["TOTALLY_FIXED"]) || !$gadget["TOTALLY_FIXED"]
$arParams["PERMISSION_ORIGINAL"] = ForumCurrUserPermissions($arParams["FID"]); $arParams["PERMISSION"] = "A"; $arError = array(); $arNote = array(); /******************************************************************** /Default params #1 ********************************************************************/ /******************************************************************** Main Data & Permissions ********************************************************************/ $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); if (empty($arResult["FORUM"])) { ShowError(GetMessage("F_FID_IS_LOST")); CHTTP::SetStatus("404 Not Found"); return false; } elseif ($arParams["MODE"] == "GROUP" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum") || $arParams["MODE"] != "GROUP" && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $arParams["USER_ID"], "forum")) { ShowError(GetMessage("FORUM_SONET_MODULE_NOT_AVAIBLE")); return false; } else { $user_id = $USER->GetID(); if ($arParams["MODE"] == "GROUP") { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "full", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "Y"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "newtopic", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "M"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "answer", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "I"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "forum", "view", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "E"; } } else {
function CheckPermission($arParams, $bOnlyUser = false) { if (isset($GLOBALS['USER']) && $GLOBALS['USER']->CanDoOperation('edit_php')) { return true; } $ownerType = isset($arParams['ownerType']) ? $arParams['ownerType'] : $this->ownerType; if ($ownerType == 'USER' || $ownerType == 'GROUP') { $ownerId = isset($arParams['ownerId']) ? $arParams['ownerId'] : $this->ownerId; $SONET_ENT = $ownerType == 'USER' ? SONET_ENTITY_USER : SONET_ENTITY_GROUP; if (!CSocNetFeatures::IsActiveFeature($SONET_ENT, $ownerId, "calendar") || !CSocNetFeaturesPerms::CanPerformOperation($this->userId, $SONET_ENT, $ownerId, "calendar", 'write')) { return false; } if ($bOnlyUser) { return true; } $calendarId = isset($arParams['calendarId']) ? intVal($arParams['calendarId']) : 0; $sectionId = isset($arParams['sectionId']) ? $arParams['sectionId'] : $this->sectionId; $iblockId = isset($arParams['iblockId']) ? $arParams['iblockId'] : $this->iblockId; $arFilter = array("ID" => $calendarId, "SECTION_ID" => $sectionId, "IBLOCK_ID" => $iblockId, "ACTIVE" => "Y"); if ($ownerType == 'USER') { $arFilter["CREATED_BY"] = $ownerId; } else { $arFilter["SOCNET_GROUP_ID"] = $ownerId; } $rsData = CIBlockSection::GetList(array('ID' => 'ASC'), $arFilter); $arRes = $rsData->Fetch(); if (!$arRes) { return false; } } return true; }
public static function GetAbsent($users = false, $Params = array()) { global $DB; // Can be called from agent... So we have to create $USER if it is not exists $tempUser = CCalendar::TempUser(false, true); $curUserId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId(); $arUsers = array(); if ($users !== false && is_array($users)) { foreach ($users as $id) { if ($id > 0) { $arUsers[] = intVal($id); } } } if (!count($arUsers)) { $users = false; } // Part 1: select ordinary events $arFilter = array('CAL_TYPE' => 'user', 'DELETED' => 'N', 'ACCESSIBILITY' => 'absent'); if (isset($Params['fromLimit'])) { $arFilter['FROM_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['fromLimit'], false), true, false); } if (isset($Params['toLimit'])) { $arFilter['TO_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['toLimit'], false), true, false); } $arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'getUserfields' => false, 'parseRecursion' => true, 'fetchAttendees' => false, 'fetchMeetings' => true, 'userId' => $curUserId, 'checkPermissions' => false, 'preciseLimits' => true)); // Part 2: select attendees CTimeZone::Disable(); if (count($arUsers) > 0) { $userQ = ' AND CA.USER_ID in (' . implode(',', $arUsers) . ')'; } else { $userQ = ''; } $strSql = "\n\t\t\tSELECT\n\t\t\t\tCA.EVENT_ID as ID, CA.USER_ID, CA.STATUS, CA.ACCESSIBILITY,\n\t\t\t\tCE.CAL_TYPE,CE.OWNER_ID,CE.NAME," . $DB->DateToCharFunction("CE.DT_FROM") . " as DT_FROM," . $DB->DateToCharFunction("CE.DT_TO") . " as DT_TO, CE.DT_LENGTH, CE.PRIVATE_EVENT, CE.ACCESSIBILITY, CE.IMPORTANCE, CE.IS_MEETING, CE.MEETING_HOST, CE.MEETING, CE.LOCATION, CE.RRULE, CE.EXRULE, CE.RDATE, CE.EXDATE,\n\t\t\t\tCES.SECT_ID\n\t\t\tFROM b_calendar_attendees CA\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event CE ON(CA.EVENT_ID=CE.ID)\n\t\t\tLEFT JOIN\n\t\t\t\tb_calendar_event_sect CES ON (CA.EVENT_ID=CES.EVENT_ID)\n\t\t\tWHERE\n\t\t\t\t\tCE.ID IS NOT NULL\n\t\t\t\tAND\n\t\t\t\t\tCE.DELETED='N'\n\t\t\t\tAND\n\t\t\t\t\tSTATUS='Y'\n\t\t\t\tAND\n\t\t\t\t\tCA.ACCESSIBILITY='absent'\n\t\t\t\t{$userQ}\n\t\t\t"; if (isset($arFilter['FROM_LIMIT'])) { $strSql .= "AND "; if (strtoupper($DB->type) == "MYSQL") { $strSql .= "CE.DT_TO>=FROM_UNIXTIME('" . MkDateTime(FmtDate($arFilter['FROM_LIMIT'], "D.M.Y"), "d.m.Y") . "')"; } elseif (strtoupper($DB->type) == "MSSQL") { $strSql .= "CE.DT_TO>=" . $DB->CharToDateFunction($arFilter['FROM_LIMIT'], "SHORT"); } elseif (strtoupper($DB->type) == "ORACLE") { $strSql .= "CE.DT_TO>=TO_DATE('" . FmtDate($arFilter['FROM_LIMIT'], "D.M.Y") . " 00:00:00','dd.mm.yyyy hh24:mi:ss')"; } } if ($arFilter['TO_LIMIT']) { $strSql .= "AND "; if (strtoupper($DB->type) == "MYSQL") { $strSql .= "CE.DT_FROM<=FROM_UNIXTIME('" . MkDateTime(FmtDate($arFilter['TO_LIMIT'], "D.M.Y") . " 23:59:59", "d.m.Y H:i:s") . "')"; } elseif (strtoupper($DB->type) == "MSSQL") { $strSql .= "CE.DT_FROM<=dateadd(day, 1, " . $DB->CharToDateFunction($arFilter['TO_LIMIT'], "SHORT") . ")"; } elseif (strtoupper($DB->type) == "ORACLE") { $strSql .= "CE.DT_FROM<=TO_DATE('" . FmtDate($arFilter['TO_LIMIT'], "D.M.Y") . " 23:59:59','dd.mm.yyyy hh24:mi:ss')"; } } $res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__); $arEvents2 = array(); while ($event = $res->Fetch()) { $event = self::PreHandleEvent($event); if ($event['CAL_TYPE'] == 'user' && $event['IS_MEETING'] && $event['OWNER_ID'] == $event['USER_ID']) { continue; } if (self::CheckRecurcion($event)) { self::ParseRecursion($arEvents2, $event, array('fromLimit' => $arFilter["FROM_LIMIT"], 'toLimit' => $arFilter["TO_LIMIT"])); } else { self::HandleEvent($arEvents2, $event); } } CTimeZone::Enable(); $arEvents = array_merge($arEvents, $arEvents2); $bSocNet = CModule::IncludeModule("socialnetwork"); $result = array(); $settings = CCalendar::GetSettings(array('request' => false)); foreach ($arEvents as $event) { $userId = isset($event['USER_ID']) ? $event['USER_ID'] : $event['OWNER_ID']; if ($users !== false && !in_array($userId, $arUsers)) { continue; } if ($bSocNet && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userId, "calendar")) { continue; } if ((!$event['CAL_TYPE'] != 'user' || $curUserId != $event['OWNER_ID']) && $curUserId != $event['CREATED_BY'] && !isset($arUserMeeting[$event['ID']])) { $sectId = $event['SECT_ID']; if (!$event['ACCESSIBILITY']) { $event['ACCESSIBILITY'] = 'busy'; } $private = $event['PRIVATE_EVENT'] && $event['CAL_TYPE'] == 'user'; $bManager = false; if (!$private && CCalendar::IsIntranetEnabled() && CModule::IncludeModule('intranet') && $event['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) { $bManager = in_array($curUserId, CCalendar::GetUserManagers($event['OWNER_ID'], true)); } if ($private || !CCalendarSect::CanDo('calendar_view_full', $sectId) && !$bManager) { if ($private) { $event['NAME'] = '[' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']'; } else { if (!CCalendarSect::CanDo('calendar_view_title', $sectId)) { $event['NAME'] = '[' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']'; } else { $event['NAME'] = $event['NAME'] . ' [' . GetMessage('EC_ACCESSIBILITY_' . strtoupper($event['ACCESSIBILITY'])) . ']'; } } } } $result[] = array('ID' => $event['ID'], 'NAME' => $event['NAME'], 'DATE_FROM' => $event['DT_FROM'], 'DATE_TO' => $event['DT_TO'], 'DT_FROM_TS' => $event['DT_FROM_TS'], 'DT_TO_TS' => $event['DT_TO_TS'], 'CREATED_BY' => $userId, 'DETAIL_TEXT' => '', 'USER_ID' => $userId); } // Sort by DT_FROM_TS usort($result, array('CCalendar', '_NearestSort')); CCalendar::TempUser($tempUser, false); return $result; }
public static function GetAbsent($users = false, $Params = array()) { // Can be called from agent... So we have to create $USER if it is not exists $tempUser = CCalendar::TempUser(false, true); $curUserId = isset($Params['userId']) ? intVal($Params['userId']) : CCalendar::GetCurUserId(); $arUsers = array(); if ($users !== false && is_array($users)) { foreach ($users as $id) { if ($id > 0) { $arUsers[] = intVal($id); } } } if (!count($arUsers)) { $users = false; } $arFilter = array('DELETED' => 'N', 'ACCESSIBILITY' => 'absent'); if ($users) { $arFilter['CREATED_BY'] = $users; } if (isset($Params['fromLimit'])) { $arFilter['FROM_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['fromLimit'], false), true, false); } if (isset($Params['toLimit'])) { $arFilter['TO_LIMIT'] = CCalendar::Date(CCalendar::Timestamp($Params['toLimit'], false), true, false); } $arEvents = CCalendarEvent::GetList(array('arFilter' => $arFilter, 'parseRecursion' => true, 'getUserfields' => false, 'userId' => $curUserId, 'preciseLimits' => true, 'checkPermissions' => false, 'skipDeclined' => true)); $bSocNet = CModule::IncludeModule("socialnetwork"); $result = array(); $settings = CCalendar::GetSettings(array('request' => false)); foreach ($arEvents as $event) { $userId = isset($event['USER_ID']) ? $event['USER_ID'] : $event['CREATED_BY']; if ($users !== false && !in_array($userId, $arUsers)) { continue; } if ($bSocNet && !CSocNetFeatures::IsActiveFeature(SONET_ENTITY_USER, $userId, "calendar")) { continue; } if ((!$event['CAL_TYPE'] != 'user' || $curUserId != $event['OWNER_ID']) && $curUserId != $event['CREATED_BY'] && !isset($arUserMeeting[$event['ID']])) { $sectId = $event['SECT_ID']; if (!$event['ACCESSIBILITY']) { $event['ACCESSIBILITY'] = 'busy'; } $private = $event['PRIVATE_EVENT'] && $event['CAL_TYPE'] == 'user'; $bManager = false; if (!$private && CCalendar::IsIntranetEnabled() && CModule::IncludeModule('intranet') && $event['CAL_TYPE'] == 'user' && $settings['dep_manager_sub']) { $bManager = in_array($curUserId, CCalendar::GetUserManagers($event['OWNER_ID'], true)); } if ($private || !CCalendarSect::CanDo('calendar_view_full', $sectId) && !$bManager) { $event = self::ApplyAccessRestrictions($event, $userId); } } $skipTime = $event['DT_SKIP_TIME'] === 'Y'; $fromTs = CCalendar::Timestamp($event['DATE_FROM'], false, !$skipTime); $toTs = CCalendar::Timestamp($event['DATE_TO'], false, !$skipTime); if ($event['DT_SKIP_TIME'] !== 'Y') { $fromTs -= $event['~USER_OFFSET_FROM']; $toTs -= $event['~USER_OFFSET_TO']; } $result[] = array('ID' => $event['ID'], 'NAME' => $event['NAME'], 'DATE_FROM' => CCalendar::Date($fromTs, !$skipTime, false), 'DATE_TO' => CCalendar::Date($toTs, !$skipTime, false), 'DT_FROM_TS' => $fromTs, 'DT_TO_TS' => $toTs, 'CREATED_BY' => $userId, 'DETAIL_TEXT' => '', 'USER_ID' => $userId); } // Sort by DATE_FROM_TS_UTC usort($result, array('CCalendar', '_NearestSort')); CCalendar::TempUser($tempUser, false); return $result; }