public static function CanUserDeletePost($ID, $userID, $blogOwnerID, $groupOwnerID) { $ID = IntVal($ID); $userID = IntVal($userID); $blogOwnerID = IntVal($blogOwnerID); $groupOwnerID = IntVal($groupOwnerID); $blogModulePermissions = $GLOBALS["APPLICATION"]->GetGroupRight("blog"); if ($blogModulePermissions >= "W") { return True; } $arPost = CBlogPost::GetByID($ID); if (empty($arPost)) { return False; } if ($groupOwnerID > 0) { $arBlogUser = CBlogUser::GetByID($userID, BLOG_BY_USER_ID); if ($arBlogUser && $arBlogUser["ALLOW_POST"] != "Y") { return False; } $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "view_post")) { $perms = BLOG_PERMS_READ; } if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "write_post")) { $perms = BLOG_PERMS_WRITE; } if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_GROUP, $groupOwnerID, "blog", "full_post")) { $perms = BLOG_PERMS_FULL; } if ($perms >= BLOG_PERMS_WRITE && $arPost["AUTHOR_ID"] == $userID) { return true; } if ($perms > BLOG_PERMS_WRITE) { return true; } } else { $arBlog = CBlog::GetByID($arPost["BLOG_ID"]); $arBlogUser = CBlogUser::GetByID($userID, BLOG_BY_USER_ID); if ($arBlogUser && $arBlogUser["ALLOW_POST"] != "Y") { return False; } $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "view_post")) { $perms = BLOG_PERMS_READ; } if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "write_post")) { $perms = BLOG_PERMS_WRITE; } if (CSocNetFeaturesPerms::CanPerformOperation($userID, SONET_ENTITY_USER, $blogOwnerID, "blog", "full_post")) { $perms = BLOG_PERMS_FULL; } if ($perms >= BLOG_PERMS_WRITE && $arPost["AUTHOR_ID"] == $userID) { return true; } if ($perms > BLOG_PERMS_WRITE) { return true; } } return False; }
function __InTaskDeleteView($delViewId, $iblockId, $taskType, $ownerId) { $delViewId = IntVal($delViewId); $iblockId = IntVal($iblockId); $ownerId = IntVal($ownerId); if ($delViewId <= 0 || $iblockId <= 0 || $ownerId <= 0) { return ""; } $errorMessage = ""; $userSettingsCategory = "IntranetTasks"; $userSettingsNamePart = "Settings_"; $arUserSettings = CUserOptions::GetOption($userSettingsCategory, $userSettingsNamePart . $delViewId, false, $GLOBALS["USER"]->GetID()); if (!$arUserSettings) { $errorMessage .= GetMessage("INTL_VIEW_NOT_FOUND") . "."; } if (StrLen($errorMessage) <= 0) { if ($arUserSettings["IBLOCK_ID"] != $iblockId || $arUserSettings["TASK_TYPE"] != $taskType || $arUserSettings["OWNER_ID"] != $ownerId) { $errorMessage .= GetMessage("INTL_WRONG_VIEW") . "."; } } if (StrLen($errorMessage) <= 0) { if ($arUserSettings["COMMON"] != "N") { $canModifyCommon = $taskType == 'user' && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $ownerId, "tasks", 'modify_common_views') || $taskType == 'group' && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $ownerId, "tasks", 'modify_common_views'); if (!$canModifyCommon) { $errorMessage .= GetMessage("INTL_NO_VIEW_PERMS") . "."; } } } if (StrLen($errorMessage) <= 0) { CUserOptions::DeleteOption($userSettingsCategory, $userSettingsNamePart . $delViewId, $arUserSettings["COMMON"] == "Y" ? true : false, $GLOBALS["USER"]->GetID()); } return $errorMessage; }
function __ShowGroupField($name, $propertyField, $value, $taskType = "group") { if (!is_array($value)) { $value = array($value); } $flag = 0; $ha = false; $res = ""; $bWas = false; $dbSections = CIBlockSection::GetTreeList(array("IBLOCK_ID" => $propertyField["IBLOCK_ID"])); while ($arSections = $dbSections->GetNext()) { if ($taskType == "group") { if ($flag == 0) { if ($arSections["EXTERNAL_ID"] != $propertyField["ROOT_ID"]) { continue; } $flag = $arSections["DEPTH_LEVEL"]; continue; } else { if ($flag == $arSections["DEPTH_LEVEL"]) { break; } } } else { $flag = 1; if ($arSections["DEPTH_LEVEL"] == 1) { if ($arSections["XML_ID"] == "users_tasks") { $ha = true; } else { $ha = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arSections["XML_ID"], "tasks", $arResult["arSocNetFeaturesSettings"]["tasks"]["minoperation"][0]); } } if (!$ha) { continue; } } $res .= '<option value="' . $arSections["ID"] . '"'; if (in_array($arSections["ID"], $value)) { $bWas = true; $res .= ' selected'; } $res .= '>' . str_repeat(" . ", $arSections["DEPTH_LEVEL"] - $flag) . $arSections["NAME"] . '</option>'; } echo '<select name="' . $name . '" style="width:98%">'; echo '<option value=""' . (!$bWas ? ' selected' : '') . '>' . GetMessage("INTVT_NOT_SET") . '</option>'; echo $res; echo '</select>'; }
public static function OnFillSocNetMenu(&$arResult, $arParams = array()) { global $USER; $arResult["AllowSettings"]["group_lists"] = true; $arResult["CanView"]["group_lists"] = (array_key_exists("ActiveFeatures", $arResult) ? array_key_exists("group_lists", $arResult["ActiveFeatures"]) : true) && CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), $arParams["ENTITY_TYPE"], $arParams["ENTITY_ID"], "group_lists", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["Title"]["group_lists"] = array_key_exists("ActiveFeatures", $arResult) && array_key_exists("group_lists", $arResult["ActiveFeatures"]) && strlen($arResult["ActiveFeatures"]["group_lists"]) > 0 ? $arResult["ActiveFeatures"]["group_lists"] : GetMessage("LISTS_SOCNET_TAB"); if (!array_key_exists("SEF_MODE", $arResult) || $arResult["SEF_MODE"] != "N") { if (isset($arResult["Urls"])) { $arResult["Urls"]["group_lists"] = $arResult["Urls"]["view"] . "lists/"; } } else { if (!array_key_exists("PAGE_VAR", $arResult)) { $arResult["PAGE_VAR"] = "page"; } if (!array_key_exists("GROUP_VAR", $arResult)) { $arResult["GROUP_VAR"] = "group_id"; } $arResult["Urls"]["group_lists"] = "?" . $arResult["PAGE_VAR"] . "=group_lists&" . $arResult["GROUP_VAR"] . "=" . $arResult["Group"]["ID"]; } }
private static function getAllowedActionsArrayInternal($executiveUserId, array $arTaskData, $bmUserRoles) { $arBaseAllowedActions = self::getBaseAllowedActions(); $arActualBaseAllowedActions = $arBaseAllowedActions[$arTaskData['REAL_STATUS']]; // actions allowed on read-access $arAllowedActions = array(self::ACTION_TOGGLE_FAVORITE); if ($arTaskData['FAVORITE'] == 'Y') { $arAllowedActions[] = self::ACTION_DELETE_FAVORITE; } else { $arAllowedActions[] = self::ACTION_ADD_FAVORITE; } $mergesCount = 0; if (is_array($arActualBaseAllowedActions)) { foreach ($arActualBaseAllowedActions as $userRole => $arActions) { if ($userRole & $bmUserRoles) { $arAllowedActions = array_merge($arAllowedActions, $arActions); ++$mergesCount; } } } if ($mergesCount > 1) { $arAllowedActions = array_unique($arAllowedActions); } $isAdmin = CTasksTools::IsAdmin($executiveUserId) || CTasksTools::IsPortalB24Admin($executiveUserId); if (self::$bSocialNetworkModuleIncluded === null) { self::$bSocialNetworkModuleIncluded = CModule::IncludeModule('socialnetwork'); } // Admin always can edit and remove, also implement rights from task group if (!in_array(self::ACTION_REMOVE, $arAllowedActions, true)) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if ($isAdmin || $arTaskData['GROUP_ID'] > 0 && self::$bSocialNetworkModuleIncluded && CSocNetFeaturesPerms::CanPerformOperation($executiveUserId, SONET_ENTITY_GROUP, $arTaskData['GROUP_ID'], 'tasks', 'delete_tasks')) { $arAllowedActions[] = self::ACTION_REMOVE; } } if (!in_array(self::ACTION_EDIT, $arAllowedActions, true)) { /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if ($isAdmin || $arTaskData['GROUP_ID'] > 0 && self::$bSocialNetworkModuleIncluded && CSocNetFeaturesPerms::CanPerformOperation($executiveUserId, SONET_ENTITY_GROUP, $arTaskData['GROUP_ID'], 'tasks', 'edit_tasks')) { $arAllowedActions[] = self::ACTION_EDIT; } } // Precache result of slow 'in_array' function $bCanEdit = in_array(self::ACTION_EDIT, $arAllowedActions, true); // User can change deadline, if ... if ($isAdmin || $bCanEdit || $arTaskData['ALLOW_CHANGE_DEADLINE'] === 'Y' && self::ROLE_RESPONSIBLE & $bmUserRoles) { $arAllowedActions[] = self::ACTION_CHANGE_DEADLINE; } // If user can edit task, he can also add elapsed time and checklist items if ($isAdmin || $bCanEdit) { $arAllowedActions[] = self::ACTION_ELAPSED_TIME_ADD; $arAllowedActions[] = self::ACTION_CHECKLIST_ADD_ITEMS; } // Director can change director, and user who can edit can if ($isAdmin || $bCanEdit || self::ROLE_DIRECTOR & $bmUserRoles) { $arAllowedActions[] = self::ACTION_CHANGE_DIRECTOR; } if ($arTaskData['ALLOW_TIME_TRACKING'] === 'Y') { // User can do time tracking, if he is participant in the task if ($executiveUserId == $arTaskData['RESPONSIBLE_ID'] || !empty($arTaskData['ACCOMPLICES']) && in_array($executiveUserId, $arTaskData['ACCOMPLICES'])) { $arAllowedActions[] = self::ACTION_START_TIME_TRACKING; } } return array_values(array_unique($arAllowedActions)); }
function MkFilter($arFilter, &$arJoinProps, &$arAddWhereFields, $level = 0, $bPropertyLeftJoin = false) { global $DB, $USER; $arSqlSearch = array(); $permSQL = ""; $arSectionFilter = array("LOGIC" => "", "BE" => array(), "BS" => array()); $strSqlSearch = ""; if (!is_array($arFilter)) { $arFilter = array(); } foreach ($arFilter as $key => $val) { $key = strtoupper($key); $p = strpos($key, "PROPERTY_"); if ($p !== false && $p < 4) { $arFilter[substr($key, 0, $p) . "PROPERTY"][substr($key, $p + 9)] = $val; unset($arFilter[$key]); } } if (array_key_exists("LOGIC", $arFilter) && $arFilter["LOGIC"] == "OR") { $Logic = "OR"; unset($arFilter["LOGIC"]); $bPropertyLeftJoin = true; } else { $Logic = "AND"; } if ($Logic === "AND" && $level === 0) { $f = new \Bitrix\Iblock\PropertyIndex\QueryBuilder($arFilter["IBLOCK_ID"]); if ($f->isValid()) { $arJoinProps["FC"] = $f->getFilterSql($arFilter, $arSqlSearch); $arJoinProps["FC_DISTINCT"] = $f->getDistinct(); } } foreach ($arFilter as $orig_key => $val) { $res = CIBlock::MkOperationFilter($orig_key); $key = $res["FIELD"]; $cOperationType = $res["OPERATION"]; //it was done before $key = strtoupper($key); switch ($key . "") { case "ACTIVE": case "DETAIL_TEXT_TYPE": case "PREVIEW_TEXT_TYPE": $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "string_equal", $bFullJoinTmp, $cOperationType); break; case "NAME": case "XML_ID": case "TMP_ID": case "DETAIL_TEXT": case "SEARCHABLE_CONTENT": case "PREVIEW_TEXT": case "CODE": case "TAGS": case "WF_COMMENTS": $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "string", $bFullJoinTmp, $cOperationType); break; case "ID": if (is_object($val)) { $arSqlSearch[] = $val->_sql_in("BE." . $key, $cOperationType); } else { $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType); } break; case "SHOW_COUNTER": case "WF_PARENT_ELEMENT_ID": case "WF_STATUS_ID": case "SORT": case "CREATED_BY": case "PREVIEW_PICTURE": case "DETAIL_PICTURE": $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType); break; case "IBLOCK_ID": $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "number", $bFullJoinTmp, $cOperationType); break; case "TIMESTAMP_X": case "DATE_CREATE": case "SHOW_COUNTER_START": $arSqlSearch[] = CIBlock::FilterCreateEx("BE." . $key, $val, "date", $bFullJoinTmp, $cOperationType); break; case "EXTERNAL_ID": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.XML_ID", $val, "string", $bFullJoinTmp, $cOperationType); break; case "IBLOCK_TYPE": $flt = CIBlock::FilterCreateEx("B.IBLOCK_TYPE_ID", $val, "string", $bFullJoinTmp, $cOperationType); $arSqlSearch[] = $flt; break; case "CHECK_PERMISSIONS": if ($val == "Y" && (!is_object($USER) || !$USER->IsAdmin())) { $permSQL = CIBlockElement::_check_rights_sql($arFilter["MIN_PERMISSION"]); } break; case "CHECK_BP_PERMISSIONS": if (IsModuleInstalled('bizproc') && (!is_object($USER) || !$USER->IsAdmin())) { if (is_array($val)) { $MODULE_ID = $DB->ForSQL($val["MODULE_ID"]); $ENTITY = $DB->ForSQL($val["ENTITY"]); $PERMISSION = $DB->ForSQL($val["PERMISSION"]); $arUserGroups = array(); if (is_array($val["GROUPS"])) { $USER_ID = intval($val["USER_ID"]); foreach ($val["GROUPS"] as $GROUP_ID) { $GROUP_ID = intval($GROUP_ID); if ($GROUP_ID) { $arUserGroups[$GROUP_ID] = $GROUP_ID; } } } else { $USER_ID = 0; } } else { $MODULE_ID = "iblock"; $ENTITY = "CIBlockDocument"; $PERMISSION = $val; $arUserGroups = false; $USER_ID = 0; } if ($PERMISSION == "read" || $PERMISSION == "write") { if (!is_array($arUserGroups) && is_object($USER)) { $USER_ID = intval($USER->GetID()); $arUserGroups = $USER->GetUserGroupArray(); } if (!is_array($arUserGroups) || count($arUserGroups) <= 0) { $arUserGroups = array(2); } $arSqlSearch[] = "EXISTS (\n\t\t\t\t\t\t\tSELECT S.DOCUMENT_ID_INT\n\t\t\t\t\t\t\tFROM\n\t\t\t\t\t\t\tb_bp_workflow_state S\n\t\t\t\t\t\t\tINNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tS.DOCUMENT_ID_INT = BE.ID\n\t\t\t\t\t\t\t\tAND S.MODULE_ID = '{$MODULE_ID}'\n\t\t\t\t\t\t\t\tAND S.ENTITY = '{$ENTITY}'\n\t\t\t\t\t\t\t\tAND P.PERMISSION = '{$PERMISSION}'\n\t\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\t\tP.OBJECT_ID IN ('" . implode("', '", $arUserGroups) . "')\n\t\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = {$USER_ID})\n\t\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = " . $DB->Concat("'USER_'", "'{$USER_ID}'") . ")\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t)"; } } break; case "CHECK_BP_TASKS_PERMISSIONS": if (IsModuleInstalled('bizproc') && CModule::IncludeModule("socialnetwork") && (!is_object($USER) || !$USER->IsAdmin())) { $val = explode("_", $val); $taskType = $val[0]; if (!in_array($taskType, array("user", "group"))) { $taskType = "user"; } $ownerId = intval($val[1]); $val = $val[2]; if (!in_array($val, array("read", "write", "comment"))) { $val = "write"; } $userId = is_object($USER) ? intval($USER->GetID()) : 0; $arUserGroups = array(); if ($taskType == "group") { $r = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $ownerId, "tasks", $val == "write" ? "edit_tasks" : "view_all"); if ($r) { break; } $arUserGroups[] = SONET_ROLES_ALL; $r = CSocNetUserToGroup::GetUserRole($userId, $ownerId); if (strlen($r) > 0) { $arUserGroups[] = $r; } } else { // $arUserGroups[] = SONET_RELATIONS_TYPE_ALL; // if (CSocNetUserRelations::IsFriends($userId, $ownerId)) // $arUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS; // elseif (CSocNetUserRelations::IsFriends2($userId, $ownerId)) // $arUserGroups[] = SONET_RELATIONS_TYPE_FRIENDS2; } $arSqlSearch[] = "EXISTS (\n\t\t\t\t\t\tSELECT S.DOCUMENT_ID_INT\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\tb_bp_workflow_state S\n\t\t\t\t\t\tINNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tS.DOCUMENT_ID_INT = BE.ID\n\t\t\t\t\t\t\tAND S.MODULE_ID = 'intranet'\n\t\t\t\t\t\t\tAND S.ENTITY = 'CIntranetTasksDocument'\n\t\t\t\t\t\t\tAND P.PERMISSION = '" . $val . "'\n\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\t" . ($taskType == "group" ? "P.OBJECT_ID IN ('" . implode("', '", $arUserGroups) . "') OR" : "") . "\n\t\t\t\t\t\t\t\t(P.OBJECT_ID = 'author' AND BE.CREATED_BY = " . $userId . ")\n\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = 'responsible' AND " . $userId . " IN (\n\t\t\t\t\t\t\t\t\tSELECT SFPV0.VALUE_NUM\n\t\t\t\t\t\t\t\t\tFROM b_iblock_element_property SFPV0\n\t\t\t\t\t\t\t\t\t\tINNER JOIN b_iblock_property SFP0 ON (SFPV0.IBLOCK_PROPERTY_ID = SFP0.ID)\n\t\t\t\t\t\t\t\t\tWHERE " . CIBlock::_Upper("SFP0.CODE") . "='TASKASSIGNEDTO'\n\t\t\t\t\t\t\t\t\t\tAND SFP0.IBLOCK_ID = BE.IBLOCK_ID\n\t\t\t\t\t\t\t\t\t\tAND SFPV0.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = 'trackers' AND " . $userId . " IN (\n\t\t\t\t\t\t\t\t\tSELECT SFPV0.VALUE_NUM\n\t\t\t\t\t\t\t\t\tFROM b_iblock_element_property SFPV0\n\t\t\t\t\t\t\t\t\t\tINNER JOIN b_iblock_property SFP0 ON (SFPV0.IBLOCK_PROPERTY_ID = SFP0.ID)\n\t\t\t\t\t\t\t\t\tWHERE " . CIBlock::_Upper("SFP0.CODE") . "='TASKTRACKERS'\n\t\t\t\t\t\t\t\t\t\tAND SFP0.IBLOCK_ID = BE.IBLOCK_ID\n\t\t\t\t\t\t\t\t\t\tAND SFPV0.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t\t\t\t\t\t))\n\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = '" . ("USER_" . $userId) . "')\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)"; } break; case "CHECK_BP_VIRTUAL_PERMISSIONS": if (IsModuleInstalled('bizproc') && (!is_object($USER) || !$USER->IsAdmin())) { if (!in_array($val, array("read", "create", "admin"))) { $val = "admin"; } $userId = is_object($USER) ? intval($USER->GetID()) : 0; if (is_object($USER)) { $arUserGroups = $USER->GetUserGroupArray(); } if (!is_array($arUserGroups) || count($arUserGroups) <= 0) { $arUserGroups = array(2); } $arSqlSearch[] = "EXISTS (\n\t\t\t\t\t\tSELECT S.DOCUMENT_ID_INT\n\t\t\t\t\t\tFROM b_bp_workflow_state S\n\t\t\t\t\t\t\tINNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID\n\t\t\t\t\t\tWHERE S.DOCUMENT_ID_INT = BE.ID\n\t\t\t\t\t\t\tAND S.MODULE_ID = 'bizproc'\n\t\t\t\t\t\t\tAND S.ENTITY = 'CBPVirtualDocument'\n\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t(P.PERMISSION = '" . $val . "'\n\t\t\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\t\t\tP.OBJECT_ID IN ('" . implode("', '", $arUserGroups) . "')\n\t\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = " . $userId . ")\n\t\t\t\t\t\t\t\t\tOR (P.OBJECT_ID = " . $DB->Concat("'USER_'", "'" . $userId . "'") . ")\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t)\n\t\t\t\t\t)"; } break; case "TASKSTATUS": if (IsModuleInstalled('bizproc')) { $arSqlSearch[] = ($cOperationType == "N" ? "NOT " : "") . "EXISTS (\n\t\t\t\t\t\tSELECT S.DOCUMENT_ID_INT\n\t\t\t\t\t\tFROM\n\t\t\t\t\t\tb_bp_workflow_state S\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tS.DOCUMENT_ID_INT = BE.ID\n\t\t\t\t\t\t\tAND S.MODULE_ID = 'intranet'\n\t\t\t\t\t\t\tAND S.ENTITY = 'CIntranetTasksDocument'\n\t\t\t\t\t\t\tAND S.STATE = '" . $DB->ForSql($val) . "'\n\t\t\t\t\t)"; } break; case "LID": case "SITE_ID": case "IBLOCK_LID": case "IBLOCK_SITE_ID": $flt = CIBlock::FilterCreateEx("SITE_ID", $val, "string_equal", $bFullJoinTmp, $cOperationType); if (strlen($flt)) { $arSqlSearch[] = ($cOperationType == "N" ? "NOT " : "") . "EXISTS (\n\t\t\t\t\t\tSELECT IBLOCK_ID FROM b_iblock_site WHERE IBLOCK_ID = B.ID\n\t\t\t\t\t\tAND " . $flt . "\n\t\t\t\t\t)"; } break; case "DATE_ACTIVE_FROM": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.ACTIVE_FROM", $val, "date", $bFullJoinTmp, $cOperationType); break; case "DATE_ACTIVE_TO": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.ACTIVE_TO", $val, "date", $bFullJoinTmp, $cOperationType); break; case "IBLOCK_ACTIVE": $flt = CIBlock::FilterCreateEx("B.ACTIVE", $val, "string_equal", $bFullJoinTmp, $cOperationType); $arSqlSearch[] = $flt; break; case "IBLOCK_CODE": $flt = CIBlock::FilterCreateEx("B.CODE", $val, "string", $bFullJoinTmp, $cOperationType); $arSqlSearch[] = $flt; break; case "ID_ABOVE": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.ID", $val, "number_above", $bFullJoinTmp, $cOperationType); break; case "ID_LESS": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.ID", $val, "number_less", $bFullJoinTmp, $cOperationType); break; case "ACTIVE_FROM": if (strlen($val) > 0) { $arSqlSearch[] = "(BE.ACTIVE_FROM " . ($cOperationType == "N" ? "<" : ">=") . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ($cOperationType == "N" ? "" : " OR BE.ACTIVE_FROM IS NULL") . ")"; } break; case "ACTIVE_TO": if (strlen($val) > 0) { $arSqlSearch[] = "(BE.ACTIVE_TO " . ($cOperationType == "N" ? ">" : "<=") . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ($cOperationType == "N" ? "" : " OR BE.ACTIVE_TO IS NULL") . ")"; } break; case "ACTIVE_DATE": if (strlen($val) > 0) { $arSqlSearch[] = ($cOperationType == "N" ? " NOT" : "") . "((BE.ACTIVE_TO >= " . $DB->GetNowFunction() . " OR BE.ACTIVE_TO IS NULL) AND (BE.ACTIVE_FROM <= " . $DB->GetNowFunction() . " OR BE.ACTIVE_FROM IS NULL))"; } break; case "DATE_MODIFY_FROM": if (strlen($val) > 0) { $arSqlSearch[] = "(BE.TIMESTAMP_X " . ($cOperationType == "N" ? "<" : ">=") . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ($cOperationType == "N" ? "" : " OR BE.TIMESTAMP_X IS NULL") . ")"; } break; case "DATE_MODIFY_TO": if (strlen($val) > 0) { $arSqlSearch[] = "(BE.TIMESTAMP_X " . ($cOperationType == "N" ? ">" : "<=") . $DB->CharToDateFunction($DB->ForSql($val), "FULL") . ($cOperationType == "N" ? "" : " OR BE.TIMESTAMP_X IS NULL") . ")"; } break; case "WF_NEW": if ($val == "Y" || $val == "N") { $arSqlSearch[] = CIBlock::FilterCreateEx("BE.WF_NEW", "Y", "string_equal", $bFullJoinTmp, $val == "Y" ? false : true, false); } break; case "MODIFIED_USER_ID": case "MODIFIED_BY": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.MODIFIED_BY", $val, "number", $bFullJoinTmp, $cOperationType); break; case "CREATED_USER_ID": case "CREATED_BY": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.CREATED_BY", $val, "number", $bFullJoinTmp, $cOperationType); break; case "RATING_USER_ID": $arSqlSearch[] = CIBlock::FilterCreateEx("RVV.USER_ID", $val, "number", $bFullJoinTmp, $cOperationType); $arJoinProps["RVV"] = array("bFullJoin" => $bFullJoinTmp); break; case "WF_STATUS": $arSqlSearch[] = CIBlock::FilterCreateEx("BE.WF_STATUS_ID", $val, "number", $bFullJoinTmp, $cOperationType); break; case "WF_LOCK_STATUS": if (strlen($val) > 0) { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; $arSqlSearch[] = " if(BE.WF_DATE_LOCK is null, 'green', if(DATE_ADD(BE.WF_DATE_LOCK, interval " . COption::GetOptionInt("workflow", "MAX_LOCK_TIME", 60) . " MINUTE)<now(), 'green', if(BE.WF_LOCKED_BY=" . $USER_ID . ", 'yellow', 'red'))) = '" . $DB->ForSql($val) . "'"; } break; case "WF_LAST_STATUS_ID": $arSqlSearch[] = "exists (\n\t\t\t\t\tselect\n\t\t\t\t\t\thistory.ID\n\t\t\t\t\tfrom\n\t\t\t\t\t\tb_iblock_element history\n\t\t\t\t\twhere\n\t\t\t\t\t\thistory.WF_PARENT_ELEMENT_ID = BE.ID\n\t\t\t\t\t\tand history.WF_STATUS_ID = " . intval($val) . "\n\t\t\t\t\t\tand history.ID = (\n\t\t\t\t\t\t\tselect max(history0.ID) LAST_ID\n\t\t\t\t\t\t\tfrom b_iblock_element history0\n\t\t\t\t\t\t\twhere history0.WF_PARENT_ELEMENT_ID = BE.ID\n\t\t\t\t\t\t)\n\t\t\t\t)\n\t\t\t\t"; break; case "SECTION_ACTIVE": if ($arFilter["INCLUDE_SUBSECTIONS"] === "Y") { $arSectionFilter["BS"][] = "BSubS.ACTIVE = 'Y'"; } else { $arSectionFilter["BS"][] = "BS.ACTIVE = 'Y'"; } break; case "SECTION_GLOBAL_ACTIVE": if ($arFilter["INCLUDE_SUBSECTIONS"] === "Y") { $arSectionFilter["BS"][] = "BSubS.GLOBAL_ACTIVE = 'Y'"; } else { $arSectionFilter["BS"][] = "BS.GLOBAL_ACTIVE = 'Y'"; } break; case "SUBSECTION": if (!is_array($val)) { $val = array($val); } //Find out margins of sections $arUnknownMargins = array(); foreach ($val as $i => $section) { if (!is_array($section)) { $arUnknownMargins[intval($section)] = intval($section); } } if (count($arUnknownMargins) > 0) { $rs = $DB->Query("SELECT ID, LEFT_MARGIN, RIGHT_MARGIN FROM b_iblock_section WHERE ID in (" . implode(", ", $arUnknownMargins) . ")"); while ($ar = $rs->Fetch()) { $arUnknownMargins[intval($ar["ID"])] = array(intval($ar["LEFT_MARGIN"]), intval($ar["RIGHT_MARGIN"])); } foreach ($val as $i => $section) { if (!is_array($section)) { $val[$i] = $arUnknownMargins[intval($section)]; } } } //Now sort them out $arMargins = array(); foreach ($val as $i => $section) { if (is_array($section) && count($section) == 2) { $left = intval($section[0]); $right = intval($section[1]); if ($left > 0 && $right > 0) { $arMargins[$left] = $right; } } } ksort($arMargins); //Remove subsubsections of the sections $prev_right = 0; foreach ($arMargins as $left => $right) { if ($right <= $prev_right) { unset($arMargins[$left]); } else { $prev_right = $right; } } if (isset($arFilter["INCLUDE_SUBSECTIONS"]) && $arFilter["INCLUDE_SUBSECTIONS"] === "Y") { $bsAlias = "BSubS"; } else { $bsAlias = "BS"; } $res = ""; foreach ($arMargins as $left => $right) { if ($res != "") { $res .= $cOperationType == "N" ? " AND " : " OR "; } $res .= ($cOperationType == "N" ? " NOT " : " ") . "({$bsAlias}.LEFT_MARGIN >= " . $left . " AND {$bsAlias}.RIGHT_MARGIN <= " . $right . ")\n"; } if ($res != "") { $arSectionFilter["BS"][] = "(" . $res . ")"; } break; case "SECTION_ID": if (!is_array($val)) { $val = array($val); } $arSections = array(); foreach ($val as $section_id) { $section_id = intval($section_id); $arSections[$section_id] = $section_id; } if ($cOperationType == "N") { if (array_key_exists(0, $arSections)) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS<>'N'"; $arSectionFilter["LOGIC"] = "AND"; unset($arSections[0]); if (count($arSections) > 0) { $arSectionFilter["BS"][] = "BS.ID NOT IN (" . implode(", ", $arSections) . ")"; } } elseif (count($arSections) > 0) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS='N'"; $arSectionFilter["LOGIC"] = "OR"; $arSectionFilter["BS"][] = "BS.ID NOT IN (" . implode(", ", $arSections) . ")"; } } else { if (array_key_exists(0, $arSections)) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS='N'"; $arSectionFilter["LOGIC"] = "OR"; unset($arSections[0]); } if (count($arSections) > 0) { $arSectionFilter["BS"][] = "BS.ID IN (" . implode(", ", $arSections) . ")"; } } break; case "SECTION_CODE": if (!is_array($val)) { $val = array($val); } $arSections = array(); foreach ($val as $section_code) { $section_code = $DB->ForSql($section_code); $arSections[$section_code] = $section_code; } if ($cOperationType == "N") { if (array_key_exists("", $arSections)) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS<>'N'"; $arSectionFilter["LOGIC"] = "AND"; unset($arSections[""]); if (count($arSections) > 0) { $arSectionFilter["BS"][] = "BS.CODE NOT IN ('" . implode("', '", $arSections) . "')"; } } elseif (count($arSections) > 0) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS='N'"; $arSectionFilter["LOGIC"] = "OR"; $arSectionFilter["BS"][] = "BS.CODE NOT IN ('" . implode("', '", $arSections) . "')"; } } else { if (array_key_exists("", $arSections)) { $arSectionFilter["BE"][] = "BE.IN_SECTIONS='N'"; $arSectionFilter["LOGIC"] = "OR"; unset($arSections[""]); } if (count($arSections) > "") { $arSectionFilter["BS"][] = "BS.CODE IN ('" . implode("', '", $arSections) . "')"; } } break; case "PROPERTY": foreach ($val as $propID => $propVAL) { $res = CIBlock::MkOperationFilter($propID); $res["LOGIC"] = $Logic; $res["LEFT_JOIN"] = $bPropertyLeftJoin; if (preg_match("/^([^.]+)\\.([^.]+)\$/", $res["FIELD"], $arMatch)) { $db_prop = CIBlockProperty::GetPropertyArray($arMatch[1], CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"], $arFilter["~IBLOCK_ID"], $arFilter["~IBLOCK_CODE"])); if (is_array($db_prop) && $db_prop["PROPERTY_TYPE"] == "E") { $res["FIELD"] = $arMatch; CIBlockElement::MkPropertyFilter($res, $cOperationType, $propVAL, $db_prop, $arJoinProps, $arSqlSearch); } } else { if ($db_prop = CIBlockProperty::GetPropertyArray($res["FIELD"], CIBlock::_MergeIBArrays($arFilter["IBLOCK_ID"], $arFilter["IBLOCK_CODE"], $arFilter["~IBLOCK_ID"], $arFilter["~IBLOCK_CODE"]))) { CIBlockElement::MkPropertyFilter($res, $cOperationType, $propVAL, $db_prop, $arJoinProps, $arSqlSearch); } } } break; default: if (is_numeric($orig_key)) { //Here is hint for better property resolution: if (!is_array($val) || !array_key_exists("~IBLOCK_ID", $val)) { if (array_key_exists("IBLOCK_ID", $arFilter)) { $val["~IBLOCK_ID"] = $arFilter["IBLOCK_ID"]; } elseif (array_key_exists("~IBLOCK_ID", $arFilter)) { $val["~IBLOCK_ID"] = $arFilter["~IBLOCK_ID"]; } } if (!is_array($val) || !array_key_exists("~IBLOCK_CODE", $val)) { if (array_key_exists("IBLOCK_CODE", $arFilter)) { $val["~IBLOCK_CODE"] = $arFilter["IBLOCK_CODE"]; } elseif (array_key_exists("~IBLOCK_CODE", $arFilter)) { $val["~IBLOCK_CODE"] = $arFilter["~IBLOCK_CODE"]; } } //Subfilter process $arSubSqlSearch = CIBlockElement::MkFilter($val, $arJoinProps, $arAddWhereFields, $level + 1, $bPropertyLeftJoin); if (strlen(trim($arSubSqlSearch[0], "\n\t"))) { $arSqlSearch[] = str_replace("\n\t\t\t", "\n\t\t\t\t", $arSubSqlSearch[0]); } } elseif (strtoupper(substr($key, 0, 8)) == "CATALOG_" && CModule::IncludeModule("catalog")) { $res_catalog = CCatalogProduct::GetQueryBuildArrays(array(), array($orig_key => $val), array()); if (strlen($res_catalog["WHERE"])) { $arSqlSearch[] = substr($res_catalog["WHERE"], 5); // " AND ".$res $arAddWhereFields[$orig_key] = $val; } } break; } } //SECTION sub filter $sWhere = ""; foreach ($arSectionFilter["BS"] as $strFilter) { if (strlen($strFilter)) { if (strlen($sWhere)) { $sWhere .= " " . $Logic . " "; } $sWhere .= "(" . $strFilter . ")"; } } $bINCLUDE_SUBSECTIONS = isset($arFilter["INCLUDE_SUBSECTIONS"]) && $arFilter["INCLUDE_SUBSECTIONS"] === "Y"; if (strlen($sWhere)) { $sectionScope = ""; if (isset($arFilter["SECTION_SCOPE"])) { if ($arFilter["SECTION_SCOPE"] == "IBLOCK") { $sectionScope = "AND BSE.ADDITIONAL_PROPERTY_ID IS NULL"; } elseif ($arFilter["SECTION_SCOPE"] == "PROPERTY") { $sectionScope = "AND BSE.ADDITIONAL_PROPERTY_ID IS NOT NULL"; } elseif (preg_match("/^PROPERTY_(\\d+)\$/", $arFilter["SECTION_SCOPE"], $match)) { $sectionScope = "AND BSE.ADDITIONAL_PROPERTY_ID = " . $match[1]; } } //Try to convert correlated subquery to join subquery if ($level == 0 && $Logic == "AND" && !count($arSectionFilter["BE"])) { $arJoinProps["BES"] .= " INNER JOIN (\n\t\t\t\t\tSELECT DISTINCT BSE.IBLOCK_ELEMENT_ID\n\t\t\t\t\tFROM b_iblock_section_element BSE\n\t\t\t\t\t" . ($bINCLUDE_SUBSECTIONS ? "\n\t\t\t\t\tINNER JOIN b_iblock_section BSubS ON BSE.IBLOCK_SECTION_ID = BSubS.ID\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON (BSubS.IBLOCK_ID=BS.IBLOCK_ID\n\t\t\t\t\t\tAND BSubS.LEFT_MARGIN>=BS.LEFT_MARGIN\n\t\t\t\t\t\tAND BSubS.RIGHT_MARGIN<=BS.RIGHT_MARGIN)\n\t\t\t\t\t" : "\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID\n\t\t\t\t\t") . "\n\t\t\t\t\tWHERE (" . $sWhere . "){$sectionScope}\n\t\t\t\t\t) BES ON BES.IBLOCK_ELEMENT_ID = BE.ID\n"; } else { $arSqlSearch[] = "(" . (count($arSectionFilter["BE"]) ? implode(" " . $arSectionFilter["LOGIC"] . " ", $arSectionFilter["BE"]) . " " . $arSectionFilter["LOGIC"] : "") . " EXISTS (\n\t\t\t\t\tSELECT BSE.IBLOCK_ELEMENT_ID\n\t\t\t\t\tFROM b_iblock_section_element BSE\n\t\t\t\t\t" . ($bINCLUDE_SUBSECTIONS ? "\n\t\t\t\t\tINNER JOIN b_iblock_section BSubS ON BSE.IBLOCK_SECTION_ID = BSubS.ID\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON (BSubS.IBLOCK_ID=BS.IBLOCK_ID\n\t\t\t\t\t\tAND BSubS.LEFT_MARGIN>=BS.LEFT_MARGIN\n\t\t\t\t\t\tAND BSubS.RIGHT_MARGIN<=BS.RIGHT_MARGIN)\n\t\t\t\t\t" : "\n\t\t\t\t\tINNER JOIN b_iblock_section BS ON BSE.IBLOCK_SECTION_ID = BS.ID\n\t\t\t\t\t") . "\n\t\t\t\t\tWHERE BSE.IBLOCK_ELEMENT_ID = BE.ID\n\t\t\t\t\tAND (" . $sWhere . "){$sectionScope}\n\t\t\t\t\t))"; } } elseif (count($arSectionFilter["BE"])) { foreach ($arSectionFilter["BE"] as $strFilter) { $arSqlSearch[] = $strFilter; } } $sWhere = ""; foreach ($arSqlSearch as $strFilter) { if (strlen(trim($strFilter, "\n\t"))) { if (strlen($sWhere)) { $sWhere .= "\n\t\t\t\t" . $Logic . " "; } else { $sWhere .= "\n\t\t\t\t"; } $sWhere .= "(" . $strFilter . ")"; } } $arSqlSearch = array("\n\t\t\t" . $sWhere . "\n\t\t\t"); $SHOW_BP_NEW = ""; $SHOW_NEW = isset($arFilter["SHOW_NEW"]) && $arFilter["SHOW_NEW"] == "Y" ? "Y" : "N"; if ($SHOW_NEW == "Y" && isset($arFilter["SHOW_BP_NEW"]) && is_array($arFilter["SHOW_BP_NEW"]) && IsModuleInstalled('bizproc') && (!is_object($USER) || !$USER->IsAdmin())) { $MODULE_ID = $DB->ForSQL($arFilter["SHOW_BP_NEW"]["MODULE_ID"]); $ENTITY = $DB->ForSQL($arFilter["SHOW_BP_NEW"]["ENTITY"]); $PERMISSION = $DB->ForSQL($arFilter["SHOW_BP_NEW"]["PERMISSION"]); $arUserGroups = array(); if (is_array($arFilter["SHOW_BP_NEW"]["GROUPS"])) { $USER_ID = intval($arFilter["SHOW_BP_NEW"]["USER_ID"]); foreach ($arFilter["SHOW_BP_NEW"]["GROUPS"] as $GROUP_ID) { $GROUP_ID = intval($GROUP_ID); if ($GROUP_ID) { $arUserGroups[$GROUP_ID] = $GROUP_ID; } } } else { $USER_ID = false; $arUserGroups = false; } if ($PERMISSION == "read" || $PERMISSION == "write") { if (!is_array($arUserGroups)) { $USER_ID = is_object($USER) ? intval($USER->GetID()) : 0; if (is_object($USER)) { $arUserGroups = $USER->GetUserGroupArray(); } } if (!is_array($arUserGroups) || count($arUserGroups) <= 0) { $arUserGroups = array(2); } $SHOW_BP_NEW = " AND EXISTS (\n\t\t\t\t\tSELECT S.DOCUMENT_ID_INT\n\t\t\t\t\tFROM\n\t\t\t\t\tb_bp_workflow_state S\n\t\t\t\t\tINNER JOIN b_bp_workflow_permissions P ON S.ID = P.WORKFLOW_ID\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tS.DOCUMENT_ID_INT = BE.ID\n\t\t\t\t\t\tAND S.MODULE_ID = '{$MODULE_ID}'\n\t\t\t\t\t\tAND S.ENTITY = '{$ENTITY}'\n\t\t\t\t\t\tAND P.PERMISSION = '{$PERMISSION}'\n\t\t\t\t\t\tAND (\n\t\t\t\t\t\t\tP.OBJECT_ID IN ('" . implode("', '", $arUserGroups) . "')\n\t\t\t\t\t\t\tOR (P.OBJECT_ID = 'Author' AND BE.CREATED_BY = {$USER_ID})\n\t\t\t\t\t\t\tOR (P.OBJECT_ID = " . $DB->Concat("'USER_'", "'{$USER_ID}'") . ")\n\t\t\t\t\t\t)\n\t\t\t\t)"; } } if (!isset($arFilter["SHOW_HISTORY"]) || $arFilter["SHOW_HISTORY"] != "Y") { $arSqlSearch[] = "((BE.WF_STATUS_ID=1 AND BE.WF_PARENT_ELEMENT_ID IS NULL)" . ($SHOW_NEW == "Y" ? " OR (BE.WF_NEW='Y'" . $SHOW_BP_NEW . ")" : "") . ")"; } if ($permSQL) { $arSqlSearch[] = $permSQL; } if (isset($this) && is_object($this) && isset($this->subQueryProp)) { //Subquery list value should not be null $this->MkPropertyFilter(CIBlock::MkOperationFilter("!" . substr($this->strField, 9)), "NE", false, $this->subQueryProp, $arJoinProps, $arSqlSearch); } return $arSqlSearch; }
Default params ********************************************************************/ $arParams["IBLOCK_ID"] = intVal($object == "user" ? $arParams["PHOTO_USER_IBLOCK_ID"] : $arParams["PHOTO_GROUP_IBLOCK_ID"]); $cache = new CPHPCache(); /************** Permission *****************************************/ $arParams["PERMISSION"] = "D"; if ($object == "user") { if (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "photo", "write", CSocNetUser::IsCurrentUserModuleAdmin())) { $arParams["PERMISSION"] = "W"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["VARIABLES"]["user_id"], "photo", "view", CSocNetUser::IsCurrentUserModuleAdmin())) { $arParams["PERMISSION"] = "R"; } } else { if (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "photo", "write", CSocNetUser::IsCurrentUserModuleAdmin())) { $arParams["PERMISSION"] = "W"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, $arResult["VARIABLES"]["group_id"], "photo", "view", CSocNetUser::IsCurrentUserModuleAdmin())) { $arParams["PERMISSION"] = "R"; } } $user_alias = $arResult["VARIABLES"]["user_alias"]; if (empty($user_alias)) { $arFilter = array("IBLOCK_ID" => $arParams["IBLOCK_ID"], "IBLOCK_ACTIVE" => "Y", "SECTION_ID" => 0, "SOCNET_GROUP_ID" => false); if ($object == "user") { $uid = $arResult["VARIABLES"]["user_id"]; if ($uid <= 0 && $componentPage == "user_photo_my" && $GLOBALS["USER"]->IsAuthorized()) { $uid = $GLOBALS["USER"]->GetId(); } if ($uid <= 0) { $arParams["ERROR_MESSAGE"] = "User is not exists."; return 0; }
function __SLEGetLogRecord($logID, $arParams, $arCurrentUserSubscribe, $current_page_date) { static $isExtranetInstalled, $isExtranetSite, $isExtranetUser, $arUserIdVisible, $arAvailableExtranetUserID, $isExtranetAdmin, $bCurrentUserIsAdmin, $arSocNetFeaturesSettings; if (!$isExtranetInstalled) { $isExtranetInstalled = CModule::IncludeModule("extranet") ? "Y" : "N"; $isExtranetSite = $isExtranetInstalled == "Y" && CExtranet::IsExtranetSite() ? "Y" : "N"; $isExtranetUser = $isExtranetInstalled == "Y" && !CExtranet::IsIntranetUser() ? "Y" : "N"; $isExtranetAdmin = $isExtranetInstalled == "Y" && CExtranet::IsExtranetAdmin() ? "Y" : "N"; $bCurrentUserIsAdmin = CSocNetUser::IsCurrentUserModuleAdmin(); $arSocNetFeaturesSettings = CSocNetAllowed::GetAllowedFeatures(); if ($isExtranetUser == "Y") { $arUserIdVisible = CExtranet::GetMyGroupsUsersSimple(SITE_ID); } elseif ($isExtranetInstalled == "Y" && $isExtranetUser != "Y") { if ($isExtranetAdmin == "Y" && $bCurrentUserIsAdmin) { $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsers(SITE_ID); } else { $arAvailableExtranetUserID = CExtranet::GetMyGroupsUsersSimple(CExtranet::GetExtranetSiteID()); } } } $cache_time = 31536000; $arEvent = array(); $cache = new CPHPCache(); $arCacheID = array(); $arKeys = array("AVATAR_SIZE", "DESTINATION_LIMIT", "CHECK_PERMISSIONS_DEST", "NAME_TEMPLATE", "NAME_TEMPLATE_WO_NOBR", "SHOW_LOGIN", "DATE_TIME_FORMAT", "PATH_TO_USER", "PATH_TO_GROUP", "PATH_TO_CONPANY_DEPARTMENT"); foreach ($arKeys as $param_key) { if (array_key_exists($param_key, $arParams)) { $arCacheID[$param_key] = $arParams[$param_key]; } else { $arCacheID[$param_key] = false; } } $cache_id = "log_post_" . $logID . "_" . md5(serialize($arCacheID)) . "_" . SITE_TEMPLATE_ID . "_" . SITE_ID . "_" . LANGUAGE_ID . "_" . FORMAT_DATETIME . "_" . CTimeZone::GetOffset(); $cache_path = "/sonet/log/" . intval(intval($logID) / 1000) . "/" . $logID . "/entry/"; if (is_object($cache) && $cache->InitCache($cache_time, $cache_id, $cache_path)) { $arCacheVars = $cache->GetVars(); $arEvent["FIELDS_FORMATTED"] = $arCacheVars["FIELDS_FORMATTED"]; if (array_key_exists("CACHED_CSS_PATH", $arEvent["FIELDS_FORMATTED"])) { if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) && strlen($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]) > 0) { $GLOBALS['APPLICATION']->SetAdditionalCSS($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"]); } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"])) { foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_CSS_PATH"] as $css_path) { $GLOBALS['APPLICATION']->SetAdditionalCSS($css_path); } } } if (array_key_exists("CACHED_JS_PATH", $arEvent["FIELDS_FORMATTED"])) { if (!is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]) && $arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] !== '') { $GLOBALS['APPLICATION']->AddHeadScript($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"]); } elseif (is_array($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"])) { foreach ($arEvent["FIELDS_FORMATTED"]["CACHED_JS_PATH"] as $js_path) { $GLOBALS['APPLICATION']->AddHeadScript($js_path); } } } } else { if (is_object($cache)) { $cache->StartDataCache($cache_time, $cache_id, $cache_path); } $arFilter = array("ID" => $logID); $arListParams = array("CHECK_RIGHTS" => "N", "USE_FOLLOW" => "N", "USE_SUBSCRIBE" => "N"); $arSelect = array("ID", "TMP_ID", "ENTITY_TYPE", "ENTITY_ID", "USER_ID", "EVENT_ID", "LOG_DATE", "LOG_UPDATE", "TITLE_TEMPLATE", "TITLE", "MESSAGE", "TEXT_MESSAGE", "URL", "MODULE_ID", "CALLBACK_FUNC", "EXTERNAL_ID", "SITE_ID", "PARAMS", "COMMENTS_COUNT", "ENABLE_COMMENTS", "SOURCE_ID", "GROUP_NAME", "GROUP_OWNER_ID", "GROUP_INITIATE_PERMS", "GROUP_VISIBLE", "GROUP_OPENED", "GROUP_IMAGE_ID", "USER_NAME", "USER_LAST_NAME", "USER_SECOND_NAME", "USER_LOGIN", "USER_PERSONAL_PHOTO", "USER_PERSONAL_GENDER", "CREATED_BY_NAME", "CREATED_BY_LAST_NAME", "CREATED_BY_SECOND_NAME", "CREATED_BY_LOGIN", "CREATED_BY_PERSONAL_PHOTO", "CREATED_BY_PERSONAL_GENDER", "RATING_TYPE_ID", "RATING_ENTITY_ID", "SOURCE_TYPE"); $dbEvent = CSocNetLog::GetList(array(), $arFilter, false, false, $arSelect, $arListParams); if ($arEvent = $dbEvent->GetNext()) { if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->StartTagCache($cache_path); $GLOBALS["CACHE_MANAGER"]->RegisterTag("USER_NAME_" . intval($arEvent["USER_ID"])); $GLOBALS["CACHE_MANAGER"]->RegisterTag("SONET_LOG_" . intval($arEvent["ID"])); if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) { $GLOBALS["CACHE_MANAGER"]->RegisterTag("sonet_group_" . $arEvent["ENTITY_ID"]); } } $arEvent["EVENT_ID_FULLSET"] = CSocNetLogTools::FindFullSetEventIDByEventID($arEvent["EVENT_ID"]); if ($arEvent["ENTITY_TYPE"] == SONET_ENTITY_GROUP) { static $arSiteWorkgroupsPage; if (!$arSiteWorkgroupsPage && (IsModuleInstalled("extranet") || is_set($arEvent["URL"]) && strpos($arEvent["URL"], "#GROUPS_PATH#") !== false)) { $rsSite = CSite::GetList($by = "sort", $order = "desc", array("ACTIVE" => "Y")); while ($arSite = $rsSite->Fetch()) { $arSiteWorkgroupsPage[$arSite["ID"]] = COption::GetOptionString("socialnetwork", "workgroups_page", $arSite["DIR"] . "workgroups/", $arSite["ID"]); } } if (is_set($arEvent["URL"]) && isset($arSiteWorkgroupsPage[SITE_ID])) { $arEvent["URL"] = str_replace("#GROUPS_PATH#", $arSiteWorkgroupsPage[SITE_ID], $arEvent["URL"]); } } $arEventTmp = CSocNetLogTools::FindLogEventByID($arEvent["EVENT_ID"]); if ($arEventTmp && isset($arEventTmp["CLASS_FORMAT"]) && isset($arEventTmp["METHOD_FORMAT"])) { $arEvent["UF"] = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("SONET_LOG", $arEvent["ID"], LANGUAGE_ID); $arEvent["FIELDS_FORMATTED"] = call_user_func(array($arEventTmp["CLASS_FORMAT"], $arEventTmp["METHOD_FORMAT"]), $arEvent, $arParams); if (is_array($arEvent["FIELDS_FORMATTED"])) { if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"])) { if (in_array($arEvent["EVENT_ID"], array('calendar'))) { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"]); } else { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"] = CSocNetTextParser::closetags(htmlspecialcharsback($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["MESSAGE"])); } } if (isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"])) { $arFields2Cache = array("URL", "STYLE", "DESTINATION", "DESTINATION_MORE", "TITLE_24", "TITLE_24_2", "TITLE_24_2_STYLE", "IS_IMPORTANT", "MESSAGE", "FOOTER_MESSAGE", "MESSAGE_TITLE_24", "DATETIME_FORMATTED", "LOG_DATE_FORMAT", "MENU", "COMMENT_URL"); foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"][$field]); } } } if (isset($arEvent["FIELDS_FORMATTED"]["EVENT"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT"])) { $arFields2Cache = array("ID", "URL", "USER_ID", "ENTITY_TYPE", "ENTITY_ID", "EVENT_ID", "EVENT_ID_FULLSET", "TITLE", "MESSAGE", "SOURCE_ID", "PARAMS", "RATING_TYPE_ID", "RATING_ENTITY_ID"); foreach ($arEvent["FIELDS_FORMATTED"]["EVENT"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["EVENT"][$field]); } } } if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"])) { $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL", "IS_EXTRANET"); foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"][$field]); } } if (isset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"])) { $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL"); foreach ($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["CREATED_BY"]["TOOLTIP_FIELDS"][$field]); } } } } if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"])) { $arFields2Cache = array("TOOLTIP_FIELDS", "FORMATTED", "URL"); foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["ENTITY"][$field]); } } if (isset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"]) && is_array($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"])) { $arFields2Cache = array("ID", "PATH_TO_SONET_USER_PROFILE", "NAME", "LAST_NAME", "SECOND_NAME", "LOGIN", "EMAIL"); foreach ($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"] as $field => $value) { if (!in_array($field, $arFields2Cache)) { unset($arEvent["FIELDS_FORMATTED"]["ENTITY"]["TOOLTIP_FIELDS"][$field]); } } } } $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["UF"] = $arEvent["UF"]; } else { $bEmpty = true; } } if (!$bEmpty) { $dateFormated = FormatDate($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATE), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]))); $timeFormated = FormatDateFromDB(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]), stripos($arParams["DATE_TIME_FORMAT"], 'a') || ($arParams["DATE_TIME_FORMAT"] == 'FULL' && IsAmPmMode()) !== false ? strpos(FORMAT_DATETIME, 'TT') !== false ? 'H:MI TT' : 'H:MI T' : 'HH:MI'); $dateTimeFormated = FormatDate(!empty($arParams["DATE_TIME_FORMAT"]) ? $arParams["DATE_TIME_FORMAT"] == "FULL" ? $GLOBALS["DB"]->DateFormatToPHP(str_replace(":SS", "", FORMAT_DATETIME)) : $arParams["DATE_TIME_FORMAT"] : $GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), MakeTimeStamp(isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && isset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"]) ? $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["LOG_DATE_FORMAT"] : (array_key_exists("LOG_DATE_FORMAT", $arEvent) ? $arEvent["LOG_DATE_FORMAT"] : $arEvent["LOG_DATE"]))); if (strcasecmp(LANGUAGE_ID, 'EN') !== 0 && strcasecmp(LANGUAGE_ID, 'DE') !== 0) { $dateTimeFormated = ToLower($dateTimeFormated); $dateFormated = ToLower($dateFormated); $timeFormated = ToLower($timeFormated); } // strip current year if (!empty($arParams['DATE_TIME_FORMAT']) && ($arParams['DATE_TIME_FORMAT'] == 'j F Y G:i' || $arParams['DATE_TIME_FORMAT'] == 'j F Y g:i a')) { $dateTimeFormated = ltrim($dateTimeFormated, '0'); $curYear = date('Y'); $dateTimeFormated = str_replace(array('-' . $curYear, '/' . $curYear, ' ' . $curYear, '.' . $curYear), '', $dateTimeFormated); } $arEvent["MESSAGE_FORMAT"] = htmlspecialcharsback($arEvent["MESSAGE"]); if (StrLen($arEvent["CALLBACK_FUNC"]) > 0) { if (StrLen($arEvent["MODULE_ID"]) > 0) { CModule::IncludeModule($arEvent["MODULE_ID"]); } $arEvent["MESSAGE_FORMAT"] = call_user_func($arEvent["CALLBACK_FUNC"], $arEvent); } $arEvent["FIELDS_FORMATTED"]["LOG_TIME_FORMAT"] = $timeFormated; $arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_TS"] = MakeTimeStamp($arEvent["LOG_UPDATE"]); $arEvent["FIELDS_FORMATTED"]["LOG_DATE_TS"] = MakeTimeStamp($arEvent["LOG_DATE"]); $arEvent["FIELDS_FORMATTED"]["LOG_DATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_DATE"]), "SHORT"); $arEvent["FIELDS_FORMATTED"]["LOG_UPDATE_DAY"] = ConvertTimeStamp(MakeTimeStamp($arEvent["LOG_UPDATE"]), "SHORT"); $arEvent["FIELDS_FORMATTED"]["COMMENTS_COUNT"] = $arEvent["COMMENTS_COUNT"]; $arEvent["FIELDS_FORMATTED"]["TMP_ID"] = $arEvent["TMP_ID"]; $arEvent["FIELDS_FORMATTED"]["DATETIME_FORMATTED"] = $dateTimeFormated; $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["EVENT_ID"]); if (!array_key_exists("HAS_COMMENTS", $arEvent["FIELDS_FORMATTED"]) || $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] != "N") { $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] = $arCommentEvent && (!array_key_exists("ENABLE_COMMENTS", $arEvent) || $arEvent["ENABLE_COMMENTS"] != "N") ? "Y" : "N"; } } } if (is_object($cache)) { $arCacheData = array("FIELDS_FORMATTED" => $arEvent["FIELDS_FORMATTED"]); $cache->EndDataCache($arCacheData); if (defined("BX_COMP_MANAGED_CACHE")) { $GLOBALS["CACHE_MANAGER"]->EndTagCache(); } } } if ($bEmpty) { return false; } $feature = CSocNetLogTools::FindFeatureByEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]); if ($feature && (!array_key_exists($feature, $arSocNetFeaturesSettings) || array_key_exists("allowed", $arSocNetFeaturesSettings[$feature]) && is_array($arSocNetFeaturesSettings[$feature]["allowed"]) && !in_array($arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arSocNetFeaturesSettings[$feature]["allowed"]))) { return false; } if (!array_key_exists("COMMENTS_PARAMS", $arEvent["FIELDS_FORMATTED"])) { $arForumMetaData = CSocNetLogTools::GetForumCommentMetaData($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]); if ($arForumMetaData && $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"] > 0) { $arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => $arForumMetaData[1], "ENTITY_XML_ID" => $arForumMetaData[0] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["SOURCE_ID"], "NOTIFY_TAGS" => $arForumMetaData[2]); } else { $arEvent["FIELDS_FORMATTED"]["COMMENTS_PARAMS"] = array("ENTITY_TYPE" => substr(strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], 0, 2), "ENTITY_XML_ID" => strtoupper($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]) . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], "NOTIFY_TAGS" => ""); } } foreach (GetModuleEvents("socialnetwork", "OnSonetLogEntryMenuCreate", true) as $arModuleEvent) { if (!array_key_exists("FIELDS_FORMATTED", $arEvent)) { $arEvent["FIELDS_FORMATTED"] = array(); } if (!array_key_exists("MENU", $arEvent["FIELDS_FORMATTED"])) { $arEvent["FIELDS_FORMATTED"]["MENU"] = array(); } $arMenuItems = ExecuteModuleEventEx($arModuleEvent, array($arEvent)); if (!empty($arMenuItems)) { $arEvent["FIELDS_FORMATTED"]["MENU"] = array_merge($arEvent["FIELDS_FORMATTED"]["MENU"], $arMenuItems); } } if (is_array($arCurrentUserSubscribe)) { $arEvent["FIELDS_FORMATTED"]["TRANSPORT"] = __SLEGetTransport($arEvent, $arCurrentUserSubscribe); } $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]); if (!$GLOBALS["USER"]->IsAuthorized()) { $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = "N"; } elseif ($arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && $arCommentEvent["OPERATION_ADD"] == "log_rights") { $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = CSocNetLogRights::CheckForUser($arEvent["FIELDS_FORMATTED"]["EVENT"]["ID"], $GLOBALS["USER"]->GetID()) ? "Y" : "N"; } else { $array_key = $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"] . "_" . $arEvent["FIELDS_FORMATTED"]["EVENT"]["EVENT_ID"]; if (array_key_exists($array_key, $GLOBALS["CurUserCanAddComments"])) { $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N"; } else { if ($feature && $arCommentEvent && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) { $GLOBALS["CurUserCanAddComments"][$array_key] = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_TYPE"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["ENTITY_ID"], $feature == "microblog" ? "blog" : $feature, $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin) ? "Y" : "N"; } else { $GLOBALS["CurUserCanAddComments"][$array_key] = "Y"; } $arEvent["FIELDS_FORMATTED"]["CAN_ADD_COMMENTS"] = $GLOBALS["CurUserCanAddComments"][$array_key] == "Y" && $arEvent["FIELDS_FORMATTED"]["HAS_COMMENTS"] == "Y" ? "Y" : "N"; } } $arEvent["FIELDS_FORMATTED"]["FAVORITES"] = $arParams["EVENT"]["FAVORITES"]; if ($arParams["USE_FOLLOW"] == "Y") { $arEvent["FIELDS_FORMATTED"]["EVENT"]["FOLLOW"] = $arParams["EVENT"]["FOLLOW"]; $arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW_X1"] = $arParams["EVENT"]["DATE_FOLLOW_X1"]; $arEvent["FIELDS_FORMATTED"]["EVENT"]["DATE_FOLLOW"] = $arParams["EVENT"]["DATE_FOLLOW"]; } if ($arParams["CHECK_PERMISSIONS_DEST"] == "N" && !$bCurrentUserIsAdmin && is_object($GLOBALS["USER"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) || array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"]))) { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"] = 0; $arGroupID = CSocNetLogTools::GetAvailableGroups(); if (array_key_exists("DESTINATION", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"])) { foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] as $key => $arDestination) { if (array_key_exists("TYPE", $arDestination) && array_key_exists("ID", $arDestination) && ($arDestination["TYPE"] == "SG" && !in_array(intval($arDestination["ID"]), $arGroupID) || in_array($arDestination["TYPE"], array("CRMCOMPANY", "CRMLEAD", "CRMCONTACT", "CRMDEAL")) && CModule::IncludeModule("crm") && !CCrmAuthorizationHelper::CheckReadPermission(CCrmLiveFeedEntity::ResolveEntityTypeID($arDestination["TYPE"]), $arDestination["ID"]) || in_array($arDestination["TYPE"], array("DR", "D")) && $isExtranetUser == "Y" || $arDestination["TYPE"] == "U" && isset($arUserIdVisible) && is_array($arUserIdVisible) && !in_array(intval($arDestination["ID"]), $arUserIdVisible) || $arDestination["TYPE"] == "U" && isset($arDestination["IS_EXTRANET"]) && $arDestination["IS_EXTRANET"] == "Y" && isset($arAvailableExtranetUserID) && is_array($arAvailableExtranetUserID) && !in_array(intval($arDestination["ID"]), $arAvailableExtranetUserID))) { unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"][$key]); $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++; } } if (intval($arParams["DESTINATION_LIMIT_SHOW"]) > 0 && count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) > $arParams["DESTINATION_LIMIT_SHOW"]) { $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_MORE"] = count($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"]) - $arParams["DESTINATION_LIMIT_SHOW"]; $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"] = array_slice($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION"], 0, $arParams["DESTINATION_LIMIT_SHOW"]); } } elseif (array_key_exists("DESTINATION_CODE", $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]) && is_array($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"])) { foreach ($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"] as $key => $right_tmp) { if (preg_match('/^SG(\\d+)$/', $right_tmp, $matches) && !in_array(intval($matches[1]), $arGroupID)) { unset($arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_CODE"][$key]); $arEvent["FIELDS_FORMATTED"]["EVENT_FORMATTED"]["DESTINATION_HIDDEN"]++; } } } } if ($arParams["SHOW_RATING"] == "Y" && strlen($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"]) > 0 && intval($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]) > 0) { $arEvent["FIELDS_FORMATTED"]["RATING"] = CRatings::GetRatingVoteResult($arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_TYPE_ID"], $arEvent["FIELDS_FORMATTED"]["EVENT"]["RATING_ENTITY_ID"]); } return $arEvent["FIELDS_FORMATTED"]; }
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"]; }
$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 { if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_USER, $arParams["USER_ID"], "forum", "full", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "Y"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_USER, $arParams["USER_ID"], "forum", "newtopic", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "M"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_USER, $arParams["USER_ID"], "forum", "answer", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "I"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_USER, $arParams["USER_ID"], "forum", "view", $bCurrentUserIsAdmin)) { $arParams["PERMISSION"] = "E"; } } } if ($arParams["SHOW_VOTE"] == "Y") { // A - NO ACCESS E - READ I - ANSWER // M - NEW TOPIC Q - MODERATE U - EDIT Y - FULL_ACCESS $arResult["VOTE_PERMISSION"] = $arParams['PERMISSION'] === 'A' ? 0 : ($arParams['PERMISSION'] === 'E' ? 1 : 2); $arParams["SHOW_VOTE"] = $arResult["VOTE_PERMISSION"] <= 'A' ? "N" : "Y"; } if (!CForumNew::CanUserViewForum($arParams["FID"], $USER->GetUserGroupArray(), $arParams["PERMISSION"])) { ShowError(GetMessage("FORUM_SONET_NO_ACCESS")); return false; } $arResult["CURRENT_PAGE"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_TOPIC"], array("UID" => $arParams["USER_ID"], "TID" => $arParams["TID"], "GID" => $arParams["SOCNET_GROUP_ID"], "FID" => $arParams["FID"]));
$arResult["BLOG"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_BLOG_TITLE")); if (array_key_exists("blog", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "blog", "view_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("blog") >= "W") && CModule::IncludeModule("blog")) { $arResult["BLOG"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["blog"]) > 0) { $arResult["BLOG"]["TITLE"] = $arResult["ActiveFeatures"]["blog"]; } } $arResult["forum"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_FORUM_TITLE")); if (array_key_exists("forum", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "forum", "view", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("forum") >= "W") && CModule::IncludeModule("forum")) { $arResult["forum"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["forum"]) > 0) { $arResult["forum"]["TITLE"] = $arResult["ActiveFeatures"]["forum"]; } } $arResult["tasks"] = array("SHOW" => false, "TITLE" => GetMessage("SONET_C39_TASKS_TITLE")); if (array_key_exists("tasks", $arResult["ActiveFeatures"]) && (CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "tasks", "view", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("intranet") >= "W") && CModule::IncludeModule("intranet")) { $arResult["tasks"]["SHOW"] = true; if (StrLen($arResult["ActiveFeatures"]["tasks"]) > 0) { $arResult["tasks"]["TITLE"] = $arResult["ActiveFeatures"]["tasks"]; } } } } if (array_key_exists("RatingMultiple", $arResult) && count($arResult["RatingMultiple"]) > 0) { foreach ($arParams["RATING_ID_ARR"] as $rating_id) { if (array_key_exists($rating_id, $arResult["RatingMultiple"])) { $arResult["RatingMultiple"][$rating_id]["VALUE"] = $arResult["User"]["RATING_" . $rating_id . "_CURRENT_VALUE"]; } } } }
/** * <p>Метод проверяет доступ пользователя.</p> * * * * * @param string $access Тип проверяемого доступа (view, write, delete) * * * * @return bool * * * <h4>See Also</h4> * <ul> <li> <a href="http://dev.1c-bitrix.ru/api_help/wiki/classes/cwikiutils/IsReadable.php">CWikiUtils::isReadable</a> * </li> <li> <a * href="http://dev.1c-bitrix.ru/api_help/wiki/classes/cwikiutils/IsWriteable.php">CWikiUtils::isWriteable</a> </li> <li> * <a href="http://dev.1c-bitrix.ru/api_help/wiki/classes/cwikiutils/IsDeleteable.php">CWikiUtils::IsDeleteable</a> </li> * <li> <a href="http://dev.1c-bitrix.ru/api_help/wiki/classes/cwikiutils/IsAllowHTML.php">CWikiUtils::isAllowHTML</a> * </li> </ul><br><br> * * * @static * @link http://dev.1c-bitrix.ru/api_help/wiki/classes/cwikiutils/CheckAccess.php * @author Bitrix */ static function CheckAccess($access = 'view') { global $APPLICATION, $USER, $arParams; if ($USER->IsAdmin()) { return true; } if (CWikiSocnet::IsSocNet()) { $arSonetGroup = CSocNetGroup::GetByID($iSocNetId); if ($arSonetGroup && CSocNetUser::IsCurrentUserModuleAdmin($arSonetGroup['SITE_ID'])) { return true; } if (!CSocNetFeaturesPerms::CanPerformOperation($USER->GetID(), SONET_ENTITY_GROUP, CWikiSocnet::$iSocNetId, 'wiki', $access)) { return false; } return true; } else { $letter = 'R'; $letterI = 'R'; switch ($access) { case 'write': $letter = 'W'; $letterI = 'W'; break; case 'delete': $letter = 'Y'; $letterI = 'W'; break; case 'perm': $letter = 'Z'; $letterI = 'X'; break; } $wikiModulePermission = $APPLICATION->GetGroupRight('wiki'); $iblockPermission = CIBlock::GetPermission($arParams['IBLOCK_ID']); return $wikiModulePermission >= $letter && $iblockPermission >= $letterI; } }
$arResult["Urls"]["Microblog"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_MICROBLOG"], array("user_id" => $arResult["User"]["ID"])); $arResult["Urls"]["Photo"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_PHOTO"], array("user_id" => $arResult["User"]["ID"])); $arResult["Urls"]["Forum"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_FORUM"], array("user_id" => $arResult["User"]["ID"])); $arResult["Urls"]["Calendar"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_CALENDAR"], array("user_id" => $arResult["User"]["ID"])); $arResult["Urls"]["Tasks"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_TASKS"], array("user_id" => $arResult["User"]["ID"])); $arResult["Urls"]["Files"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_FILES"], array("user_id" => $arResult["User"]["ID"], "path" => "")); $arResult["Urls"]["content_search"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER_CONTENT_SEARCH"], array("user_id" => $arResult["User"]["ID"])); $arResult["ActiveFeatures"] = CSocNetFeatures::GetActiveFeaturesNames(SONET_ENTITY_USER, $arResult["User"]["ID"]); $arResult["CanView"]["files"] = array_key_exists("files", $arResult["ActiveFeatures"]) && (CSocNetUser::IsCurrentUserModuleAdmin() || CModule::IncludeModule('webdav') && CIBlockWebdavSocnet::CanAccessFiles($arParams["FILES_USER_IBLOCK_ID"], 'user', $arResult["User"]["ID"])); $arResult["CanView"]["tasks"] = array_key_exists("tasks", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "tasks", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["CanView"]["calendar"] = array_key_exists("calendar", $arResult["ActiveFeatures"]); $arResult["CanView"]["microblog"] = array_key_exists("microblog", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "blog", "view_post", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["CanView"]["blog"] = array_key_exists("blog", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "blog", "view_post", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["CanView"]["photo"] = array_key_exists("photo", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "photo", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["CanView"]["forum"] = array_key_exists("forum", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "forum", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["CanView"]["content_search"] = array_key_exists("search", $arResult["ActiveFeatures"]) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arResult["User"]["ID"], "search", "view", CSocNetUser::IsCurrentUserModuleAdmin()); $arResult["Title"]["blog"] = array_key_exists("blog", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["blog"]) > 0 ? $arResult["ActiveFeatures"]["blog"] : GetMessage("SONET_UM_BLOG"); $arResult["Title"]["microblog"] = array_key_exists("microblog", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["microblog"]) > 0 ? $arResult["ActiveFeatures"]["microblog"] : GetMessage("SONET_UM_MICROBLOG"); $arResult["Title"]["photo"] = array_key_exists("photo", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["photo"]) > 0 ? $arResult["ActiveFeatures"]["photo"] : GetMessage("SONET_UM_PHOTO"); $arResult["Title"]["forum"] = array_key_exists("forum", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["forum"]) > 0 ? $arResult["ActiveFeatures"]["forum"] : GetMessage("SONET_UM_FORUM"); $arResult["Title"]["calendar"] = array_key_exists("calendar", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["calendar"]) > 0 ? $arResult["ActiveFeatures"]["calendar"] : GetMessage("SONET_UM_CALENDAR"); $arResult["Title"]["tasks"] = array_key_exists("tasks", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["tasks"]) > 0 ? $arResult["ActiveFeatures"]["tasks"] : GetMessage("SONET_UM_TASKS"); $arResult["Title"]["files"] = array_key_exists("files", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["files"]) > 0 ? $arResult["ActiveFeatures"]["files"] : GetMessage("SONET_UM_FILES"); $arResult["Title"]["content_search"] = array_key_exists("search", $arResult["ActiveFeatures"]) && StrLen($arResult["ActiveFeatures"]["search"]) > 0 ? $arResult["ActiveFeatures"]["search"] : GetMessage("SONET_UM_SEARCH"); $a = array_keys($arResult["Urls"]); foreach ($a as $v) { $arResult["Urls"][strtolower($v)] = $arResult["Urls"][$v]; } $events = GetModuleEvents("socialnetwork", "OnFillSocNetMenu"); while ($arEvent = $events->Fetch()) { ExecuteModuleEventEx($arEvent, array(&$arResult));
function GetSocNetUserPerms($postId = 0, $authorId = 0) { global $APPLICATION, $USER, $AR_BLOG_PERMS; $userId = IntVal($USER->GetID()); $postId = IntVal($postId); $authorId = IntVal($authorId); if ($postId <= 0) { return false; } $perms = BLOG_PERMS_DENY; $blogModulePermissions = $APPLICATION->GetGroupRight("blog"); if ($authorId > 0 && $userId == $authorId) { $perms = BLOG_PERMS_FULL; } elseif ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) { end($AR_BLOG_PERMS); $perms = key($AR_BLOG_PERMS); reset($AR_BLOG_PERMS); } if ($perms <= BLOG_PERMS_DENY) { $arPerms = CBlogPost::GetSocNetPerms($postId); $arEntities = array(); if (!empty(CBlogPost::$arUACCache[$userId])) { $arEntities = CBlogPost::$arUACCache[$userId]; } else { $arCodes = CAccess::GetUserCodesArray($userId); foreach ($arCodes as $code) { if (preg_match('/^DR([0-9]+)/', $code, $match) || preg_match('/^D([0-9]+)/', $code, $match) || preg_match('/^IU([0-9]+)/', $code, $match)) { $arEntities["DR"][$code] = $code; } elseif (preg_match('/^SG([0-9]+)_([A-Z])/', $code, $match)) { $arEntities["SG"][$match[1]][$match[2]] = $match[2]; } } CBlogPost::$arUACCache[$userId] = $arEntities; } if (!empty($arEntities["DR"]) && !empty($arPerms["DR"])) { foreach ($arPerms["DR"] as $id => $val) { if (isset($arEntities["DR"]["DR" . $id])) { $perms = BLOG_PERMS_READ; break; } } } if (!empty($arPerms["U"][$userId]) && in_array("US" . $userId, $arPerms["U"][$userId]) || $authorId > 0 && $userId == $authorId) { // if author $perms = BLOG_PERMS_FULL; } else { if ($authorId <= 0) { foreach ($arPerms["U"] as $id => $p) { if (in_array("US" . $id, $p)) { $authorId = $id; break; } } } if (!empty($arPerms["U"][$userId]) || !empty($arPerms["U"][$authorId]) && in_array("US" . $authorId, $arPerms["U"][$authorId]) || $perms == BLOG_PERMS_READ) { if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment")) { $perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment")) { $perms = BLOG_PERMS_PREMODERATE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment")) { $perms = BLOG_PERMS_READ; } } } if ($perms <= BLOG_PERMS_FULL) { $arGroupsId = array(); if (!empty($arPerms["SG"])) { foreach ($arPerms["SG"] as $gid => $val) { //if(!empty($arEntities["SG"][$gid])) $arGroupsId[] = $gid; } $operation = array("full_comment", "moderate_comment", "write_comment", "premoderate_comment"); if ($perms < BLOG_PERMS_READ) { $operation[] = "view_comment"; } } if (!empty($arGroupsId)) { foreach ($operation as $v) { if ($perms <= BLOG_PERMS_READ) { $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v); if (!empty($f)) { foreach ($f as $gid => $val) { if (!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid]) || $val == SONET_ROLES_ALL || $userId > 0 && $val == SONET_ROLES_AUTHORIZED) { switch ($v) { case "full_comment": $perms = BLOG_PERMS_FULL; break; case "moderate_comment": $perms = BLOG_PERMS_MODERATE; break; case "write_comment": $perms = BLOG_PERMS_WRITE; break; case "premoderate_comment": $perms = BLOG_PERMS_PREMODERATE; break; case "view_comment": $perms = BLOG_PERMS_READ; break; } } } } } } } } } return $perms; }
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; }
} if (!$photo_detail_url) { $photo_detail_url = $arParams["PATH_TO_" . ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_PHOTO_ELEMENT"]; } if (strlen($photo_iblock_type) > 0 && intval($photo_iblock_id) > 0 && intval($photo_section_id) > 0 && count($arPhotoItems) > 0) { $photo_permission = "D"; if ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP) { if (CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvent["EVENT"]["ENTITY_ID"], "photo", "write", CSocNetUser::IsCurrentUserModuleAdmin())) { $photo_permission = "W"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $arEvent["EVENT"]["ENTITY_ID"], "photo", "view", CSocNetUser::IsCurrentUserModuleAdmin())) { $photo_permission = "R"; } } else { if (CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvent["EVENT"]["ENTITY_ID"], "photo", "write", CSocNetUser::IsCurrentUserModuleAdmin())) { $photo_permission = "W"; } elseif (CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvent["EVENT"]["ENTITY_ID"], "photo", "view", CSocNetUser::IsCurrentUserModuleAdmin())) { $photo_permission = "R"; } } $APPLICATION->IncludeComponent("bitrix:photogallery.detail.list.ex", "", array("IBLOCK_TYPE" => $photo_iblock_type, "IBLOCK_ID" => $photo_iblock_id, "SHOWN_PHOTOS" => count($arPhotoItems) > $arParams["PHOTO_COUNT"] ? array_slice($arPhotoItems, 0, $arParams["PHOTO_COUNT"]) : $arPhotoItems, "DRAG_SORT" => "N", "MORE_PHOTO_NAV" => "N", "PERMISSION" => $photo_permission, "THUMBNAIL_SIZE" => $arParams["PHOTO_THUMBNAIL_SIZE"], "SHOW_CONTROLS" => "Y", "USE_RATING" => $arParams["PHOTO_USE_RATING"] == "Y" || $arParams["SHOW_RATING"] == "Y" ? "Y" : "N", "SHOW_RATING" => $arParams["SHOW_RATING"], "SHOW_SHOWS" => "N", "SHOW_COMMENTS" => "Y", "MAX_VOTE" => $arParams["PHOTO_MAX_VOTE"], "VOTE_NAMES" => isset($arParams["PHOTO_VOTE_NAMES"]) ? $arParams["PHOTO_VOTE_NAMES"] : array(), "DISPLAY_AS_RATING" => $arParams["SHOW_RATING"] == "Y" ? "rating_main" : isset($arParams["PHOTO_DISPLAY_AS_RATING"]) ? $arParams["PHOTO_DISPLAY_AS_RATING"] : "rating", "RATING_MAIN_TYPE" => $arParams["SHOW_RATING"] == "Y" ? $arParams["RATING_TYPE"] : "", "BEHAVIOUR" => "SIMPLE", "SET_TITLE" => "N", "CACHE_TYPE" => "A", "CACHE_TIME" => $arParams["CACHE_TIME"], "CACHE_NOTES" => "", "SECTION_ID" => $photo_section_id, "ELEMENT_LAST_TYPE" => "none", "ELEMENT_SORT_FIELD" => "ID", "ELEMENT_SORT_ORDER" => "asc", "ELEMENT_SORT_FIELD1" => "", "ELEMENT_SORT_ORDER1" => "asc", "PROPERTY_CODE" => array(), "INDEX_URL" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_" . ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_PHOTO"], array("user_id" => $arEvent["EVENT"]["ENTITY_ID"], "group_id" => $arEvent["EVENT"]["ENTITY_ID"])), "DETAIL_URL" => CComponentEngine::MakePathFromTemplate($photo_detail_url, array("user_id" => $arEvent["EVENT"]["ENTITY_ID"], "group_id" => $arEvent["EVENT"]["ENTITY_ID"])), "GALLERY_URL" => "", "SECTION_URL" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_" . ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_PHOTO_SECTION"], array("user_id" => $arEvent["EVENT"]["ENTITY_ID"], "group_id" => $arEvent["EVENT"]["ENTITY_ID"], "section_id" => $EVENT_ID == "photo_photo" ? $photo_section_id : $arEvent["EVENT"]["SOURCE_ID"])), "PATH_TO_USER" => $arParams["PATH_TO_USER"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"], "GROUP_PERMISSIONS" => array(), "PAGE_ELEMENTS" => $arParams["PHOTO_COUNT"], "DATE_TIME_FORMAT" => $arParams["DATE_TIME_FORMAT_DETAIL"], "SET_STATUS_404" => "N", "ADDITIONAL_SIGHTS" => array(), "PICTURES_SIGHT" => "real", "USE_COMMENTS" => $arParams["PHOTO_USE_COMMENTS"], "COMMENTS_TYPE" => $arParams["PHOTO_COMMENTS_TYPE"] == "blog" ? "blog" : "forum", "FORUM_ID" => $arParams["PHOTO_FORUM_ID"], "BLOG_URL" => $arParams["PHOTO_BLOG_URL"], "USE_CAPTCHA" => $arParams["PHOTO_USE_CAPTCHA"], "SHOW_LINK_TO_FORUM" => "N", "IS_SOCNET" => "Y", "USER_ALIAS" => $alias ? $alias : ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "group" : "user") . "_" . $arEvent["EVENT"]["ENTITY_ID"], "~UNIQUE_COMPONENT_ID" => 'bxfg_ucid_from_req_' . $photo_iblock_id . '_' . ($EVENT_ID == "photo_photo" ? $photo_section_id : $arEvent["EVENT"]["SOURCE_ID"]) . "_" . $arEvent["EVENT"]["ID"], "ACTION_URL" => CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_" . ($arEvent["EVENT"]["ENTITY_TYPE"] == SONET_SUBSCRIBE_ENTITY_GROUP ? "GROUP" : "USER") . "_PHOTO_SECTION"], array("user_id" => $arEvent["EVENT"]["ENTITY_ID"], "group_id" => $arEvent["EVENT"]["ENTITY_ID"], "section_id" => $EVENT_ID == "photo_photo" ? $photo_section_id : $arEvent["EVENT"]["SOURCE_ID"]))), $component, array("HIDE_ICONS" => "Y")); } } ?> </div><?php } elseif ($EVENT_ID === "tasks") { ?> <div class="feed-post-info-block-wrap"><?php echo $arEvent["EVENT_FORMATTED"]["MESSAGE"]; ?> </div><?php } elseif ($EVENT_ID === "timeman_entry" || $EVENT_ID === "report") {
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; }
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"] )
public static function GetSocNetUserPerms($postId = 0, $authorId = 0) { global $APPLICATION, $USER, $AR_BLOG_PERMS, $BLOG_POST; $userId = IntVal($USER->GetID()); $postId = IntVal($postId); $authorId = IntVal($authorId); if($postId <= 0) return false; $perms = BLOG_PERMS_DENY; $blogModulePermissions = $APPLICATION->GetGroupRight("blog"); if($authorId > 0 && $userId == $authorId) $perms = BLOG_PERMS_FULL; elseif ($blogModulePermissions >= "W" || CSocNetUser::IsCurrentUserModuleAdmin()) { end($AR_BLOG_PERMS); $perms = key($AR_BLOG_PERMS); reset($AR_BLOG_PERMS); } if($perms <= BLOG_PERMS_DENY) { $arPerms = CBlogPost::GetSocNetPerms($postId); $arEntities = Array(); if (isset($BLOG_POST["UAC_CACHE_".$userId]) && !empty($BLOG_POST["UAC_CACHE_".$userId])) { $arEntities = $BLOG_POST["UAC_CACHE_".$userId]; } else { $dbA = CAccess::GetUserCodes($userId); while($arA = $dbA->Fetch()) { if($arA["PROVIDER_ID"] == "intranet") { $arEntities["DR"][$arA["ACCESS_CODE"]] = $arA["ACCESS_CODE"]; } elseif($arA["PROVIDER_ID"] == "socnetgroup") { $g = substr($arA["ACCESS_CODE"], 2); $gId = IntVal($g); $gR = substr($g, strpos($g, "_")+1); $arEntities["SG"][$gId][$gR] = $gR; } } $BLOG_POST["UAC_CACHE_".$userId] = $arEntities; } if(!empty($arEntities["DR"]) && !empty($arPerms["DR"])) { foreach($arPerms["DR"] as $id => $val) { if(isset($arEntities["DR"]["DR".$id])) { $perms = BLOG_PERMS_READ; break; } } } if((!empty($arPerms["U"][$userId]) && in_array("US".$userId, $arPerms["U"][$userId])) || ($authorId >0 && $userId == $authorId)) // if author $perms = BLOG_PERMS_FULL; else { if($authorId <= 0) { foreach($arPerms["U"] as $id => $p) { if(in_array("US".$id, $p)) { $authorId = $id; break; } } } if(!empty($arPerms["U"][$userId]) || (!empty($arPerms["U"][$authorId]) && in_array("US".$authorId, $arPerms["U"][$authorId])) || $perms == BLOG_PERMS_READ) { if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "write_comment")) $perms = BLOG_PERMS_WRITE; elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "premoderate_comment")) $perms = BLOG_PERMS_PREMODERATE; elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_USER, $authorId, "blog", "view_comment")) $perms = BLOG_PERMS_READ; } } if($perms <= BLOG_PERMS_FULL) { $arGroupsId = Array(); if(!empty($arPerms["SG"])) { foreach($arPerms["SG"] as $gid => $val) { //if(!empty($arEntities["SG"][$gid])) $arGroupsId[] = $gid; } $operation = Array("full_comment", "moderate_comment", "write_comment", "premoderate_comment"); if($perms < BLOG_PERMS_READ) $operation[] = "view_comment"; } if(!empty($arGroupsId)) { foreach($operation as $v) { if($perms <= BLOG_PERMS_READ) { $f = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_GROUP, $arGroupsId, "blog", $v); if(!empty($f)) { foreach($f as $gid => $val) { if((!empty($arEntities["SG"][$gid]) && in_array($val, $arEntities["SG"][$gid])) || $val == SONET_ROLES_ALL || ($userId > 0 && $val == SONET_ROLES_AUTHORIZED)) { switch($v) { case "full_comment": $perms = BLOG_PERMS_FULL; break; case "moderate_comment": $perms = BLOG_PERMS_MODERATE; break; case "write_comment": $perms = BLOG_PERMS_WRITE; break; case "premoderate_comment": $perms = BLOG_PERMS_PREMODERATE; break; case "view_comment": $perms = BLOG_PERMS_READ; break; } } } } } } } } } return $perms; }
} if (intval($arParams["PHOTO_THUMBNAIL_SIZE"]) <= 0) { $arParams["PHOTO_THUMBNAIL_SIZE"] = $parent->arParams["LOG_PHOTO_THUMBNAIL_SIZE"]; } if (intval($arParams["FORUM_ID"]) <= 0) { $arParams["FORUM_ID"] = $parent->arParams["FORUM_ID"]; } } } if (intval($arParams["PHOTO_COUNT"]) <= 0) { $arParams["PHOTO_COUNT"] = 6; } if (intval($arParams["PHOTO_THUMBNAIL_SIZE"]) <= 0) { $arParams["PHOTO_THUMBNAIL_SIZE"] = 48; } if ($user_id > 0 && ($arParams["ENTITY_TYPE"] != SONET_ENTITY_GROUP || (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog", "full_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("blog") >= "W" || CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog", "write_post") || CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog", "moderate_post") || CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["GROUP_ID"], "blog", "premoderate_post")))) { $arResult["MICROBLOG_USER_ID"] = $user_id; } if (IsModuleInstalled("photogallery")) { if (strlen($arParams["PHOTO_USER_IBLOCK_TYPE"]) <= 0) { $arParams["PHOTO_USER_IBLOCK_TYPE"] = "photos"; } if (intval($arParams["PHOTO_USER_IBLOCK_ID"]) <= 0 && CModule::IncludeModule("iblock")) { $dbRes = CIBlock::GetList(array(), array("SITE_ID" => SITE_ID, "CODE" => "user_photogallery")); if ($arRes = $dbRes->Fetch()) { $arParams["PHOTO_USER_IBLOCK_ID"] = $arRes["ID"]; } } if (intval($arParams["PHOTO_FORUM_ID"]) <= 0 && CModule::IncludeModule("forum")) { $dbRes = CForumNew::GetListEx(array(), array("SITE_ID" => SITE_ID, "XML_ID" => "PHOTOGALLERY_COMMENTS")); if ($arRes = $dbRes->Fetch()) {
$userSettingsId = 0; } if ($userSettingsId > 0) { if ($arUserSettings["IBLOCK_ID"] != $iblockId || $arUserSettings["TASK_TYPE"] != $taskType || $arUserSettings["OWNER_ID"] != $ownerId) { $userSettingsId = 0; $userTemplateId = ""; $arUserSettings = false; } } } } if ($userSettingsId <= 0) { $viewId = 0; $action = "create"; } $arResult["Perms"]["CanModifyCommon"] = $taskType == 'user' && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $ownerId, "tasks", 'modify_common_views') || $taskType == 'group' && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_GROUP, $ownerId, "tasks", 'modify_common_views'); if ($action == "edit" && $userSettingsId > 0 && $arUserSettings["COMMON"] != "N") { if (!$arResult["Perms"]["CanModifyCommon"]) { $viewId = 0; $action = "create"; } } if ($arParams["SET_TITLE"] == "Y") { if ($action == "create") { $APPLICATION->SetTitle(GetMessage("INTV_CREATE_TITLE")); } else { $APPLICATION->SetTitle(Str_Replace("#NAME#", $arUserTemplate["NAME"], GetMessage("INTV_EDIT_TITLE"))); } } $arResult["MODE"] = $action; if (StrLen($userTemplateId) > 0) {
public static function GetUserGroups($userId = 0) { if (!$userId || !class_exists('CSocNetUserToGroup') || !class_exists('CSocNetFeatures')) { return; } $dbGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), array("USER_ID" => $userId, "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => SITE_ID, "GROUP_ACTIVE" => "Y"), false, false, array("GROUP_ID", "GROUP_NAME")); $arRes = array(); if ($dbGroups) { $arGroupIds = array(); $arGroups = array(); while ($g = $dbGroups->GetNext()) { $arGroups[] = $g; $arGroupIds[] = $g['GROUP_ID']; } if (count($arGroupIds) > 0) { $arFeaturesActive = CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $arGroupIds, "calendar"); $arView = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroupIds, "calendar", 'view'); $arWrite = CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroupIds, "calendar", 'write'); foreach ($arGroups as $group) { $groupId = intVal($group['~GROUP_ID']); // Calendar is disabled as feature or user can't even view it if (!$arFeaturesActive[$groupId] || !$arView[$groupId]) { continue; } $arRes[$groupId] = array('ID' => $groupId, 'NAME' => $group['~GROUP_NAME'], 'READONLY' => !$arWrite[$groupId]); } } } return $arRes; }
continue; } } elseif ($arEvents["EVENT_ID"] == "blog_post") { if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) { continue; } } elseif ($arEvents["EVENT_ID"] == "blog_post_micro") { if (!array_key_exists("microblog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], "blog", "view_post", $bCurrentUserIsAdmin)) { continue; } } elseif ($arEvents["EVENT_ID"] == "blog_comment") { if (!array_key_exists("blog", $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], "blog", "view_comment", $bCurrentUserIsAdmin)) { continue; } } else { if (!array_key_exists($arEvents["EVENT_ID"], $arSocNetFeaturesSettings) || !CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), SONET_ENTITY_USER, $arEvents["ENTITY_ID"], $arEvents["EVENT_ID"], $arSocNetFeaturesSettings[$arEvents["EVENT_ID"]]["minoperation"][0], $bCurrentUserIsAdmin)) { continue; } } $path2Entity = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_USER"], array("user_id" => $arEvents["ENTITY_ID"])); } $arDateTmp = ParseDateTime($arEvents["LOG_DATE"], CSite::GetDateFormat('FULL')); $day = IntVal($arDateTmp["DD"]); $month = IntVal($arDateTmp["MM"]); $year = IntVal($arDateTmp["YYYY"]); $dateFormated = $day . ' ' . ToLower(GetMessage('MONTH_' . $month . '_S')) . ' ' . $year; $timeFormated = $arDateTmp["HH"] . ':' . $arDateTmp["MI"] . ':' . $arDateTmp["SS"]; $arEvents["MESSAGE_FORMAT"] = htmlspecialcharsback($arEvents["MESSAGE"]); if (StrLen($arEvents["CALLBACK_FUNC"]) > 0) { if (StrLen($arEvents["MODULE_ID"]) > 0) { CModule::IncludeModule($arEvents["MODULE_ID"]);
static function OnFillSocNetMenu(&$arResult, $arParams = array()) { $arResult['AllowSettings']['wiki'] = true; $arResult['CanView']['wiki'] = (array_key_exists('ActiveFeatures', $arResult) ? array_key_exists('wiki', $arResult['ActiveFeatures']) : true) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS['USER']->GetID(), $arParams['ENTITY_TYPE'], $arParams['ENTITY_ID'], 'wiki', 'view', CSocNetUser::IsCurrentUserModuleAdmin()); $arResult['Title']['wiki'] = array_key_exists('ActiveFeatures', $arResult) && array_key_exists('wiki', $arResult['ActiveFeatures']) && strlen($arResult['ActiveFeatures']['wiki']) > 0 ? $arResult['ActiveFeatures']['wiki'] : GetMessage('WIKI_SOCNET_TAB'); if (!array_key_exists('SEF_MODE', $arResult) || $arResult['SEF_MODE'] != 'N') { $arResult['Urls']['wiki'] = $arResult['Urls']['view'] . 'wiki/'; } else { if (!array_key_exists('PAGE_VAR', $arResult)) { $arResult['PAGE_VAR'] = 'page'; } if (!array_key_exists('GROUP_VAR', $arResult)) { $arResult['GROUP_VAR'] = 'group_id'; } $arResult['Urls']['wiki'] = '?' . $arResult['PAGE_VAR'] . '=group_wiki_index&' . $arResult['GROUP_VAR'] . '=' . $arResult['Group']['ID']; } }
if ($arUser['PERSONAL_BIRTHDAY']) { $arBirthDate = ParseDateTime($arUser['PERSONAL_BIRTHDAY'], CSite::GetDateFormat('SHORT')); $arUser['IS_BIRTHDAY'] = intval($arBirthDate['MM']) == date('n') && intval($arBirthDate['DD']) == date('j'); } $arUser['IS_FEATURED'] = CIntranetUtils::IsUserHonoured($arUser['ID']); $arUser['IS_ABSENT'] = CIntranetUtils::IsUserAbsent($arUser['ID']); $arResult["SEARCH"][$i]["USER"] = $arUser; } } } $arResult['USER_PROP'] = array(); $arRes = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFields("USER", 0, LANGUAGE_ID); if (!empty($arRes)) { foreach ($arRes as $key => $val) { $arResult['USER_PROP'][$val["FIELD_NAME"]] = strLen($val["EDIT_FORM_LABEL"]) > 0 ? $val["EDIT_FORM_LABEL"] : $val["FIELD_NAME"]; } } } $arrDropdown = array(); $arResult["DROPDOWN_SONET"] = array(); $EntityType = array_key_exists("arrFILTER", $arParams) && in_array("socialnetwork_group", $arParams["arrFILTER"]) ? SONET_ENTITY_GROUP : SONET_ENTITY_USER; $EntityID = $EntityType == SONET_ENTITY_GROUP ? $arParams["arrFILTER_socialnetwork"][0] : $arParams["arrFILTER_socialnetwork_user"]; $arActiveFeaturesNames = CSocNetFeatures::GetActiveFeaturesNames($EntityType, $EntityID); foreach ($arParams["arrWHERE_SONET"] as $feature_id) { if (strlen($feature_id) > 0 && array_key_exists($feature_id, $arActiveFeaturesNames) && CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $EntityType, $EntityID, $feature_id, $arSocNetFeaturesSettings[$feature_id]["minoperation"][0], CSocNetUser::IsCurrentUserModuleAdmin()) && array_key_exists($feature_id, $arSocNetFeaturesSettings)) { $arrDropdown[$feature_id] = strlen($arActiveFeaturesNames[$feature_id]) > 0 ? $arActiveFeaturesNames[$feature_id] : GetMessage("SEARCH_CONTENT_TYPE_" . strtoupper($feature_id) . "_" . $EntityType); } } if (count($arrDropdown) > 0) { $arResult["DROPDOWN_SONET"] = htmlspecialcharsex($arrDropdown); }
if (!$GLOBALS["USER"]->IsAuthorized()) $arResult[0] = "*"; elseif (!check_bitrix_sessid()) $arResult[0] = "*"; elseif ($action == "add_comment") { $log_id = $_REQUEST["log_id"]; if ($arLog = CSocNetLog::GetByID($log_id)) { $arCommentEvent = CSocNetLogTools::FindLogCommentEventByLogEventID($arLog["EVENT_ID"]); if ($arCommentEvent) { $feature = CSocNetLogTools::FindFeatureByEventID($arCommentEvent["EVENT_ID"]); if ($feature && array_key_exists("OPERATION_ADD", $arCommentEvent) && strlen($arCommentEvent["OPERATION_ADD"]) > 0) $bCanAddComments = CSocNetFeaturesPerms::CanPerformOperation($GLOBALS["USER"]->GetID(), $arLog["ENTITY_TYPE"], $arLog["ENTITY_ID"], ($feature == "microblog" ? "blog" : $feature), $arCommentEvent["OPERATION_ADD"], $bCurrentUserIsAdmin); else $bCanAddComments = true; if ($bCanAddComments) { // add source object and get source_id, $source_url $arParams = array( "PATH_TO_SMILE" => $_REQUEST["p_smile"], "PATH_TO_USER_BLOG_POST" => $_REQUEST["p_ubp"], "PATH_TO_GROUP_BLOG_POST" => $_REQUEST["p_gbp"], "PATH_TO_USER_MICROBLOG_POST" => $_REQUEST["p_umbp"], "PATH_TO_GROUP_MICROBLOG_POST" => $_REQUEST["p_gmbp"], "BLOG_ALLOW_POST_CODE" => $_REQUEST["bapc"] ); $parser = new logTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
unset($arFilter[">PERMS"]); $arFilter["BLOG_USE_SOCNET"] = "Y"; if (IntVal($arParams["SOCNET_GROUP_ID"]) <= 0 && IntVal($arParams["USER_ID"]) <= 0) { $arFilter["FOR_USER"] = $user_id; } else { if (IntVal($arParams["USER_ID"]) > 0) { $arFilter["AUTHOR_ID"] = $arParams["USER_ID"]; $arFilter["FOR_USER"] = $user_id; } elseif (IntVal($arParams["SOCNET_GROUP_ID"]) > 0) { $arFilter["SOCNET_GROUP_ID"] = $arParams["SOCNET_GROUP_ID"]; $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "full_post", CSocNetUser::IsCurrentUserModuleAdmin()) || $APPLICATION->GetGroupRight("blog") >= "W") { $perms = BLOG_PERMS_FULL; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "write_post")) { $perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($user_id, SONET_ENTITY_GROUP, $arParams["SOCNET_GROUP_ID"], "blog", "view_post")) { $perms = BLOG_PERMS_READ; } } } } if ($perms != BLOG_PERMS_DENY) { $SORT = array($arParams["SORT_BY1"] => $arParams["SORT_ORDER1"], $arParams["SORT_BY2"] => $arParams["SORT_ORDER2"]); if ($arParams["MESSAGE_COUNT"] > 0) { $COUNT = array("nTopCount" => $arParams["MESSAGE_COUNT"]); } else { $COUNT = false; } $ids = array(); $dbPosts = CBlogPost::GetList($SORT, $arFilter, false, $COUNT, $arSelectedFields); $p = new blogTextParser(false, $arParams["PATH_TO_SMILE"]);
public static function PostIntoBuzzAsBlog($userTwit, $arSiteId = array(), $userLogin = '') { global $DB; if (!CModule::IncludeModule("blog")) { return; } $arParams = array(); if (IsModuleInstalled('bitrix24') && defined('BX24_HOST_NAME') && $userLogin != '') { if ($arUserTwit = unserialize(base64_decode($userTwit))) { $userTwit = $arUserTwit; } if ($arSiteIdCheck = unserialize(base64_decode($arSiteId))) { $arSiteId = $arSiteIdCheck; } $dbUser = CUser::GetByLogin($userLogin); if ($arUser = $dbUser->Fetch()) { $arParams["USER_ID"] = $arUser["ID"]; } } else { $arParams["USER_ID"] = $userTwit['kp_user_id']; } if (isset($arSiteId[$userTwit['kp_user_id']])) { $siteId = $arSiteId[$userTwit['kp_user_id']]; } if (strlen($siteId) <= 0) { $siteId = SITE_ID; } if (isset($userTwit['text'])) { $arParams["GROUP_ID"] = COption::GetOptionString("socialnetwork", "userbloggroup_id", false, $siteId); $arParams["PATH_TO_BLOG"] = COption::GetOptionString("socialnetwork", "userblogpost_page", false, $siteId); $arParams["PATH_TO_SMILE"] = COption::GetOptionString("socialnetwork", "smile_page", false, $siteId); $arParams["NAME_TEMPLATE"] = COption::GetOptionString("main", "TOOLTIP_NAME_TEMPLATE", false, $siteId); $arParams["SHOW_LOGIN"] = '******'; $arParams["PATH_TO_POST"] = $arParams["PATH_TO_BLOG"]; $arFilterblg = array("ACTIVE" => "Y", "USE_SOCNET" => "Y", "GROUP_ID" => $arParams["GROUP_ID"], "GROUP_SITE_ID" => $siteId, "OWNER_ID" => $arParams["USER_ID"]); $groupId = is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]); if (isset($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]]) && !empty($GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]])) { $arBlog = $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]]; } else { $dbBl = CBlog::GetList(array(), $arFilterblg); $arBlog = $dbBl->Fetch(); if (!$arBlog && IsModuleInstalled("intranet")) { $arBlog = CBlog::GetByOwnerID($arParams["USER_ID"]); } $GLOBALS["BLOG_POST"]["BLOG_P_" . $groupId . "_" . $arParams["USER_ID"]] = $arBlog; } $arResult["Blog"] = $arBlog; if (empty($arBlog)) { if (!empty($arParams["GROUP_ID"])) { $arFields = array("=DATE_UPDATE" => $DB->CurrentTimeFunction(), "GROUP_ID" => is_array($arParams["GROUP_ID"]) ? IntVal($arParams["GROUP_ID"][0]) : IntVal($arParams["GROUP_ID"]), "ACTIVE" => "Y", "ENABLE_COMMENTS" => "Y", "ENABLE_IMG_VERIF" => "Y", "EMAIL_NOTIFY" => "Y", "ENABLE_RSS" => "Y", "ALLOW_HTML" => "N", "ENABLE_TRACKBACK" => "N", "SEARCH_INDEX" => "Y", "USE_SOCNET" => "Y", "=DATE_CREATE" => $DB->CurrentTimeFunction(), "PERMS_POST" => array(1 => "I", 2 => "I"), "PERMS_COMMENT" => array(1 => "P", 2 => "P")); $bRights = false; $rsUser = CUser::GetByID($arParams["USER_ID"]); $arUser = $rsUser->Fetch(); if (strlen($arUser["NAME"] . "" . $arUser["LAST_NAME"]) <= 0) { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["LOGIN"]; } else { $arFields["NAME"] = GetMessage("BLG_NAME") . " " . $arUser["NAME"] . " " . $arUser["LAST_NAME"]; } $arFields["URL"] = str_replace(" ", "_", $arUser["LOGIN"]) . "-blog-" . SITE_ID; $arFields["OWNER_ID"] = $arParams["USER_ID"]; $urlCheck = preg_replace("/[^a-zA-Z0-9_-]/is", "", $arFields["URL"]); if ($urlCheck != $arFields["URL"]) { $arFields["URL"] = "u" . $arParams["USER_ID"] . "-blog-" . SITE_ID; } if (CBlog::GetByUrl($arFields["URL"])) { $uind = 0; do { $uind++; $arFields["URL"] = $arFields["URL"] . $uind; } while (CBlog::GetByUrl($arFields["URL"])); } $featureOperationPerms = CSocNetFeaturesPerms::GetOperationPerm(SONET_ENTITY_USER, $arFields["OWNER_ID"], "blog", "view_post"); if ($featureOperationPerms == SONET_RELATIONS_TYPE_ALL) { $bRights = true; } $arFields["PATH"] = CComponentEngine::MakePathFromTemplate($arParams["PATH_TO_BLOG"], array("blog" => $arFields["URL"], "user_id" => $arFields["OWNER_ID"], "group_id" => $arFields["SOCNET_GROUP_ID"])); $blogID = CBlog::Add($arFields); if ($bRights) { CBlog::AddSocnetRead($blogID); } $arBlog = CBlog::GetByID($blogID, $arParams["GROUP_ID"]); } } // $DATE_PUBLISH = ""; // if(strlen($_POST["DATE_PUBLISH_DEF"]) > 0) // $DATE_PUBLISH = $_POST["DATE_PUBLISH_DEF"]; // elseif (strlen($_POST["DATE_PUBLISH"])<=0) $DATE_PUBLISH = ConvertTimeStamp(time() + CTimeZone::GetOffset(), "FULL"); // else // $DATE_PUBLISH = $_POST["DATE_PUBLISH"]; $arFields = array("DETAIL_TEXT" => $userTwit['text'], "DETAIL_TEXT_TYPE" => "text", "DATE_PUBLISH" => $DATE_PUBLISH, "PUBLISH_STATUS" => BLOG_PUBLISH_STATUS_PUBLISH, "PATH" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => "#post_id#", "user_id" => $arBlog["OWNER_ID"])), "URL" => $arBlog["URL"], "SOURCE_TYPE" => "twitter"); $arFields["PERMS_POST"] = array(); $arFields["PERMS_COMMENT"] = array(); $arFields["MICRO"] = "N"; if (strlen($arFields["TITLE"]) <= 0) { $arFields["MICRO"] = "Y"; $arFields["TITLE"] = trim(blogTextParser::killAllTags($arFields["DETAIL_TEXT"])); if (strlen($arFields["TITLE"]) <= 0) { $arFields["TITLE"] = GetMessage("BLOG_EMPTY_TITLE_PLACEHOLDER"); } } $arFields["SOCNET_RIGHTS"] = array(); if (!empty($userTwit['user_perms'])) { $bOne = true; foreach ($userTwit['user_perms'] as $v => $k) { if (strlen($v) > 0 && is_array($k) && !empty($k)) { foreach ($k as $vv) { if (strlen($vv) > 0) { $arFields["SOCNET_RIGHTS"][] = $vv; if ($v != "SG") { $bOne = false; } } } } } if ($bOne && !empty($userTwit['user_perms']["SG"])) { $bOnesg = false; $bFirst = true; $oGrId = 0; foreach ($userTwit['user_perms']["SG"] as $v) { if (strlen($v) > 0) { if ($bFirst) { $bOnesg = true; $bFirst = false; $v = str_replace("SG", "", $v); $oGrId = IntVal($v); } else { $bOnesg = false; } } } if ($bOnesg) { if (!CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "write_post") && !CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "moderate_post") && !CSocNetFeaturesPerms::CanPerformOperation($arParams["USER_ID"], SONET_ENTITY_GROUP, $oGrId, "blog", "full_post")) { $arFields["PUBLISH_STATUS"] = BLOG_PUBLISH_STATUS_READY; } } } } $bError = false; /* if (CModule::IncludeModule('extranet') && !CExtranet::IsIntranetUser()) { if(empty($arFields["SOCNET_RIGHTS"]) || in_array("UA", $arFields["SOCNET_RIGHTS"])) { $bError = true; $arResult["ERROR_MESSAGE"] = GetMessage("BLOG_BPE_EXTRANET_ERROR"); } }*/ if (!$bError) { preg_match_all("/\\[user\\s*=\\s*([^\\]]*)\\](.+?)\\[\\/user\\]/ies" . BX_UTF_PCRE_MODIFIER, $userTwit['text'], $arMention); $arFields["=DATE_CREATE"] = $DB->GetNowFunction(); $arFields["AUTHOR_ID"] = $arParams["USER_ID"]; $arFields["BLOG_ID"] = $arBlog["ID"]; $newID = CBlogPost::Add($arFields); $socnetRightsOld = array("U" => array()); $bAdd = true; $bNeedMail = false; if ($newID) { $arFields["ID"] = $newID; $arParamsNotify = array("bSoNet" => true, "UserID" => $arParams["USER_ID"], "allowVideo" => $arResult["allowVideo"], "PATH_TO_SMILE" => $arParams["PATH_TO_SMILE"], "PATH_TO_POST" => $arParams["PATH_TO_POST"], "SOCNET_GROUP_ID" => $arParams["GROUP_ID"], "user_id" => $arParams["USER_ID"], "NAME_TEMPLATE" => $arParams["NAME_TEMPLATE"], "SHOW_LOGIN" => $arParams["SHOW_LOGIN"]); CBlogPost::Notify($arFields, $arBlog, $arParamsNotify); } } if ($newID > 0 && strlen($arResult["ERROR_MESSAGE"]) <= 0 && $arFields["PUBLISH_STATUS"] == BLOG_PUBLISH_STATUS_PUBLISH) { BXClearCache(true, "/" . SITE_ID . "/blog/last_messages_list/"); $arFieldsIM = array("TYPE" => "POST", "TITLE" => $arFields["TITLE"], "URL" => CComponentEngine::MakePathFromTemplate(htmlspecialcharsBack($arParams["PATH_TO_POST"]), array("post_id" => $newID, "user_id" => $arBlog["OWNER_ID"])), "ID" => $newID, "FROM_USER_ID" => $arParams["USER_ID"], "TO_USER_ID" => array(), "TO_SOCNET_RIGHTS" => $arFields["SOCNET_RIGHTS"], "TO_SOCNET_RIGHTS_OLD" => $socnetRightsOld["U"]); if (!empty($arMentionOld)) { $arFieldsIM["MENTION_ID_OLD"] = $arMentionOld[1]; } if (!empty($arMention)) { $arFieldsIM["MENTION_ID"] = $arMention[1]; } CBlogPost::NotifyIm($arFieldsIM); $arParams["ID"] = $newID; if (!empty($_POST["SPERM"]["SG"])) { foreach ($_POST["SPERM"]["SG"] as $v) { $group_id_tmp = substr($v, 2); if (IntVal($group_id_tmp) > 0) { CSocNetGroup::SetLastActivity(IntVal($group_id_tmp)); } } } } } }
function GetUsersBlogs($params, $arPath) { global $USER; $blog = CBlogMetaWeblog::DecodeParams($params[0]["#"]["value"][0]["#"]); $user = CBlogMetaWeblog::DecodeParams($params[1]["#"]["value"][0]["#"]); $password = CBlogMetaWeblog::DecodeParams($params[2]["#"]["value"][0]["#"]); if (CBlogMetaWeblog::Authorize($user, $password)) { $result = ''; $userId = $USER->GetID(); $dbBlog = CBlog::GetList(array(), array("OWNER_ID" => $userId, "GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y"), false, false, array("ID", "URL", "NAME", "OWNER_ID")); while ($arBlog = $dbBlog->GetNext()) { if (strlen($arPath["PATH_TO_BLOG"]) > 0) { if (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0) { $serverName = SITE_SERVER_NAME; } else { $serverName = COption::GetOptionString("main", "server_name", ""); } if (strlen($serverName) <= 0) { $serverName = $_SERVER["SERVER_NAME"]; } $path2Blog = "http://" . $serverName . CComponentEngine::MakePathFromTemplate($arPath["PATH_TO_BLOG"], array("blog" => $arBlog["URL"], "user_id" => $arBlog["OWNER_ID"])); } else { $path2Blog = $arBlog["URL"]; } $result .= ' <value> <struct> <member> <name>url</name> <value>' . $path2Blog . '</value> </member> <member> <name>blogid</name> <value>' . $arBlog["ID"] . '</value> </member> <member> <name>blogName</name> <value>' . $arBlog["NAME"] . '</value> </member> </struct> </value> '; } if (CModule::IncludeModule("socialnetwork")) { $arGroupFilter = array("USER_ID" => $userId, "<=ROLE" => SONET_ROLES_USER, "GROUP_SITE_ID" => SITE_ID, "GROUP_ACTIVE" => "Y"); $dbGroups = CSocNetUserToGroup::GetList(array("GROUP_NAME" => "ASC"), $arGroupFilter, false, false, array("ID", "GROUP_ID", "GROUP_OWNER_ID", "GROUP_NAME", "GROUP_SITE_ID")); while ($arGroups = $dbGroups->GetNext()) { $perms = BLOG_PERMS_DENY; if (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroups["GROUP_ID"], "blog", "write_post", CSocNetUser::IsCurrentUserModuleAdmin($arGroups["GROUP_SITE_ID"]))) { $perms = BLOG_PERMS_WRITE; } elseif (CSocNetFeaturesPerms::CanPerformOperation($userId, SONET_ENTITY_GROUP, $arGroups["GROUP_ID"], "blog", "full_post")) { $perms = BLOG_PERMS_FULL; } if ($perms >= BLOG_PERMS_WRITE) { $dbBlog = CBlog::GetList(array(), array("SOCNET_GROUP_ID" => $arGroups["GROUP_ID"], "GROUP_SITE_ID" => SITE_ID, "ACTIVE" => "Y"), false, false, array("ID", "URL", "NAME")); if ($arBlog = $dbBlog->GetNext()) { $result .= ' <value> <struct> <member> <name>url</name> <value>' . $arBlog["URL"] . '</value> </member> <member> <name>blogid</name> <value>' . $arBlog["ID"] . '</value> </member> <member> <name>blogName</name> <value>' . $arBlog["NAME"] . '</value> </member> </struct> </value> '; } } } } if (strlen($result) > 0) { return '<params> <param> <value> <array> <data>' . $result . '</data> </array> </value> </param> </params>'; } else { return '<fault> <value> <struct> <member> <name>faultCode</name> <value><int>4</int></value> </member> <member> <name>faultString</name> <value><string>User hasn\'t blog.</string></value> </member> </struct> </value> </fault>'; } } else { return '<fault> <value> <struct> <member> <name>faultCode</name> <value><int>3</int></value> </member> <member> <name>faultString</name> <value><string>' . $arAuthResult["MESSAGE"] . '</string></value> </member> </struct> </value> </fault>'; } }
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); } } } } }