/** * Редактировать комментарий * * @param integer $id ИД редактируемого комментария * @return array [коды ошибок, описание ошибок] (по умолчанию оба занчения null) */ function editComment($id) { $DB = new DB('master'); $blog = $_POST['blogID']; $user = get_uid(); $IDEdit = $id; //intval($this->uri[3]); $alert = array(); $deleted_attach = $_POST['editattach']; if ($deleted_attach) { foreach ($deleted_attach as $key => $val) { if ($val == 1) { front::og("db")->delete("DELETE FROM corporative_blog_attach WHERE id = ?n", $key); } } } if (strlen($_POST['msg']) > blogs::MAX_DESC_CHARS) { $error_flag = 1; $alert[2] = "Максимальный размер сообщения " . blogs::MAX_DESC_CHARS . " символов!"; $msg =& $_POST['msg']; } else { $msg = $_POST['msg']; $msg = preg_replace("/<ul.*>/Ui", "<ul>", $msg); $msg = preg_replace("/<li.*>/Ui", "<li>", $msg); $msg = change_q_x_a(antispam($msg), false, false); } $msg_name = substr(change_q_x(antispam($_POST['title']), true), 0, 96); $yt_link = substr(change_q_x(antispam(str_replace('watch?v=', 'v/', $_POST['yt_link'])), true), 0, 128); if ($yt_link != '') { if (strpos($yt_link, 'http://ru.youtube.com/v/') !== 0 && strpos($yt_link, 'http://youtube.com/v/') !== 0 && strpos($yt_link, 'http://www.youtube.com/v/') !== 0) { $error_flag = 1; $alert[4] = "Неверная ссылка."; } } if (is_empty_html($msg)) { $msg = ''; } // загрузка файлов $attach = $_FILES['attach']; if (is_array($attach) && sizeof($attach) <= 10) { if (is_array($attach) && !empty($attach['name'])) { foreach ($attach['name'] as $key => $v) { if (!$attach['name'][$key]) { continue; } $files[] = new CFile(array('name' => $attach['name'][$key], 'type' => $attach['type'][$key], 'tmp_name' => $attach['tmp_name'][$key], 'error' => $attach['error'][$key], 'size' => $attach['size'][$key])); } } if ($group == 7) { $max_image_size = array('width' => 400, 'height' => 600, 'less' => 0); } else { $max_image_size = array('width' => 470, 'height' => 1000, 'less' => 0); } list($files, $alert_, $error_flag___) = self::uploadFile($files, $max_image_size); $error_flag = max($error_flag___, $error_flag); if (is_array($alert_)) { $alert = array_merge($alert, $alert_); } } else { if (is_array($attach) && !empty($attach['name'])) { $error_flag = 1; $alert[2] = "Файлов не должно быть больше 10"; } } if (!$msg && !count($files)) { $error_flag = 1; $alert[2] = "Поле заполнено некорректно"; } if (($msg || $files['f_name'][0]) && get_uid() && !$error_flag) { $upd = array("title" => $msg_name, "yt_link" => $yt_link, "msg" => $msg, "id_modified" => get_uid(), "id_deleted" => 0, "date_change" => date("Y-m-d H:i:s")); front::og("db")->update("UPDATE corporative_blog SET ?s WHERE (id = ?n)", $upd, $IDEdit); if (is_array($files)) { $asql = ''; for ($i = 0; $i < count($files['f_name']); $i++) { if ($files['f_name'][$i]) { $asql .= ", ({$IDEdit}, '{$files['f_name'][$i]}', '{$files['tn'][$i]}')"; } } if ($asql) { $asql = substr($asql, 2); } } if ($asql) { $DB->query("INSERT INTO corporative_blog_attach(msg_id, \"name\", small) VALUES {$asql}"); } $tags = $_POST['tags']; if ($tags) { $tags_arr = $tags; //explode(",", $tags); array_unique($tags_arr); $this->tagsDelete($IDEdit); $tg = tags::Add($tags_arr); $this->tagsAdd($IDEdit, $tg); } } front::og("tpl")->ederror_flag = $error_flag; front::og("tpl")->edalert = $alert; front::og("tpl")->edpost = array("blog" => $blog, "user" => $user, "parent" => $parent, "msg" => $msg, "title" => $msg_name, "yt_link" => $yt_link); return array($error_flag, $error); }