Exemple #1
0
function DelLogo($key)
{
    $objResponse = new xajaxResponse();
    $tmpPrj = new tmp_project($key);
    if ($tmpPrj->init(2)) {
        $tmpPrj->delLogo(true);
        $objResponse->script('try{adlogo()}catch(eeee){}');
    }
    return $objResponse;
}
/**
 * Отдает 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'); } });");
    }
}
 /**
  * Обработка и оплата операций
  * 
  * @global type $DB
  * @param type $option
  * @return boolean 
  */
 function billingOperation($option, $transaction_id)
 {
     global $DB;
     $ok = false;
     $account = new account();
     switch ($option['op_code']) {
         // Аккаунт ПРО у фрилансера
         case 48:
         case 49:
         case 50:
         case 51:
         case 76:
             // Удаляем операции по покупке ответов - публикуем ответы
             $prof = new payed();
             $ok = $prof->SetOrderedTarif($this->uid, $transaction_id, 1, "Аккаунт PRO", $option['op_code'], $error);
             if ($ok) {
                 $_SESSION['pro_last'] = payed::ProLast($_SESSION['login']);
                 $_SESSION['pro_last'] = $_SESSION['pro_last']['freeze_to'] ? false : $_SESSION['pro_last']['cnt'];
                 $userdata = new users();
                 $_SESSION['pro_test'] = $userdata->GetField($this->uid, $error2, 'is_pro_test', false);
                 $this->clearBlockedOperations(step_freelancer::OFFERS_OP_CODE);
                 $step_frl = new step_freelancer();
                 $offers = $step_frl->getWizardOffers($this->uid, 'all', false);
                 if ($offers) {
                     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php";
                     $step_frl->log = $this->log;
                     $step_frl->user = new users();
                     $step_frl->user->GetUserByUID($this->uid);
                     $step_frl->transferOffers($offers);
                 }
                 $this->showProjectsFeedbacks();
             }
             break;
             // Аккаунт ПРО у работодателя
         // Аккаунт ПРО у работодателя
         case 15:
             $prof = new payed();
             $ok = $prof->SetOrderedTarif($this->uid, $transaction_id, 1, "Аккаунт PRO", $option['op_code'], $error);
             if ($ok) {
                 $_SESSION['pro_last'] = payed::ProLast($_SESSION['login']);
                 $_SESSION['pro_last'] = $_SESSION['pro_last']['freeze_to'] ? false : $_SESSION['pro_last']['cnt'];
                 $userdata = new users();
                 $_SESSION['pro_test'] = $userdata->GetField($this->uid, $error2, 'is_pro_test', false);
             }
             // Обновляем выбор цвета для проектов тк он для ПРО бесплатный
             $colorProjects = $this->updateColorProject();
             $prj = new new_projects();
             foreach ($colorProjects as $k => $project) {
                 $delete_color[] = $project['op_id'];
                 if ($project['country'] == null) {
                     $project['country'] = 'null';
                 }
                 if ($project['city'] == null) {
                     $project['city'] = 'null';
                 }
                 $project['name'] = addslashes($project['name']);
                 $project['descr'] = addslashes($project['descr']);
                 if ($project['logo_id'] <= 0) {
                     $project['logo_id'] = 'null';
                 }
                 $project['payed_items'] = $project['payed_items'] | '010';
                 $project['is_color'] = 't';
                 $prj->editPrj($project, false);
             }
             // Удаляем данные операции
             if ($delete_color) {
                 $this->deleteDraftAccountOperation($delete_color);
             }
             break;
             // Публикация конкурса
         // Публикация конкурса
         case new_projects::OPCODE_KON:
         case new_projects::OPCODE_KON_NOPRO:
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/wizard/step_wizard_registration.php';
             $drafts = new drafts();
             $draft = $drafts->getDraft($option['parent_id'], $this->uid, 1);
             // Если еще не опубликован
             if (!$draft['prj_id']) {
                 $project_id = $draft['id'];
                 $error = $account->Buy($bill_id, $transaction_id, $option['op_code'], $this->uid, $option['descr'], $option['comment'], 1, 0);
                 $ok = $bill_id > 0;
                 if ($bill_id) {
                     $color = $DB->val("SELECT id FROM draft_account_operations WHERE parent_id = ? AND op_type = 'contest' AND option = 'color' AND uid = ?", $project_id, wizard::getUserIDReg());
                     $draft['billing_id'] = $bill_id;
                     $draft['folder_id'] = 'null';
                     $draft['payed'] = '0';
                     $draft['payed_items'] = '000';
                     if (is_pro() && $color > 0) {
                         $draft['is_color'] = 't';
                     } else {
                         $draft['is_color'] = 'f';
                     }
                     $draft['win_date'] = date('d-m-Y', strtotime($draft['win_date']));
                     $draft['end_date'] = date('d-m-Y', strtotime($draft['end_date']));
                     $draft['is_bold'] = 'f';
                     $draft['user_id'] = $this->uid;
                     if ($draft['country'] == null) {
                         $draft['country'] = 'null';
                     }
                     if ($draft['city'] == null) {
                         $draft['city'] = 'null';
                     }
                     $draft['name'] = addslashes($draft['name']);
                     $draft['descr'] = addslashes($draft['descr']);
                     if ($draft['logo_id'] <= 0) {
                         $draft['logo_id'] = 'null';
                     }
                     $prj = new new_projects();
                     $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($option['parent_id'], 4);
                     if ($attachedfiles_tmpdraft_files) {
                         $attachedfiles_tmpdraft_files = array_map(create_function('$a', 'return array("id" => $a);'), $attachedfiles_tmpdraft_files);
                     }
                     if ($attachedfiles_tmpdraft_files) {
                         $month = date('Ym');
                         $dir = 'projects/upload/' . $month . '/';
                         $files = step_wizard_registration::transferFiles($attachedfiles_tmpdraft_files, 'file_projects', $dir);
                     }
                     $spec = $draft["categories"];
                     $spec = explode("|", $spec);
                     $spec = array(array('category_id' => $spec[0], 'subcategory_id' => $spec[1]));
                     $prj->addPrj($draft, $files);
                     $prj->saveSpecs($draft["id"], $spec);
                     // смотрим были ли выбраны платные опции для опубликованного конкурса
                     if ($draft['id'] != $project_id && $draft['id'] > 0) {
                         if ($this->sleep[$project_id]) {
                             foreach ($this->sleep[$project_id] as $k => $opt) {
                                 $opt['parent_id'] = $draft['id'];
                                 $this->billingOperation($opt);
                             }
                         } else {
                             //Обновляем родителя на всякий случай
                             $update = array("parent_id" => $draft['id']);
                             $DB->update("draft_account_operations", $update, "parent_id = ? AND op_type = 'contest' AND uid = ?", $project_id, wizard::getUserIDReg());
                             $this->sleep_parent[$project_id] = $draft['id'];
                         }
                         $DB->update("draft_projects", array('prj_id' => $draft['id']), "id = ? AND uid = ?", $project_id, wizard::getUserIDReg());
                     }
                 }
             }
             break;
             // Платный проект/конкурс
         // Платный проект/конкурс
         case 53:
             $prj = new new_projects();
             if ($this->sleep_parent[$option['parent_id']]) {
                 $option['parent_id'] = $this->sleep_parent[$option['parent_id']];
             }
             $project = $prj->getProject($option['parent_id']);
             if (!$project['id']) {
                 $this->sleep[$option['parent_id']][$option['id']] = $option;
                 return true;
             } else {
                 unset($this->sleep[$option['parent_id']]);
             }
             if ($project['country'] == null) {
                 $project['country'] = 'null';
             }
             if ($project['city'] == null) {
                 $project['city'] = 'null';
             }
             $project['name'] = addslashes($project['name']);
             $project['descr'] = addslashes($project['descr']);
             if ($project['logo_id'] <= 0) {
                 $project['logo_id'] = 'null';
             }
             $project['folder_id'] = 'null';
             $items = array();
             switch ($option['option']) {
                 case 'top':
                     $project['top_days'] = $option['op_count'];
                     break;
                 case 'color':
                     $is_pay = $project['payed_items'] & '010';
                     if ($is_pay != '010') {
                         $project['payed_items'] = $project['payed_items'] | '010';
                         $project['is_color'] = 't';
                         $items['color'] = true;
                         if (is_pro()) {
                             $is_payed = true;
                             $prj->SavePayedInfo($items, $project['id'], null, $project['top_days']);
                             $prj->editPrj($project, false);
                         }
                     } else {
                         $is_payed = true;
                     }
                     break;
                 case 'bold':
                     $is_pay = $project['payed_items'] & '001';
                     if ($is_pay != '001') {
                         $project['payed_items'] = $project['payed_items'] | '001';
                         $project['is_bold'] = 't';
                         $items['bold'] = true;
                     } else {
                         $is_payed = true;
                     }
                     break;
                 case 'logo':
                     $is_pay = $project['payed_items'] & '100';
                     if ($is_pay != '100') {
                         $key = md5(microtime());
                         $prj = new tmp_project($key);
                         $prj->init(1);
                         $fu = new CFile($option['src_id']);
                         $ext = $fu->getext();
                         $tmp_dir = $prj->getDstAbsDir();
                         $tmp_name = $fu->secure_tmpname($tmp_dir, '.' . $ext);
                         $tmp_name = substr_replace($tmp_name, "", 0, strlen($tmp_dir));
                         $fu->table = 'file_projects';
                         $r = $fu->_remoteCopy($tmp_dir . $tmp_name);
                         $project['payed_items'] = $project['payed_items'] | '100';
                         $project['logo_id'] = $fu->id;
                         $items['logo'] = true;
                         if ($option['extra']) {
                             $project['link'] = $option['extra'];
                         }
                     } else {
                         $is_payed = true;
                     }
                     break;
             }
             if (!$is_payed) {
                 $error = $account->Buy($bill_id, $transaction_id, $option['op_code'], $this->uid, $option['descr'], $option['comment'], $option['ammount'], 0);
                 $ok = $bill_id > 0;
                 $project['billing_id'] = $bill_id;
                 $prj->SavePayedInfo($items, $project['id'], $bill_id, $project['top_days']);
                 $prj->editPrj($project, false);
             } else {
                 $ok = true;
             }
             break;
             // Платные ответы на проекты
         // Платные ответы на проекты
         case 61:
             $answers = new projects_offers_answers();
             $error = $answers->BuyByFM($this->uid, $option['op_count'], $transaction_id, 0);
             if (!$error) {
                 $ok = true;
                 $_SESSION['answers_ammount'] = $option['op_count'];
                 // Публикуем ответы
                 $step_frl = new step_freelancer();
                 $offers = $step_frl->getWizardOffers($this->uid, $option['op_count']);
                 if ($offers) {
                     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/users.php";
                     $step_frl->log = $this->log;
                     $step_frl->user = new users();
                     $step_frl->user->GetUserByUID($this->uid);
                     $step_frl->transferOffers($offers);
                 }
             }
             break;
     }
     return $ok;
 }
