Ejemplo n.º 1
0
 public static function AddComment_Calendar($arFields)
 {
     global $DB;
     if (!CModule::IncludeModule("forum")) {
         return false;
     }
     $ufFileID = array();
     $ufDocID = array();
     $dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array("ID", "SOURCE_ID", "SITE_ID"));
     if ($arLog = $dbResult->Fetch()) {
         $arCalendarEvent = CCalendarEvent::GetById($arLog["SOURCE_ID"]);
         if ($arCalendarEvent) {
             $arCalendarSettings = CCalendar::GetSettings();
             $forumID = $arCalendarSettings["forum_id"];
             if ($forumID) {
                 $arFilter = array("FORUM_ID" => $forumID, "XML_ID" => "EVENT_" . $arLog["SOURCE_ID"]);
                 $dbTopic = CForumTopic::GetList(null, $arFilter);
                 if ($dbTopic && ($arTopic = $dbTopic->Fetch())) {
                     $topicID = $arTopic["ID"];
                 } else {
                     $topicID = 0;
                 }
                 $currentUserId = CCalendar::GetCurUserId();
                 $strPermission = $currentUserId == $arCalendarEvent["OWNER_ID"] ? "Y" : "M";
                 $arFieldsMessage = array("POST_MESSAGE" => $arFields["TEXT_MESSAGE"], "USE_SMILES" => "Y", "PERMISSION_EXTERNAL" => "Q", "PERMISSION" => $strPermission, "APPROVED" => "Y");
                 if ($topicID === 0) {
                     $arFieldsMessage["TITLE"] = "EVENT_" . $arLog["SOURCE_ID"];
                     $arFieldsMessage["TOPIC_XML_ID"] = "EVENT_" . $arLog["SOURCE_ID"];
                 }
                 $arTmp = false;
                 $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)) {
                         $arFieldsMessage["FILES"] = array();
                         foreach ($arTmp["UF_SONET_COM_FILE"] as $file_id) {
                             $arFieldsMessage["FILES"][] = array("FILE_ID" => $file_id);
                         }
                     }
                 }
                 $messageID = ForumAddMessage($topicID > 0 ? "REPLY" : "NEW", $forumID, $topicID, 0, $arFieldsMessage, $sError, $sNote);
                 // get UF DOC value and FILE_ID there
                 if ($messageID > 0) {
                     $messageUrl = CCalendar::GetPath("user", $arCalendarEvent["OWNER_ID"]);
                     $messageUrl = $messageUrl . (strpos($messageUrl, "?") === false ? "?" : "&") . "EVENT_ID=" . $arCalendarEvent["ID"] . "&MID=" . $messageID;
                     $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
                     while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
                         $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
                     }
                     $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
                 }
             }
         }
     }
     if (!$messageID) {
         $sError = GetMessage("EC_LF_ADD_COMMENT_SOURCE_ERROR");
     }
     return array("SOURCE_ID" => $messageID, "MESSAGE" => $arFieldsMessage ? $arFieldsMessage["POST_MESSAGE"] : false, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $messageID, "ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID), "URL" => $messageUrl);
 }
Ejemplo n.º 2
0
 protected static function checkParams($arMessage = array(), &$arTopic, &$arForum)
 {
     if (\Freetrix\Main\Loader::includeModule('forum')) {
         $arTopic = !empty($arTopic) ? $arTopic : \CForumTopic::GetByID($arMessage["TOPIC_ID"]);
         if (empty($arTopic)) {
             return false;
         }
         $arSitemaps = SitemapForumTable::getSitemapsByEntityId($arTopic["FORUM_ID"]);
         if (!empty($arSitemaps) && ($arForum = \CForumNew::GetByIDEx($arTopic["FORUM_ID"])) && $arForum) {
             $arForum["PATH2FORUM_MESSAGE"] = \CForumNew::GetSites($arTopic["FORUM_ID"]);
             $date = MakeTimeStamp($arTopic['LAST_POST_DATE']);
             $result = array();
             foreach ($arSitemaps as $arSitemap) {
                 $path = $arForum["PATH2FORUM_MESSAGE"][$arSitemap["SITE_ID"]];
                 if (!empty($path)) {
                     $arSitemap["fileName"] = str_replace("#FORUM_ID#", $arForum["ID"], $arSitemap['SITEMAP_FILE_FORUM']);
                     $arSitemap["url"] = \CForumNew::PreparePath2Message($path, array("FORUM_ID" => $arForum["ID"], "TOPIC_ID" => $arTopic["ID"], "TITLE_SEO" => $arTopic["TITLE_SEO"], "MESSAGE_ID" => "s", "SOCNET_GROUP_ID" => $arTopic["SOCNET_GROUP_ID"], "OWNER_ID" => $arTopic["OWNER_ID"], "PARAM1" => $arTopic["PARAM1"], "PARAM2" => $arTopic["PARAM2"]));
                     $arSitemap["date"] = $date;
                     $result[] = $arSitemap;
                 }
             }
             return empty($result) ? false : $result;
         }
     }
     return false;
 }
Ejemplo n.º 3
0
 public static function updateIBlockProperty($ID, $TYPE, $arMessage, $arTopic = array())
 {
     if ($ID > 0 && $arMessage["PARAM1"] != "IB" && IsModuleInstalled("iblock")) {
         $arTopic = empty($arTopic) ? CForumTopic::GetByID($arMessage["TOPIC_ID"]) : $arTopic;
         if (!empty($arTopic) && $arTopic["XML_ID"] == "IBLOCK_" . $arMessage["PARAM2"] && CModule::IncludeModule("iblock")) {
             CIBlockElement::SetPropertyValuesEx($arMessage["PARAM2"], 0, array("FORUM_MESSAGE_CNT" => array("VALUE" => CForumMessage::GetList(array(), array("TOPIC_ID" => $arMessage["TOPIC_ID"], "APPROVED" => "Y", "!PARAM1" => "IB"), true), "DESCRIPTION" => "")));
         }
     }
 }
Ejemplo n.º 4
0
 public function Execute()
 {
     if (!CModule::IncludeModule("forum")) {
         return CBPActivityExecutionStatus::Closed;
     }
     if (!CModule::IncludeModule("iblock")) {
         return CBPActivityExecutionStatus::Closed;
     }
     $forumId = intval($this->ForumId);
     if ($forumId <= 0) {
         return CBPActivityExecutionStatus::Closed;
     }
     $rootActivity = $this->GetRootActivity();
     $documentId = $rootActivity->GetDocumentId();
     $iblockId = $this->IBlockId;
     $dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID"));
     $arResult = $dbResult->Fetch();
     if (!$arResult) {
         $obProperty = new CIBlockProperty();
         $obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum topic", "CODE" => "FORUM_TOPIC_ID"));
         $obProperty->Add(array("IBLOCK_ID" => $iblockId, "ACTIVE" => "Y", "PROPERTY_TYPE" => "N", "MULTIPLE" => "N", "NAME" => "Forum message count", "CODE" => "FORUM_MESSAGE_CNT"));
         $dbResult = CIBlockElement::GetProperty($iblockId, $documentId[2], false, false, array("CODE" => "FORUM_TOPIC_ID"));
         $arResult = $dbResult->Fetch();
     }
     $forumTopicId = intval($arResult["VALUE"]);
     $arForumUserTmp = $this->ForumUser;
     $arForumUser = CBPHelper::ExtractUsers($arForumUserTmp, $documentId, true);
     $forumUserId = 1;
     $forumUserName = "******";
     if ($arForumUser != null) {
         $forumUserId = $arForumUser;
         $dbResult = CUser::GetByID($forumUserId);
         if ($arResult = $dbResult->Fetch()) {
             $forumUserName = CUser::FormatName(COption::GetOptionString("bizproc", "name_template", CSite::GetNameFormat(false), SITE_ID), $arResult, true);
         }
     }
     $newTopic = "N";
     if ($forumTopicId <= 0) {
         $documentService = $this->workflow->GetService("DocumentService");
         $document = $documentService->GetDocument($documentId);
         $newTopic = "Y";
         $arFields = array("TITLE" => $document["NAME"], "FORUM_ID" => $forumId, "USER_START_ID" => $forumUserId, "USER_START_NAME" => $forumUserName, "LAST_POSTER_NAME" => $forumUserName, "APPROVED" => "Y");
         $forumTopicId = CForumTopic::Add($arFields);
         CIBlockElement::SetPropertyValues($documentId[2], $iblockId, $forumTopicId, "FORUM_TOPIC_ID");
     }
     $arFields = array("POST_MESSAGE" => $this->ForumPostMessage, "AUTHOR_ID" => $forumUserId, "AUTHOR_NAME" => $forumUserName, "FORUM_ID" => $forumId, "TOPIC_ID" => $forumTopicId, "APPROVED" => "Y", "NEW_TOPIC" => $newTopic, "PARAM2" => $documentId[2]);
     $forumMessageId = CForumMessage::Add($arFields, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
     return CBPActivityExecutionStatus::Closed;
 }
Ejemplo n.º 5
0
 public static function GetAdminListViewHTML($arProperty, $value, $strHTMLControlName)
 {
     static $cache = array();
     if (CModule::IncludeModule("forum")) {
         $value["VALUE"] = intval($value["VALUE"]);
         if ($value["VALUE"] <= 0) {
             $value["VALUE"] = '';
             $res = '';
         } else {
             if (!array_key_exists($value["VALUE"], $cache)) {
                 $cache[$value["VALUE"]] = CForumTopic::GetByID($value["VALUE"]);
             }
             $arTopic = $cache[$value["VALUE"]];
             $res = !empty($arTopic) ? "[" . $value["VALUE"] . "] (" . htmlspecialcharsEx($arTopic["TITLE"]) . ")" : $value["VALUE"];
         }
         return $res;
     }
     return '';
 }
Ejemplo n.º 6
0
             $res["SITE_URL"] = substr($res["SITE_URL"], 0, strpos($res["SITE_URL"], "#message"));
         }
         $res["TAGS"] = array();
         if (!empty($res["~TAGS_FORMATED"])) {
             foreach ($res["~TAGS_FORMATED"] as $name => $tag) {
                 $tags = $tag;
                 $res["TAGS"][] = array("URL" => $APPLICATION->GetCurPageParam("tags=" . urlencode($tags), array("tags")), "TAG_NAME" => htmlspecialcharsbx($name));
             }
         }
         $topics[$res["PARAM2"]] = !!$topics[$res["PARAM2"]] ? $topics[$res["PARAM2"]] : array();
         $topics[$res["PARAM2"]][] = count($arResult["TOPICS"]);
         $arResult["TOPICS"][] = $res;
     } while ($res = $obSearch->GetNext());
 }
 if (strpos($arParams["URL_TEMPLATES_READ"], "#TITLE_SEO#") !== false && !empty($topics)) {
     $db_res2 = CForumTopic::GetList(array(), array("@ID" => array_keys($topics)));
     while ($db_res2 && ($res2 = $db_res2->Fetch())) {
         if (array_key_exists($res2["ID"], $topics)) {
             foreach ($topics[$res2["ID"]] as $key) {
                 $res = $arResult["TOPICS"][$key];
                 if (intVal($res["ITEM_ID"]) > 0) {
                     $res["URL"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["PARAM1"], "TID" => $res["PARAM2"], "TITLE_SEO" => $res2["TITLE_SEO"], "MID" => $res["ITEM_ID"]));
                     $res["~URL"] = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["PARAM1"], "TID" => $res["PARAM2"], "TITLE_SEO" => $res2["TITLE_SEO"], "MID" => $res["ITEM_ID"]));
                 } else {
                     $res["URL"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"], array("FID" => $res["PARAM1"], "TID" => $res["PARAM2"], "TITLE_SEO" => $res2["TITLE_SEO"], "MID" => "s"));
                     $res["~URL"] = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $res["PARAM1"], "TID" => $res["PARAM2"], "TITLE_SEO" => $res2["TITLE_SEO"], "MID" => "s"));
                 }
                 $arResult["TOPICS"][$key] = $res;
             }
         }
     }
