if ($user_obj->setUserBan(get_uid(), 0, $sReason, 4, '', 1, true)) { // если удалось заблокировать аккаунт // пишем лог admin_log::addLog(admin_log::OBJ_CODE_USER, admin_log::ACT_ID_DEL_ACC, $sUid, $sUid, $sObjName, $sObjLink, 1, '', null, $sReason); header("Location: /users/{$user}"); } break; case 'real_name_splash': // сохранение имени, фамилии и юзерпика с соответствующего сплэш-скрина require_once ABS_PATH . "/classes/users.php"; require_once ABS_PATH . "/classes/attachedfiles.php"; require_once ABS_PATH . "/classes/CFile.php"; $userObj = new users(); $userID = get_uid(); $aFiles = new attachedfiles($_POST['attachedfiles_session']); $userpics = $aFiles->getFiles(array(1)); if (is_array($userpics) && !empty($userpics)) { $userpic = array_pop($userpics); $aFiles->setStatusTo3($userpic['id']); $foto = new CFile($userpic['id']); $to = $foto->path . 'sm_' . $foto->name; $foto->resizeImage($to, 50, 50, 'auto', true); $userObj->photo = $userpic['name']; } $name = change_q(substr(trim($_POST['name']), 0, 21), true); $surname = change_q(substr(trim($_POST['surname']), 0, 21), true); if ($name && !preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $name)) { $error_flag = 1; $alert[1] = "Поле заполнено некорректно"; } if ($surname && !preg_match("/^[-a-zA-Zа-яёА-ЯЁ]+\$/", $surname)) {
/** * формирует превью проекта на главной странице. */ function GetPreview($data) { $objResponse = new xajaxResponse(); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/CFile.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/HTML/projects_lenta.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/memBuff2.php'; $kind = 1; $memBuff = new memBuff(); $htmlLenta = $memBuff->get('projectsLentaHTML'); if (!$htmlLenta) { $prj = new new_projects(); $prjs = $prj->getProjects($num_prjs, -1, 1, false, null, true); foreach ($prjs as &$proj) { // стираем принадлежность проекта к пользователю, чтобы не появилось кнопок РЕДАКТИРОВАТЬ и пр. unset($proj['user_id']); } unset($proj); $htmlPrj = new HTMLProjects(); $htmlPrj->template = '/projects/tpl.lenta.new.php'; $prj_content = $htmlPrj->ShowProjects($num_prjs, $prjs, 1, 1, null, true); $prfs = new professions(); $profs = $prfs->GetAllProfessions('', 0, 1); // подложка с лентой проектов ob_start(); include $_SERVER['DOCUMENT_ROOT'] . '/templates/main.php'; $htmlLenta = ob_get_clean(); // кэшируем ленту проектов $memBuff->set('projectsLentaHTML', $htmlLenta, 1800); } // подготавливаем данные для шаблона в ленту проектов $row = array(); $row['kind'] = __paramValue('int', $data['kind']); $row['cost'] = __paramValue('int', $data['cost']); $row['currency'] = __paramValue('int', $data['currency_db_id']); $row['priceby'] = __paramValue('int', $data['priceby_db_id']); $row['name'] = stripslashes(__paramValue('html', $data['name'], null, true)); $contacts = array('phone' => array('name' => 'Телефон', 'value' => ''), 'site' => array('name' => 'Сайт', 'value' => ''), 'icq' => array('name' => 'ICQ', 'value' => ''), 'skype' => array('name' => 'Skype', 'value' => ''), 'email' => array('name' => 'E-mail', 'value' => '')); if (isset($data['contacts'])) { foreach ($data['contacts'] as $name => $value) { if (!isset($contacts[$name])) { continue; } switch ($name) { case 'site': if (!url_validate(ltrim(ltrim($value, 'http://'), 'https://')) && trim($value) != '') { $error["contact_{$name}"] = 'Поле заполнено некорректно'; } if (strpos($value, 'htt') === false && trim($value) != '') { $value = 'http://' . $value; } break; case 'email': if (!is_email($value) && trim($value) != '') { $error["contact_{$name}"] = 'Поле заполнено некорректно'; } break; } $contacts[$name]['value'] = __paramValue('htmltext', stripslashes($value)); } $row['contacts'] = serialize($contacts); } $descrFull = stripslashes(__paramValue('html', $data['descr'], null, true)); $descr = preg_replace('/^ /', "", $descrFull); $descr = preg_replace("/(\n) /", "\$1", $descr); $descr = reformat(strip_tags(htmlspecialchars(LenghtFormatEx(htmlspecialchars_decode($descr, ENT_QUOTES), 180), ENT_QUOTES), '<br />'), 50, 1, 0, 1); $descr = preg_replace("//", ' ', $descr); $row['descr'] = $descr; $row['t_is_payed'] = $data['logo_ok'] || $data['top_ok']; $row['t_is_ontop'] = __paramValue('bool', $data['top_ok']); $row['t_pro_only'] = $data['pro_only'] ? 't' : 'f'; $row['t_verify_only'] = $data['verify_only'] ? 't' : 'f'; $row['t_urgent'] = $data['urgent'] ? 't' : 'f'; $row['t_hide'] = $data['hide'] ? 't' : 'f'; $row['create_date'] = date('Y-m-d H:i', strtotime(date('Y-m-d H:i:s')) - 120); // делаем дату публикации 2 минуты назад $row['end_date'] = __paramValue('string', $data['end_date']); $row['win_date'] = __paramValue('string', $data['win_date']); $row['country'] = __paramValue('int', $data['project_location_columns'][0]); $row['city'] = __paramValue('int', $data['project_location_columns'][1]); list($row['country_name'], $row['city_name']) = explode(': ', __paramValue('string', $data['location'])); $logoOK = __paramValue('bool', $data['logo_ok']); $topOK = __paramValue('bool', $data['top_ok']); $row['link'] = __paramValue('string', $data['link']); if ($logoOK) { $logoAttach = new attachedfiles($data['logo_attachedfiles_session']); $logoFiles = $logoAttach->getFiles(array(1)); if (count($logoFiles)) { $logoFile = array_pop($logoFiles); // загружено может быть несколько файлов, берем последний $logoCFile = new CFile($logoFile['id']); } elseif (__paramValue('int', $data['logo_file_id'])) { $logoCFile = new CFile(__paramValue('int', $data['logo_file_id'])); } $row['logo_name'] = $logoCFile->name; $row['logo_path'] = $logoCFile->path; } $is_ajax = true; // подготовка данных для подробной страницы проекта $project = $row; $categories = array(); for ($i = 0; $i < 3; ++$i) { $categoryID = __paramValue('int', $data['project_profession' . $i . '_columns'][0]); $subcategoryID = __paramValue('int', $data['project_profession' . $i . '_spec_columns'][0]); if ($categoryID || $subcategoryID) { $categories[] = array('category_id' => $categoryID, 'subcategory_id' => $subcategoryID); } } $project['spec_txt'] = projects::_getSpecsStr($categories, ' / ', ', ', true); $project['ico_payed'] = $logoOK; $project['is_upped'] = $topOK; $project['descr'] = $descrFull; $project['logo_id'] = $logoCFile->id; $project['prefer_sbr'] = __paramValue('bool', $data['prefer_sbr']) ? 't' : 'f'; $project['urgent'] = __paramValue('bool', $data['urgent']) ? 't' : 'f'; $project['hide'] = __paramValue('bool', $data['hide']) ? 't' : 'f'; if (trim($project['contacts']) != '') { $contacts_employer = unserialize($project['contacts']); $empty_contacts_employer = 0; foreach ($contacts_employer as $name => $contact) { if (trim($contact['value']) == '') { $empty_contacts_employer++; } } $is_contacts_employer_empty = count($contacts_employer) == $empty_contacts_employer; } $isPreview = true; $project_exRates = project_exrates::GetAll(); $translate_exRates = array(0 => 2, 1 => 3, 2 => 4, 3 => 1); ob_start(); include $_SERVER['DOCUMENT_ROOT'] . '/public/new/tpl.preview.php'; ?> <?php $htmlProject = ob_get_clean(); $objResponse->assign('project_preview_lenta', 'innerHTML', $htmlLenta); $objResponse->assign('project_preview_content', 'innerHTML', $htmlProject); $objResponse->script('Public.showPreview()'); return $objResponse; }
<script type="text/javascript"> window.addEvent('domready', function(){ $(document.body).addEvent('click', function(){ $('attachedfiles_info').addClass('b-shadow_hide'); }); $('hint_files').removeEvents('click').addEvent('click', function(e){ e.stop(); $('attachedfiles_info').toggleClass('b-shadow_hide');}); $('attachedfiles_close_info').removeEvents('click').addEvent('click', function(){ e.stop(); $('attachedfiles_info').toggleClass('b-shadow_hide');}); }); (function () { var attachedfiles_list = new Array(); <?php if ($action == 'create_project') { $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_files = $attachedfiles->getFiles(); } else { $attachedfiles = new attachedfiles(); $attachedfiles_files = $attachedfiles->getFilesForWizard($existPrjID); } if ($attachedfiles_files) { $n = 0; foreach ($attachedfiles_files as $attachedfiles_file) { echo "attachedfiles_list[{$n}] = new Object;\n"; echo "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n"; echo "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n"; echo "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n"; echo "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n"; echo "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n"; ++$n; }
/** * Регистрирует новое личное сообщение. * * @param int $user_id id пользователя-отправителя * @param string $target_login логин пользователя-получателя * @param string $text текст сообщения * @param array $files прикрепленные файлы * @param int $force разрешение/отказ ответа на письмо (1/0) * @param bool $skip_mail Если TRUE - не отправлять уведомление о новом сообщении на емайл. * @param string $attachedfiles_session ID сессии загруженных файлов * * @return mixed сообщение об ошибке и флаг ошибки в случае ее возниконовения */ public function Add($user_id, $target_login, $text, $files, $force = 0, $skip_mail = false, $attachedfiles_session = null, &$message_id = 0) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/users.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/ignor.php'; $users = new users(); $login = $users->GetName($user_id, $err); $tar_id = $users->GetUid($err, $target_login); if ((ignor::CheckIgnored($tar_id, $user_id) || in_array($target_login, array('admin', 'Anonymous'))) && !$force) { $error = 'Пользователь запретил отправлять ему сообщения'; } else { if ($files) { if (count($files) > self::MAX_FILES) { $alert[1] = 'Вы не можете прикрепить больше ' . self::MAX_FILES . ' файлов к сообщению.'; } else { $max_file_size = self::MAX_FILE_SIZE; foreach ($files as $file) { $ext = $file->getext(); $file->max_size = $max_file_size; $max_file_size -= $file->size; if (!in_array($ext, $GLOBALS['disallowed_array'])) { $f_name = $file->MoveUploadedFile($login['login'] . '/contacts'); if (!isNulArray($file->error)) { if ($max_file_size < 0) { $alert[1] = 'Вы превысили максимально допустимый размер файлов'; } else { $alert[1] = $GLOBALS['PDA'] ? 'Файл не удовлетворяет условиям загрузки' : 'Один или несколько файлов не удовлетворяют условиям загрузки.'; } break; } } else { $alert[1] = $GLOBALS['PDA'] ? 'Файл не удовлетворяет условиям загрузки' : 'Один или несколько файлов имеют неправильный формат.'; } } } } if (empty($alert) && empty($error)) { $memBuff = new memBuff(); // автоматические папки для массовых рассылок личных менеджеров global $aPmUserUids; if (in_array($tar_id, $aPmUserUids) || SERVER === 'local' || SERVER === 'beta' || SERVER === 'alpha') { $DBproxy = new DB(); $nRecId = $DBproxy->val('SELECT mess_pm_ustf_add(?i, ?i)', $tar_id, $user_id); if ($nRecId) { $memBuff->delete('pmAutoFolder' . $tar_id . '_' . $nRecId); } } //--------------------------------------------- $DB = new DB(); $f = array(); if ($files) { foreach ($files as $file) { $f[] = $file->id; } } require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_files = $attachedfiles->getFiles(); if ($attachedfiles_files) { foreach ($attachedfiles_files as $attachedfiles_file) { $cFile = new CFile($attachedfiles_file['id']); $cFile->table = 'file'; $ext = $cFile->getext(); $tmp_dir = 'users/' . substr($login['login'], 0, 2) . '/' . $login['login'] . '/contacts/'; $tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext); $tmp_name = substr_replace($tmp_name, '', 0, strlen($tmp_dir)); $cFile->_remoteCopy($tmp_dir . $tmp_name, true); $f[] = $cFile->id; } } $attachedfiles->clear(); $aNoMod = array_merge($GLOBALS['aContactsNoMod'], $GLOBALS['aPmUserUids']); //$bNoMod = hasPermissions('streamnomod', $user_id) || hasPermissions('streamnomod', $tar_id) || is_pro(true, $user_id) || is_pro(true, $tar_id) || in_array($user_id, $aNoMod); $bNoMod = true; // #0022344: Убрать из потоков личку $message_id = $DB->val('SELECT messages_add(?i, ?i, ?, ?b, ?a, ?b)', $user_id, $tar_id, $text, $skip_mail, $f, $bNoMod); if ($user_id % 2 == $tar_id % 2) { $memBuff->delete(self::MEMBUFF_CHAT_PREFIX . $tar_id); } if ($message_id && !$skip_mail && !QChat::active($tar_id)) { $mail = new pmail(); $mail->NewMessage($user_id, $tar_id, stripslashes($text)); } if ($message_id) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/external/base.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/external/api/api.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/external/api/mobile.php'; externalApi_Mobile::addPushMsg($tar_id, 'message', array('from_user_id' => get_uid(false), 'text' => stripslashes($text))); } } } return array($alert, $error); }
/** * Обработка информации шага проекты. */ public function actionProjects() { $prj_id = $_SESSION['view_wizard_project']; if (!$prj_id) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php'; $prj_exrates = project_exrates::GetAll(); $categories = professions::GetAllGroupsLite(); $professions = professions::GetAllProfessions(); array_group($professions, 'groupid'); $professions[0] = array(); $addedPrc = is_pro() ? 0 : new_projects::PRICE_ADDED; $colorPrc = new_projects::PRICE_COLOR * ($addedPrc > 0 ? 1 : 0); $boldPrc = new_projects::PRICE_BOLD + $addedPrc; $logoPrc = new_projects::PRICE_LOGO + $addedPrc; $cTopPrice = new_projects::PRICE_CONTEST_TOP1DAY + $addedPrc; $pTopPrice = new_projects::PRICE_TOP1DAY + $addedPrc; $action = __paramInit('string', 'action', 'action', null); $attachedfiles_session = __paramInit('string', 'attachedfiles_session', 'attachedfiles_session', false); // проверяем есть ли уже созданый проект $projects = $this->getCreatedProjects(); $existPrjID = count($projects) > 0 ? $projects[0][id] : null; // выводим ранее сохраненный проект if ($action != 'create_project' && $existPrjID) { $data = $projects[0]; list($category, $subcategory) = explode('|', $data['categories']); $currency_name = $this->CURRENCY_TYPE[$data['currency']]; $priceby_name = $this->PRICEBY_TYPE[$data['priceby']]; $data['pro_only'] = $data['pro_only'] === 't'; $price = $data['payed']; $option = array(); $option['top'] = $data['top_count'] > 0; $option['top_count'] = $data['top_count']; $option['color'] = $data['is_color'] === 't'; $option['bold'] = $data['is_bold'] === 't'; $option['logo'] = $data['logo_id'] > 0; } elseif ($action == 'create_project') { // сохраняем новый проект или изменяем старый $in_office = __paramInit('int', null, 'in_office', 0); $type = __paramInit('string', null, 'kind'); if ($type == 'contest') { $data['kind'] = 7; $data['end_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'end_date_eng_format', 0))); $data['win_date'] = date('d-m-Y', strtotime(__paramInit('string', null, 'win_date_eng_format', 0))); } elseif ($in_office == 1) { $location = __paramInit('integer', null, 'location_column_id'); if ($location == 1) { $data['city'] = __paramInit('integer', null, 'location_db_id'); $data['country'] = country::getCountryByCityId($data['city']); } else { $data['country'] = __paramInit('integer', null, 'location_db_id'); } $data['kind'] = 4; } else { $data['kind'] = 1; } $data['name'] = __paramInit('string', null, 'name'); $data['descr'] = __paramInit('string', null, 'descr'); $category = __paramInit('int', null, 'r_category'); $subcategory = __paramInit('int', null, 'r_subcategory'); $agreement = __paramInit('int', null, 'agreement', 0); $data['pro_only'] = __paramInit('int', null, 'pro_only', 0) == 1 ? true : false; if ($agreement != 1) { $data['cost'] = __paramInit('int', null, 'cost', 0); $data['priceby'] = __paramInit('int', null, 'r_priceby', 0); $data['currency'] = __paramInit('int', null, 'r_currency', 0); $data['budget_type'] = __paramInit('int', null, 'budget_type', 0); } if (is_empty_html($data['descr'])) { $error['descr'] = 'Поле не заполнено'; } if (is_empty_html($data['name'])) { $error['name'] = 'Поле не заполнено'; } // проверяем длину необработанной строки, а иначе спецсимволы считаются как несколько символов if (strlen(stripslashes($_POST['name'])) > 60) { $error['name'] = 'Превышен лимит - 60 символов'; } if (!$category) { $error['category'] = 'Не выбран раздел'; } elseif ($subcategory) { $data['categories'] = "{$category}|{$subcategory}"; } else { $data['categories'] = $category; } if ($data['cost'] < 0) { $error['cost'] = 'Введите положительную сумму'; } if ($data['cost'] > 999999) { $error['cost'] = 'Слишком большая сумма'; } if ($data['cost'] > 0 && ($data['currency'] < 0 || $data['currency'] > 3)) { $error['currency'] = 'Валюта не определена'; } if ($data['cost'] > 0 && ($data['priceby'] < 1 || $data['priceby'] > 4)) { $error['priceby'] = 'Вид бюджета не определен'; } $descr_limit = projects::LIMIT_DESCR; if (strlen_real($data['descr']) > $descr_limit) { $error['descr'] = "Исчерпан лимит символов ({$descr_limit})"; } if ($data['kind'] == 7) { if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['end_date'], $o1) || !checkdate($o1[2], $o1[1], $o1[3])) { $error['end_date'] = 'Неправильная дата'; } if (!preg_match("/^([0-9]{1,2})\\-([0-9]{1,2})\\-([0-9]{4})\$/", $data['win_date'], $o2) || !checkdate($o2[2], $o2[1], $o2[3])) { $error['win_date'] = 'Неправильная дата'; } if (!$error['end_date'] && mktime(0, 0, 0, $o1[2], $o1[1], $o1[3]) <= mktime(0, 0, 0)) { $error['end_date'] = 'Дата окончания конкурса не может находиться в прошлом'; } if (!$error['win_date'] && mktime(0, 0, 0, $o2[2], $o2[1], $o2[3]) <= mktime(0, 0, 0, $o1[2], $o1[1], $o1[3])) { $error['win_date'] = 'Дата определения победителя должна быть больше даты окончания конкурса'; } } $option['top'] = __paramInit('int', null, 'option_top', 0); $option['top_count'] = __paramInit('int', null, 'option_top_count', 0); $option['color'] = __paramInit('int', null, 'option_color', 0); $option['bold'] = __paramInit('int', null, 'option_bold', 0); $option['logo'] = __paramInit('int', null, 'option_logo', 0); // логотип if ($option['logo'] == 1) { $data['logo_link'] = str_replace('http://', '', __paramInit('string', null, 'logo_link', null)); $data['logo_id'] = __paramInit('int', null, 'logo_id', null); // если выбрана опция "Логотип со ссылкой", то картинка должна быть обязательно if (!$data['logo_id']) { $error['logo_image'] = 'Отсутствует логотип'; } if ($data['logo_link'] === 'Адрес сайта') { $data['logo_link'] = ''; } if ($data['logo_link'] !== '' && !is_url($data['logo_link'])) { $error['logo_link'] = 'Не верно введен адрес'; } } else { $data['logo_id'] = null; } $price = 0; // закрепление на верху if ($option['top'] == 1 && $option['top_count'] > 0) { if ($option['top_count'] > 999) { $option['top_count'] = 999; } $price = (int) $option['top_count'] * ($data['kind'] == 7 ? $cTopPrice : $pTopPrice); $data['top_count'] = (int) $option['top_count']; $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_TOP, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $price); } else { $data['top_count'] = 0; } // выделение цветом if ($option['color'] == 1) { $price += (int) $colorPrc; $data['is_color'] = true; $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_COLOR, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $colorPrc); } else { $data['is_color'] = false; } // выделение жирным if ($option['bold'] == 1) { $price += (int) $boldPrc; $data['is_bold'] = true; $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_BOLD, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $boldPrc); } else { $data['is_bold'] = false; } if ($option['logo'] == 1) { $price += (int) $logoPrc; $pay_option[] = array('wiz_uid' => $this->getWizardUserID(), 'op_code' => new_projects::OPCODE_PAYED, 'option' => self::PROJECT_OPTION_LOGO, 'type' => $data['kind'] == 7 ? self::BILL_TYPE_CONTEST : self::BILL_TYPE_PROJECT, 'ammount' => $logoPrc); } if ($price > 0) { $data['payed'] = (int) $price; } if (!$error) { $data['wiz_uid'] = $this->getWizardUserID(); // если проект уже есть if ($existPrjID) { // то просто обновляем его $prj_id = $this->updateProject($data, $existPrjID); // и очищаем все платные опции для этого проекта wizard_billing::clearPayedOptions($prj_id); } else { $prj_id = $this->createProject($data); } if ($prj_id && $_POST['attachedfiles_session']) { $attachedfiles = new attachedfiles($_POST['attachedfiles_session']); $files = $attachedfiles->getFiles(array(1, 2, 3, 4)); $this->parent->addAttachedFiles($files, $prj_id); $attachedfiles->clear(); } if ($prj_id && $data['kind'] == 7) { $insert = array('wiz_uid' => $data['wiz_uid'], 'op_code' => new_projects::OPCODE_KON_NOPRO, 'type' => self::BILL_TYPE_CONTEST, 'ammount' => new_projects::getKonkursPrice(), 'parent' => $prj_id); wizard_billing::addPaidOption($insert); } if ($price > 0 && $prj_id) { foreach ($pay_option as $k => $opt) { $opt['parent'] = $prj_id; wizard_billing::addPaidOption($opt); } } if ($prj_id) { $_SESSION['view_wizard_project'] = $prj_id; header('Location: /wizard/registration/'); exit; } else { $error['project'] = 'Ошибка записи проекта'; } } $currency_name = __paramInit('string', null, 'currency'); $priceby_name = __paramInit('string', null, 'priceby'); } // Генерируем данные для вывода ошибок и заполнения полей $loc[] = country::GetCountryName($data['country']); if ($data['city']) { $loc[] = city::GetCityName($data['city']); } $location_name = implode(': ', $loc); $cat[] = professions::GetGroupName($category); if ($subcategory) { $cat[] = professions::GetProfName($subcategory); } $category_name = implode(': ', $cat); if ($data['logo_id']) { $file = new CFile($data['logo_id']); $logo_path = WDCPREFIX . '/' . $file->path . $file->name; } include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.php'; } else { $project = $this->getProjectById($prj_id); $attached = $this->getProjectAttach($prj_id); include $_SERVER['DOCUMENT_ROOT'] . '/wizard/registration/steps/tpl.step.project.view.php'; } }
$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']); if ($alert || $error || $error_flag) { $question = str_replace(array('"', "'", '\\', '<', '>'), array('"', ''', '\', '<', '>'), stripslashes($_POST['question']));
$hasReserve = $reserveInstance->hasReserveByUserId($uid); $reqvs[$form_type]['validate_status'] = ($hasReserve)?1:0; */ //после успешного сохранения отправлям на модерацию $reqvs[$form_type]['validate_status'] = 1; unset($_SESSION['sms_accept_code']); if (!isset($reqvs['is_activate_mob']) || !$reqvs['is_activate_mob'] || $reqvs['is_activate_mob'] == 'f' and !isset($_SESSION['sms_accept_phone']) || !isset($reqvs[$form_type]['phone']) || $_SESSION['sms_accept_phone'] != $reqvs[$form_type]['phone'] || !isset($_SESSION['sms_accept']) || $_SESSION['sms_accept'] !== true) { $other_error['phone'] = true; unset($_SESSION['sms_accept_phone'], $_SESSION['sms_accept'], $_SESSION['sms_accept_try']); } } $error_file = array(); if ($form_type == sbr::FT_PHYS && !is_emp($u->role)) { // сканы документов $attachedFiles = new attachedfiles($_POST['attachedfiles_session']); $attachedFiles_files = $attachedFiles->getFiles(array(1, 4)); $err = $account->addAttach2($attachedFiles_files); // сохраняем файлы $filesExists = count($attachedFiles->getFiles()) > 0; $attachedFiles->clearBySession(); if ($err) { $error_file['err_attach'] = $err; } elseif (!$filesExists) { $error_file['err_attach'] = "Необходимо загрузить скан одной или нескольких страниц паспорта."; } } $required_error = sbr_meta::checkRequired($form_type, $rez_type, $reqvs[$form_type], is_emp($u->role)); $start_errors = array_merge($required_error, $error_file, $other_error); if ($err = sbr_meta::setUserReqv($uid, $rez_type, $form_type, $reqvs[$form_type], $ft_disabled, $is_agree_view, $start_errors)) { if (isset($err['mob_phone'])) { $err['phone'] = $err['mob_phone'];
function aSaveDocument($stage_id, $doc_id, $name, $type, $access, $session) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/sbr_meta.php'; $stage_id = __paramValue('int', $stage_id); $doc_id = __paramValue('int', $doc_id); $objResponse = new xajaxResponse(); if (!hasPermissions('sbr')) { $objResponse->script('window.sended = false'); return $objResponse; } $sbr = sbr_meta::getInstance(); $sbr_id = $sbr->getSbrIdFromStage($stage_id); $sbr->initFromId($sbr_id, true, false, false); if ($sbr->error) { $objResponse->script('window.sended = false'); return $objResponse; } $stage = $sbr->initFromStage($stage_id, false); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attachedfiles = new attachedfiles($session); $attach = current($attachedfiles->getFiles()); if ($attach['id']) { $file = new CFile($attach['id']); $file->table = 'file_sbr'; $file->_remoteCopy($sbr->getUploadDir() . $file->name); } else { $file = false; } if ($doc_id) { $old_doc = $sbr->getDoc($doc_id); $doc = array('name' => $name, 'type' => $type, 'access_role' => $access, 'status' => $old_doc['status'], 'stage_id' => $stage_id, 'id' => $doc_id); if ($file) { $doc['file_id'] = $file->id; } $sbr->editDoc($doc, $old_doc); if ($old_doc['access_role'] == 0 && $doc['access_role'] > 0) { $stage->removeEvent(29, true); } elseif ($old_doc['access_role'] > 0 && $doc['access_role'] == 0) { $stage->removeEvent(30, true); } } else { if (!$file) { $objResponse->script('window.sended = false'); $objResponse->call('alert', 'Загрузите файл'); return $objResponse; } $doc = array('stage_id' => $stage_id, 'file_id' => $file->id, 'status' => sbr::DOCS_STATUS_PUBL, 'access_role' => $access, 'owner_role' => 0, 'type' => $type); $add_doc = $sbr->addDocR($doc); if (!$add_doc) { $objResponse->script('window.sended = false;'); $objResponse->call('alert', 'Ошибка запроса'); return $objResponse; } } $objResponse->script('window.location.reload()'); return $objResponse; }
$error['win_date'] = 'Неправильная дата'; } // Модераторам аккуратней if (!hasPermissions('projects')) { if (!$error['end_date'] && mktime(0, 0, 0, $o1[2], $o1[1], $o1[3]) <= mktime(0, 0, 0)) { $error['end_date'] = 'Дата окончания конкурса не может находиться в прошлом'; } if (!$error['win_date'] && mktime(0, 0, 0, $o2[2], $o2[1], $o2[3]) <= mktime(0, 0, 0, $o1[2], $o1[1], $o1[3])) { $error['win_date'] = 'Дата определения победителя должна быть больше даты окончания конкурса'; } } } $logoOK = __paramInit('bool', NULL, 'logo_ok'); if ($logoOK) { $logoAttach = new attachedfiles($_POST['logo_attachedfiles_session']); $logoFiles = $logoAttach->getFiles(array(1, 3)); if (count($logoFiles)) { $logoFile = array_pop($logoFiles); // загружено может быть несколько файлов, берем последний $logoCFile = new CFile($logoFile['id']); $tmpPrj->setLogoNew($logoCFile); $logoAttach->setStatusTo3($logoFile['id']); } elseif ($_POST['logo_file_id']) { //$logoCFile = new CFile(__paramInit('int', null, 'logo_file_id')); //$tmpPrj->setLogoNew($logoCFile); } else { if ($_POST['is_exec_quickprj'] != 1) { $error['logo'] = 'Необходимо выбрать файл'; } } } else {
/** * Обработка входящих данных на запись рассылки * * @param array $post Входящие данные $_POST * @return array Обработканные данные для записи array(name=>value) где name - имя поля в таблице value - значение поля */ public function initPost($post) { $insert = array(); if ($post['attachedfiles_session']) { $attachedfiles = new attachedfiles($post['attachedfiles_session']); $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4)); if (count($attachedfiles_files) > 0) { $insert['is_attached'] = true; $_POST['attachedfiles_files'] = $attachedfiles_files; } else { $insert['is_attached'] = false; } } $insert['in_draft'] = (int) $post['in_draft'] == 0 ? 'false' : 'true'; if (isset($post['status_sending'])) { $insert['status_sending'] = (int) $post['status_sending']; } if (isset($post['status_message'])) { $insert['status_message'] = (int) $post['status_message']; } if (!is_empty_html($post['subject'])) { $insert['subject'] = __paramValue('string', addslashes($post['subject'])); } else { $insert['subject'] = 'Рассылка Free-lance.ru'; //$this->error['subject'] = 'Введите заголовок письма'; } if (!is_empty_html($post['message'])) { //$insert['message'] = addslashes(__paramValue('ckedit', stripslashes($post['message']) )); $insert['message'] = $post['message']; } else { $this->error['message'] = 'Введите текст письма'; } if ($post['type_sending']) { $post['type_sending'] = array_map('intval', $post['type_sending']); $insert['type_sending'] = (string) implode("", array((int) $post['type_sending'][0], (int) $post['type_sending'][1])); } if ($post['type_regular']) { $insert['type_regular'] = __paramValue('int', $post['type_regular']); } if ($post['type_send_regular']) { $insert['type_send_regular'] = __paramValue('int', $post['type_send_regular']); } if (!is_empty_html($post['time_sending'])) { $time = __paramValue('string', $post['time_sending']) . ":00"; if (is_empty_html($post['date_sending'])) { $insert['date_sending'] = date('Y-m-d ' . $time); } } elseif ($insert['type_regular'] == 2) { $this->error['time_sending'] = 'Введите время отправки рассылки'; } if (!is_empty_html($post['date_sending'])) { $time = "00:00"; if (!is_empty_html($post['time_sending'])) { $time = __paramValue('string', $post['time_sending']) . ":00"; } $insert['date_sending'] = date('Y-m-d ' . $time, strtotime($post['date_sending'])); } elseif ($insert['type_regular'] != 2) { $this->error['date_sending'] = 'Введите дату отправки рассылки'; } // Обработка фильтра Работодателя if ($post['filter_emp']) { // Записываем фильтр $insert['filter_emp'] = $this->initPostEmpFilter($post); } if ($post['filter_frl']) { // Записываем фильтр $insert['filter_frl'] = $this->initPostFrlFilter($post); } if ($post['filter_file']) { $insert['filter_file'] = true; } else { $insert['filter_file'] = ''; } $insert['user_id'] = get_uid(); //$insert['count_recipients'] = 0; return $insert; }
// 1 мб $max_files = 10; $imageTypes = array(2, 3); $maxImageHeight = 100; $maxImageWidth = 100; $dir = $login . '/foto'; break; case 'project_logo': require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/projects.php"; $cFile->server_root = true; $dir = 'users/' . substr($login, 0, 2) . '/' . $login . "/tmpproj/"; $cFile->table = 'file_projects'; $cFile->disable_animate = true; // так как для логотипа нужен только один файл, то удаляем все файлы текущей сессии кроме последнего, на случай если файл по какой-то причине не подойдет или не загрузится $aFiles = new attachedfiles($sess); $logos = $aFiles->getFiles(array(1)); if (is_array($logos)) { while (count($logos) > 1) { $logos = array_splice($logos, 0, 1); $aFiles->delete($logos['id']); } } $max_files_size = new_projects::LOGO_SIZE; $max_files = 10; $imageTypes = array(1, 2, 3); $cFile->max_image_size = array('width' => 150, 'height' => 150, 'less' => 0); $cFile->resize = 1; $cFile->proportional = 1; $cFile->crop = 1; break; default:
function quickprjedit_get_prj($prj_id) { $objResponse = new xajaxResponse(); if (hasPermissions('projects')) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php'; $categories = professions::GetAllGroupsLite(); $professions = professions::GetAllProfessions(); array_group($professions, 'groupid'); $professions[0] = array(); $oprj = new new_projects(); $project = $oprj->getPrj($prj_id); if ($project['id']) { $project_categories = $oprj->getSpecs($project['id']); if (empty($project_categories)) { $project_categories[] = array('category_id' => 0, 'subcategory_id' => 0); } $html_categories = ''; foreach ($project_categories as $project_category) { $html_categories .= "<div id='category_line'>\n <select name='categories[]' class='b-select__select b-select__select_width_180' onchange='popupQEditPrjRefreshSubCategory(this);'>\n <option value='0'>Выберите раздел</option>\n "; foreach ($categories as $cat) { if ($cat['id'] <= 0) { continue; } $html_categories .= "<option value='{$cat['id']}' " . ($project_category['category_id'] == $cat['id'] ? ' selected' : '') . ">{$cat['name']}</option>"; } $html_categories .= "</select>\n <select name='subcategories[]' class='b-select__select b-select__select_width_180'>\n "; $categories_specs = $professions[$project_category['category_id']]; for ($i = 0; $i < sizeof($categories_specs); ++$i) { $html_categories .= "<option value='{$categories_specs[$i]['id']}'" . ($categories_specs[$i]['id'] == $project_category['subcategory_id'] ? ' selected' : '') . ">{$categories_specs[$i]['profname']}</option>"; } $html_categories .= " <option value='0' " . ($project_category['subcategory_id'] == 0 ? ' selected' : '') . '>Все специализации</option> </select> </div> '; } $countries = country::GetCountries(); if ($project['country']) { $cities = city::GetCities($project['country']); } $html_location = ''; $html_location .= "<div><select id='popup_qedit_prj_fld_country' name='country' onChange='popupQEditPrjCityUpd(this.value);'><option value='0'>Страна</option>"; foreach ($countries as $country_id => $country) { $html_location .= "<option value='{$country_id}' " . ($country_id == $project['country'] ? 'selected' : '') . ">{$country}</option>"; } $html_location .= '</select></div>'; $html_location .= "<div id='frm_city'><select name='city'><option value='0'>Город</option>"; if ($cities) { foreach ($cities as $city_id => $city) { $html_location .= "<option value='{$city_id}' " . ($city_id == $project['city'] ? 'selected' : '') . ">{$city}</option>"; } } $html_location .= '</select>'; $objResponse->assign('popup_qedit_prj_fld_id', 'value', $project['id']); $objResponse->assign('popup_qedit_prj_fld_name', 'value', htmlspecialchars_decode($project['name'], ENT_QUOTES)); $objResponse->assign('popup_qedit_prj_fld_descr', 'value', htmlspecialchars_decode($project['descr'], ENT_QUOTES)); $objResponse->assign('popup_qedit_prj_fld_categories', 'innerHTML', $html_categories); $objResponse->assign('popup_qedit_prj_fld_location', 'innerHTML', $html_location); $objResponse->script('$("popup_qedit_prj_fld_kind_1").set("checked", false);'); switch ($project['kind']) { case 1: $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_fld_kind_1").set("checked", true);'); $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "none");'); break; case 2: //$objResponse->script('$("sbr_text_block").setStyle("display", "none");'); break; case 4: $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_fld_kind_2").set("checked", true);'); $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "block");'); break; case 7: $objResponse->script('$("popup_qedit_prj_cal1").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_cal2").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_kind").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_fld_location").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_fld_end_date").set("value", "' . date('d-m-Y', strtotime($project['end_date'])) . '");'); $objResponse->script('$("popup_qedit_prj_fld_win_date").set("value", "' . date('d-m-Y', strtotime($project['win_date'])) . '");'); break; } if ($project['pro_only'] == 't') { $objResponse->script('$("popup_qedit_prj_fld_pro_only").set("checked", true);'); } else { $objResponse->script('$("popup_qedit_prj_fld_pro_only").set("checked", false);'); } if ($project['verify_only'] == 't') { $objResponse->script('$("popup_qedit_prj_fld_verify_only").set("checked", true);'); } else { $objResponse->script('$("popup_qedit_prj_fld_verify_only").set("checked", false);'); } if ($project['prefer_sbr'] == 't') { $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", true);'); } else { $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", false);'); } if ($project['strong_top'] == 1) { $objResponse->script('$("popup_qedit_prj_fld_strong_top").set("checked", true);'); } else { $objResponse->script('$("popup_qedit_prj_fld_strong_top").set("checked", false);'); } /*if($project['prefer_sbr']=='t') { $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", true);'); } else { $objResponse->script('$("popup_qedit_prj_fld_prefer_sbr").set("checked", false);'); }*/ $objResponse->script("var mx = new MultiInput('popup_qedit_prj_fld_categories','category_line', " . (int) ($project['is_pro'] === 't') . '); mx.init();'); require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attchedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_tmpprj_files = $oprj->GetAllAttach($project['id']); if ($attachedfiles_tmpprj_files) { $attachedfiles_prj_files = array(); foreach ($attachedfiles_tmpprj_files as $attachedfiles_prj_file) { $attachedfiles_prj_files[] = $attachedfiles_prj_file['file_id']; } $attchedfiles->setFiles($attachedfiles_prj_files); } $attachedfiles_files = $attchedfiles->getFiles(); $js_attachedfiles = 'attachedfiles_list = [];'; if ($attachedfiles_files) { $n = 0; foreach ($attachedfiles_files as $attachedfiles_file) { $js_attachedfiles .= "attachedfiles_list[{$n}] = new Object;\n"; $js_attachedfiles .= "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n"; $js_attachedfiles .= "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n"; $js_attachedfiles .= "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n"; $js_attachedfiles .= "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n"; $js_attachedfiles .= "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n"; ++$n; } } $objResponse->script($js_attachedfiles); $objResponse->script("attachedFiles.init('popup_qedit_prj_attachedfiles', '" . $attchedfiles->getSession() . "', attachedfiles_list, " . tmp_project::MAX_FILE_COUNT . ', ' . tmp_project::MAX_FILE_SIZE . ",'" . implode(', ', $GLOBALS['disallowed_array']) . "', 'project', " . get_uid(false) . ');'); if ($project['is_color'] == 't') { $objResponse->script("\$('popup_qedit_prj_is_color').set('checked', true); popupQEditPrjToggleIsColor();"); } else { $objResponse->script("\$('popup_qedit_prj_is_color').set('checked', false); popupQEditPrjToggleIsColor();"); } if ($project['is_bold'] == 't') { $objResponse->script("\$('popup_qedit_prj_is_bold').set('checked', true); popupQEditPrjToggleIsBold();"); } else { $objResponse->script("\$('popup_qedit_prj_is_bold').set('checked', false); popupQEditPrjToggleIsBold();"); } if ($project['hide'] == 't') { $objResponse->script("\$('popup_qedit_prj_is_hide').set('checked', true); "); } else { $objResponse->script("\$('popup_qedit_prj_is_hide').set('checked', false); "); } if ($project['urgent'] == 't') { $objResponse->script("\$('popup_qedit_prj_is_urgent').set('checked', true); "); } else { $objResponse->script("\$('popup_qedit_prj_is_urgent').set('checked', false); "); } $objResponse->assign('popup_qedit_prj_logolink', 'value', $project['link']); $key = md5(uniqid($uid)); $tmpPrj = new tmp_project($key); $tmpPrj->init(1, $project['id']); $remTPeriod = $tmpPrj->getRemainingTopPeriod($remTD, $remTH, $remTM, $remtverb); $addedTD = $tmpPrj->getAddedTopDays(); $objResponse->assign('popup_qedit_prj_fld_tmpid', 'value', $key); if ($remTPeriod || $addedTD) { $objResponse->script('$("popup_qedit_prj_top_ok").set("checked", true);'); $objResponse->script('$("popup_qedit_prj_top_ok").set("disabled", true);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("value", "1");'); $objResponse->script('$("popup_qedit_prj_top_ok_icon").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("disabled", true);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("checked", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("disabled", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("disabled", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("value", "1");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_left").set("html", "' . $remtverb . ' ' . $remTPeriod . '");'); } else { $objResponse->script('$("popup_qedit_prj_top_ok").set("checked", false);'); $objResponse->script('$("popup_qedit_prj_top_ok").set("disabled", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("value", "1");'); $objResponse->script('$("popup_qedit_prj_top_ok_icon").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_top_ok_tab1_days").set("disabled", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("checked", false);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_c").set("disabled", true);'); $objResponse->script('$("popup_qedit_prj_top_ok_tab2_days").set("disabled", true);'); } if ($project['logo_id']) { $logo = $tmpPrj->getLogo(); $objResponse->script('$("popup_qedit_prj_use_logo_src").set("href", "' . WDCPREFIX . '/' . $logo['path'] . $logo['name'] . '");'); $objResponse->script('$("popup_qedit_prj_use_logo").set("checked", true);'); $objResponse->script('$("popup_qedit_prj_use_logo").set("disabled", true);'); $objResponse->script('$("popup_qedit_prj_use_logo_tab").setStyle("display", "block");'); $objResponse->script('$("popup_qedit_prj_use_logo_tab2").setStyle("display", "none");'); } else { $objResponse->script('$("popup_qedit_prj_use_logo").set("checked", false);'); $objResponse->script('$("popup_qedit_prj_use_logo").set("disabled", false);'); $objResponse->script('$("popup_qedit_prj_use_logo_tab").setStyle("display", "none");'); $objResponse->script('$("popup_qedit_prj_use_logo_tab2").setStyle("display", "none");'); } $tmpPrj->fix(); $objResponse->call('center_popup', '.b-shadow_center-quick'); } } return $objResponse; }
/** * Функция для вывода и обработки редактирования финансов в попап окне * */ public static function view_finance_popup($redirect_url = "") { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/account.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/smail.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $action = __paramInit('string', NULL, 'action'); $sbr_id = __paramInit('int', 'id'); $account = new account(); $uid = $_SESSION['uid']; $ok = $account->GetInfo($uid, true); $reqvs = sbr_meta::getUserReqvs($uid); $sbr = sbr_meta::getInstance(); $form_type = $reqvs['form_type']; $rez_type = __paramInit('int', NULL, 'rez_type'); if ($rt_disabled = $sbr->checkChangeRT()) { if (!($rez_type = $reqvs['rez_type'])) { $rez_type = sbr::RT_RU; } $reqvs['rez_type'] = $rez_type; } if (!isset($rez_type)) { $rez_type = $reqvs['rez_type']; } $reqvs['rez_type'] = $rez_type; // !!! if ($action == 'updfin') { $popup_open = true; $error = array(); $form_type = __paramInit('int', NULL, 'form_type'); if ($form_type || $rez_type || isset($_POST['ft' . $form_type])) { if (!$ft_disabled) { $reqvs['form_type'] = $form_type; } $reqvs[$form_type] = $_POST['ft' . $form_type]; //@todo: запрещаем изменять финансы в старой СБР #29196 $error['sbr'] = 'Прекращена поддержка СБР.'; //if ($err = sbr_meta::setUserReqv($uid, $rez_type, $form_type, $reqvs[$form_type], $ft_disabled)) // $error['sbr'] = $err; } // обработка загруженных и удаленных файлов $attachedFiles = new attachedfiles($_POST['attachedfiles_session']); $attachedFiles_files = $attachedFiles->getFiles(array(1, 4)); $err = $account->addAttach2($attachedFiles_files); // сохраняем файлы if ($err) { $error['all']['err_attach'] = $err; } if (!$error) { if ($stage) { $stage->setPayoutSys((int) $_POST['credit_sys'], true); } //$_SESSION['users.setup.fin_success'] = 1; if (!hasPermissions('users')) { $smail = new smail(); $smail->FinanceChanged($login); } header_location_exit($redirect_url, 1); } $finance_error = $error; } $attach = $account->getAllAttach(); $prepared = sbr_meta::prepareFinanceFiles($attach); $attachDoc = $prepared['attachDoc']; $attachOther = $prepared['attachOther']; $attachedFilesDoc = $prepared['attachedFilesDoc']; $attachedFilesOther = $prepared['attachedFilesOther']; include $_SERVER['DOCUMENT_ROOT'] . '/sbr/tpl.finance.php'; }
function CreateCommentForm($backto, $top_id, $message_id, $commune_id, $om, $page = 0, $action = 'Create.post', $mod, $adv = 0, $draft_id = 0, $attachedfiles_session = '') { global $session; session_start(); commune::RestoreMarkedAttach($message_id); $objResponse = new xajaxResponse(); if ($action == 'Create.post') { // Комментируем сообщение. $objResponse->assign($backto, 'style.position', 'static'); $objResponse->assign($backto, 'innerHTML', __commPrntCommentForm($commune_id, $om, $page, $action, $top_id, NULL, $message_id, NULL, NULL, !$page ? 'Topic' : NULL, $mod)); } else { // Выводим форму с атрибутами сообщения. $objResponse->assign($backto, 'style.position', 'static'); $objResponse->assign($backto, 'innerHTML', __commPrntCommentForm($commune_id, $om, $page, $action, $top_id, $message_id, NULL, NULL, NULL, !$page ? 'Topic' : NULL, $mod, 0, $draft_id)); } $objResponse->script(" var editMsg = document.getElementById('{$backto}');\n if(__commLastOpenedForm!=editMsg) {\n try { \n if(!__commLastOpenedForm) {\n var ___acf = document.getElementById('idAlertedCommentForm');\n if(___acf && ___acf.parentNode)\n __commLastOpenedForm = ___acf.parentNode;\n }\n __commLastOpenedForm.innerHTML = ''; __commLastOpenedForm.style.position='absolute'; \n } catch(e) {}\n }\n __commLastOpenedForm = editMsg;\n __commLastOpenedForm.action = '{$action}';\n\t\n\tpoll.init('Commune', document.getElementById('" . $backto . "'), " . commune::POLL_ANSWERS_MAX . ", '" . $_SESSION['CommunePoll_Sess'] . "');\n\tif (document.getElementById('question')) maxChars('question', 'polls_error', " . commune::POLL_QUESTION_CHARS_MAX . ");\n\teditMsg.scrollIntoView(true);\n\t//new mAttach(document.getElementById('files_block'), " . (commune::MAX_FILES - $adv) . ");\n //mA = new mAttach2(document.getElementById('files_block'), " . (commune::MAX_FILES - $adv) . ", {p:'btn-add', m:'btn-del', nv:true});\n "); $js = "var attachedfiles_list = new Array();\n"; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $attachedfiles = new attachedfiles($attachedfiles_session); $attachedfiles_tmpcomm_files = commune::getAttachedFiles($message_id); if ($attachedfiles_tmpcomm_files) { $attachedfiles_comm_files = array(); foreach ($attachedfiles_tmpcomm_files as $attachedfiles_comm_file) { $attachedfiles_comm_files[] = $attachedfiles_comm_file; } $attachedfiles->setFiles($attachedfiles_comm_files); } $attachedfiles_files = $attachedfiles->getFiles(); if ($attachedfiles_files) { $n = 0; foreach ($attachedfiles_files as $attachedfiles_file) { $js .= "attachedfiles_list[{$n}] = new Object;\n"; $js .= "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n"; $js .= "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n"; $js .= "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n"; $js .= "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n"; $js .= "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n"; ++$n; } } $js .= "attachedFiles.init('attachedfiles', \n '" . $attachedfiles->getSession() . "',\n attachedfiles_list, \n '" . commune::MAX_FILES . "',\n '" . commune::MAX_FILE_SIZE . "',\n '" . implode(', ', $GLOBALS['disallowed_array']) . "',\n 'commune',\n '" . get_uid(false) . "'\n );"; $objResponse->script($js); $objResponse->call('initWysiwyg'); $objResponse->call('tawlTextareaInit'); if ($action != 'Create.post') { $objResponse->script('DraftInit(4);'); } return $objResponse; }
/** * Возвращает яваскрипт код для инициализации прикрепленных файлов * * @param array $tmp_files массив прикрепленных файлов * @param int $max_files максимально возможное количество прикрепленных файлов * @param int $max_file_size максимальный размер каждого из прикрепленных файлов * @param string $kind тип записи (contacts, blog и т.д) * @param string $tag_id id html тэга для инициализации прикрепленных файлов * @return string */ function getAttachedFilesJs($tmp_files = array(), $max_files = 0, $max_file_size = 0, $kind = '', $tag_id = 'adm_edit_attachedfiles') { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $sAttach = 'attachedfiles_list = new Array();'; $attachedfiles = new attachedfiles('', true); $attachedfiles_session = $attachedfiles->createSessionID(); $attachedfiles->addNewSession($attachedfiles_session); if ($tmp_files) { $attachedfiles_files = array(); foreach ($tmp_files as $attachedfiles_file) { if ($kind == 'contacts' || $kind == 'project') { $sId = $kind == 'contacts' ? 'id' : 'file_id'; $attachedfiles_files[] = $attachedfiles_file[$sId]; } else { $attachedfiles_files[] = $attachedfiles_file; } } $attachedfiles->setFiles($attachedfiles_files); } $files = $attachedfiles->getFiles(); if ($files) { $n = 0; foreach ($files as $attachedfiles_file) { $sAttach .= "attachedfiles_list[{$n}] = new Object;\n"; $sAttach .= "attachedfiles_list[{$n}].id = '" . md5($attachedfiles_file['id']) . "';\n"; $sAttach .= "attachedfiles_list[{$n}].name = '{$attachedfiles_file['orig_name']}';\n"; $sAttach .= "attachedfiles_list[{$n}].path = '" . WDCPREFIX . "/{$attachedfiles_file['path']}{$attachedfiles_file['name']}';\n"; $sAttach .= "attachedfiles_list[{$n}].size = '" . ConvertBtoMB($attachedfiles_file['size']) . "';\n"; $sAttach .= "attachedfiles_list[{$n}].type = '{$attachedfiles_file['type']}';\n"; $n++; } } $sAttach .= "attachedFiles.init('adm_edit_attachedfiles', '{$attachedfiles_session}', attachedfiles_list, \n '{$max_files}', '{$max_file_size}', '" . implode(', ', $GLOBALS['disallowed_array']) . "',\n '{$kind}', " . get_uid(false) . "\n );"; return $sAttach; }
/** * Сохранение проекта в черновики (новый шаблон) * * @param array $prj Информация о проекте * @return array ['id'] - ID черновика, ['date'] - дата сохранения черновика */ function SaveProjectNew($prj, $attachedfiles_files = false) { global $DB; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; $categories = ""; $check = array(); for ($i = 0; $i <= 2; $i++) { $catID = __paramValue('int', $prj['project_profession' . $i . '_columns'][0]); $subcatID = __paramValue('int', $prj['project_profession' . $i . '_spec_columns'][0]); if ($catID || $subcatID) { $categories .= $catID . '|' . $subcatID . ','; } } $categories = preg_replace("/,\$/", "", $categories); if ($prj['name'] === false) { $prj['name'] = ''; } if ($prj['descr'] === false) { $prj['descr'] = ''; } if (!$prj['end_date']) { $prj['end_date'] = NULL; } if (!$prj['win_date']) { $prj['win_date'] = NULL; } $prj['budget_type'] = intval($prj['budget_type']); if (!intval($prj['draft_prj_id'])) { $prj['prj_id'] = NULL; } else { $prj['prj_id'] = $prj['draft_prj_id']; } $prj['draft_id'] = intval($prj['draft_id']); if (!isset($prj['kind'])) { $prj['kind'] = 7; } $prj['cost'] = $prj['agreement'] ? 0 : floatval($prj['cost']); $date = date("Y-m-d H:i:s"); $prj['strong_top'] = hasPermissions('projects') ? (int) $prj['strong_top'] : 0; $prj['verify_only'] = (bool) $prj['verify_only']; // платные опции $prj['urgent'] = (bool) $prj['urgent']; $prj['hide'] = (bool) $prj['hide']; $topDays = $prj['top_ok'] ? $prj['top_days'] : 0; if ($prj['logo_ok']) { $logoAttach = new attachedfiles($prj['logo_attachedfiles_session']); $logoFiles = $logoAttach->getFiles(); if (is_array($logoFiles) && count($logoFiles)) { $logoFile = array_pop($logoFiles); // файлов может быть несколько, берем последний $logoAttach->setStatusTo3($logoFile['id']); $logoFileID = $logoFile['id']; } elseif ($prj['logo_file_id']) { $logoFileID = $prj['logo_file_id']; } $logoLink = $prj['link']; } if (self::isDraftExists($prj['draft_id'], $prj['uid'], 1, $prj['prj_id'])) { $sql = "UPDATE draft_projects SET \n name = ?u,\n descr = ?u,\n cost = ?,\n currency = ?i,\n kind = ?i,\n pro_only = ?,\n strong_top = ?i,\n end_date = ?,\n win_date = ?,\n country = ?i,\n city = ?i,\n categories = ?,\n date = ?,\n prj_id = ?,\n priceby = ?i,\n prefer_sbr = ?,\n budget_type = ?i,\n verify_only = ?,\n urgent = ?,\n hide = ?,\n top_days = ?i,\n logo_id = ?,\n logo_link = ?,\n contacts = ?\n WHERE (id=? OR prj_id=?)AND uid=?i"; $DB->query($sql, $prj['name'], $prj['descr'], $prj['cost'], $prj['currency_db_id'], $prj['kind'], $prj['pro_only'] == 1 ? 't' : 'f', $prj['strong_top'], $prj['end_date'], $prj['win_date'], (int) $prj['project_location_columns'][0], (int) $prj['project_location_columns'][1], $categories, $date, $prj['prj_id'], intval($prj['priceby_db_id']), $prj['prefer_sbr'] == 1 ? 't' : 'f', $prj['budget_type'], $prj['verify_only'], $prj['urgent'], $prj['hide'], $topDays, $logoFileID, $logoLink, $prj['contacts'], $prj['draft_id'], $prj['prj_id'], $prj['uid']); $id = $prj['draft_id']; } else { $new_draft = true; $sql = "INSERT INTO draft_projects (\n name,\n descr,\n cost,\n currency,\n kind,\n pro_only,\n end_date,\n win_date,\n country,\n city,\n categories,\n date,\n uid,\n prj_id,\n priceby,\n prefer_sbr,\n budget_type,\n strong_top,\n verify_only,\n urgent,\n hide, \n top_days,\n logo_id,\n logo_link,\n contacts\n ) VALUES (\n ?u,\n ?u,\n ?,\n ?i,\n ?i,\n ?,\n ?,\n ?,\n ?i,\n ?i,\n ?,\n ?,\n ?i,\n ?,\n ?i,\n ?,\n ?i,\n ?i,\n ?,\n ?,\n ?,\n ?i,\n ?,\n ?,\n ?\n ) RETURNING id;"; $id = $DB->val($sql, $prj['name'], $prj['descr'], $prj['cost'], $prj['currency_db_id'], $prj['kind'], $prj['pro_only'] == 1 ? 't' : 'f', $prj['end_date'], $prj['win_date'], (int) $prj['project_location_columns'][0], (int) $prj['project_location_columns'][1], $categories, $date, $prj['uid'], $prj['prj_id'], intval($prj['priceby_db_id']), $prj['prefer_sbr'] == 1 ? 't' : 'f', $prj['budget_type'], (int) $prj['strong_top'], $prj['verify_only'], $prj['urgent'], $prj['hide'], $topDays, $logoFileID, $logoLink, $prj['contacts']); } // - BEGIN атачи if (!$attachedfiles_files) { require_once $_SERVER['DOCUMENT_ROOT'] . "/classes//uploader/uploader.php"; $mask_files = array(1, 3); $uploader = new uploader(current($prj['IDResource'])); $attachedfiles_files = $uploader->getFiles($mask_files); } $file_id = array(); // массив с ID файлов которые не надо удалять $noDeletedFiles = array(); foreach ($attachedfiles_files as $attachedfiles_file) { $noDeletedFiles[] = $attachedfiles_file['id']; // старые файлы не трогаем if ($attachedfiles_file['status'] == 3) { continue; } if (in_array($f->id, $file_id)) { continue; } // Чтобы не было дублей $file_id[] = $f->id; $f = new CFile($attachedfiles_file['id']); $f->table = 'file'; $f->makeLink(); $sql = "INSERT INTO draft_attaches(draft_id, draft_type, file_id) VALUES(?i, 4, ?i)"; $DB->hold()->query($sql, $id, $f->id); } if ($DB->sqls) { $DB->query(); } if ($uploader && $attachedfiles_files) { $uploader->setStatusFiles(uploader::STATUS_CREATE, uploader::STATUS_ADDED); } $sqlNoDeletedFiles = count($noDeletedFiles) ? $DB->parse('AND file_id NOT IN (?l)', $noDeletedFiles) : ''; $sql = "SELECT * FROM draft_attaches WHERE draft_id = ?i AND draft_type = 4 {$sqlNoDeletedFiles};"; $files = $DB->rows($sql, $id, $noDeletedFiles); if ($files) { foreach ($files as $f) { $cf = new CFile($f['file_id']); $cf->table = 'file'; $cf->Delete($cf->id); } } $sql = "DELETE FROM draft_attaches WHERE draft_id = ?i AND draft_type = 4 {$sqlNoDeletedFiles};"; $DB->query($sql, $id, array()); // - END атачи $_SESSION['drafts_count'] = drafts::getCount($msg['uid']); return array('id' => $id, 'date' => $date); }
/** * Редактирует сделку по данным пользовательского запроса. * * @see sbr_emp::initFromRequest() * * @param array $request данные запроса (гет, пост). * @param array $files массив $_FILES с вложениями к каждому этапу. * * @return bool успешно? */ private function __new_edit($request, attachedfiles $files, &$old) { $old = clone $this; $attached = $files->getFiles(array(1, 4), true); if (!$this->_new_initFromRequest($request, $attached, $old)) { return false; } if (!$this->_openXact(true)) { return false; } if ($this->_delstages) { foreach ($this->_delstages as $dstage) { if (!$dstage->delete($old->isDraft())) { $this->_abortXact(); return false; } } } $sql_data = $this->_preSql(true); $sql = "\n UPDATE sbr\n SET name = '{$sql_data['name']}',\n frl_id = {$sql_data['frl_id']},\n cost_sys = {$sql_data['cost_sys']},\n is_draft = '{$sql_data['is_draft']}',\n scheme_type = {$sql_data['scheme_type']}\n WHERE id = {$this->data['id']}\n AND emp_id = {$this->uid}\n "; if (!($res = pg_query(self::connect(false), $sql)) || !pg_affected_rows($res)) { $this->_abortXact(); return false; } // Ситуация когда редактируем сделку (отправляем из черновиков) а в ней нет офферт, тогда просто генерируем их if ($this->scheme_type == sbr::SCHEME_LC) { $docs = $this->getDocs(); foreach ($docs as $doc) { if ($doc['type'] == sbr::DOCS_TYPE_OFFER) { $offers_doc[] = $doc['file_id']; } } if (count($offers_doc) != 2) { $doc_delete = current($offers_doc); // Удаляем, если одна оферта сгенерировалась уже, а вторая нет if ($doc_delete) { $doc_file = CFile($doc_delete); $doc_file->delete(); } if ($doc_file = $this->generateAgreement($err)) { $doc = array('file_id' => $doc_file->id, 'status' => sbr::DOCS_STATUS_SIGN, 'access_role' => sbr::DOCS_ACCESS_ALL, 'owner_role' => 0, 'type' => sbr::DOCS_TYPE_OFFER, 'subtype' => 2); $this->addDocR($doc); } if (!$err) { if ($doc_file = $this->generateContract($err)) { $doc = array('file_id' => $doc_file->id, 'status' => sbr::DOCS_STATUS_SIGN, 'access_role' => sbr::DOCS_ACCESS_ALL, 'owner_role' => 0, 'type' => sbr::DOCS_TYPE_OFFER, 'subtype' => 1); $this->addDocR($doc); } } if ($err) { $this->_abortXact(); unset($this->data['id']); return false; } } } //////////////////////// pg_query(self::connect(false), "SELECT sbr_trigger_fvrs_gt_vrs('sbr', {$this->data['id']})"); //////////////////////// foreach ($this->stages as $stage) { if ($this->scheme_type == sbr::SCHEME_LC && ($this->data['state'] == pskb::STATE_NEW || $this->data['state'] == pskb::STATE_FORM || $this->data['status'] >= sbr::STATUS_CHANGED)) { $cur_stage = $this->initFromStage($stage->id, false); $stage->data['cost'] = $cur_stage->cost; } if ($this->data['delstages'][$stage->id] || $this->data['stage_id'] && $stage->id != $this->data['stage_id'] || $stage->isFixedState()) { continue; } if (!($stage->id ? $stage->edit() : $stage->_new_create())) { $this->_abortXact(); return false; } } // записываем профессию сделки //$this->saveProfessions(); при редактировании ничего не записываем $this->_commitXact(); return true; }
/** * Сохранение комментария к статьям * * @param object $objResponse xajaxResponse * @param string $rec_id идентификатор записи * @param string $rec_type тип записи * @param array $aForm массив данных * @param string $sDrawFunc имя функции для выполнения после сохранения */ function _admEditArtComSaveForm(&$objResponse, $rec_id = '', $rec_type = '', $aForm = array(), $sDrawFunc = '') { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/messages.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/comments/CommentsArticles.php'; $oComments = new CommentsArticles(); $attachedfiles = new attachedfiles($aForm['attachedfiles_session']); $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4)); $oComments->addAttachedFiles($attachedfiles_files, $rec_id, $aForm['user_login']); $attachedfiles->clear(); $sReason = _parseReason($aForm['user_id'], $aForm['adm_edit_text']); messages::artComModifiedNotification($rec_id, $aForm['user_login'], $aForm['user_uname'], $aForm['user_usurname'], $sReason, $aForm['resource']); $content_id = user_content::MODER_ART_COM; _admEditAfterAll($objResponse, $content_id, $rec_id, $rec_type, $sDrawFunc, $aForm); }
/** * Изменение документа * * @param integer $id ID документа * @param array $data Данные документа */ function updateDocument($id, $data) { global $DB; if (!$data['letters_doc_frm_user_3_db_id'] || $data['letters_doc_frm_user_3_db_id'] == 'null') { $data['letters_doc_frm_user_3_db_id'] = null; $data['letters_doc_frm_user3_status_data'] = null; $data['letters_doc_frm_user3_status_date_data'] = null; } if (!$data['letters_doc_frm_user3_status_date_data']) { $data['letters_doc_frm_user3_status_date_data'] = null; } if (!$data['letters_doc_frm_user2_status_date_data']) { $data['letters_doc_frm_user2_status_date_data'] = null; } if (!$data['letters_doc_frm_user1_status_date_data']) { $data['letters_doc_frm_user1_status_date_data'] = null; } if (!$data['letters_doc_frm_user3_status_data']) { $data['letters_doc_frm_user3_status_data'] = null; } if (!$data['letters_doc_frm_user2_status_data']) { $data['letters_doc_frm_user2_status_data'] = null; } if (!$data['letters_doc_frm_user1_status_data']) { $data['letters_doc_frm_user1_status_data'] = null; } if (!$data['letters_doc_frm_parent_db_id'] || $data['letters_doc_frm_parent_db_id'] == 'null') { $data['letters_doc_frm_parent_db_id'] = null; } if (!$data['letters_doc_frm_group'] || $data['letters_doc_frm_group'] == 'null') { $data['letters_doc_frm_group'] = null; } if (!$data['letters_doc_frm_group_db_id'] || $data['letters_doc_frm_group_db_id'] == 'null') { $data['letters_doc_frm_group_db_id'] = null; } if (!$data['letters_doc_frm_group_db_id'] && !empty($data['letters_doc_frm_group'])) { $data['letters_doc_frm_group_db_id'] = letters::checkCreateGroup($data['letters_doc_frm_group']); } if ($data['letters_doc_frm_user_1_section'] == '1') { $data['letters_doc_frm_user_1_section'] = true; } else { $data['letters_doc_frm_user_1_section'] = false; } if ($data['letters_doc_frm_user_2_section'] == '1') { $data['letters_doc_frm_user_2_section'] = true; } else { $data['letters_doc_frm_user_2_section'] = false; } if ($data['letters_doc_frm_user_3_section'] == '1') { $data['letters_doc_frm_user_3_section'] = true; } else { $data['letters_doc_frm_user_3_section'] = false; } if ($data['letters_doc_frm_withoutourdoc'] == '1') { $data['letters_doc_frm_withoutourdoc'] = true; } else { $data['letters_doc_frm_withoutourdoc'] = false; } $doc = self::getDocument($id); $doc_data['title'] = $data['letters_doc_frm_title']; $doc_data['user_1'] = $data['letters_doc_frm_user_1_db_id']; $doc_data['user_2'] = $data['letters_doc_frm_user_2_db_id']; $doc_data['user_3'] = $data['letters_doc_frm_user_3_db_id']; $doc_data['group_id'] = $data['letters_doc_frm_group_db_id']; $doc_data['parent'] = $data['letters_doc_frm_parent_db_id']; $doc_data['user_status_1'] = $data['letters_doc_frm_user1_status_data']; $doc_data['user_status_2'] = $data['letters_doc_frm_user2_status_data']; $doc_data['user_status_3'] = $data['letters_doc_frm_user3_status_data']; $doc_data['user_status_date_1'] = $data['letters_doc_frm_user1_status_date_data']; $doc_data['user_status_date_2'] = $data['letters_doc_frm_user2_status_date_data']; $doc_data['user_status_date_3'] = $data['letters_doc_frm_user3_status_date_data']; $doc_data['is_user_1_company'] = $data['letters_doc_frm_user_1_section'] ? 't' : 'f'; $doc_data['is_user_2_company'] = $data['letters_doc_frm_user_2_section'] ? 't' : 'f'; $doc_data['is_user_3_company'] = $data['letters_doc_frm_user_3_section'] ? 't' : 'f'; $doc_data['withoutourdoc'] = $data['withoutourdoc'] ? 't' : 'f'; if (isset($data['letters_doc_frm_comment']) && $data['letters_doc_frm_comment']) { $doc_data['comment'] = $data['letters_doc_frm_comment']; } else { $data['letters_doc_frm_comment'] = $doc['comment']; } if ($doc_data['user_status_1'] != $doc['user_status_1'] || $doc_data['user_status_2'] != $doc['user_status_2'] || $doc_data['user_status_3'] != $doc['user_status_3']) { letters::updateDateStatusChange($id); } letters::saveHistory($id, $doc_data); $sql = "UPDATE letters SET\n date_add = " . ($data['letters_doc_frm_dateadd_eng_format'] ? "'{$data['letters_doc_frm_dateadd_eng_format']}'" : "NOW()") . ",\n title = ?,\n user_1 = ?,\n user_2 = ?,\n user_3 = ?,\n group_id = ?,\n parent = ?,\n user_status_1 = ?, \n user_status_2 = ?, \n user_status_3 = ?, \n user_status_date_1 = ?, \n user_status_date_2 = ?, \n user_status_date_3 = ?,\n is_user_1_company = ?, \n is_user_2_company = ?, \n is_user_3_company = ?, \n withoutourdoc = ?,\n comment = ?\n WHERE id = ?i;"; $DB->query($sql, $data['letters_doc_frm_title'], $data['letters_doc_frm_user_1_db_id'], $data['letters_doc_frm_user_2_db_id'], $data['letters_doc_frm_user_3_db_id'], $data['letters_doc_frm_group_db_id'], $data['letters_doc_frm_parent_db_id'], $data['letters_doc_frm_user1_status_data'], $data['letters_doc_frm_user2_status_data'], $data['letters_doc_frm_user3_status_data'], $data['letters_doc_frm_user1_status_date_data'], $data['letters_doc_frm_user2_status_date_data'], $data['letters_doc_frm_user3_status_date_data'], $data['letters_doc_frm_user_1_section'], $data['letters_doc_frm_user_2_section'], $data['letters_doc_frm_user_3_section'], $data['letters_doc_frm_withoutourdoc'], $data['letters_doc_frm_comment'], $id); $sql = "UPDATE letters SET is_out=false WHERE (user_status_1 IS DISTINCT FROM 1 AND user_status_2 IS DISTINCT FROM 1 AND user_status_3 IS DISTINCT FROM 1) AND id=?i"; $DB->query($sql, $id); require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/attachedfiles.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/CFile.php"; $attachedfiles = new attachedfiles($data['attachedfiles_session']); $attachedfiles_files = $attachedfiles->getFiles(); if ($attachedfiles_files) { foreach ($attachedfiles_files as $attachedfiles_file) { $cFile = new CFile(); $cFile->table = 'file'; $cFile->GetInfoById($attachedfiles_file['id']); if ($cFile->id != $doc['file_id']) { $ext = $cFile->getext(); $tmp_dir = "letters/"; $tmp_name = $cFile->secure_tmpname($tmp_dir, '.' . $ext); $tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir)); $cFile->_remoteCopy($tmp_dir . $tmp_name, true); $sql = "UPDATE letters SET file_id = ?i WHERE id = ?i"; $DB->query($sql, $cFile->id, intval($id)); $cFile->delete($doc['file_id']); } } } $attachedfiles->clear(); return $id; }