Exemple #4
0
                $fileid = $file->id;
                $err = $file->StrError();
                if (!$err && $type == 'work_prev' && (!in_array($file->getext(), $GLOBALS['graf_array']) || strtolower($file->getext()) == 'swf' || strtolower($file->getext()) == 'flv')) {
                    $err = 'Недопустимый тип файла';
                }
                if ($type == 'photo' || $type == 'logo') {
                    if (!$err && !$file->img_to_small('sm_' . $filename, array('width' => 50, 'height' => 50))) {
                        $err .= 'Невозможно уменьшить картинку.';
                    }
                }
            }
        } elseif (!$err) {
            // логотип проекта
            require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
            $tmpPrj = new tmp_project($pkey);
            $prj = $tmpPrj->init(1);
            $err = $tmpPrj->setLogo($file);
            $tmpPrj->fix();
            $logo = $tmpPrj->getLogo();
            $logourl = WDCPREFIX . '/' . $logo['path'] . $logo['name'];
        }
    }
}
?>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<?php 
$stc->Add('/css/projects3.css');
$stc->Add('/scripts/warning.js');
Exemple #5
0
$scrollToPay = __paramInit('bool', 'pay_services', 'pay_services', false);
$draft_id = intval(__paramInit('int', 'draft_id', 'draft_id'));
$auto_draft = intval(__paramInit('int', 'auto_draft', 'auto_draft'));
if (!$key) {
    $key = md5(uniqid($uid));
    // ключ-идентификатор создаваемого/редактируемого проекта, для хранения в кэше.
    if ($step == 1 && !$proj_id) {
        // если с нулевого шага пришли. Не передаем ключ оттуда сразу, т.к. юзер может несколько
        // несколько проектов сразу открыть, в этом случае ключ должен быть уникальным.
        header("Location: /public/?step=1&kind={$kind}" . ($exec ? "&exec={$exec}" : '') . "&pk={$key}&" . ($auto_draft ? 'auto_draft=1&' : '') . ($draft_id ? 'draft_id=' . $draft_id . '&' : '') . ($hash ? 'hash=' . $hash . '&' : '') . "red=" . urlencode($back));
        exit;
    }
}
$pprm = '&pk=' . $key;
$tmpPrj = new tmp_project($key);
if (!($project = $tmpPrj->init($step, $proj_id))) {
    $user_action = $exec ? '/registration/?user_action=add_project_to_' . $exec : '/guest/new/project/';
    if ($kind != 1 && $kind != 4 || $exec) {
        ref_uri();
        //Сохраняем ref_uri страницы
    }
    if ($kind == 4) {
        $user_action = '/guest/new/vacancy/';
    } elseif ($kind == 7) {
        $user_action = '/registration/?user_action=add_contest';
    }
    // Публикация проектов доступна только для работодателя
    header('Location: ' . $user_action);
    exit;
}
//Проверка перехода с лендинга публикации проекта
 public function paidOperation($id)
 {
     global $DB;
     if (!$id) {
         return false;
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
     $operation = $DB->row('SELECT * FROM draft_account_operations WHERE id = ? AND status IS NULL', $id);
     $account = new account();
     $this->_transactionId = $account->start_transaction($_SESSION['uid'], $this->_transactionId);
     switch ($operation['op_type']) {
         case 'project':
             $project = $DB->row('SELECT id, payed_info FROM projects WHERE id = ?i', $operation['parent']);
             if (!$project['id']) {
                 return 'Ошибка обработки операции.';
             }
             if ($account->sum >= $operation['ammount']) {
                 if ($error = $account->Buy($bill_id, $this->_transactionId, $operation['op_code'], $_SESSION['uid'], trim($operations['descr'], '/'), trim($operations['comments'], '/'), 1, true)) {
                     return $error;
                 }
             }
             if (!$bill_id) {
                 return 'Не хватает денег.';
             }
             $update = array();
             switch ($operation['option']) {
                 case 'color':
                     $update['is_color'] = true;
                     $update['payed_items'] = $project['payed_info'] | '010';
                     break;
                 case 'bold':
                     $update['is_bold'] = true;
                     $update['payed_items'] = $project['payed_info'] | '001';
                     break;
                 case 'top':
                     $update['top_from'] = date('d.m.Y H:i', strtotime('now'));
                     $update['top_to'] = date('d.m.Y H:i', strtotime("now +{$operation['op_count']} day"));
                     break;
                 case 'logo':
                     $update['logo_id'] = $operation['src_id'];
                     $update['payed_items'] = $project['payed_info'] | '100';
                     break;
             }
             $update['billing_id'] = $bill_id;
             $DB->update('projects', $update, 'id = ?', $operation['parent']);
             header('Location: /bill/success/');
             exit;
             break;
         case 'contest':
             // Публикация конкурса
             if ($account->sum >= $operation['ammount']) {
                 if ($error = $account->Buy($bill_id, $this->_transactionId, $operation['op_code'], $_SESSION['uid'], trim($operations['descr'], '/'), trim($operations['comments'], '/'), 1, true)) {
                     return $error;
                 }
             }
             if (!$bill_id) {
                 return 'Не хватает денег.';
             }
             $key = md5(microtime());
             $prj = new tmp_project($key);
             if (get_uid()) {
                 $prj->init(1);
             }
             $draft = new drafts();
             $project = $drafts->getDraft($operation['parent'], $_SESSION['uid'], 1);
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/attachedfiles.php';
             $attachedfiles = new attachedfiles();
             $attachedfiles_tmpdraft_files = drafts::getAttachedFiles($operation['parent'], 4);
             if ($attachedfiles_tmpdraft_files) {
                 $attachedfiles_prj_files = array();
                 foreach ($attachedfiles_tmpdraft_files as $attachedfiles_draft_file) {
                     $attachedfiles_draft_files[] = $attachedfiles_draft_file;
                 }
                 $attachedfiles->setFiles($attachedfiles_draft_files, 1);
             }
             $insert = array('user_id' => $_SESSION['uid'], 'name' => $project['name'], 'descr' => $project['descr'], 'kind' => $project['kind'], 'cost' => $project['cost'], 'currency' => $project['currency'], 'country' => $project['country'] > 0 ? $project['country'] : 'NULL', 'city' => $project['city'] > 0 ? $project['city'] : 'NULL', 'payed' => '0', 'pro_only' => $project['pro_only'], 'logo_id' => 'NULL', 'link' => $project['logo_link'], 'is_color' => 'f', 'is_bold' => 'f', 'billing_id' => 0, 'payed_items' => '000', 'folder_id' => 0, 'budget_type' => $project['budget_type'], 'priceby' => $project['priceby'], 'prefer_sbr' => $project['prefer_sbr'], 'end_date' => $project['p_end_date'], 'win_date' => $project['p_win_date']);
             if (!empty($project['categories'])) {
                 $cat = explode('|', $project['categories']);
                 $categories[0] = array('category_id' => intval($cat[0]), 'subcategory_id' => intval($cat[1]));
             }
             $create = $prj->addPrj($insert, $attachedfiles_draft_files, $categories);
             // Добавляем проект
             if ($create) {
                 $drafts->DeleteDraft($draft_id, $uid, 1);
                 header('Location: /bill/success/');
                 exit;
             }
             break;
         case 'account':
             // Покупка ПРО
             break;
     }
 }
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;
}
Exemple #8
0
 /**
  * Добавление проекта
  * 
  * @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']));
 }