/** * Сохранение Блоги: посты и комментарии * * @param object $objResponse xajaxResponse * @param string $rec_id идентификатор записи * @param string $rec_type тип записи * @param array $aForm массив данных * @param string $sDrawFunc имя функции для выполнения после сохранения */ function _admEditBlogsSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '') { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/blogs.php'; $mod = hasPermissions('blogs') ? 0 : 1; $alert = array(); $olduserlogin = $aForm['olduserlogin']; // логин автора блога $close_comments = $aForm['close_comments'] ? 't' : 'f'; // запретить комментирование $is_private = $aForm['is_private'] ? 't' : 'f'; // показывать только мне $ontop = $aForm['ontop'] ? 't' : 'f'; // закрепить тему наверху $categ = change_q_x($aForm['category'], true); // раздел $close_comments = $rec_type == 2 ? 'n' : $close_comments; $is_private = $rec_type == 2 ? 'n' : $is_private; list($gr, $t) = explode('|', $categ); // название, текст if (strlen($aForm['msg']) > blogs::MAX_DESC_CHARS) { $error_flag = 1; $alert[1] = 'Максимальный размер сообщения ' . blogs::MAX_DESC_CHARS . ' символов!'; } $msg = change_q_x(antispam($aForm['msg']), false, false, 'b|br|i|p|ul|li|cut|s|h[1-6]{1}', false, false); $name = substr_entity(change_q_x(antispam($aForm['name']), true, false), 0, 96, true); // ссылка на youtube $yt_link = $aForm['yt_link'] ? $aForm['yt_link'] : ''; if ($yt_link != '') { $v_yt_link = video_validate($yt_link); if (!$v_yt_link) { $alert[4] = 'Неверная ссылка.'; } else { $yt_link = $v_yt_link; } } // опросы $question = substr_entity(change_q_x(antispam(trim((string) $aForm['question'])), false, false, ''), 0, blogs::MAX_POLL_CHARS, true); $multiple = (bool) $aForm['multiple']; $answers = array(); $answers_exists = array(); $i = 0; if (is_array($aForm['answers']) && !empty($aForm['answers'])) { foreach ($aForm['answers'] as $pa) { if (trim((string) $pa) !== '') { $answers[] = substr_entity(change_q_x(antispam(preg_replace('/&/', '&', (string) trim($pa))), false, false, ''), 0, blogs::MAX_POLL_ANSWER_CHARS * 2, true); $i++; } } } if (is_array($aForm['answers_exists']) && !empty($aForm['answers_exists'])) { foreach ($aForm['answers_exists'] as $key => $pa) { if (trim((string) $pa) !== '') { $answers_exists[$key] = substr_entity(change_q_x(antispam(preg_replace('/&/', '&', (string) trim($pa))), false, false, ''), 0, blogs::MAX_POLL_ANSWER_CHARS * 2, true); $i++; } } } if ($i > 0 && $question === '') { $alert[5] = 'Введите текст вопроса'; } else { if ($i > blogs::MAX_POLL_ANSWERS) { $alert[5] = 'Вы можете указать максимум ' . blogs::MAX_POLL_ANSWERS . ' отетов'; } else { if ($i < 2 && $question !== '') { $alert[5] = 'Нужно указать минимум 2 варианта ответа в голосовании'; } } } // файлы $files_session = $aForm['attachedfiles_session']; if (!$files_session) { $attachedfiles = new attachedfiles('', true); $asid = $attachedfiles->createSessionID(); $attachedfiles->addNewSession($asid); $files_session = $asid; } else { $attachedfiles = new attachedfiles($files_session); $asid = $files_session; } $files_info = $attachedfiles->calcFiles(); if ($msg === '' && $question === '' && empty($alert[5]) && !$files_info['count'] && $yt_link === '') { $alert[1] = 'Сообщение не должно быть пустым'; } if (!$alert) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php'; $blogs = new blogs(); $blogs->Edit($_SESSION['uid'], $rec_id, $msg, $name, array(), getRemoteIP(), $err, $mod, '', $gr, $t, array(), $olduserlogin, $yt_link, $close_comments, $is_private, $ontop, null, $question, $answers, $answers_exists, $multiple); $files = $attachedfiles->getFiles(array(1, 3, 4)); $blogs->addAttachedFiles($files, $rec_id, $olduserlogin, false); $attachedfiles->clear(); $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']); messages::blogModifiedNotification($rec_type, $aForm['oldusertitle'], $aForm['post_time'], $aForm['user_name'], $aForm['user_surname'], $olduserlogin, $sReason); $content_id = user_content::MODER_BLOGS; _admEditAfterAll($objResponse, $content_id, $rec_id, $rec_type, $sDrawFunc, $aForm); } else { _setErrors($objResponse, $alert, array(1 => 'msg', 4 => 'yt_link', 5 => 'question'), $sDrawFunc); } }
$asid = $attachedfiles->createSessionID(); $attachedfiles->addNewSession($asid); $attachedfiles_session = $asid; } else { $attachedfiles = new attachedfiles($attachedfiles_session); $asid = $attachedfiles_session; } $attachedfiles_info = $attachedfiles->calcFiles(); if ($attachedfiles_session) { $countfiles = 0; } if ($msg === '' && $question === '' && empty($alert[5]) && !($countfiles || $attachedfiles_info['count']) && $yt_link === '') { $error_flag = 1; $alert[2] = 'Ошибка. Сообщение не должно быть пустым!'; } elseif (!$error && !$error_flag && ($msg !== '' || $attach['name'] || $attach_have || $attach_delete || $question || $yt_link || $attachedfiles_info['count'])) { $blog_obj->Edit($_SESSION['uid'], $thread, $msg, $msg_name, $files, getRemoteIP(), $err, $mod, NULL, $gr, $t, $attach_delete, $olduserlogin, $yt_link, $close_comments, $is_private, $ontop, null, $question, $answers, $answers_exists, $multiple); //$nStopWordsCnt = $stop_words->calculate( $msg, $msg_name, $question, $answers, $answers_exists ); $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4)); $blog_obj->addAttachedFiles($attachedfiles_files, $thread, $olduserlogin, $draft_id ? true : false); $attachedfiles->clear(); //$blog_obj->insertIntoModeration( $thread, $nStopWordsCnt ); // больше не модерируем if ($err) { $alert = $alert + $err; } if ($draft_id && !($alert || $error || $error_flag)) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/drafts.php'; drafts::DeleteDraft($draft_id, get_uid(false), 3, true); } } if ($site == 'journal') { unset($_SESSION['user.journal.change.result']);