Ejemplo n.º 7
0
    }
    $arParams["FATAL_ERROR"] = $res <= 0 ? "Y" : "N";
    if (strPos($componentPage, "group_photo") !== false && CModule::IncludeModule('iblock')) {
        $arPhotoIBlockID = array();
        $rsIBlock = CIBlock::GetList(array(), array("ACTIVE" => "Y", "CODE" => "group_photogallery%"));
        while ($arIBlock = $rsIBlock->Fetch()) {
            $arPhotoIBlockID[] = $arIBlock["ID"];
        }
        if (count($arPhotoIBlockID) > 0) {
            $rsPhotoSection = CIBlockSection::GetList(array("timestamp_x" => "desc"), array("IBLOCK_ID" => $arPhotoIBlockID, "SOCNET_GROUP_ID" => $arResult["VARIABLES"]["group_id"]));
            if ($arPhotoSection = $rsPhotoSection->Fetch()) {
                $arParams["PHOTO_GROUP_IBLOCK_ID"] = $arPhotoSection["IBLOCK_ID"];
                if (intval($_GET["ELEMENT_ID"]) > 0 && intval($arParams["PHOTO"]["ALL"]["FORUM_ID"]) > 0 && $arParams["PHOTO"]["ALL"]["COMMENTS_TYPE"] == "FORUM" && CModule::IncludeModule("forum")) {
                    $rsIBlockElement = CIBlockElement::GetList(array(), array("IBLOCK_ID" => $arParams["PHOTO_GROUP_IBLOCK_ID"], "ID" => $_GET["ELEMENT_ID"]), false, false, array("IBLOCK_ID", "PROPERTY_FORUM_TOPIC_ID"));
                    if (($arIBlockElement = $rsIBlockElement->Fetch()) && array_key_exists("PROPERTY_FORUM_TOPIC_ID_VALUE", $arIBlockElement)) {
                        $arForumTopic = CForumTopic::GetByID($arIBlockElement["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
                        $arParams["PHOTO"]["ALL"]["FORUM_ID"] = $arForumTopic["FORUM_ID"];
                    }
                }
            }
        }
    }
} elseif (strPos($componentPage, "group_calendar") !== false && CModule::IncludeModule("iblock")) {
    $arCalendarIBlockID = array();
    $rsIBlock = CIBlock::GetList(array(), array("ACTIVE" => "Y", "CODE" => "calendar_group%"));
    while ($arIBlock = $rsIBlock->Fetch()) {
        $arCalendarIBlockID[] = $arIBlock["ID"];
    }
    if (count($arCalendarIBlockID) > 0) {
        $rsCalendarSection = CIBlockSection::GetList(array("timestamp_x" => "desc"), array("IBLOCK_ID" => $arCalendarIBlockID, "SOCNET_GROUP_ID" => $arResult["VARIABLES"]["group_id"]));
        if ($arCalendarSection = $rsCalendarSection->Fetch()) {
Ejemplo n.º 8
0
    }
    $arResult["ERROR_MESSAGE"] = $strErrorMessage;
    $arResult["OK_MESSAGE"] = $strOKMessage;
}
/********************************************************************
				/Action
********************************************************************/
/********************************************************************
				Data
********************************************************************/
/************** Topic for move *************************************/
$arFilter = array("@ID" => implode(",", $topics), "FORUM_ID" => $arParams["FID"]);
if (!CForumUser::IsAdmin()) {
    $arFilter["PERMISSION_STRONG"] = true;
}
$db_res = CForumTopic::GetListEx(array(), $arFilter);
if ($db_res && ($res = $db_res->GetNext())) {
    do {
        $res["read"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s"));
        $res["read_last_message"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => intVal($res["LAST_MESSAGE_ID"]))) . "#message" . $res["LAST_MESSAGE_ID"];
        $res["USER_START_HREF"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["USER_START_ID"])));
        $res["LAST_POSTER_HREF"] = CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => intVal($res["LAST_POSTER_ID"])));
        $arResult["TOPICS"][$res["ID"]] = $res;
    } while ($res = $db_res->GetNext());
}
$arParams["TID"] = implode(",", array_keys($arResult["TOPICS"]));
/************** Forums *********************************************/
$arFilter = array();
if ($arParams["SHOW_FORUM_ANOTHER_SITE"] == "N" || !CForumUser::IsAdmin()) {
    $arFilter["LID"] = SITE_ID;
}
Ejemplo n.º 9
0
 function OnRate($rateID, $arData)
 {
     if (!isset($arData['ENTITY_TYPE_ID']) || !isset($arData['ENTITY_ID']) || $arData['ENTITY_TYPE_ID'] !== 'FORUM_POST' && $arData['ENTITY_TYPE_ID'] !== 'FORUM_TOPIC') {
         return false;
     }
     if ($arData['ENTITY_TYPE_ID'] === 'FORUM_POST') {
         $arMessage = CForumMessage::GetByID($arData['ENTITY_ID']);
         if ($arMessage) {
             $this->ClearTag("T", $arMessage['TOPIC_ID']);
         }
     } else {
         if ($arData['ENTITY_TYPE_ID'] === 'FORUM_TOPIC') {
             $arTopic = CForumTopic::GetByID($arData['ENTITY_ID']);
             if ($arTopic) {
                 $this->ClearTag("F", $arTopic['FORUM_ID']);
             }
             $this->ClearTag("T", $arData['ENTITY_ID']);
         }
     }
     return true;
 }
