/** * Добавляет жалобу на проект. * * @param integer $project_id ID проекта * @param integer $user_id ID пользователя * @param integer $type тип жалобы * @param string $msg текст жалобы * @param string $files имена загруженных скриншотов * * @return xajax responce */ function SendComplain($project_id, $type, $msg, $files) { global $session; session_start(); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_complains.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/userecho.php'; $objResponse = new xajaxResponse(); $project_id = (int) $project_id; $user_id = get_uid(false); $type = (int) $type; $msg = __paramValue('htmltext', $msg); $error = false; $project = new projects(); $prj = $project->GetPrj(0, $project_id, 1); $file_list = array(); if ($files != '') { $files = uploader::sgetFiles($files); if (!empty($files)) { $emp = new users(); $emp->GetUser($emp->GetField($prj['user_id'], $ee, 'login')); $dir = 'users/' . substr($emp->login, 0, 2) . '/' . $emp->login . '/upload/'; foreach ($files as $file) { $copy = uploader::remoteCopy($file['id'], 'file_projects', $dir); $rfiles[] = $copy->name; $file_list[] = array('name' => $copy->original_name, 'link' => WDCPREFIX . '/' . $copy->path . $copy->name); } $files = implode(',', $rfiles); } else { $files = ''; } } if (!$files) { $files = ''; } if (projects::IsHaveComplainType($project_id, $user_id, $type)) { // Уже жаловался return $objResponse; } $projects_complains = new projects_complains(); $type_name = $projects_complains->GetComplainType($type); $project_url = getAbsUrl(getFriendlyURL('project', $project_id)); $is_moder = $projects_complains->isComplainTypeModer($type); if ($is_moder) { $userEcho = new UserEcho(); $topic_message = $userEcho->constructMessage($project_url, $prj['name'], $msg, $file_list); $topicUrl = $userEcho->newTopicComplain($type_name, $topic_message, $file_list); if ($topicUrl) { messages::sendProjectComplain($user_id, $project_url, $prj['name'], $msg, $topicUrl); } else { $error = true; } } if (!$error) { $error = projects::AddComplain($project_id, $user_id, $type, $msg, $files, $is_moder && $topicUrl); } if ($error) { $objResponse->script("\$('abuse_project_popup').toggleClass('b-shadow_hide');"); if ($is_moder) { $objResponse->script("\$('abuse-cause-error').removeClass('b-layout__txt_hide'); abuseResetSelection();"); } else { $objResponse->script("\$\$('.abuse-btn-send').removeClass('b-button_rectangle_color_disable')"); } } else { $upl = array('umask' => uploader::umask('prj_abuse'), 'validation' => array('allowedExtensions' => array('jpg', 'gif', 'png', 'jpeg'), 'restrictedExtensions' => array()), 'text' => array('uploadButton' => iconv('cp1251', 'utf8', 'Прикрепить файлы'))); $objResponse->script("\n \$('abuse{$type}').addClass('abuse-checked');\n \$('abuse{$type}').getChildren().each(function(el) { \$(el).addClass('abuse-checked'); });\n "); $objResponse->script("uploader.create('abuse_uploader', " . json_encode($upl) . ');'); $objResponse->script("\$('prj_abuse_msg').set('value', '')"); $objResponse->script("\$\$('.abuse-btn-send').removeClass('b-button_disabled')"); $objResponse->script("\$('abuse_project_popup').toggleClass('b-shadow_hide');"); $objResponse->script("\$('project_abuse_success').removeClass('b-layout__txt_hide');"); $objResponse->script("\$('form_abuse').hide();"); $objResponse->script("setTimeout(\"\$('project_abuse_success').addClass('b-layout__txt_hide')\", 5000);"); if ($is_moder) { $objResponse->script("\$('abuse-cause-error').addClass('b-layout__txt_hide');"); } } return $objResponse; }
public function editWork($uid, $params) { global $DB; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/uploader/uploader.php'; $params = self::prepareWork($params); $error = self::validateWork($params); $work_id = $params['id']; if (!empty($error)) { return $error; } $update = array('link' => $params['link'], 'name' => antispam($params['work_name']), 'descr' => antispam($params['work_descr']), 'cost' => $params['work_cost'], 'cost_type' => $params['work_cost_type_db_id'], 'time_value' => $params['time_cost'], 'time_type' => $params['work_time_type_db_id'], 'prev_type' => $params['work_preview_type'], 'prof_id' => $params['work_category_db_id']); if ($params['video'] != '') { $video_link = video_validate($params['video']); $video_link = preg_replace("/^http:\\/\\//", '', $video_link); $update['video_link'] = $video_link; $update['is_video'] = true; } else { $update['video_link'] = ''; $update['is_video'] = false; } if ($uid == $_SESSION['uid'] && !hasPermissions('users')) { // автор, не админ, не про меняет заголовок либо текст - отправить на модерирование $update['moderator_status'] = !is_pro() ? '0' : '-2'; } if ($params['position_num'] !== NULL) { $update['norder'] = intval($params['position_num']); } $dir = 'users/' . substr($_SESSION['login'], 0, 2) . "/{$_SESSION['login']}/upload/"; if (isset($params['IDResource']) && is_array($params['IDResource'])) { foreach ($params['IDResource'] as $resource) { $resources[uploader::sgetTypeUpload($resource)] = $resource; } if (isset($resources['portfolio'])) { $mainFile = current(uploader::sgetFiles($resources['portfolio'])); if (!empty($mainFile)) { // Если что-то загрузили и не удаляли $MFile = uploader::remoteCopy($mainFile['id'], 'file', $dir, false); uploader::sclear($resources['portfolio']); // Делаем отдельное привью из оригинальной большой картинки -- @todo ХЗ зачем но раньше так делали if (in_array($MFile->getext(), $GLOBALS['graf_array']) && $MFile->getext() != 'swf') { $MFile->resizeImage($dir . 'tn_' . $MFile->name, self::PREVIEW_MAX_WIDTH, self::PREVIEW_MAX_HEIGHT, 'auto', true); } $update['pict'] = $MFile->name; $is_remove_main_file = true; } } if (isset($resources['pf_preview'])) { $preview = current(uploader::sgetFiles($resources['pf_preview'])); if (!empty($preview)) { // Если что-то загрузили и не удаляли $PFile = uploader::remoteCopy($preview['id'], 'file', $dir, false, 'sm_f_'); uploader::sclear($resources['pf_preview']); $update['prev_pict'] = $PFile->name; $is_remove_preview_file = true; } } } if ($params['main_file'] == '' && !isset($MFile)) { // Удаляем файл $update['pict'] = ''; $is_remove_main_file = true; } if ($params['preview_file'] == '' && !isset($PFile)) { // Удаляем файл $update['prev_pict'] = ''; $is_remove_preview_file = true; } if ($is_remove_main_file) { $cf = new CFile(); $cf->Delete(0, $dir, $params['old_main_file']); // удаляем ранее загруженный файл } if ($is_remove_preview_file) { $cf = new CFile(); $cf->Delete(0, $dir, $params['old_preview_file']); // удаляем ранее загруженный файл } if (empty($error)) { $wmodeAllowValues = array('direct', 'gpu', 'window'); if (!in_array($params['wmode'], $wmodeAllowValues)) { $params['wmode'] = 'window'; } if ($work_id) { $update['edit_date'] = 'NOW()'; $result = $DB->update('portfolio', $update, 'id = ?i AND user_id = ?i', $work_id, $uid); } else { $update['user_id'] = $uid; $result = $DB->insert('portfolio', $update, 'id'); $work_id = $result; } if ($MFile && $MFile->getext() == 'swf' && $MFile->id) { $res = $DB->query('UPDATE swf_file_params SET wmode = ?, table_name = ? WHERE fid = ?i', $params['wmode'], $MFile->table, $MFile->id); if (pg_affected_rows($res) == 0) { $res = $DB->query('INSERT INTO swf_file_params (fid, wmode, table_name) VALUES(?i, ?, ?)', $MFile->id, $params['wmode'], $MFile->table); } } else { if (!$MFile) { $ext = preg_replace("#.*(\\.[a-zA-Z0-9]*)\$#", '$1', $params['main_file']); if (strtolower($ext) == '.swf') { $res = $DB->query('UPDATE swf_file_params SET wmode = ? WHERE fid = (SELECT id FROM file WHERE fname = ?)', $params['wmode'], $params['main_file']); if (pg_affected_rows($res) == 0) { $res = $DB->query('INSERT INTO swf_file_params (fid, wmode, table_name) VALUES( ( SELECT id FROM file WHERE fname = ?) , ?, ?)', $params['main_file'], $params['wmode'], 'file'); } } } } } else { return $error; } if ($work_id && $result && !is_pro()) { /*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php' ); require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php' ); $stop_words = new stop_words(); $nStopWordsCnt = $stop_words->calculate($update['name'], $update['descr']); $DB->insert('moderation', array('rec_id' => $work_id, 'rec_type' => user_content::MODER_PORTFOLIO, 'stop_words_cnt' => $nStopWordsCnt));*/ } return $result; }
} } } else { $sess_p = uploader::createResource('tupreview'); } //------------------------------------------------------------------------------ //Прикрепленные файлы $uploader_field_element = array(); if (count($tservice->images)) { foreach ($tservice->images as $key => $image) { $uploader_field_element[] = array('hash' => md5($solt . $image['id'] . $tuid . $uid), 'qquuid' => $image['id'], 'src' => WDCPREFIX . '/' . $image['path'] . $image['fname']); } } $sess = __paramInit('string', NULL, 'uploader_sess', NULL); if ($sess) { $files = uploader::sgetFiles($sess); if (count($files)) { foreach ($files as $file) { if (strpos($file['fname'], 'tiny_') === FALSE) { continue; } $uploader_field_element[] = array('qquuid' => $file['id'], 'src' => WDCPREFIX . '/' . $file['path'] . $file['fname']); } } } else { $sess = uploader::createResource('tservices'); } //------------------------------------------------------------------------------ $city = new city(); if (!$tservice->city) { $tservice->city = $user_obj->city > 0 ? $user_obj->city : 1;
/** * Возвращает опции текущей сессии необходимые для инициализации загрузчка на стороне клиента * * @param string $resource Сессия загрузчика * @return array */ static function sgetLoaderOptions($resource) { $option = array('items' => uploader::sgetFiles($resource), 'resource' => $resource); $option = self::encodeCharset($option); $type = self::sgetTypeUpload($resource); $valid = self::getValidationInfo('project'); switch ($type) { case 'project': case 'guest_prj': $setting = array('showGraph' => false, 'text' => array('uploadButton' => self::encodeCharset('+ Добавить файл'), 'sufSize' => ''), 'validation' => array('sizeLimit' => $valid['max_file_size'])); break; default: $setting = array(); break; } $option = array_merge($option, $setting); return $option; }