<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $user_id = IntVal($USER->GetID()); CJSCore::Init(array('socnetlogdest')); $arResult["DEST_SORT"] = CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "BLOG_POST")); $arResult["FEED_DESTINATION"]['LAST'] = array(); CSocNetLogDestination::fillLastDestination($arResult["DEST_SORT"], $arResult["FEED_DESTINATION"]['LAST']); $cacheTtl = defined("BX_COMP_MANAGED_CACHE") ? 3153600 : 3600 * 4; $cacheId = 'blog_post_form_dest_' . SITE_ID . '_' . $user_id; $cacheDir = '/blog/form/dest/' . SITE_ID . '/' . $user_id; $obCache = new CPHPCache(); if ($obCache->InitCache($cacheTtl, $cacheId, $cacheDir)) { $arResult["FEED_DESTINATION"]['SONETGROUPS'] = $obCache->GetVars(); } else { $obCache->StartDataCache(); $arResult["FEED_DESTINATION"]['SONETGROUPS'] = CSocNetLogDestination::GetSocnetGroup(array('features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post")))); if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->StartTagCache($cacheDir); foreach ($arResult["FEED_DESTINATION"]['SONETGROUPS'] as $val) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_features_G_" . $val["entityId"]); $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group_" . $val["entityId"]); } $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_user2group_U" . $user_id); $GLOBALS["CACHE_MANAGER"]->EndTagCache(); } $obCache->EndDataCache($arResult["FEED_DESTINATION"]['SONETGROUPS']); } $arDestUser = array();
$backurl .= (strpos($arResult['BACKURL'], '?') > 0 ? "&" : "?") . "current_fieldset=SOCSERV"; } } else { $backurl = $APPLICATION->GetCurPageParam($componentTemplate == 'twitpost' ? "current_fieldset=SOCSERV" : "", array("sessid", "user_id", "action")); } LocalRedirect($backurl); } if ($componentTemplate == 'twitpost') { $arResult["TWIT_HASH"] = htmlspecialcharsbx(COption::GetOptionString("socialservices", "twitter_search_hash", "#b24")); } $arResult['CURRENTURL'] = $APPLICATION->GetCurPageParam($add, $arParamsToDelete); if (CModule::IncludeModule("socialnetwork")) { CJSCore::Init(array('socnetlogdest')); // socialnetwork if (method_exists('CSocNetLogDestination', 'GetDestinationSort')) { $arResult["PostToShow"]["FEED_DESTINATION"] = array('DEST_SORT' => CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "SOCSERVICES")), 'LAST' => array()); CSocNetLogDestination::fillLastDestination($arResult["PostToShow"]["FEED_DESTINATION"]['DEST_SORT'], $arResult["PostToShow"]["FEED_DESTINATION"]['LAST']); } else { $arResult["PostToShow"]["FEED_DESTINATION"] = array('LAST' => array('SONETGROUPS' => CSocNetLogDestination::GetLastSocnetGroup(), 'DEPARTMENT' => CSocNetLogDestination::GetLastDepartment(), 'LAST' => CSocNetLogDestination::GetLastUser())); } $arResult["PostToShow"]["FEED_DESTINATION"]['SONETGROUPS'] = CSocNetLogDestination::GetSocnetGroup(array('features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post")))); $arDestUser = array(); $arResult["PostToShow"]["FEED_DESTINATION"]['SELECTED'] = array(); if (!empty($arResult["PostToShow"]["SPERM"])) { $arResult["PostToShow"]["FEED_DESTINATION"]['SELECTED'] = array(); if (empty($arResult["PostToShow"]["SPERM"])) { if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()) { if (!empty($arResult["PostToShow"]["FEED_DESTINATION"]['LAST']['SONETGROUPS'])) { foreach ($arResult["PostToShow"]["FEED_DESTINATION"]['LAST']['SONETGROUPS'] as $val) { $arResult["PostToShow"]["FEED_DESTINATION"]['SELECTED'][$val] = "sonetgroups"; }
} else { $arResult["GROUP_ID"] = $arParams["GROUP_ID"]; } if ($arResult["ShowForm"] == "Input") { if (!array_key_exists("TAB", $arResult) || $arResult["TAB"] == "edit") { $arResult["Subjects"] = array(); $dbSubjects = CSocNetGroupSubject::GetList(array("SORT" => "ASC", "NAME" => "ASC"), array("SITE_ID" => SITE_ID), false, false, array("ID", "NAME")); while ($arSubject = $dbSubjects->GetNext()) { $arResult["Subjects"][$arSubject["ID"]] = $arSubject["NAME"]; } $arResult["InitiatePerms"] = array(SONET_ROLES_OWNER => GetMessage("SONET_GCE_IP_OWNER"), SONET_ROLES_MODERATOR => GetMessage("SONET_GCE_IP_MOD"), SONET_ROLES_USER => GetMessage("SONET_GCE_IP_USER")); $arResult["SpamPerms"] = array(SONET_ROLES_OWNER => GetMessage("SONET_GCE_IP_OWNER"), SONET_ROLES_MODERATOR => GetMessage("SONET_GCE_IP_MOD"), SONET_ROLES_USER => GetMessage("SONET_GCE_IP_USER"), SONET_ROLES_ALL => GetMessage("SONET_GCE_IP_ALL")); } } if (!array_key_exists("TAB", $arResult) || $arResult["TAB"] == "invite") { $arResult["DEST_SORT"] = CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "GROUP_INVITE", "CODE_TYPE" => 'U')); $arResult["DEST_USERS_LAST"] = array(); CSocNetLogDestination::fillLastDestination($arResult["DEST_SORT"], $arResult["DEST_USERS_LAST"]); if (isset($arResult["DEST_USERS_LAST"]['USERS'])) { $arResult["DEST_USERS_LAST"] = $arResult["DEST_USERS_LAST"]['USERS']; } if (is_array($arResult["DEST_USERS_LAST"]) && !empty($arResult["DEST_USERS_LAST"])) { $arLastUserID = array(); foreach ($arResult["DEST_USERS_LAST"] as $user_code) { if (preg_match('/^U(\\d+)$/', $user_code, $match)) { $arLastUserID[] = $match[1]; } } $dbUsers = CUser::GetList($sort_by = array('last_name' => 'asc', 'IS_ONLINE' => 'desc'), $dummy = '', array("ID" => implode("|", $arLastUserID)), array("FIELDS" => array("ID", "LAST_NAME", "NAME", "SECOND_NAME", "LOGIN", "PERSONAL_PHOTO", "WORK_POSITION", "PERSONAL_PROFESSION"), "SELECT" => array("UF_DEPARTMENT"))); $arResult["siteDepartmentID"] = COption::GetOptionString("main", "wizard_departament", false, SITE_ID, true); while ($arUser = $dbUsers->Fetch()) {
} $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_user2group_U" . $GLOBALS["USER"]->GetID()); $GLOBALS["CACHE_MANAGER"]->EndTagCache(); } $obCache->EndDataCache(array("SONET_GROUPS" => $arSonetGroups, "SONET_GROUPS_EXTRANET" => $arSonetGroupsExtranet)); } if (is_array($arSonetGroupsExtranet) && !empty($arSonetGroupsExtranet)) { $arExtranetGroupID = array(); foreach ($arSonetGroupsExtranet as $arSonetGroupTmp) { if (is_array($arSonetGroupTmp) && array_key_exists("entityId", $arSonetGroupTmp) && intval($arSonetGroupTmp["entityId"]) > 0) { $arExtranetGroupID[] = intval($arSonetGroupTmp["entityId"]); } } } if (method_exists('CSocNetLogDestination', 'GetDestinationSort')) { $arSonetGroupsLast = array("DEST_SORT" => CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "USER_INVITE", "CODE_TYPE" => 'SG')), "LAST" => array()); CSocNetLogDestination::fillLastDestination($arSonetGroupsLast["DEST_SORT"], $arSonetGroupsLast["LAST"]); } else { $arSonetGroupsLast = array("LAST" => array('SONETGROUPS' => CSocNetLogDestination::GetLastSocnetGroup())); } $APPLICATION->IncludeComponent("bitrix:intranet.user.selector.new", ".default", array("MULTIPLE" => "N", "NAME" => "INVITE_DEPARTMENT", "VALUE" => 0, "POPUP" => "Y", "INPUT_NAME" => "UF_DEPARTMENT", "ON_SECTION_SELECT" => "onInviteDialogSectionsSelect", "SITE_ID" => $SITE_ID, "SHOW_STRUCTURE_ONLY" => "Y", "SHOW_EXTRANET_USERS" => "NONE"), null, array("HIDE_ICONS" => "Y")); ?> <div class="intranet-tabs-box" id="intranet-dialog-tabs"><?php ?> <div class="webform-round-corners webform-error-block" id="invite-dialog-error-block" style="display: none;"> <div class="webform-corners-top"><div class="webform-left-corner"></div><div class="webform-right-corner"></div></div> <div class="webform-content" id="invite-dialog-error-content"><?php echo $strError; ?> </div> <div class="webform-corners-bottom"><div class="webform-left-corner"></div><div class="webform-right-corner"></div></div>
} if ($arParams["CACHE_TIME"] > 0) { $cache->EndDataCache(array("comment_props" => $arResult["COMMENT_PROPERTIES"])); } } CJSCore::Init(array('socnetlogdest')); $lastAuthors = array(); if ($arParams["FROM_LOG"] != "Y") { $lastAuthors["U" . $arPost["AUTHOR_ID"]] = "U" . $arPost["AUTHOR_ID"]; if (isset($arResult["CommentsResult"]) && is_array($arResult["CommentsResult"])) { foreach ($arResult["CommentsResult"] as $v) { $lastAuthors["U" . $v["AUTHOR_ID"]] = "U" . $v["AUTHOR_ID"]; } } } $arLastDestinations = CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "MENTION", "CODE_TYPE" => 'U')); $arResult["FEED_DESTINATION"]['LAST'] = array('USERS' => array()); CSocNetLogDestination::fillLastDestination($arLastDestinations, $arResult["FEED_DESTINATION"]['LAST']); if (count($lastAuthors) >= 5) { $arResult["FEED_DESTINATION"]['LAST']['USERS'] = $lastAuthors; } else { $arResult["FEED_DESTINATION"]['LAST']['USERS'] = array_merge($arResult["FEED_DESTINATION"]['LAST']['USERS'], $lastAuthors); } $arStructure = CSocNetLogDestination::GetStucture(array("LAZY_LOAD" => true)); $arResult["FEED_DESTINATION"]['DEPARTMENT'] = $arStructure['department']; $arResult["FEED_DESTINATION"]['DEPARTMENT_RELATION'] = $arStructure['department_relation']; if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()) { $arResult["FEED_DESTINATION"]['EXTRANET_USER'] = '******'; $arResult["FEED_DESTINATION"]['USERS'] = CSocNetLogDestination::GetExtranetUser(); } else { $arDestUser = array();
} if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()) { $arParams["DESTINATION"]['EXTRANET_USER'] = '******'; $arParams["DESTINATION"]['USERS'] = CSocNetLogDestination::GetExtranetUser(); } else { $arDestUser = array(); foreach ($arParams["DESTINATION"]['LAST']['USERS'] as $value) { $arDestUser[] = str_replace('U', '', $value); } $arParams["DESTINATION"]['EXTRANET_USER'] = '******'; $arParams["DESTINATION"]['USERS'] = CSocNetLogDestination::GetUsers(array('id' => $arDestUser)); } } if (in_array("MentionUser", $arParams["BUTTONS"])) { if (CModule::IncludeModule("socialnetwork") && method_exists('CSocNetLogDestination', 'GetDestinationSort')) { $arResult["MENTION_DEST_SORT"] = CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "MENTION")); } else { $arResult["MENTION_DEST_SORT"] = array(); } $arParams["DESTINATION"]['LAST']['MENTION_USERS'] = array(); $arDestUser = array(); foreach ($arResult["MENTION_DEST_SORT"] as $code => $sortInfo) { if (preg_match('/^U(\\d+)$/i', $code, $matches)) { $arParams["DESTINATION"]['LAST']['MENTION_USERS'][$code] = $code; $arDestUser[] = str_replace('U', '', $code); } } $arParams["DESTINATION"]['MENTION_USERS'] = CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser() ? $arParams["DESTINATION"]['USERS'] : (!empty($arDestUser) ? CSocNetLogDestination::GetUsers(array('id' => $arDestUser)) : array()); } $arParams["TAGS"] = is_array($arParams["TAGS"]) ? $arParams["TAGS"] : array(); if (!empty($arParams["TAGS"])) {
public static function GetSocNetDestination($user_id = false, $selected = array()) { global $CACHE_MANAGER; if (!is_array($selected)) { $selected = array(); } if (method_exists('CSocNetLogDestination', 'GetDestinationSort')) { $DESTINATION = array('LAST' => array(), 'DEST_SORT' => CSocNetLogDestination::GetDestinationSort(array("DEST_CONTEXT" => "CALENDAR"))); CSocNetLogDestination::fillLastDestination($DESTINATION['DEST_SORT'], $DESTINATION['LAST']); } else { $DESTINATION = array('LAST' => array('SONETGROUPS' => CSocNetLogDestination::GetLastSocnetGroup(), 'DEPARTMENT' => CSocNetLogDestination::GetLastDepartment(), 'USERS' => CSocNetLogDestination::GetLastUser())); } if (!$user_id) { $user_id = CCalendar::GetCurUserId(); } $cacheTtl = defined("BX_COMP_MANAGED_CACHE") ? 3153600 : 3600 * 4; $cacheId = 'blog_post_form_dest_' . $user_id; $cacheDir = '/blog/form/dest/' . SITE_ID . '/' . $user_id; $obCache = new CPHPCache(); if ($obCache->InitCache($cacheTtl, $cacheId, $cacheDir)) { $DESTINATION['SONETGROUPS'] = $obCache->GetVars(); } else { $obCache->StartDataCache(); $DESTINATION['SONETGROUPS'] = CSocNetLogDestination::GetSocnetGroup(array('features' => array("blog", array("premoderate_post", "moderate_post", "write_post", "full_post")))); if (defined("BX_COMP_MANAGED_CACHE")) { $CACHE_MANAGER->StartTagCache($cacheDir); foreach ($DESTINATION['SONETGROUPS'] as $val) { $CACHE_MANAGER->RegisterTag("sonet_features_G_" . $val["entityId"]); $CACHE_MANAGER->RegisterTag("sonet_group_" . $val["entityId"]); } $CACHE_MANAGER->RegisterTag("sonet_user2group_U" . $user_id); $CACHE_MANAGER->EndTagCache(); } $obCache->EndDataCache($DESTINATION['SONETGROUPS']); } $arDestUser = array(); $DESTINATION['SELECTED'] = array(); foreach ($selected as $ind => $code) { if (substr($code, 0, 2) == 'DR') { $DESTINATION['SELECTED'][$code] = "department"; } elseif (substr($code, 0, 2) == 'UA') { $DESTINATION['SELECTED'][$code] = "groups"; } elseif (substr($code, 0, 2) == 'SG') { $DESTINATION['SELECTED'][$code] = "sonetgroups"; } elseif (substr($code, 0, 1) == 'U') { $DESTINATION['SELECTED'][$code] = "users"; $arDestUser[] = str_replace('U', '', $code); } } // intranet structure $arStructure = CSocNetLogDestination::GetStucture(); //$arStructure = CSocNetLogDestination::GetStucture(array("LAZY_LOAD" => true)); $DESTINATION['DEPARTMENT'] = $arStructure['department']; $DESTINATION['DEPARTMENT_RELATION'] = $arStructure['department_relation']; $DESTINATION['DEPARTMENT_RELATION_HEAD'] = $arStructure['department_relation_head']; if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()) { $DESTINATION['EXTRANET_USER'] = '******'; $DESTINATION['USERS'] = CSocNetLogDestination::GetExtranetUser(); } else { if (is_array($DESTINATION['LAST']['USERS'])) { foreach ($DESTINATION['LAST']['USERS'] as $value) { $arDestUser[] = str_replace('U', '', $value); } } $DESTINATION['EXTRANET_USER'] = '******'; $DESTINATION['USERS'] = CSocNetLogDestination::GetUsers(array('id' => $arDestUser)); } $users = array(); foreach ($DESTINATION['USERS'] as $key => $entry) { if ($entry['isExtranet'] == 'N') { $users[$key] = $entry; } } $DESTINATION['USERS'] = $users; return $DESTINATION; }