Ejemplo n.º 10
0
 function Create($site_id, $max_execution_time, $NS, $arOptions = array())
 {
     @set_time_limit(0);
     if (!is_array($NS)) {
         $NS = array("ID" => 0, "CNT" => 0, "FILE_SIZE" => 0, "FILE_ID" => 1, "FILE_URL_CNT" => 0, "ERROR_CNT" => 0, "PARAM2" => 0);
     } else {
         $NS = array("ID" => intval($NS["ID"]), "CNT" => intval($NS["CNT"]), "FILE_SIZE" => intval($NS["FILE_SIZE"]), "FILE_ID" => intval($NS["FILE_ID"]), "FILE_URL_CNT" => intval($NS["FILE_URL_CNT"]), "ERROR_CNT" => intval($NS["ERROR_CNT"]), "PARAM2" => intval($NS["ID"]));
     }
     if (is_array($max_execution_time)) {
         $record_limit = $max_execution_time[1];
         $max_execution_time = $max_execution_time[0];
     } else {
         $record_limit = 5000;
     }
     if ($max_execution_time > 0) {
         $end_of_execution = time() + $max_execution_time;
     } else {
         $end_of_execution = 0;
     }
     if (is_array($arOptions) && $arOptions["FORUM_TOPICS_ONLY"] == "Y") {
         $bForumTopicsOnly = CModule::IncludeModule("forum");
     } else {
         $bForumTopicsOnly = false;
     }
     if (is_array($arOptions) && $arOptions["BLOG_NO_COMMENTS"] == "Y") {
         $bBlogNoComments = CModule::IncludeModule("blog");
     } else {
         $bBlogNoComments = false;
     }
     if (is_array($arOptions) && $arOptions["USE_HTTPS"] == "Y") {
         $strProto = "https://";
     } else {
         $strProto = "http://";
     }
     $rsSite = CSite::GetByID($site_id);
     if ($arSite = $rsSite->Fetch()) {
         $SERVER_NAME = trim($arSite["SERVER_NAME"]);
         if (strlen($SERVER_NAME) <= 0) {
             $this->m_error = GetMessage("SEARCH_ERROR_SERVER_NAME", array("#SITE_ID#" => '<a href="site_edit.php?LID=' . urlencode($site_id) . '&lang=' . urlencode(LANGUAGE_ID) . '">' . htmlspecialcharsbx($site_id) . '</a>')) . "<br>";
             return false;
         }
         //Cache events
         $this->m_events = GetModuleEvents("search", "OnSearchGetURL", true);
         //Clear error file
         if ($NS["ID"] == 0 && $NS["CNT"] == 0) {
             $e = fopen($arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_errors.xml", "w");
             $strBegin = "<?xml version='1.0' encoding='UTF-8'?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
             fwrite($e, $strBegin);
         } else {
             $e = fopen($arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_errors.xml", "a");
         }
         if (!$e) {
             $this->m_error = GetMessage("SEARCH_ERROR_OPEN_FILE") . " " . $arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_errors.xml" . "<br>";
             return false;
         }
         //Open current sitemap file
         if ($NS["FILE_SIZE"] == 0) {
             $f = fopen($arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_" . sprintf("%03d", $NS["FILE_ID"]) . ".xml", "w");
             $strBegin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
             fwrite($f, $strBegin);
             $NS["FILE_SIZE"] += strlen($strBegin);
         } else {
             $f = fopen($arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_" . sprintf("%03d", $NS["FILE_ID"]) . ".xml", "a");
         }
         if (!$f) {
             $this->m_error = GetMessage("SEARCH_ERROR_OPEN_FILE") . " " . $arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_" . sprintf("%03d", $NS["FILE_ID"]) . ".xml" . "<br>";
             return false;
         }
         CTimeZone::Disable();
         $this->GetURLs($site_id, $NS["ID"], $record_limit);
         $bFileIsFull = false;
         while (!$bFileIsFull && ($ar = $this->Fetch())) {
             $record_limit--;
             $NS["ID"] = $ar["ID"];
             if (strlen($ar["URL"]) < 1) {
                 continue;
             }
             if ($bForumTopicsOnly && $ar["MODULE_ID"] == "forum") {
                 //Forum topic ID
                 $PARAM2 = intval($ar["PARAM2"]);
                 if ($NS["PARAM2"] < $PARAM2) {
                     $NS["PARAM2"] = $PARAM2;
                     $arTopic = CForumTopic::GetByIDEx($PARAM2);
                     if ($arTopic) {
                         $ar["FULL_DATE_CHANGE"] = $arTopic["LAST_POST_DATE"];
                     }
                 } else {
                     continue;
                 }
             }
             if ($bBlogNoComments && $ar["MODULE_ID"] == "blog") {
                 if (substr($ar["ITEM_ID"], 0, 1) === "C") {
                     continue;
                 }
             }
             if (preg_match("/^[a-z]+:\\/\\//", $ar["URL"])) {
                 $strURL = $ar["URL"];
             } else {
                 $strURL = $strProto . $ar["SERVER_NAME"] . $ar["URL"];
             }
             $strURL = $this->LocationEncode($this->URLEncode($strURL, "UTF-8"));
             $strTime = $this->TimeEncode(MakeTimeStamp(ConvertDateTime($ar["FULL_DATE_CHANGE"], "DD.MM.YYYY HH:MI:SS"), "DD.MM.YYYY HH:MI:SS"));
             $strToWrite = "\t<url>\n\t\t<loc>" . $strURL . "</loc>\n\t\t<lastmod>" . $strTime . "</lastmod>\n\t</url>\n";
             if (strlen($strURL) > 2048) {
                 fwrite($e, $strToWrite);
                 $NS["ERROR_CNT"]++;
             } else {
                 fwrite($f, $strToWrite);
                 $NS["CNT"]++;
                 $NS["FILE_SIZE"] += strlen($strToWrite);
                 $NS["FILE_URL_CNT"]++;
             }
             //Next File on file size or url count limit
             if ($NS["FILE_SIZE"] > 9000000 || $NS["FILE_URL_CNT"] >= 50000) {
                 $bFileIsFull = true;
             } elseif ($end_of_execution) {
                 if (time() > $end_of_execution) {
                     fclose($e);
                     fclose($f);
                     CTimeZone::Enable();
                     return $NS;
                 }
             }
         }
         CTimeZone::Enable();
         if ($bFileIsFull) {
             fwrite($e, "</urlset>\n");
             fclose($e);
             fwrite($f, "</urlset>\n");
             fclose($f);
             $NS["FILE_SIZE"] = 0;
             $NS["FILE_URL_CNT"] = 0;
             $NS["FILE_ID"]++;
             return $NS;
         } elseif ($record_limit <= 0) {
             return $NS;
         } else {
             fwrite($e, "</urlset>\n");
             fclose($e);
             fwrite($f, "</urlset>\n");
             fclose($f);
         }
         //WRITE INDEX FILE HERE
         $f = fopen($arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_index.xml", "w");
         if (!$f) {
             $this->m_error = GetMessage("SEARCH_ERROR_OPEN_FILE") . " " . $arSite["ABS_DOC_ROOT"] . $arSite["DIR"] . "sitemap_index.xml" . "<br>";
             return false;
         }
         $strBegin = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
         fwrite($f, $strBegin);
         for ($i = 0; $i <= $NS["FILE_ID"]; $i++) {
             $strFile = $arSite["DIR"] . "sitemap_" . sprintf("%03d", $i) . ".xml";
             $strTime = $this->TimeEncode(filemtime($arSite["ABS_DOC_ROOT"] . $strFile));
             fwrite($f, "\t<sitemap>\n\t\t<loc>" . $this->URLEncode($strProto . $arSite["SERVER_NAME"] . $strFile, "UTF-8") . "</loc>\n\t\t<lastmod>" . $strTime . "</lastmod>\n\t</sitemap>\n");
         }
         fwrite($f, "</sitemapindex>\n");
         fclose($f);
         $this->m_errors_count = $NS["ERROR_CNT"];
         $this->m_errors_href = $strProto . $arSite["SERVER_NAME"] . $arSite["DIR"] . "sitemap_errors.xml";
         $this->m_href = $strProto . $arSite["SERVER_NAME"] . $arSite["DIR"] . "sitemap_index.xml";
         return true;
     } else {
         $this->m_error = GetMessage("SEARCH_ERROR_SITE_ID") . "<br>";
         return false;
     }
 }
Ejemplo n.º 11
0
                                $arResult["~QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
                            }
                        } while ($res = $db_res->Fetch());
                    }
                }
                $arResult["QUESTIONS"] = $arResult["~QUESTIONS"];
            }
        }
    }
} else {
    $arResult["FORUM"] = CForumNew::GetByID($arParams["FID"]);
    if (empty($arResult["FORUM"])) {
        $arError = array("code" => "fid_is_lost", "title" => GetMessage("F_FID_IS_LOST"), "link" => $arResult["index"]);
    }
}
if (empty($arError) && ($arParams["MESSAGE_TYPE"] == "NEW" && !CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID())) || $arParams["MESSAGE_TYPE"] == "EDIT" && !CForumMessage::CanUserUpdateMessage($arParams["MID"], $USER->GetUserGroupArray(), $USER->GetID())) {
    $arError = array("code" => "rightsn_new", "title" => $arParams["MESSAGE_TYPE"] == "NEW" ? GetMessage("F_NO_NPERMS") : GetMessage("F_NO_EPERMS"), "link" => $arResult["index"]);
}
if (!empty($arError)) {
    if ($arParams["AJAX_CALL"] == "Y") {
        $res = array("error" => $arError, "note" => $arNote, "id" => $arParams["MID"], "post" => ShowError($arError["title"]));
        if ($_REQUEST["CONVERT_DATA"] == "Y") {
            array_walk($res, "htmlspecialcharsEx");
        }
        $APPLICATION->RestartBuffer();
        echo CUtil::PhpToJSObject($res);
        die;
    }
    ShowError($arError["title"]);
    return false;
}
Ejemplo n.º 12
0
if ($_REQUEST['AGENDA_EX'] && check_bitrix_sessid()) {
    $APPLICATION->RestartBuffer();
    $arResult['POPUP'] = $_REQUEST['POPUP'] == 'Y';
    $this->IncludeComponentTemplate('agenda_ex');
    die;
}
$arResult['USERS'] = array();
$dbUsers = CUser::GetList($by = 'ID', $order = 'ASC', array('ID' => implode('|', array_keys($arResult['MEETING']['USERS']))));
while ($arUser = $dbUsers->GetNext()) {
    $arResult['USERS'][$arUser['ID']] = $arUser;
}
if (CModule::IncludeModule('forum')) {
    $obForumConnector = new CMeetingForumHandlers($arParams['FORUM_ID'], $arResult['MEETING']);
    $arParams['FORUM_ID'] = $obForumConnector->GetForumID();
    foreach ($arResult['MEETING']['AGENDA'] as &$arItem) {
        $arItem['COMMENTS_COUNT'] = intval(CForumTopic::GetMessageCount($arParams['FORUM_ID'], "MEETING_ITEM_" . $arItem['ITEM_ID'], true));
        if ($arItem['COMMENTS_COUNT'] > 0) {
            $arItem['COMMENTS_COUNT']--;
        }
    }
}
CJSCore::Init(array('ajax', 'popup', 'date', 'meeting'));
if ($arResult['CAN_EDIT']) {
    $APPLICATION->AddHeadScript('/bitrix/js/main/utils.js');
    $APPLICATION->AddHeadScript('/bitrix/js/main/dd.js');
}
if ($arParams['EDIT'] && $arResult['CAN_EDIT'] || isset($arResult["MEETING"]["PLACE_ID"])) {
    $arResult['MEETING_ROOMS_LIST'] = array();
    if ($arParams['RESERVE_MEETING_IBLOCK_ID'] || $arParams['RESERVE_VMEETING_IBLOCK_ID']) {
        $dbMeetingsList = CIBlockSection::GetList(array('IBLOCK_ID' => 'ASC', 'NAME' => 'ASC', 'ID' => 'DESC'), array('IBLOCK_ID' => array(intval($arParams['RESERVE_MEETING_IBLOCK_ID']), intval($arParams['RESERVE_VMEETING_IBLOCK_ID']))), false, array('ID', 'IBLOCK_ID', 'NAME', 'DESCRIPTION'));
        while ($arRoom = $dbMeetingsList->Fetch()) {
Ejemplo n.º 13
0
 function BeforeIndexSocNet($bxSocNetSearch, $fields)
 {
     static $bizprocForumId = false;
     if (!$bizprocForumId) {
         $bizprocForumId = intval(COption::GetOptionString('bizproc', 'forum_id'));
     }
     if ($fields['ENTITY_TYPE_ID'] == 'FORUM_POST' && intval($fields['PARAM1']) == $bizprocForumId && !empty($fields['PARAM2']) && !empty($bxSocNetSearch->_params["PATH_TO_WORKFLOW"]) && CModule::IncludeModule("forum") && CModule::IncludeModule("bizproc")) {
         $topic = CForumTopic::GetByID($fields['PARAM2']);
         if (!empty($topic) && is_array($topic) && !empty($topic["XML_ID"])) {
             if (preg_match('/^WF_([0-9a-f\\.]+)/', $topic["XML_ID"], $match)) {
                 $workflowId = $match[1];
                 $state = CBPStateService::GetStateDocumentId($workflowId);
                 if ($state[0] == 'lists' && $state[1] == 'BizprocDocument' && CModule::IncludeModule('iblock') && intval($state[2]) > 0) {
                     $iblockElementQuery = CIBlockElement::GetList(array(), array("ID" => intval($state[2])), false, false, array("ID", "IBLOCK_ID"));
                     if ($iblockElement = $iblockElementQuery->Fetch()) {
                         $listId = $iblockElement["IBLOCK_ID"];
                         $fields["URL"] = $bxSocNetSearch->Url(str_replace(array("#list_id#", "#workflow_id#"), array($listId, urlencode($workflowId)), $bxSocNetSearch->_params["PATH_TO_WORKFLOW"]), array("MID" => $fields["ENTITY_ID"]), "message" . $fields["ENTITY_ID"]);
                         if (!empty($fields["LID"]) && is_array($fields["LID"])) {
                             foreach ($fields["LID"] as $siteId => $url) {
                                 $fields["LID"][$siteId] = $fields["URL"];
                             }
                         }
                     }
                 }
             }
         }
     }
     return $fields;
 }
Ejemplo n.º 14
0
 function GetByIDEx($ID, $arAddParams = array())
 {
     global $DB;
     $ID = intVal($ID);
     $res = false;
     if ($ID <= 0) {
         return false;
     }
     $arAddParams = is_array($arAddParams) ? $arAddParams : array($arAddParams);
     $arAddParams["GET_TOPIC_INFO"] = $arAddParams["GET_TOPIC_INFO"] == "Y" ? "Y" : "N";
     $arAddParams["FILTER_TOPIC_INFO"] = $arAddParams["FILTER_TOPIC_INFO"] == "N" ? "N" : "Y";
     $arAddParams["GET_FORUM_INFO"] = $arAddParams["GET_FORUM_INFO"] == "Y" ? "Y" : "N";
     $arAddParams["FILTER_FORUM_INFO"] = $arAddParams["FILTER_FORUM_INFO"] == "N" ? "N" : "Y";
     $arAddParams["FILTER_MESSAGE_INFO"] = $arAddParams["FILTER_MESSAGE_INFO"] == "N" ? "N" : "Y";
     if (COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
         $arAddParams["FILTER"] = is_set($arAddParams, "FILTER") ? $arAddParams["FILTER"] : "P";
         $arAddParams["FILTER"] = $arAddParams["FILTER"] == "Y" || $arAddParams["FILTER"] == "P" ? $arAddParams["FILTER"] : "N";
     } else {
         $arAddParams["FILTER"] = "N";
     }
     if ($arAddParams["FILTER"] == "N") {
         $arAddParams["FILTER_TOPIC_INFO"] = "N";
         $arAddParams["FILTER_FORUM_INFO"] = "N";
         $arAddParams["FILTER_MESSAGE_INFO"] = "N";
     } elseif ($arAddParams["FILTER"] == "P") {
         $arAddParams["FILTER_MESSAGE_INFO"] = "N";
     }
     $arSqlSelect = array();
     $arSqlFrom = array();
     if ($arAddParams["GET_TOPIC_INFO"] == "Y") {
         $arSqlSelect[] = CForumTopic::GetSelectFields(array("sPrefix" => "FT_", "sReturnResult" => "string"));
         if ($arAddParams["FILTER_TOPIC_INFO"] != "N") {
             $arSqlSelect[] = "FT.HTML as FT_HTML";
         }
         $arSqlSelect[] = "FT.XML_ID as FT_XML_ID";
         $arSqlFrom[] = "INNER JOIN b_forum_topic FT ON (FM.TOPIC_ID = FT.ID)";
     }
     if ($arAddParams["GET_FORUM_INFO"] == "Y") {
         $arSqlSelect[] = CForumNew::GetSelectFields(array("sPrefix" => "F_", "sReturnResult" => "string"));
         if ($arAddParams["FILTER_FORUM_INFO"] != "N") {
             $arSqlSelect[] = "F.HTML as F_HTML";
         }
         $arSqlFrom[] = "INNER JOIN b_forum F ON (FM.FORUM_ID = F.ID)";
     }
     $strSql = "SELECT FM.*, " . $DB->DateToCharFunction("FM.POST_DATE", "FULL") . " as POST_DATE,\n\t\t\t\tFU.SHOW_NAME, FU.DESCRIPTION, FU.NUM_POSTS, FU.POINTS as NUM_POINTS, FU.SIGNATURE, FU.AVATAR, FU.RANK_ID,\n\t\t\t\t" . $DB->DateToCharFunction("FU.DATE_REG", "SHORT") . " as DATE_REG,\n\t\t\t\tU.EMAIL, U.PERSONAL_ICQ, U.LOGIN, U.NAME, U.SECOND_NAME, U.LAST_NAME" . (!empty($arSqlSelect) ? ", " . implode(", ", $arSqlSelect) : "") . "\n\t\t\tFROM b_forum_message FM\n\t\t\t\tLEFT JOIN b_forum_user FU ON (FM.AUTHOR_ID = FU.USER_ID)\n\t\t\t\tLEFT JOIN b_user U ON (FM.AUTHOR_ID = U.ID)\n\t\t\t\t" . implode(" ", $arSqlFrom) . "\n\t\t\tWHERE FM.ID = " . $ID . "";
     $db_res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
     if ($db_res && ($res = $db_res->Fetch())) {
         if ($arAddParams["FILTER_MESSAGE_INFO"] == "N") {
             unset($res["HTML"]);
         }
         if ($arAddParams["GET_TOPIC_INFO"] == "Y" && COption::GetOptionString("forum", "FILTER", "Y") == "Y") {
             $arTopic = array();
             foreach ($res as $key => $val) {
                 if (substr($key, 0, 3) == "FT_") {
                     $arTopic[substr($key, 3)] = $val;
                 }
             }
             if (!empty($arTopic)) {
                 $GLOBALS["FORUM_CACHE"]["TOPIC"][intVal($res["TOPIC_INFO"]["ID"])] = $arTopic;
                 $db_res_filter = new CDBResult();
                 $db_res_filter->InitFromArray(array($arTopic));
                 $db_res_filter = new _CTopicDBResult($db_res_filter);
                 if ($res_filter = $db_res_filter->Fetch()) {
                     $GLOBALS["FORUM_CACHE"]["TOPIC_FILTER"][intVal($res["TOPIC_INFO"]["ID"])] = $res_filter;
                 }
             }
         }
         $db_res = new CDBResult();
         $db_res->InitFromArray(array($res));
         $db_res = new _CMessageDBResult($db_res, $arAddParams);
         $res = $db_res->Fetch();
         if ($arAddParams["GET_TOPIC_INFO"] == "Y" || $arAddParams["GET_FORUM_INFO"] == "Y") {
             $res["TOPIC_INFO"] = array();
             $res["FORUM_INFO"] = array();
             $res["MESSAGE_INFO"] = array();
             foreach ($res as $key => $val) {
                 if (substr($key, 0, 3) == "FT_") {
                     $res["TOPIC_INFO"][substr($key, 3)] = $val;
                 } elseif (substr($key, 0, 2) == "F_") {
                     $res["FORUM_INFO"][substr($key, 2)] = $val;
                 } else {
                     $res["MESSAGE_INFO"][$key] = $val;
                 }
             }
             if (COption::GetOptionString("forum", "FILTER", "Y") != "Y" && !empty($res["TOPIC_INFO"])) {
                 $GLOBALS["FORUM_CACHE"]["TOPIC"][intVal($res["TOPIC_INFO"]["ID"])] = $res["TOPIC_INFO"];
             }
             if (!empty($res["FORUM_INFO"])) {
                 $GLOBALS["FORUM_CACHE"]["FORUM"][intVal($res["FORUM_INFO"]["ID"])] = $res["FORUM_INFO"];
             }
         }
         if ($arAddParams["getFiles"] == "Y" && !empty($res)) {
             $res["FILES"] = CForumFiles::getByMessageID($ID);
         }
         return $res;
     }
     return false;
 }
Ejemplo n.º 15
0
        }
        if (strlen($strErrorMessage) <= 0) {
            $AUTHOR_IP = ForumGetRealIP();
            $AUTHOR_IP_tmp = $AUTHOR_IP;
            $AUTHOR_REAL_IP = $_SERVER['REMOTE_ADDR'];
            $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 = array("POST_MESSAGE" => $strDescription, "AUTHOR_NAME" => $_POST["comment_author"], "AUTHOR_EMAIL" => $_POST["comment_email"], "FORUM_ID" => $INQUERY_FORUM_ID, "TOPIC_ID" => $TID1, "AUTHOR_IP" => $AUTHOR_IP !== False ? $AUTHOR_IP : "<no address>", "AUTHOR_REAL_IP" => $AUTHOR_REAL_IP !== False ? $AUTHOR_REAL_IP : "<no address>", "NEW_TOPIC" => "Y", "GUEST_ID" => $_SESSION["SESS_GUEST_ID"]);
            $MID1 = CForumMessage::Add($arFields);
            if (IntVal($MID1) <= 0) {
                $strErrorMessage .= GetMessage("ADDMESS_ERROR_ADD_MESSAGE") . ". \n";
                CForumTopic::Delete($TID1);
                $TID1 = 0;
            }
        }
        if (strlen($strErrorMessage) <= 0) {
            $DB->Commit();
            $strOKMessage .= GetMessage("COMM_COMMENT_OK") . ". ";
        } else {
            if ($sTransStarted) {
                $DB->Rollback();
            }
        }
    }
    ?>

<br><a name="cm">
Ejemplo n.º 16
0
 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));
 }
