/** * Отдает HTML для Редактирование проектов и конкурсов * * @param object $objResponse xajaxResponse * @param string $rec_id идентификатор записи * @param string $rec_type тип записи * @param array $aParams дополнительные параметры с UID отправителя. остальные - опционально * @return string */ function _admEditProjectsParseForm(&$objResponse, $rec_id = '', $rec_type = '', $aParams = array()) { require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/city.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/country.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php'; require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php'; $sTmpKey = md5(uniqid($_SESSION['uid'])); $tmpPrj = new tmp_project($sTmpKey); $prj = $tmpPrj->init(1, $rec_id); $tmpPrj->fix(); // $aFolders = projects::getUserFolders( $prj['user_id'] ); // папки $remTPeriod = $tmpPrj->getRemainingTopPeriod($remTD, $remTH, $remTM, $remtverb); // закрепление // страны и города $countries = country::GetCountries(); if ($prj['country']) { $cities = city::GetCities($prj['country']); } // разделы $categories = professions::GetAllGroupsLite(); $professions = professions::GetAllProfessions(); array_group($professions, 'groupid'); $professions[0] = array(); $project_categories = new_projects::getSpecs($rec_id); if (empty($project_categories)) { $project_categories[] = array('category_id' => 0, 'subcategory_id' => 0); } ob_start(); include_once $_SERVER['DOCUMENT_ROOT'] . '/user/adm_edit_tpl/projects.php'; $sHtml = ob_get_contents(); ob_end_clean(); // текст $sOnReady = "if(document.getElementById('adm_edit_descr')) \n document.getElementById('adm_edit_descr').value = (\$('adm_edit_descr_source')? \$('adm_edit_descr_source').value : null);"; // аттачи $sAttach = getAttachedFilesJs(projects::GetAllAttach($rec_id), tmp_project::MAX_FILE_COUNT, tmp_project::MAX_FILE_SIZE, 'project'); $objResponse->assign('h4_adm_edit', 'innerHTML', 'Редактировать ' . ($rec_type == '7' ? 'конкурс' : 'проект')); $objResponse->assign('div_adm_edit', 'innerHTML', $sHtml); $objResponse->script("\$('div_adm_reason').setStyle('display', 'none');"); $objResponse->script("adm_edit_content.editMenuItems = ['', 'Основное', 'Файлы', 'Платные услуги'];"); $objResponse->script('adm_edit_content.edit();'); $objResponse->script($sAttach); $objResponse->script($sOnReady); $objResponse->script("var mx = new MultiInput('adm_edit_professions','category_line'); mx.init();"); $objResponse->script('xajax_getAdmEditReasons(' . admin_log::ACT_ID_EDIT_PROJECTS . ');'); // для конкурса даты окончания и определения победителей if ($prj['kind'] == 7) { $objResponse->script("new tcal ({ 'formname': 'adm_edit_frm', 'controlname': 'adm_edit_end_date', 'iconId': 'end_date_btn', 'clickEvent': function(){ adm_edit_content.hideError('end_date'); } });"); $objResponse->script("new tcal ({ 'formname': 'adm_edit_frm', 'controlname': 'adm_edit_win_date', 'iconId': 'win_date_btn', 'clickEvent': function(){ adm_edit_content.hideError('win_date'); } });"); } }
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; }
$tmpPrj->setProjectField('urgent', 't'); //Другие платные услуги if (false) { $tmpPrj->setAddedTopDays(4); } //Таким проект был в базе $project = $tmpPrj->getProject(); //Юзер пытается купить скрытый $tmpPrj->setProjectField('hide', 't'); //Записываются данные о скрытом и срочном. будут сохранены в кэш при $tmpPrj->fix() $oproject = $project; if ($tmpPrj->isEdit()) { $tmpPrj->setProjectField('o_hide', $oproject['hide']); $tmpPrj->setProjectField('o_urgent', $oproject['urgent']); } $tmpPrj->fix(); $account_sum = $account->sum; $account_bonus_sum = $account->bonus_sum; $bill = new billing($uid); $bill->cancelAllNewAndReserved(); //Здесь впервые считается цена if ($tmpPrj->getAmmount()) { $tmpProject = $tmpPrj->getProject(); //Цена считается повторно, в $items формируется список услуг $price = $tmpPrj->getPrice($items, $__temp, true); $option = array('is_edit' => $tmpPrj->isEdit(), 'items' => $items, 'prj_id' => $project['id'], 'logo_id' => $logo['id'], 'logo_link' => $tmpProject['link']); if ($items['top']) { $option['addTop'] = $tmpPrj->getAddedTopDays(); } if ($tmpPrj->isKonkurs()) { if (new_projects::isNewContestBudget()) {
/** * Добавление проекта * * @param array $aParams массив входящих данных * @return array $aResult ответ */ protected function x____projects_add($aParams = array()) { $this->_validDevice($aParams); require_once ABS_PATH . "/classes/projects.php"; $nKind = intvalPgSql($aParams['kind']); $nKind = !empty($nKind) ? $nKind : $this->_mCfg['default_kind']; $nUid = get_uid(false); $sKey = md5(uniqid($uid)); // ключ-идентификатор создаваемого/редактируемого проекта, для хранения в кэше. $aCats = array(array('category_id' => intvalPgSql($aParams['group_category_id']), 'subcategory_id' => intvalPgSql($aParams['category_id']))); $tmpPrj = new tmp_project($sKey); $tmpPrj->init(1, 0); $tmpPrj->setProjectField('kind', $nKind); $tmpPrj->setProjectField('descr', __paramValue('html', antispam(iconv('utf-8', 'cp1251', $aParams['descr'])), null, true)); $tmpPrj->setProjectField('name', substr(antispam(__paramValue('string', iconv('utf-8', 'cp1251', $aParams['title']), 60)), 0, 512)); $tmpPrj->setProjectField('cost', __paramValue('float', $aParams['budget'])); $tmpPrj->setProjectField('currency', intvalPgSql($aParams['currency'])); $tmpPrj->setProjectField('priceby', intvalPgSql($aParams['dimension'])); $tmpPrj->setProjectField('agreement', intvalPgSql($aParams['budget_agreement'])); $tmpPrj->setProjectField('budget_type', 0); // TODO: ??? $tmpPrj->setCategories($aCats); $tmpPrj->setProjectField('country', intvalPgSql($aParams['country_id'])); $tmpPrj->setProjectField('city', intvalPgSql($aParams['city_id'])); $tmpPrj->setProjectField('pro_only', intvalPgSql($aParams['only_pro']) ? 't' : 'f'); $tmpPrj->setProjectField('verify_only', intvalPgSql($aParams['only_verified']) ? 't' : 'f'); $tmpPrj->setProjectField('prefer_sbr', intvalPgSql($aParams['prefer_sbr']) ? 't' : 'f'); $project = $tmpPrj->getProject(); if ($project['cost'] < 0) { $this->error(EXTERNAL_ERR_PRJ_COST_MIN); } if ($project['cost'] > 999999) { $this->error(EXTERNAL_ERR_PRJ_COST_MAX); } if ($project['cost'] > 0 && ($project['currency'] < 0 || $project['currency'] > 3)) { $this->error(EXTERNAL_ERR_PRJ_CURRENCY); } if (is_empty_html($project['descr'])) { $this->error(EXTERNAL_ERR_PRJ_EMPTY_DESCR); } if (is_empty_html($project['name'])) { $this->error(EXTERNAL_ERR_PRJ_EMPTY_TITLE); } if (strlen_real($project['descr']) > $this->_mCfg['descr_limit']) { $this->error(EXTERNAL_ERR_PRJ_LENGTH_DESCR); } // TODO: пока только проекты /*if ( $project['kind'] == 7 ) { $tmpPrj->setProjectField('end_date', __paramInit('string', NULL, 'end_date'),0,64); $tmpPrj->setProjectField('win_date', __paramInit('string', NULL, 'win_date'),0,64); $project = $tmpPrj->getProject(); if (!preg_match("/^([0-9]{1,2})\-([0-9]{1,2})\-([0-9]{4})$/", $project['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})$/", $project['win_date'], $o2) || !checkdate($o2[2], $o2[1], $o2[3])) $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'] = 'Дата определения победителя должна быть больше даты окончания конкурса'; } }*/ // сохранение файлов if (is_array($_FILES['files']) && $_FILES['files']) { $aFiles = $this->_multiple($_FILES); foreach ($aFiles['files'] as $aFile) { if (is_array($aFile) && !$aFile['error']) { $_FILES['attachedfiles_file'] = $aFile; $_POST['attachedfiles_action'] = 'add'; $_POST['attachedfiles_type'] = 'project'; $bSilentMode = true; include ABS_PATH . '/attachedfiles.php'; if (isset($file['errno'])) { switch ($file['errno']) { case 1: $this->error(EXTERNAL_ERR_FILE); break; case 2: $this->error(EXTERNAL_ERR_MAX_FILES_CONUT); break; case 3: $this->error(EXTERNAL_ERR_MAX_FILES_SIZE); break; case 4: $this->error(EXTERNAL_ERR_FILE_FORMAT); break; default: $this->error(EXTERNAL_ERR_SERVER_ERROR); break; } } $attachedfiles_files = $attachedfiles->getFiles(array(1, 3, 4)); $tmpPrj->addAttachedFiles($attachedfiles_files); $attachedfiles->clear(); } } } $tmpPrj->fix(); $tmpPrj->saveProject(null, $aProject); return $this->x____projects_get(array('id' => $aProject['id'])); }