Пример #1
0
 public static function MakeRead($ID)
 {
     global $DB;
     $ID = IntVal($ID);
     $version = intVal(COption::GetOptionString("forum", "UsePMVersion", "2"));
     if ($ID > 0) {
         $db_res = CForumPrivateMessage::GetListEx(array(), array("ID" => $ID));
         if ($db_res && ($resFields = $db_res->Fetch()) && $resFields["IS_READ"] != "Y") {
             foreach (GetModuleEvents("forum", "onBeforePMMakeRead", true) as $arEvent) {
                 if (ExecuteModuleEventEx($arEvent, array($ID, &$resFields)) === false) {
                     return false;
                 }
             }
             $strSql = "UPDATE b_forum_private_message SET IS_READ='Y' WHERE ID=" . $ID;
             $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
             if ($version == 1 && $resFields["IS_READ"] == "N") {
                 $resFields = array_merge($resFields, array("USER_ID" => $resFields["AUTHOR_ID"], "FOLDER_ID" => 3, "IS_READ" => "Y"));
                 $resFields["REQUEST_IS_READ"] = $resFields["REQUEST_IS_READ"] != "Y" ? "N" : "Y";
                 if (CForumPrivateMessage::CheckFields($resFields, "E")) {
                     unset($resFields["ID"]);
                     return $DB->Add("b_forum_private_message", $resFields, array("POST_MESSAGE"));
                 }
             }
         }
     }
     return false;
 }