Ejemplo n.º 17
0
$arResult["SHOW_SUBSCRIBE"] = ((($arParams["SHOW_SUBSCRIBE"] == "Y") && ($arResult["USER"]["ID"] > 0 && $arResult["USER"]["PERMISSION"] > "E")) ? "Y" : "N");
$arResult["TOPIC_SUBSCRIBE"] = $arResult["USER"]["TOPIC_SUBSCRIBE"];
$arResult["FORUM_SUBSCRIBE"] = $arResult["USER"]["FORUM_SUBSCRIBE"];
$arResult["SHOW_LINK"] = (empty($arResult["read"]) ? "N" : "Y");
$arResult["SHOW_POSTS"]	= (empty($arResult["MESSAGES"]) ? "N" : "Y");
$arResult["PARSER"] = $parser;
$arResult["CURRENT_PAGE"] = $APPLICATION->GetCurPageParam();

$arResult["ELEMENT_REAL"] = $arResult["ELEMENT"];
$arResult["ELEMENT"] = array(
	"PRODUCT" => $arResult["ELEMENT"],
	"PRODUCT_PROPS" => array());
if (is_set($arResult["ELEMENT_REAL"], "PROPERTY_FORUM_TOPIC_ID_VALUE"))
{
	$arResult["ELEMENT"]["PRODUCT_PROPS"]["FORUM_TOPIC_ID"] = array("VALUE" => $arResult["ELEMENT_REAL"]["PROPERTY_FORUM_TOPIC_ID_VALUE"]);
	$arResult["ELEMENT"]["PRODUCT_PROPS"]["~FORUM_TOPIC_ID"] = array("VALUE" => $arResult["ELEMENT_REAL"]["~PROPERTY_FORUM_TOPIC_ID_VALUE"]);
}
if (is_set($arResult["ELEMENT_REAL"], "PROPERTY_FORUM_MESSAGE_CNT_VALUE"))
{
	$arResult["ELEMENT"]["PRODUCT_PROPS"]["FORUM_MESSAGE_CNT"] = array("VALUE" => $arResult["ELEMENT_REAL"]["PROPERTY_FORUM_MESSAGE_CNT_VALUE"]);
	$arResult["ELEMENT"]["PRODUCT_PROPS"]["~FORUM_MESSAGE_CNT"] = array("VALUE" => $arResult["ELEMENT_REAL"]["~PROPERTY_FORUM_MESSAGE_CNT_VALUE"]);
}
/* For custom template */
// *****************************************************************************************
$this->IncludeComponentTemplate();
// *****************************************************************************************
if ($arResult["FORUM_TOPIC_ID"] > 0)
	return CForumTopic::GetMessageCount($arParams["FORUM_ID"], $arResult["FORUM_TOPIC_ID"], (($arResult["USER"]["RIGHTS"]["MODERATE"] == "Y")?null:true));
