} } else { $yt_link = null; } // загрузка файлов $files = array(); $attach = $_FILES['attach']; 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])); } } list($att, $uperr, $error_flag) = $comments->UploadFiles($files, array('width' => 390, 'height' => 1000, 'less' => 0), $comment['login']); if ($uperr) { $alert[2] = $uperr; } if (isset($_POST['rmattaches']) && is_array($_POST['rmattaches'])) { $comments->removeAttaches($reply, $_POST['rmattaches']); } if (!isset($alert)) { $comments->Update($reply, $uid, $msg, $yt_link, $att, count($_POST['attaches']), $err, $tn); $q = array(); parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $q); $q['goto'] = $reply; header('Location: ./' . url($GET, $q, true, '?')); exit; } break;
/** * Редактирование комментария * * @param integer $type Тип группы комментариев * @param integer $id id комментария * @param integer $user_id uid пользователя, комментарий которого редактируем * @param integer $moder_uid uid пользователя, который редактирует * @param string $title заголовок комментария (если есть у группы) * @param string $msg сообщение * @param array $attaches массив с новыми файлами (объекты CFile) * @param array $rmattaches массив с данными для удаления файлов. содержит поля: * array(attach_id: id файлы во внутренней таблице сервиса; file_id: id файла в таблице file; name: имя файла * @param string $yt_link ссылка на Youtube/Rutube/etc... * @return string Возможная ошибка */ public function Edit($type, $id, $user_id, $moder_uid, $title, $msg, $attaches, $rmattaches, $yt_link) { global $DB; $error = ''; switch ($type) { case self::T_ARTICLES: $comments = new articles_comments(); $rmfiles = FALSE; if (!empty($rmattaches)) { $rmfiles = array(); for ($i = 0; $i < count($rmattaches); $i++) { $rmfiles[] = $rmattaches[$i]['file_id']; } $comments->removeAttaches($id, $rmfiles); } if ($attaches) { $user = new users(); $user->GetUserByUID($user_id); list($att, $error, $error_flag) = $comments->UploadFiles($attaches, array('width' => 390, 'height' => 1000, 'less' => 0), $user->login); } if (empty($error)) { $comments->Update($id, $moder_uid, $msg, $yt_link, $att, 0, $error, array()); } break; } return $error; }