$arSelect = array("ID", "USER_ID", "DATE_FROM", "DATE_TO", "MARK", "FORUM_TOPIC_ID"); //$arSelect = Array(); $dbres = CTimeManReportFull::GetList(array("ID" => "desc"), $arFilterReport, $arSelect); $res["USERS"][$arRes['ID']]["FULL_REPORT_INFO"]["GOOD"] = 0; $res["USERS"][$arRes['ID']]["FULL_REPORT_INFO"]["MARKED"] = 0; while ($report = $dbres->Fetch()) { if ($report["MARK"] != "X") { $res["USERS"][$arRes['ID']]["FULL_REPORT_INFO"]["MARKED"]++; } if ($report["MARK"] == "G") { $res["USERS"][$arRes['ID']]["FULL_REPORT_INFO"]["GOOD"]++; } $res["USERS"][$arRes['ID']]["FULL_REPORT_INFO"]["COUNT"]++; $report["DATE_TO"] = MakeTimeStamp($report["DATE_TO"], $datefomat); $report["DATE_FROM"] = MakeTimeStamp($report["DATE_FROM"], $datefomat); $report["FOR_JS"] = CTimeManReportFull::__getReportJSDraw(array("PERIOD_DATE_FROM" => $_POST["ts"], "REPORT_DATE_FROM" => $report['DATE_FROM'], "REPORT_DATE_TO" => $report['DATE_TO'])); $report["COMMENTS_COUNT"] = 0; if ($report['FORUM_TOPIC_ID'] && CModule::IncludeModule("forum")) { $count = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $report['FORUM_TOPIC_ID']), true); $report["COMMENTS_COUNT"] = $count; } $res["USERS"][$arRes['ID']]["FULL_REPORT"][] = $report; } if ($arRes['ID'] == $USER->GetID() && !CTimeMan::IsAdmin()) { $res["USERS"][$arRes['ID']]["CAN_EDIT_TIME"] = "N"; } else { $res["USERS"][$arRes['ID']]["CAN_EDIT_TIME"] = "Y"; } $tm_user = new CUserReportFull($arRes["ID"]); $res["USERS"][$arRes['ID']]["SETTINGS"] = $tm_user->GetSettings(true); }
<?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) { die; } $arParams["FORUM_ID"] = intVal(COption::GetOptionInt("timeman", "report_forum_id", "")); $arParams["REPORT_ID"] = intVal($arParams["REPORT_ID"]); $arParams["ENTRY_ID"] = intVal($arParams["ENTRY_ID"]); $arResult["COMMENTS"] = array(); $user_url = COption::GetOptionString('intranet', 'path_user', '/company/personal/user/#USER_ID#/', $_REQUEST['site_id']); if ($arParams["FORUM_ID"]) { $FORUM_TOPIC_ID = 0; if ($arParams["REPORT_ID"]) { $dbReport = CTimeManReportFull::GetByID($arParams["REPORT_ID"]); $arReport = $dbReport->Fetch(); $FORUM_TOPIC_ID = $arReport["FORUM_TOPIC_ID"]; } else { if ($arParams['ENTRY_ID']) { $dbRes = CTimeManEntry::GetByID($arParams['ENTRY_ID']); $arEntry = $dbRes->Fetch(); $FORUM_TOPIC_ID = $arEntry["FORUM_TOPIC_ID"]; } } if ($FORUM_TOPIC_ID > 0) { CModule::IncludeModule("forum"); $parser = new forumTextParser(LANGUAGE_ID); $allow = forumTextParser::GetFeatures(CForumNew::GetByID($arParams["FORUM_ID"])); $db_res = CForumMessage::GetList(array("ID" => "ASC"), array("TOPIC_ID" => $FORUM_TOPIC_ID)); while ($ar_res = $db_res->Fetch()) { $dbAuthor = CUser::GetByID($ar_res["AUTHOR_ID"]); $arAuthor = $dbAuthor->Fetch();
public static function AddComment_Report_Forum($arFields, $FORUM_ID, $arLog) { global $USER, $DB; $mess_id = false; $dbReport = CTimeManReportFull::GetByID($arLog["SOURCE_ID"]); $arReport = $dbReport->Fetch(); if (CModule::IncludeModule("forum") && $arReport) { $ufFileID = array(); $ufDocID = array(); if (!($userName = trim($USER->GetFormattedName(false)))) { $userName = $USER->GetLogin(); } if (!$arReport["FORUM_TOPIC_ID"]) { $arTopicFields = array("TITLE" => $arReport["DATE_FROM"] . "-" . $arReport["DATE_TO"], "USER_START_ID" => $arFields["USER_ID"], "STATE" => "Y", "FORUM_ID" => $FORUM_ID, "USER_START_NAME" => $userName, "START_DATE" => ConvertTimeStamp(time(), "FULL"), "POSTS" => 0, "VIEWS" => 0, "APPROVED" => "Y", "LAST_POSTER_NAME" => $userName, "LAST_POST_DATE" => ConvertTimeStamp(time(), "FULL"), "LAST_MESSAGE_ID" => 0, "XML_ID" => "TIMEMAN_REPORT_" . $arLog["SOURCE_ID"]); $TOPIC_ID = CForumTopic::Add($arTopicFields); if ($TOPIC_ID) { CTimeManReportFull::Update($arLog["SOURCE_ID"], array("FORUM_TOPIC_ID" => $TOPIC_ID)); } } else { $TOPIC_ID = $arReport["FORUM_TOPIC_ID"]; } if ($TOPIC_ID) { $arFieldsP = array("AUTHOR_ID" => $arFields["USER_ID"], "AUTHOR_NAME" => $userName, "POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "FORUM_ID" => $FORUM_ID, "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "PARAM2" => $arLog["SOURCE_ID"]); $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("SONET_COMMENT", $arTmp); if (is_array($arTmp)) { if (array_key_exists("UF_SONET_COM_DOC", $arTmp)) { $GLOBALS["UF_FORUM_MESSAGE_DOC"] = $arTmp["UF_SONET_COM_DOC"]; } elseif (array_key_exists("UF_SONET_COM_FILE", $arTmp)) { $arFieldsP["FILES"] = array(); foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) { $arFieldsP["FILES"][] = array("FILE_ID" => $file_id); } } } $GLOBALS["USER_FIELD_MANAGER"]->EditFormAddFields("FORUM_MESSAGE", $arFieldsP); $mess_id = CForumMessage::Add($arFieldsP); // get UF DOC value and FILE_ID there if ($mess_id > 0) { $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $mess_id)); while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) { $ufFileID[] = $arAddedMessageFiles["FILE_ID"]; } $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $mess_id, LANGUAGE_ID); } } } return array("SOURCE_ID" => $mess_id, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID)); }
/** * @param $userId * @return bool */ public function canRead($userId) { if ($this->canRead !== null) { return $this->canRead; } if (($res = $this->getDataToCheck($this->entityId)) && !empty($res)) { list($message, $topic) = $res; $entityId = null; $entityType = null; if (!empty($topic["XML_ID"])) { $entityId = substr($topic["XML_ID"], strrpos($topic["XML_ID"], "_") + 1); $entityType = substr($topic["XML_ID"], 0, strrpos($topic["XML_ID"], "_")); } switch ($entityType) { case "TASK": if (Loader::includeModule("tasks")) { $connector = new TaskConnector($entityId, $this->attachedObject); $this->canRead = $connector->canRead($userId); return $this->canRead; } break; case "EVENT": if (Loader::includeModule("calendar")) { $connector = new CalendarEventConnector($entityId, $this->attachedObject); $this->canRead = $connector->canRead($userId); return $this->canRead; } break; case "IBLOCK": if ((int) $topic["USER_ID"] > 0 && Loader::includeModule("socialnetwork")) { $codes = array(); if (($res = \CSocNetLog::getList(array(), array("SOURCE_ID" => $entityId, "EVENT_ID" => array("photo_photo", "news", "wiki")), false, false, array("ID"))->fetch()) && $res) { $db_res = \CSocNetLogRights::getList(array(), array("LOG_ID" => $res["ID"])); while ($res = $db_res->fetch()) { $codes[] = $res["GROUP_CODE"]; } } $this->canRead = $this->canAccess($userId, $codes); return $this->canRead; } $this->canRead = true; return $this->canRead; case "MEETING": $this->canRead = (int) $message["FORUM_ID"] == (int) \COption::getOptionInt('meeting', 'comments_forum_id', 0, SITE_ID); return $this->canRead; case "TIMEMAN_ENTRY": if (Loader::includeModule("timeman")) { $dbEntry = \CTimeManEntry::getList(array(), array("ID" => $entityId), false, false, array("ID", "USER_ID")); if ($arEntry = $dbEntry->fetch()) { if ($arEntry["USER_ID"] == $userId) { $this->canRead = true; return $this->canRead; } else { $arManagers = \CTimeMan::getUserManagers($arEntry["USER_ID"]); $this->canRead = in_array($userId, $arManagers); return $this->canRead; } } } $this->canRead = false; return $this->canRead; case "TIMEMAN_REPORT": if (Loader::includeModule("timeman")) { $dbReport = \CTimeManReportFull::getList(array(), array("ID" => $entityId), array("ID", "USER_ID")); if ($arReport = $dbReport->fetch()) { if ($arReport["USER_ID"] == $userId) { $this->canRead = true; return $this->canRead; } else { $arManagers = \CTimeMan::getUserManagers($arReport["USER_ID"]); $this->canRead = in_array($userId, $arManagers); return $this->canRead; } } } $this->canRead = false; return $this->canRead; case "WF": $this->canRead = false; if (Loader::includeModule("bizproc")) { $currentUserId = (int) $this->getUser()->getId(); $participants = \CBPTaskService::getWorkflowParticipants($entityId); if (in_array($currentUserId, $participants)) { $this->canRead = true; } else { $state = \CBPStateService::getWorkflowStateInfo($entityId); if ($state && $currentUserId === (int) $state['STARTED_BY']) { $this->canRead = true; } } } return $this->canRead; } if ((!empty($topic["SOCNET_GROUP_ID"]) || !empty($topic["OWNER_ID"])) && Loader::includeModule("socialnetwork")) { if (!empty($topic["SOCNET_GROUP_ID"])) { $this->canRead = \CSocNetFeatures::isActiveFeature(SONET_ENTITY_GROUP, $topic["SOCNET_GROUP_ID"], "forum") && \CSocNetFeaturesPerms::canPerformOperation($userId, SONET_ENTITY_GROUP, $topic["SOCNET_GROUP_ID"], "forum", "view"); return $this->canRead; } else { $this->canRead = \CSocNetFeatures::isActiveFeature(SONET_ENTITY_USER, $topic["OWNER_ID"], "forum") && \CSocNetFeaturesPerms::canPerformOperation($userId, SONET_ENTITY_USER, $topic["OWNER_ID"], "forum", "view"); return $this->canRead; } } if ($message) { $user = $this->getUser(); if ($user && $userId == $user->getId()) { $userGroups = $user->getUserGroupArray(); } else { $userGroups = array(2); } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ if (\CForumUser::isAdmin($userId, $userGroups)) { $this->canRead = true; return $this->canRead; } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $perms = \CForumNew::getUserPermission($message["FORUM_ID"], $userGroups); if ($perms >= "Y") { $this->canRead = true; return $this->canRead; } if ($perms < "E" || $perms < "Q" && $message["APPROVED"] != "Y") { $this->canRead = false; return $this->canRead; } /** @noinspection PhpDynamicAsStaticMethodCallInspection */ $forum = \CForumNew::getByID($message["FORUM_ID"]); $this->canRead = $forum["ACTIVE"] == "Y"; return $this->canRead; } } $this->canRead = false; return $this->canRead; }