else
	return 0;
?>
Ejemplo n.º 18
0
 public static function AddCrmActivityComment($arFields)
 {
     if (!CModule::IncludeModule("forum")) {
         return false;
     }
     $ufFileID = array();
     $ufDocID = array();
     $messageID = false;
     $dbResult = CSocNetLog::GetList(array(), array("ID" => $arFields["LOG_ID"]), false, false, array('ID', 'ENTITY_ID', 'SOURCE_ID', 'SITE_ID', 'TITLE', 'PARAMS'));
     if ($arLog = $dbResult->Fetch()) {
         $dbCrmActivity = CCrmActivity::GetList(array(), array('ID' => $arLog['ENTITY_ID'], 'CHECK_PERMISSIONS' => 'N'));
         if ($arCrmActivity = $dbCrmActivity->Fetch()) {
             if ($arCrmActivity['TYPE_ID'] == CCrmActivityType::Task && CModule::IncludeModule('tasks')) {
                 $userID = $GLOBALS["USER"]->GetID();
                 $dbTask = CTasks::GetByID($arCrmActivity["ASSOCIATED_ENTITY_ID"], false);
                 if ($arTaskFields = $dbTask->Fetch()) {
                     if (!($userName = trim($GLOBALS["USER"]->GetFormattedName(false)))) {
                         $userName = $GLOBALS["USER"]->GetLogin();
                     }
                     $FORUM_ID = CTasksTools::GetForumIdForIntranet();
                     if (!$arTaskFields["FORUM_TOPIC_ID"]) {
                         $arTopicFields = array("TITLE" => $arTaskFields["TITLE"], "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" => 'TASK_' . $arTaskFields['ID']);
                         $TOPIC_ID = CForumTopic::Add($arTopicFields);
                         if ($TOPIC_ID) {
                             $arFieldsFirstMessage = array("POST_MESSAGE" => $arTopicFields["XML_ID"], "AUTHOR_ID" => $arTopicFields["USER_START_ID"], "AUTHOR_NAME" => $arTopicFields["USER_START_NAME"], "FORUM_ID" => $arTopicFields["FORUM_ID"], "TOPIC_ID" => $TOPIC_ID, "APPROVED" => "Y", "NEW_TOPIC" => "Y", "PARAM1" => 'TK', "PARAM2" => $arTaskFields['ID'], "PERMISSION_EXTERNAL" => 'E', "PERMISSION" => 'E');
                             CForumMessage::Add($arFieldsFirstMessage, false, array("SKIP_INDEXING" => "Y", "SKIP_STATISTIC" => "N"));
                             $oTask = new CTasks();
                             $oTask->Update($arTaskFields["ID"], array("FORUM_TOPIC_ID" => $TOPIC_ID));
                         }
                     } else {
                         $TOPIC_ID = $arTaskFields["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");
                         $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);
                         $messageID = CForumMessage::Add($arFieldsP);
                         // get UF DOC value and FILE_ID there
                         if ($messageID > 0) {
                             $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $messageID));
                             while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
                                 $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
                             }
                             $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $messageID, LANGUAGE_ID);
                         }
                     }
                 }
             } else {
                 return array("NO_SOURCE" => "Y");
             }
         } else {
             $sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
         }
     } else {
         $sError = GetMessage("SONET_ADD_COMMENT_SOURCE_ERROR");
     }
     return array("SOURCE_ID" => $messageID, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $messageID, "ERROR" => $sError, "NOTES" => $sNote, "UF" => array("FILE" => $ufFileID, "DOC" => $ufDocID));
 }
Ejemplo n.º 19
0
 $db_res = CForumNew::GetListEx(array(), $arFilter);
 if ($db_res && ($res = $db_res->GetNext())) {
     do {
         $res["URL"] = array("LIST" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_LIST"], array("FID" => $res["ID"])), "~LIST" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_LIST"], array("FID" => $res["ID"])));
         $res["list"] = $res["URL"]["list"];
         // for custom
         $arForums[$res["ID"]] = $res;
     } while ($res = $db_res->GetNext());
 }
 if (!empty($arForums)) {
     // it need for custom components
     foreach (array("TITLE", "USER_START_NAME", "POSTS", "VIEWS", "LAST_POST_DATE") as $res) {
         $arResult["SortingEx"][$res] = SortingEx($res, false, "by" . $orderIndex, "order" . $orderIndex);
     }
     // /it need for custom components
     $db_res = CForumTopic::GetListEx($arSort, array("@FORUM_ID" => array_keys($arForums), "APPROVED" => "Y"), false, false, $arNavParams);
     if ($db_res) {
         $db_res->NavStart($arParams["TOPICS_PER_PAGE"], false);
         $arResult["NAV_STRING"] = $db_res->GetPageNavStringEx($navComponentObject, $arParams["PAGER_TITLE"], $arParams["PAGER_TEMPLATE"], $arParams["PAGER_SHOW_ALWAYS"]);
         //$arResult["NAV_CACHED_DATA"] = $navComponentObject->GetTemplateCachedData();
         $arResult["NAV_RESULT"] = $db_res;
         while ($res = $db_res->GetNext()) {
             if (strLen(trim($res["LAST_POST_DATE"])) > 0) {
                 $res["LAST_POST_DATE"] = CForumFormat::DateFormat($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($res["LAST_POST_DATE"], CSite::GetDateFormat()));
             }
             $res["URL"] = array("AUTHOR" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["USER_START_ID"])), "~AUTHOR" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_PROFILE_VIEW"], array("UID" => $res["USER_START_ID"])), "READ" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "MID" => intVal($res["LAST_MESSAGE_ID"]))) . "#message" . intVal($res["LAST_MESSAGE_ID"]), "~READ" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "MID" => intVal($res["LAST_MESSAGE_ID"]))) . "#message" . intVal($res["LAST_MESSAGE_ID"]));
             $res["user_start_id_profile"] = $res["URL"]["AUTHOR"];
             // For custom
             $res["read"] = $res["URL"]["READ"];
             // For custom
             $arTopics[] = $res;
Ejemplo n.º 20
0
                    }
                    $res["ANSWERS"][] = $resa;
                }
            }
            if (empty($res["ANSWERS"]) && empty($res["QUESTION"]) && empty($res["ID"])) {
                continue;
            }
            $arResult["QUESTIONS"][] = $res;
        }
    }
}
/*******************************************************************/
if (($arParams["MESSAGE_TYPE"] == "NEW" || $arParams["MESSAGE_TYPE"] == "REPLY") && $arResult["IsAuthorized"] == "N" || $arParams["MESSAGE_TYPE"] == "EDIT" && intVal($arResult["MESSAGE"]["AUTHOR_ID"]) <= 0) {
    $arResult["SHOW_PANEL_GUEST"] = "Y";
}
if ($arParams["MESSAGE_TYPE"] == "NEW" || $arParams["MESSAGE_TYPE"] == "EDIT" && CForumTopic::CanUserUpdateTopic($arParams["TID"], $USER->GetUserGroupArray(), $USER->GetID())) {
    $arResult["SHOW_PANEL_NEW_TOPIC"] = "Y";
    $arResult["ForumPrintIconsList"] = ForumPrintIconsList(7, "ICON_ID", $arResult["TOPIC"]["ICON_ID"], GetMessage("FPF_NO_ICON"), LANGUAGE_ID, $arParams["PATH_TO_ICON"], $arParams["CACHE_TIME"]);
    if ($arParams["SHOW_VOTE"] == "Y") {
        $arResult["SHOW_PANEL_VOTE"] = "Y";
    }
}
if ($arParams["FORUM"]["ALLOW_SMILES"] == "Y") {
    $arResult["ForumPrintSmilesList"] = ForumPrintSmilesList($arParams["SMILE_TABLE_COLS"], LANGUAGE_ID, $arParams["PATH_TO_SMILE"], $arParams["CACHE_TIME"]);
    $arResult["SMILES"] = CForumSmile::GetByType("S", LANGUAGE_ID);
}
if ($arResult["SHOW_SUBSCRIBE"] == "Y") {
    $arFields = array("USER_ID" => $USER->GetID(), "FORUM_ID" => $arParams["FID"], "SITE_ID" => SITE_ID);
    $db_res = CForumSubscribe::GetList(array(), $arFields);
    $arResult["TOPIC_SUBSCRIBE"] = "N";
    $arResult["FORUM_SUBSCRIBE"] = "N";
Ejemplo n.º 21
0
     $res["USER_START_NAME"] = $parser->wrap_long_words($res["USER_START_NAME"]);
     $res["LAST_POSTER_NAME"] = $parser->wrap_long_words($res["LAST_POSTER_NAME"]);
     $res["LAST_POST_DATE"] = CForumFormat::DateFormat($arParams["DATE_TIME_FORMAT"], MakeTimeStamp($res["LAST_POST_DATE"], CSite::GetDateFormat()));
     $res["START_DATE"] = CForumFormat::DateFormat($arParams["DATE_FORMAT"], MakeTimeStamp($res["START_DATE"], CSite::GetDateFormat()));
     /************** For custom template ********************************/
     $res["read"] = $res["URL"]["TOPIC"];
     $res["read_last_unread"] = $res["URL"]["MESSAGE_UNREAD"];
     $res["read_last_message"] = $res["URL"]["LAST_MESSAGE"];
     $res["USER_START_HREF"] = $res["URL"]["USER_START"];
     $res["LAST_POSTER_HREF"] = $res["URL"]["LAST_POSTER_HREF"];
     $res["author_profile"] = $res["URL"]["LAST_POSTER_HREF"];
     /************** For custom template/********************************/
     $arResult["Topics"][] = $res;
 }
 if (count($topicLinks) > 0) {
     $db_res1 = CForumTopic::GetListEx(array("SORT" => "ASC"), array("@ID" => $topicLinks));
     $topicLinks1 = array();
     while ($res = $db_res1->GetNext()) {
         $key = array_search($res["ID"], $topicLinks);
         if (array_key_exists($key, $arResult["Topics"])) {
             $arResult["Topics"][$key]["URL"] = array_merge($arResult["Topics"][$key]["URL"], array("TOPIC" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "~TOPIC" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "s")), "LAST_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => intVal($res["LAST_MESSAGE_ID"]))), "~LAST_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => intVal($res["LAST_MESSAGE_ID"]))), "MESSAGE_UNREAD" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "unread_mid")), "~MESSAGE_UNREAD" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE"], array("FID" => $res["FORUM_ID"], "TID" => $res["ID"], "TITLE_SEO" => $res["TITLE_SEO"], "MID" => "unread_mid"))));
         }
     }
 }
 /*******************************************************************
 				CACHE
 *******************************************************************/
 if ($PAGEN == null && $arParams["CACHE_TIME"] > 0 && defined("BX_COMP_MANAGED_CACHE")) {
     $cache->StartDataCache($arParams["CACHE_TIME"], $cache_id, $cache_path);
     CForumCacheManager::SetTag($cache_path, "forum_msg_count" . $arParams['FID']);
     CForumCacheManager::SetTag($cache_path, "forum_" . $arParams['FID']);
Ejemplo n.º 22
0
 /**
  * WARNING! This method is transitional and can be changed without 
  * any notifications! Don't use it.
  * 
  * @deprecated
  */
 public static function __deprecated_Add($commentText, $forumTopicId, $forumId, $nameTemplate, $arTask, $permissions, $commentId, $givenUserId, $imageWidth, $imageHeight, $arSmiles, $arForum, $messagesPerPage, $arUserGroupArray, $backPage, $strMsgAddComment, $strMsgEditComment, $strMsgNewTask, $componentName, &$outForumTopicId, &$arErrorCodes, &$outStrUrl, $arFieldsAdditional = array())
 {
     global $DB;
     if (is_array($arTask)) {
         if (!array_key_exists('~TITLE', $arTask)) {
             $arTmpTask = $arTask;
             foreach ($arTmpTask as $key => $value) {
                 if (substr($key, 0, 1) !== '~') {
                     $arTask['~' . $key] = $arTmpTask[$key];
                 }
             }
         }
     }
     $MID = 0;
     $TID = 0;
     if ($forumTopicId > 0 && CForumTopic::GetByID($forumTopicId) === false) {
         $forumTopicId = false;
     }
     if ($forumTopicId <= 0) {
         $arUserStart = array("ID" => intVal($arTask["CREATED_BY"]), "NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
         if ($arUserStart["ID"] > 0) {
             $res = array();
             $db_res = CForumUser::GetListEx(array(), array("USER_ID" => $arTask["CREATED_BY"]));
             if ($db_res && ($res = $db_res->Fetch())) {
                 $res["FORUM_USER_ID"] = intVal($res["ID"]);
                 $res["ID"] = $res["USER_ID"];
             } else {
                 $db_res = CUser::GetByID($arTask["CREATED_BY"]);
                 if ($db_res && ($res = $db_res->Fetch())) {
                     $res["SHOW_NAME"] = COption::GetOptionString("forum", "USER_SHOW_NAME", "Y");
                     $res["USER_PROFILE"] = "N";
                 }
             }
             if (!empty($res)) {
                 $arUserStart = $res;
                 $sName = $res["SHOW_NAME"] == "Y" ? trim(CUser::FormatName($nameTemplate, $res)) : "";
                 $arUserStart["NAME"] = empty($sName) ? trim($res["LOGIN"]) : $sName;
             }
         }
         $arUserStart["NAME"] = empty($arUserStart["NAME"]) ? $GLOBALS["FORUM_STATUS_NAME"]["guest"] : $arUserStart["NAME"];
         $DB->StartTransaction();
         $arFields = array("TITLE" => $arTask["~TITLE"], "FORUM_ID" => $forumId, "USER_START_ID" => $arUserStart["ID"], "USER_START_NAME" => $arUserStart["NAME"], "LAST_POSTER_NAME" => $arUserStart["NAME"], "APPROVED" => "Y", "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions, "NAME_TEMPLATE" => $nameTemplate, 'XML_ID' => 'TASK_' . $arTask['ID']);
         $TID = CForumTopic::Add($arFields);
         if (intVal($TID) <= 0) {
             $arErrorCodes[] = array('code' => 'topic is not created');
         } else {
             $arFields = array("FORUM_TOPIC_ID" => $TID);
             $task = new CTasks();
             $task->Update($arTask["ID"], $arFields);
         }
         if (!empty($arErrorCodes)) {
             $DB->Rollback();
             return false;
         } else {
             $DB->Commit();
         }
     }
     $arFieldsG = array("POST_MESSAGE" => $commentText, "AUTHOR_NAME" => '', "AUTHOR_EMAIL" => $GLOBALS['USER']->GetEmail(), "USE_SMILES" => NULL, "PARAM2" => $arTask['ID'], "TITLE" => $arTask["~TITLE"], "PERMISSION_EXTERNAL" => $permissions, "PERMISSION" => $permissions);
     // UF_* forwarding
     if (is_array($arFieldsAdditional)) {
         foreach ($arFieldsAdditional as $field => $value) {
             if (strlen($field) && substr($field, 0, 3) == 'UF_') {
                 $arFieldsG[$field] = $value;
                 $GLOBALS[$field] = $value;
                 // strange behaviour required for ForumMessageAdd() to handle UF_* properly
             }
         }
     }
     if (!empty($_FILES["REVIEW_ATTACH_IMG"])) {
         $arFieldsG["ATTACH_IMG"] = $_FILES["REVIEW_ATTACH_IMG"];
     } else {
         $arFiles = array();
         if (!empty($_REQUEST["FILES"])) {
             foreach ($_REQUEST["FILES"] as $key) {
                 $arFiles[$key] = array("FILE_ID" => $key);
                 if (!in_array($key, $_REQUEST["FILES_TO_UPLOAD"])) {
                     $arFiles[$key]["del"] = "Y";
                 }
             }
         }
         if (!empty($_FILES)) {
             $res = array();
             foreach ($_FILES as $key => $val) {
                 if (substr($key, 0, strLen("FILE_NEW")) == "FILE_NEW" && !empty($val["name"])) {
                     $arFiles[] = $_FILES[$key];
                 }
             }
         }
         if (!empty($arFiles)) {
             $arFieldsG["FILES"] = $arFiles;
         }
     }
     $TOPIC_ID = $forumTopicId > 0 ? $forumTopicId : $TID;
     $MESSAGE_ID = 0;
     $MESSAGE_TYPE = $TOPIC_ID > 0 ? "REPLY" : "NEW";
     if (COption::GetOptionString("tasks", "task_comment_allow_edit") && ($MESSAGE_ID = intval($commentId))) {
         $MESSAGE_TYPE = "EDIT";
     }
     $strErrorMessage = '';
     $strOKMessage = '';
     $MID = ForumAddMessage($MESSAGE_TYPE, $forumId, $TOPIC_ID, $MESSAGE_ID, $arFieldsG, $strErrorMessage, $strOKMessage, false, $_POST["captcha_word"], 0, $_POST["captcha_code"], $nameTemplate);
     if ($MID <= 0 || !empty($strErrorMessage)) {
         $arErrorCodes[] = array('code' => 'message is not added 2', 'title' => empty($strErrorMessage) ? NULL : $strErrorMessage);
     } else {
         $arMessage = CForumMessage::GetByID($MID);
         if ($forumTopicId <= 0) {
             $forumTopicId = $TID = intVal($arMessage["TOPIC_ID"]);
         }
         $outForumTopicId = intVal($forumTopicId);
         if ($componentName !== null) {
             ForumClearComponentCache($componentName);
         }
         // NOTIFICATION
         $arTask["ACCOMPLICES"] = $arTask["AUDITORS"] = array();
         $rsMembers = CTaskMembers::GetList(array(), array("TASK_ID" => $arTask["ID"]));
         while ($arMember = $rsMembers->Fetch()) {
             if ($arMember["TYPE"] == "A") {
                 $arTask["ACCOMPLICES"][] = $arMember["USER_ID"];
             } elseif ($arMember["TYPE"] == "U") {
                 $arTask["AUDITORS"][] = $arMember["USER_ID"];
             }
         }
         $arEmailUserIDs = array($arTask["RESPONSIBLE_ID"], $arTask["CREATED_BY"]);
         $arEmailUserIDs = array_unique(array_merge($arEmailUserIDs, $arTask["ACCOMPLICES"], $arTask["AUDITORS"]));
         $currentUserPos = array_search($givenUserId, $arEmailUserIDs);
         if ($currentUserPos !== false) {
             unset($arEmailUserIDs[$currentUserPos]);
         }
         $parser = new CTextParser();
         $parser->imageWidth = $imageWidth;
         $parser->imageHeight = $imageHeight;
         $parser->smiles = $arSmiles;
         $parser->allow = array("HTML" => $arForum["ALLOW_HTML"], "ANCHOR" => $arForum["ALLOW_ANCHOR"], "BIU" => $arForum["ALLOW_BIU"], "IMG" => "N", "VIDEO" => "N", "LIST" => $arForum["ALLOW_LIST"], "QUOTE" => $arForum["ALLOW_QUOTE"], "CODE" => $arForum["ALLOW_CODE"], "FONT" => $arForum["ALLOW_FONT"], "SMILES" => "N", "UPLOAD" => $arForum["ALLOW_UPLOAD"], "NL2BR" => $arForum["ALLOW_NL2BR"], "TABLE" => "Y");
         $arAllow = NULL;
         $MESSAGE = HTMLToTxt($parser->convertText($commentText, $arAllow));
         // remove [ url] for socialnetwork log
         $MESSAGE = preg_replace("/(\\s\\[\\s(http:\\/\\/|https:\\/\\/|ftp:\\/\\/))(.*?)(\\s\\])/is", "", $MESSAGE);
         $parser->allow = array("HTML" => 'Y', "ANCHOR" => 'Y', "BIU" => 'Y', "IMG" => "Y", "VIDEO" => "Y", "LIST" => 'N', "QUOTE" => 'Y', "CODE" => 'Y', "FONT" => 'Y', "SMILES" => "N", "UPLOAD" => 'N', "NL2BR" => 'N', "TABLE" => "Y");
         $message_notify = $parser->convertText($commentText);
         $arRecipientsIDs = CTaskNotifications::GetRecipientsIDs($arTask);
         // Instant Messages
         if (IsModuleInstalled("im") && CModule::IncludeModule("im") && sizeof($arRecipientsIDs)) {
             // this entire class is deprecated. disable edit message, add only here
             if ($MESSAGE_TYPE != 'EDIT') {
                 CTaskComments::sendAddMessage(array('ID' => $MID, 'POST_MESSAGE' => $message_notify), $arTask, $givenUserId, $arRecipientsIDs, array());
             }
         }
         $strURL = !empty($backPage) ? $backPage : $GLOBALS['APPLICATION']->GetCurPageParam("", array("IFRAME", "MID", "SEF_APPLICATION_CUR_PAGE_URL", BX_AJAX_PARAM_ID, "result"));
         $strURL = ForumAddPageParams($strURL, array("MID" => $MID, "result" => $arForum["MODERATION"] != "Y" || CForumNew::CanUserModerateForum($forumId, $arUserGroupArray) ? "reply" : "not_approved"), false, false);
         $outStrUrl = $strURL;
         // sonet log
         if (CModule::IncludeModule("socialnetwork")) {
             $dbRes = CSocNetLog::GetList(array("ID" => "DESC"), array("EVENT_ID" => "tasks", "SOURCE_ID" => $arTask["ID"]), false, false, array("ID", "ENTITY_TYPE", "ENTITY_ID", "TMP_ID"));
             if ($arRes = $dbRes->Fetch()) {
                 $log_id = $arRes["TMP_ID"];
                 $entity_type = $arRes["ENTITY_TYPE"];
                 $entity_id = $arRes["ENTITY_ID"];
             } else {
                 $entity_type = $arTask["GROUP_ID"] ? SONET_ENTITY_GROUP : SONET_ENTITY_USER;
                 $entity_id = $arTask["GROUP_ID"] ? $arTask["GROUP_ID"] : $arTask["CREATED_BY"];
                 $rsUser = CUser::GetByID($arTask["CREATED_BY"]);
                 if ($arUser = $rsUser->Fetch()) {
                     $arSoFields = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks", "LOG_DATE" => $arTask["CREATED_DATE"], "TITLE_TEMPLATE" => "#TITLE#", "TITLE" => htmlspecialcharsBack($arTask["~TITLE"]), "MESSAGE" => "", "TEXT_MESSAGE" => $strMsgNewTask, "MODULE_ID" => "tasks", "CALLBACK_FUNC" => false, "SOURCE_ID" => $arTask["ID"], "ENABLE_COMMENTS" => "Y", "USER_ID" => $arTask["CREATED_BY"], "URL" => CTaskNotifications::GetNotificationPath($arUser, $arTask["ID"]), "PARAMS" => serialize(array("TYPE" => "create")));
                     $log_id = CSocNetLog::Add($arSoFields, false);
                     if (intval($log_id) > 0) {
                         CSocNetLog::Update($log_id, array("TMP_ID" => $log_id));
                         $arRights = CTaskNotifications::__UserIDs2Rights(CTaskNotifications::GetRecipientsIDs($arTask, false));
                         if ($arTask["GROUP_ID"]) {
                             $arRights[] = "S" . SONET_ENTITY_GROUP . $arTask["GROUP_ID"];
                         }
                         CSocNetLogRights::Add($log_id, $arRights);
                     }
                 }
             }
             if (intval($log_id) > 0) {
                 $sText = COption::GetOptionString("forum", "FILTER", "Y") == "Y" ? $arMessage["POST_MESSAGE_FILTER"] : $arMessage["POST_MESSAGE"];
                 CSocNetLog::Update($log_id, array('PARAMS' => serialize(array('TYPE' => 'comment'))));
                 $arFieldsForSocnet = array("ENTITY_TYPE" => $entity_type, "ENTITY_ID" => $entity_id, "EVENT_ID" => "tasks_comment", "MESSAGE" => $sText, "TEXT_MESSAGE" => $parser->convert4mail($sText), "URL" => str_replace("?IFRAME=Y", "", str_replace("&IFRAME=Y", "", str_replace("IFRAME=Y&", "", $strURL))), "MODULE_ID" => "tasks", "SOURCE_ID" => $MID, "LOG_ID" => $log_id, "RATING_TYPE_ID" => "FORUM_POST", "RATING_ENTITY_ID" => $MID);
                 if ($MESSAGE_TYPE == "EDIT") {
                     $dbRes = CSocNetLogComments::GetList(array("ID" => "DESC"), array("EVENT_ID" => array("tasks_comment"), "SOURCE_ID" => $MID), false, false, array("ID"));
                     while ($arRes = $dbRes->Fetch()) {
                         CSocNetLogComments::Update($arRes["ID"], $arFieldsForSocnet);
                     }
                 } else {
                     $arFieldsForSocnet['USER_ID'] = $givenUserId;
                     $arFieldsForSocnet['=LOG_DATE'] = $GLOBALS['DB']->CurrentTimeFunction();
                     $ufFileID = array();
                     $dbAddedMessageFiles = CForumFiles::GetList(array("ID" => "ASC"), array("MESSAGE_ID" => $MID));
                     while ($arAddedMessageFiles = $dbAddedMessageFiles->Fetch()) {
                         $ufFileID[] = $arAddedMessageFiles["FILE_ID"];
                     }
                     if (count($ufFileID) > 0) {
                         $arFieldsForSocnet["UF_SONET_COM_FILE"] = $ufFileID;
                     }
                     $ufDocID = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_DOC", $MID, LANGUAGE_ID);
                     if ($ufDocID) {
                         $arFieldsForSocnet["UF_SONET_COM_DOC"] = $ufDocID;
                     }
                     $ufDocVer = $GLOBALS["USER_FIELD_MANAGER"]->GetUserFieldValue("FORUM_MESSAGE", "UF_FORUM_MESSAGE_VER", $MID, LANGUAGE_ID);
                     if ($ufDocVer) {
                         $arFieldsForSocnet["UF_SONET_COM_VER"] = $ufDocVer;
                     }
                     if (isset($arFieldsAdditional["ANCILLARY"]) && $arFieldsAdditional["ANCILLARY"]) {
                         CSocNetLogComments::Add($arFieldsForSocnet, false, false, false);
                     } else {
                         $comment_id = CSocNetLogComments::Add($arFieldsForSocnet, false, false);
                         CSocNetLog::CounterIncrement($comment_id, false, false, "LC");
                     }
                 }
             }
         }
         $occurAsUserId = CTasksTools::getOccurAsUserId();
         if (!$occurAsUserId) {
             $occurAsUserId = $arMessage["AUTHOR_ID"] ? $arMessage["AUTHOR_ID"] : 1;
         }
         // Tasks log
         $arLogFields = array("TASK_ID" => $arTask["ID"], "USER_ID" => $occurAsUserId, "CREATED_DATE" => $arMessage["EDIT_DATE"] ? ConvertTimeStamp(MakeTimeStamp($arMessage["EDIT_DATE"], CSite::GetDateFormat()), "FULL") : $arMessage["POST_DATE"], "FIELD" => "COMMENT", "TO_VALUE" => $MID);
         $log = new CTaskLog();
         $log->Add($arLogFields);
     }
     return $MID;
     // Message id
 }
Ejemplo n.º 23
0
        $arFields = array("TITLE" => trim($_REQUEST["TITLE"]), "DESCRIPTION" => trim($_REQUEST["DESCRIPTION"]), "ICON_ID" => intVal($_REQUEST["ICON_ID"]), "TAGS" => $_REQUEST["TAGS"]);
        if (ForumMoveMessage($arParams["FID"], $arParams["TID"], $message, 0, $arFields, $strErrorMessage, $strOKMessage)) {
            $res = CForumMessage::GetByID($message[0]);
            $arParams["TID"] = intVal($res["TOPIC_ID"]);
            LocalRedirect(CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $arResult["FORUM"]["ID"], "TID" => $arParams["TID"], "MID" => "s")));
        } else {
            $arError[] = array("id" => "bad_move", "text" => $strErrorMessage);
        }
    }
    if (!empty($arError)) {
        $e = new CAdminException(array_reverse($arError));
        $GLOBALS["APPLICATION"]->ThrowException($e);
        $err = $GLOBALS['APPLICATION']->GetException();
        $arResult["ERROR_MESSAGE"] .= $err->GetString();
        if (!empty($arParams["newTID"])) {
            $res = CForumTopic::GetByIDEx($arParams["newTID"]);
            $arResult["NEW_TOPIC"] = array("TOPIC" => $res["TOPIC_INFO"], "FORUM" => $res["FORUM_INFO"]);
        }
        $arResult["VALUES"]["TITLE"] = htmlspecialcharsEx($_REQUEST["TITLE"]);
        $arResult["VALUES"]["DESCRIPTION"] = htmlspecialcharsEx($_REQUEST["DESCRIPTION"]);
        $arResult["VALUES"]["ICON_ID"] = intVal($_REQUEST["ICON_ID"]);
    }
    $arResult["OK_MESSAGE"] .= $strOKMessage;
}
/********************************************************************
				/Action
********************************************************************/
/********************************************************************
				Data
********************************************************************/
$arMessage = array();
Ejemplo n.º 24
0
    }
    if (!empty($sError)) {
        $lAdmin->AddFilterError($sError);
    }
}
$rsData = CForumTopic::GetListEx(array($by => $order), $arFilter, false, 0, array("NoFilter" => true));
$rsData = new CAdminResult($rsData, $sTableID);
$rsData->NavStart();
$lAdmin->NavText($rsData->GetNavPrint(GetMessage("FM_TOPICS")));
/*******************************************************************/
$lAdmin->AddHeaders(array(array("id" => "ID", "content" => "ID", "sort" => "ID", "default" => true), array("id" => "TITLE", "content" => GetMessage("FM_TITLE_NAME"), "sort" => "TITLE", "default" => true), array("id" => "DESCRIPTION", "content" => GetMessage("FM_TITLE_DESCRIPTION"), "sort" => "DESCRIPTION", "default" => false), array("id" => "STATE", "content" => GetMessage("FM_TITLE_STATE"), "sort" => "STATE", "default" => true), array("id" => "APPROVED", "content" => GetMessage("FM_TITLE_APPROVED"), "sort" => "APPROVED", "default" => true), array("id" => "SORT", "content" => GetMessage("FM_TITLE_SORT"), "sort" => "SORT", "default" => true), array("id" => "USER_START_NAME", "content" => GetMessage("FM_TITLE_AUTHOR"), "sort" => "USER_START_NAME", "default" => true), array("id" => "START_DATE", "content" => GetMessage("FM_TITLE_DATE_CREATE"), "sort" => "START_DATE", "default" => true), array("id" => "POSTS", "content" => GetMessage("FM_TITLE_MESSAGES"), "sort" => "POSTS", "default" => false), array("id" => "VIEWS", "content" => GetMessage("FM_TITLE_VIEWS"), "sort" => "VIEWS", "default" => false), array("id" => "FORUM_ID", "content" => GetMessage("FM_TITLE_FORUM"), "sort" => "FORUM_NAME", "default" => true), array("id" => "LAST_POST_DATE", "content" => GetMessage("FM_TITLE_LAST_MESSAGE"), "sort" => "LAST_POST_DATE", "default" => false)));
/*******************************************************************/
while ($res = $rsData->NavNext(true, "t_")) {
    $row =& $lAdmin->AddRow($t_ID, $res);
    $bCanUpdateForum = CForumTopic::CanUserUpdateTopic($t_ID, $USER->GetUserGroupArray(), $USER->GetID());
    $bCanDeleteForum = CForumTopic::CanUserDeleteTopic($t_ID, $USER->GetUserGroupArray(), $USER->GetID());
    $row->bReadOnly = !$bCanUpdateForum || !$bCanDeleteForum ? true : false;
    $row->AddField("ID", $t_ID);
    $row->AddInputField("TITLE", array("size" => "35"));
    $row->AddInputField("DESCRIPTION", array("size" => "35"));
    if ($t_STATE != "L") {
        $row->AddSelectField("STATE", array("Y" => GetMessage("F_OPEN"), "N" => GetMessage("F_CLOSE")));
    } else {
        $row->AddField("STATE", "Link");
    }
    $row->AddSelectField("APPROVED", array("Y" => GetMessage("F_SHOW"), "N" => GetMessage("F_HIDE")));
    $row->AddSelectField("SORT", array("100" => GetMessage("F_PINN"), "150" => GetMessage("F_UNPINN")));
    $row->AddInputField("USER_START_NAME", array("size" => "20"));
    $row->AddInputField("START_DATE", array("size" => "16"));
    $row->AddField("POSTS", $t_POSTS);
    $row->AddInputField("VIEWS", array("size" => "2"));
Ejemplo n.º 25
0
         break;
     case "MOVE":
         $tmp_message = ForumDataToArray($message);
         $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE_MOVE"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "MID" => implode(",", $tmp_message)));
         break;
     case "MOVE_TOPIC":
         $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_TOPIC_MOVE"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"]));
         break;
 }
 if ($action != "MOVE" && $action != "MOVE_TOPIC") {
     $result = ForumActions($action, $arFields, $strErrorMessage, $strOKMessage);
     if (($action == "REPLY" || $action == "EDIT_TOPIC") && $arParams["AUTOSAVE"]) {
         $arParams["AUTOSAVE"]->Reset();
     }
     if ($action == "DEL") {
         $arFields = CForumTopic::GetByID($arParams["TID"]);
         if (empty($arFields)) {
             $url = CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_LIST"], array("FID" => $arParams["FID"]));
             $action = "del_topic";
         } else {
             $mid = intVal($message);
             if (is_array($message)) {
                 sort($message);
                 $mid = array_pop($message);
             }
             $arFilter = array("TOPIC_ID" => $arParams["TID"], ">ID" => $mid);
             if ($arResult["PERMISSION"] < "Q") {
                 $arFilter["APPROVED"] = "Y";
             }
             $db_res = CForumMessage::GetList(array("ID" => "ASC"), $arFilter, false, 1);
             if ($db_res && ($res = $db_res->Fetch())) {
Ejemplo n.º 26
0
                if ($db_res && ($res = $db_res->Fetch())) {
                    do {
                        if (is_set($arResult["~QUESTIONS"], $res["QUESTION_ID"])) {
                            $arResult["~QUESTIONS"][$res["QUESTION_ID"]]["ANSWERS"][$res["ID"]] = $res;
                        }
                    } while ($res = $db_res->Fetch());
                }
            }
            $arResult["QUESTIONS"] = $arResult["~QUESTIONS"];
        }
    } else {
        $arError[] = array("id" => "mid_is_lost", "text" => GetMessage("F_MID_IS_LOST"));
    }
}
/************** Permission *****************************************/
if ($arParams["MESSAGE_TYPE"] == "NEW" && !CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), false, $arParams["PERMISSION"])) {
    $arError[] = array("id" => "acces denied", "text" => GetMessage("F_NO_NPERMS"));
} elseif ($arParams["MESSAGE_TYPE"] == "EDIT" && !CForumMessage::CanUserUpdateMessage($arParams["MID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"])) {
    $arError[] = array("id" => "acces denied", "text" => GetMessage("F_NO_EPERMS"));
}
/************** Fatal Errors ***************************************/
if (!empty($arError)) {
    $e = new CAdminException($arError);
    $res = $e->GetString();
    ShowError($res);
    return false;
}
/*******************************************************************/
$strErrorMessage = "";
$strOKMessage = "";
$bVarsFromForm = false;
Ejemplo n.º 27
0
    ShowError($res);
    return false;
}
/********************************************************************
				/Main Data & Permissions
********************************************************************/
/********************************************************************
				Default params # 2
********************************************************************/
$arResult["MESSAGE_FIRST"] = array();
$arResult["MESSAGE_LIST"] = array();
$arResult["MESSAGE_VIEW"] = array();
$arResult["VIEW"] = "N";
$bVarsFromForm = false;
/************** Current User ***************************************/
$arResult["USER"] = array("INFO" => array(), "PERMISSION" => $arParams["PERMISSION"], "RIGHTS" => array("ADD_TOPIC" => CForumTopic::CanUserAddTopic($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arResult["FORUM"], $arParams["PERMISSION"]) ? "Y" : "N", "MODERATE" => CForumNew::CanUserModerateForum($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) == true ? "Y" : "N", "EDIT" => CForumNew::CanUserEditForum($arParams["FID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) ? "Y" : "N", "ADD_MESSAGE" => CForumMessage::CanUserAddMessage($arParams["TID"], $USER->GetUserGroupArray(), $USER->GetID(), $arParams["PERMISSION"]) ? "Y" : "N"), "SUBSCRIBE" => array(), "SHOW_NAME" => $GLOBALS["FORUM_STATUS_NAME"]["guest"]);
// to avoid forum module permissions extension for admin
if ($arParams["PERMISSION"] <= "E") {
    $arResult["USER"]["RIGHTS"] = array("ADD_TOPIC" => "N", "MODERATE" => "N", "EDIT" => "N", "ADD_MESSAGE" => "N");
}
if ($USER->IsAuthorized()) {
    $arResult["USER"]["INFO"] = CForumUser::GetByUSER_ID($USER->GetParam("USER_ID"));
    $arResult["USER"]["SHOW_NAME"] = $_SESSION["FORUM"]["SHOW_NAME"];
    $arResult["USER"]["RANK"] = CForumUser::GetUserRank($USER->GetParam("USER_ID"));
    $db_res = CForumSubscribe::GetList(array(), array("USER_ID" => $USER->GetID(), "FORUM_ID" => $arParams["FID"], "TOPIC_ID" => $arParams["TID"], "SITE_ID" => SITE_ID));
    if ($db_res && ($res = $db_res->Fetch())) {
        $arResult["USER"]["SUBSCRIBE"][$res["ID"]] = $res;
    }
}
/*******************************************************************/
$arResult["PANELS"] = array("MODERATE" => $arResult["USER"]["RIGHTS"]["MODERATE"], "DELETE" => $arResult["USER"]["RIGHTS"]["EDIT"], "SUPPORT" => IsModuleInstalled("support") && $APPLICATION->GetGroupRight("forum") >= "W" ? "Y" : "N", "EDIT" => $arResult["USER"]["RIGHTS"]["EDIT"], "STATISTIC" => IsModuleInstalled("statistic") && $APPLICATION->GetGroupRight("statistic") > "D" ? "Y" : "N", "MAIN" => $APPLICATION->GetGroupRight("main") > "D" ? "Y" : "N", "MAIL" => $APPLICATION->GetGroupRight("mail") > "R" ? "Y" : "N");
Ejemplo n.º 28
0
 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);
                 }
             }
         }
     }
 }
Ejemplo n.º 29
0
    foreach ($arForum["TOPICS"] as $arTopic) {
        $arTopic["FORUM_ID"] = $forumID;
        $topicID = CForumTopic::Add($arTopic);
        if ($topicID < 1 || !isset($arTopic["MESSAGES"]) || !is_array($arTopic["MESSAGES"])) {
            continue;
        }
        foreach ($arTopic["MESSAGES"] as $arMessage) {
            $arMessage["FORUM_ID"] = $forumID;
            $arMessage["TOPIC_ID"] = $topicID;
            $messageID = CForumMessage::Add($arMessage, false);
            if ($messageID < 1) {
                CForumTopic::Delete($topicID);
                continue 2;
            }
        }
        CForumTopic::SetStat($topicID);
    }
}
$fidParameter = "";
$dbForum = CForumNew::GetList(array(), array("SITE_ID" => WIZARD_SITE_ID));
while ($arForum = $dbForum->Fetch()) {
    if ($arForum["FORUM_GROUP_ID"] != $arGroupID["HIDDEN"] && $arForum["FORUM_GROUP_ID"] != $arGroupID["COMMENTS"]) {
        $fidParameter .= $arForum["ID"] . ",";
    }
}
$fidParameter = rtrim($fidParameter, ",");
$forum_theme = 'blue';
switch (WIZARD_THEME_ID) {
    case 'green':
        $forum_theme = "green";
        break;
Ejemplo n.º 30
0
	array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "MID" => "s"));
$arResult["URL"] = array(
	"LIST" => $arResult["list"],
	"~LIST" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_LIST"], array("FID" => $arParams["FID"])),
	"READ" => $arResult["read"],
	"~READ" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_READ"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"], "MID" => "s")),
	"MODERATE_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["URL_TEMPLATES_MESSAGE_APPR"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"])),
	"~MODERATE_MESSAGE" => CComponentEngine::MakePathFromTemplate($arParams["~URL_TEMPLATES_MESSAGE_APPR"], array("FID" => $arParams["FID"], "TID" => $arParams["TID"])),
);

$parser = new forumTextParser(LANGUAGE_ID, $arParams["PATH_TO_SMILE"]);
$parser->MaxStringLen = $arParams["WORD_LENGTH"];
$arAllow = forumTextParser::GetFeatures($arResult["FORUM"]);

if ($arParams["TID"] > 0):
	$res = CForumTopic::GetByID($arParams["TID"]);
	if ($res)
		$arResult["TOPIC"] = $res;
	else
		$arParams["TID"] = 0;
endif;
/********************************************************************
				Action
********************************************************************/
if (check_bitrix_sessid())
{
	$arError = array();
	$strOKMessage = "";

	if ($_SERVER['REQUEST_METHOD'] == "POST"):
		$message = (empty($_POST["MID_ARRAY"]) ? $_POST["MID"] : $_POST["MID_ARRAY"]);