示例#1
0
 private function getOriginProf()
 {
     if (!$this->or_prof) {
         $this->or_prof = professions::GetProfessionOrigin($this->prof_id);
     }
     return $this->or_prof;
 }
示例#2
0
 /**
  * Инициализация.
  *
  * @param $link_id ID раздела псевдо-каталога
  */
 public function fseoInit($link_id = null)
 {
     global $DB;
     $this->aGet = array();
     $this->sSQLProfId = 0;
     $aLink = $DB->row('SELECT * FROM freelancer_seo WHERE id=?i', $link_id);
     if ($aLink) {
         $this->sLinkId = $aLink['id'];
         $this->sProfId = $aLink['prof_id'];
         $this->sTitle = $aLink['title'];
         $this->sCondition = $aLink['condition'];
         $this->nSide = $aLink['side'];
         $aParts = explode('&', $aLink['condition']);
         foreach ($aParts as $sOne) {
             list($sKey, $sVal) = explode('=', $sOne);
             if ($sKey == 'additional_prof' || $sKey == 'main_prof') {
                 $this->aGet[$sKey] = professions::GetProfessionOrigin($sVal);
             } else {
                 $this->aGet[$sKey] = explode(',', $sVal);
             }
         }
         if (!empty($this->aGet['main_prof']) || !empty($this->aGet['additional_prof'])) {
             $this->sSQLProfId = !empty($this->aGet['main_prof']) ? $this->aGet['main_prof'] : $this->aGet['additional_prof'];
         }
     }
 }
示例#3
0
 /**
  * Заполнение обязательных полей после регистрации через API мобильного приложения.
  * 
  * @param  array $aParams массив входящих данных
  * @return bool true - успех, false - провал
  */
 public function actionSaveInfoMobile($aParams = array())
 {
     $this->setFieldInfo('uname', __paramValue('string', iconv('utf-8', 'cp1251', $aParams['first_name'])));
     $this->setFieldInfo('usurname', __paramValue('string', iconv('utf-8', 'cp1251', $aParams['last_name'])));
     $this->setFieldInfo('birthday', __paramValue('string', $aParams['birthday']));
     $this->setFieldInfo('country', __paramValue('int', $aParams['country_id']));
     $this->setFieldInfo('city', __paramValue('int', $aParams['city_id']));
     $this->setFieldInfo('info_for_reg', array('birthday' => 0, 'sex' => 0, 'country' => 0, 'city' => 0));
     $gender = __paramValue('int', $aParams['gender']);
     $this->setFieldInfo('sex', $gender == 1 ? 't' : ($gender == 2 ? 'f' : NULL));
     $this->checkedFields();
     if (date('Y-m-d', strtotime($aParams['birthday'])) != $aParams['birthday']) {
         $this->error['birthday'] = 'Укажите некорректную дату дня рождения';
         $this->errno['birthday'] = 2;
     }
     if (empty($this->error)) {
         if (!is_emp()) {
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer.php';
             $user = new freelancer();
         } else {
             require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/employer.php';
             $user = new employer();
         }
         $user->info_for_reg = serialize($this->info_for_reg);
         $user->uname = $this->uname;
         $user->usurname = $this->usurname;
         $user->sex = $this->sex;
         $user->birthday = $this->birthday;
         $user->country = $this->country;
         $user->city = $this->city;
         if (!is_emp()) {
             $spec = intvalPgSql($aParams['prof_id']);
             if ($spec) {
                 require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
                 $or_spec = professions::GetProfessionOrigin($spec);
                 $spec_mod = professions::getLastModifiedSpec($_SESSION['uid']);
                 if (!is_pro() && $spec_mod['days'] > 0) {
                     $this->error['spec'] = 'Не прошло 30 дней с момента последней смены специализации';
                     $this->errno['spec'] = 2;
                 } else {
                     $user->spec = $spec;
                     $user->spec_orig = $or_spec;
                     professions::setLastModifiedSpec($_SESSION['uid'], $spec);
                 }
             } else {
                 $this->error['spec'] = 'Не указан параметр ID профессии';
                 $this->errno['spec'] = 1;
             }
         }
         if (empty($this->error)) {
             if ($sError = $user->Update($_SESSION['uid'], $res)) {
                 $this->error['save'] = $sError;
             } else {
                 if (!is_emp()) {
                     $_SESSION['specs'] = $user->GetAllSpecs($_SESSION['uid']);
                 }
             }
         }
         if (empty($this->error['save'])) {
             $_SESSION['check_user_access'] = true;
         }
     }
     return empty($this->error);
 }
示例#4
0
             }
             $kwords->moderUserKeys($uid, $prof_id, $aOldIds, $ids, $uid, $keys);
         }
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     $obj_prof = new professions();
     $error_prof .= $obj_prof->UpdateProfDesc($uid, $_POST['prof_id'], str_replace(" ", "", $_POST['prof_cost_from']), str_replace(" ", "", $_POST['prof_cost_to']), str_replace(" ", "", $_POST['prof_cost_hour']), str_replace(" ", "", $_POST['prof_cost_1000']), $_POST['prof_cost_type'], $_POST['prof_cost_type_hour'], $_POST['prof_time_type'], $_POST['prof_time_from'], $_POST['prof_time_to'], $_POST['prof_text'], $errorProfText);
     if (!$error_prof) {
         $info_prof = "Изменения внесены";
     }
     $saved_prof_id = intval($_POST['prof_id']);
     break;
 case "spec_change":
     $spec = trim($_POST['spec']);
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     $or_spec = professions::GetProfessionOrigin($spec);
     $frl = new freelancer();
     $frl->spec = $spec;
     $frl->spec_orig = $or_spec;
     professions::setLastModifiedSpec($uid, $spec);
     $error .= $frl->Update($uid, $res);
     $_SESSION['specs'] = $frl->GetAllSpecs($uid);
     break;
 case "save_spec_add":
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     if (professions::UpdateProfsAddSpec($uid, __paramInit('int', NULL, 'oldprof_id'), __paramInit('int', NULL, 'prof_id'), __paramInit('int', NULL, 'paid_id'))) {
         $_SESSION['specs'] = freelancer::GetAllSpecs($uid);
         header("Location: /users/{$login}/setup/specaddsetup/");
         exit;
     }
     break;
示例#5
0
 /**
  * Обработка данных в шаге порфтоило
  * 
  * @return string 
  */
 public function actionProcessingPortfolio()
 {
     $error = array();
     $type = __paramInit('int', null, 'spec_column_id');
     $spec = __paramInit('int', null, 'spec_db_id');
     $spec_name = __paramInit('string', null, 'spec');
     if ($type == 0) {
         $error['spec'] = 'Вы должны выбрать свою специализацию';
     } else {
         $data['spec_orig'] = professions::GetProfessionOrigin($spec);
     }
     $data['spec'] = $spec;
     $data['exp'] = __paramInit('int', null, 'exp');
     $data['cost_hour'] = __paramInit('float', null, 'cost_hour');
     $data['cost_type_hour'] = __paramInit('int', null, 'currency_hour_db_id');
     $curr_hour_name = __paramInit('string', null, 'currency_hour');
     $data['cost_month'] = __paramInit('float', null, 'cost_month');
     $data['cost_type_month'] = __paramInit('int', null, 'currency_month_db_id');
     $curr_month_name = __paramInit('string', null, 'currency_month');
     $data['resume'] = __paramInit('int', null, 'resume_id');
     $data['info'] = stripslashes(__paramInit('string', null, 'info', ''));
     if (strlen($data['info']) > 4000) {
         $error['info'] = 'Исчерпан лимит символов для этого поля (4000 символов)';
     }
     $data['in_office'] = $_POST['in_office'] == 1 ? 1 : 0;
     if ($data['resume'] > 0) {
         $resume = new CFile($data['resume']);
     }
     if ($data['exp'] < 0 || $data['exp'] > step_freelancer::MAX_YEAR_VALUE) {
         $error['exp'] = 'Недопустимое значение. Опыт работы должен быть в пределе от 0 до ' . step_freelancer::MAX_YEAR_VALUE . '.';
     }
     if ($data['cost_hour'] < 0 || $data['cost_hour'] > $this->MAX_COST_HOUR[$data['cost_type_hour']]) {
         $error['cost_hour'] = 'Недопустимое значение. Стоимость часа работы должна быть в пределе ' . view_range_cost2(0, $this->MAX_COST_HOUR[$data['cost_type_hour']], '', '', false, $data['cost_type_hour'] . '.');
     }
     if ($data['cost_month'] < 0 || $data['cost_month'] > $this->MAX_COST_MONTH[$data['cost_type_month']]) {
         $error['cost_month'] = 'Недопустимое значение. Стоимость месяца работы должна быть в пределе ' . view_range_cost2(0, $this->MAX_COST_MONTH[$data['cost_type_month']], '', '', false, $data['cost_type_month']) . '.';
     }
     if (count($error) <= 0) {
         $insert['portfolio'] = serialize($data);
         $this->parent->saveFieldsInfo($insert);
     }
     // Обрабатываем порфтолио
     if (is_array($_POST['name'])) {
         foreach ($_POST['name'] as $k => $value) {
             $value = __paramValue('string', stripslashes($value));
             $descr = __paramValue('string', stripslashes($_POST['descr'][$k]));
             $id = __paramValue('int', $_POST['id'][$k]);
             // id работы, если он есть
             $link = __paramValue('string', stripslashes($_POST['link'][$k]));
             $link = preg_replace("/^http:\\/\\//", "", trim($link));
             if ($value == '' && $descr == '' && $link == '' && empty($_POST['pict_id'][$k])) {
                 continue;
             }
             if (is_empty_html($value)) {
                 $error['portf' . $k]['name'] = "Введите название работы";
             }
             if (strlen($descr) > 1500) {
                 $error['descr' . $k]['name'] = "Исчерпан лимит символов для этого поля (1500 символов)";
             }
             if ($link != '' && !url_validate($link)) {
                 $error['portf' . $k]['link'] = "Поле заполнено некорректно";
             }
             $portf_insert[] = array("name" => $value, "pict_id" => $_POST['pict_id'][$k] > 0 ? intval($_POST['pict_id'][$k]) : null, "link" => $link, "prof_id" => $spec, "wiz_uid" => $this->getWizardUserID(), "descr" => $descr, "id" => $id);
         }
     }
     if (count($error) <= 0) {
         if (count($portf_insert) > 0) {
             $ids = $this->createWorks($portf_insert);
         }
         $this->parent->setCompliteStep(true);
         $this->parent->setNextStep($this->parent->getPosition() + 1);
         header("Location: /wizard/registration/");
         exit;
     }
     $this->request = $data;
     $this->portf_insert = $portf_insert;
     return $error;
 }
示例#6
0
 /**
  * Возвращает количество всех и PRO фрилансеров по заданными профессиям
  * @param   integer          $all_count   возвращает количество всех фрилансеров
  * @param   integer          $pro_count   возвращает количество всех PRO-фрилансеров
  * @param   string           $all_profs   если NULL, то $pro_profs должен быть не NULL, что означает, что нужно считать только ПРО-количество.
  *                                        если 'ALL', то $pro_profs игнорируется и выдаются количества (то есть ВСЕХ и ПРО из них)
  *                                        всех юзеров независимо от их специализаций, главное, чтобы они каким-то образом (по логике каталога) присутствовали в каталоге.
  * @param   integer|string   $all_profs   список профессий (если список, то должна быть строка разделенная запятыми), из которых нужно брать только ПРО юзеров
  * @return  integer                       успех выполнения
  */
 function GetMergeCountByProfs(&$all_count, &$pro_count, $all_profs = NULL, $pro_profs = NULL)
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . "/classes/professions.php";
     $all_count = 0;
     $pro_count = 0;
     if (!$all_profs && !$pro_profs) {
         return 0;
     }
     if ($all_profs == 'ALL') {
         $pro_profs = NULL;
     }
     if ($all_profs && $all_profs != 'ALL') {
         $all_profs = professions::GetProfessionOrigin($all_profs);
     }
     if ($pro_profs && $pro_profs != 'ALL') {
         $pro_profs = professions::GetProfessionOrigin($pro_profs);
     }
     if ($all_profs == 'ALL' || $pro_profs == 'ALL') {
         $sql = "SELECT COUNT(fu.uid) as count,\n              SUM((fu.is_pro IS TRUE)::int) as pro_count\n         FROM fu\n       INNER JOIN\n         portf_choise pc\n           ON pc.user_id = fu.uid\n          AND pc.prof_id = fu.spec_orig" . ($pro_profs == 'ALL' ? ' WHERE fu.is_pro = true' : '');
     } else {
         $sql = "\n        SELECT\n               COUNT(su.uid) as count,\n               SUM((su.is_pro IS TRUE)::int) as pro_count\n          FROM\n          (" . (!$all_profs ? '' : "SELECT " . (!$pro_profs ? 'DISTINCT' : '') . " s.*\n                   FROM\n                   (\n                     SELECT uid, is_pro FROM fu WHERE is_banned = '0' AND spec_orig IN ({$all_profs})\n                     UNION ALL\n                     SELECT fu.uid, fu.is_pro\n                       FROM fu\n                     INNER JOIN\n                       spec_add_choise sp\n                         ON sp.user_id = fu.uid\n                        AND sp.prof_id IN ({$all_profs})\n                      WHERE fu.is_pro = true\n                        AND fu.is_banned = '0'\n                     UNION ALL\n                     SELECT fu.uid, fu.is_pro\n                       FROM fu\n                     INNER JOIN\n                       spec_paid_choise pc\n                         ON pc.user_id = fu.uid\n                        AND pc.prof_id IN ({$all_profs}) AND pc.paid_to > NOW()\n                      WHERE fu.is_banned = '0'\n                   ) as s" . (!$pro_profs ? '' : ' UNION ')) . (!$pro_profs ? '' : "SELECT " . (!$all_profs ? 'DISTINCT' : '') . " s.*\n                   FROM\n                   (\n                     SELECT uid, is_pro, is_team FROM fu WHERE is_pro=true AND is_banned = '0' AND spec_orig IN ({$pro_profs})\n                     UNION ALL\n                     SELECT fu.uid, fu.is_pro, fu.is_team\n                       FROM fu\n                     INNER JOIN\n                       spec_add_choise sp\n                         ON sp.user_id = fu.uid\n                        AND sp.prof_id IN ({$pro_profs})\n                      WHERE fu.is_pro = true\n                        AND fu.is_banned = '0'\n                     UNION ALL\n                     SELECT fu.uid, fu.is_pro, fu.is_team\n                       FROM fu\n                     INNER JOIN\n                       spec_paid_choise pc\n                         ON pc.user_id = fu.uid\n                        AND pc.prof_id IN ({$pro_profs}) AND pc.paid_to > NOW()\n                      WHERE fu.is_banned = '0'\n                   ) as s ") . "\n          ) as su";
     }
     $memBuff = new memBuff();
     $count_arr = $memBuff->getSql($error, $sql, 1800);
     if (!$error) {
         $all_count = $count_arr[0]['count'];
         $pro_count = $count_arr[0]['pro_count'];
         return 1;
     }
     return 0;
 }
示例#7
0
// #f5f5f5 фон графика
// #f6f6f6 серый фон таблицы
// #f7f7f7 серый блок внизу
// #808080 темно-серые подписи к графику
// #b2b2b2 светло-серые подписи к графику
$u_m_prm_periods = array();
// склеенные периоды использования параметра (текущего инструмента самопродвижения), начиная с текущего месяца.
$u_y_prm_periods = array();
// склеенные периоды использования параметра, начиная с текущего года.
$u_last_prm_left = 0;
// отступ в пикселях от начала годового графика до начала последнего юзерского ПРО-периода.
$u_last_prm_width = 0;
// ширина последнего юзерского ПРО-периода, в пикселях.
$u_last_prm_period = NULL;
$u_prm_end_time = 0;
$u_spec = professions::GetProfessionOrigin($user->spec);
$u_login = $user->login;
$u_is_profi = $user->is_profi == 't';
$u_is_pro = $iAmAdmin ? is_pro(true, $uid) : $_SESSION['pro_last'] !== NULL;
// ПРО ли он. Может измениться далее (см. ниже) -- связано с тем, что поле is_pro обновляется раз в минуту.
$u_is_pro_auto_prolong = $user->GetField($uid, $e, 'is_pro_auto_prolong', false);
// Включено ли у юзера автоматическое продление PRO
$u_is_verify = $user->is_verify;
$u_summary = promotion::GetSummary($uid);
// данные по юзеру из stat_summary.
$u_rating = $user->GetField($uid, $e, 'rating_get(rating, is_pro, is_verify)');
$u_pro_rating = $u_rating;
// рейтинг, с учетом, что юзер купит ПРО (определяется ниже).
$u_has_ps = false;
// есть ли у него платные места хоть где-то.
$u_has_ps_fp = false;
示例#8
0
    //Cсылка для new_paginator()
    $sHref = "%s" . $cur_page_url . "page=%d%s";
    if ($page > 1) {
        $additional_header .= '<link rel="prev" href="' . $cur_page_url . 'page=' . ($page - 1) . '">';
    }
    if ($page < $pages) {
        $additional_header .= '<link rel="next" href="' . $cur_page_url . 'page=' . ($page + 1) . '">';
    }
    $content = "content.php";
}
//------------------------------------------------------------------------------
// Попапы закреплений фрилансеров ----------------------------------------------
$popup = __paramInit('string', 'popup');
$freelancer_binds = new freelancer_binds();
$is_spec = $prof_id > 0;
$prof_use = $is_spec ? professions::GetProfessionOrigin($prof_id) : $prof_group_id;
$allow_frl_bind = $freelancer_binds->isAllowBind($uid, $prof_use, $is_spec);
$binded_to = $freelancer_binds->getBindDateStop($uid, $prof_use, $is_spec);
if ($allow_frl_bind || $binded_to) {
    quickPaymentPopupFrlbind::getInstance()->init(array('prof_id' => $prof_id, 'prof_group_id' => $prof_group_id, 'prof_use' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPrice($prof_use, $is_spec, (bool) $binded_to, $uid), 'date_stop' => $binded_to, 'autoshow' => $popup == 'bind_prolong', 'addprof' => $is_spec && $freelancer_binds->needAddProf($uid, $prof_use)));
}
$is_bind_first = $freelancer_binds->isBindFirst($uid, $prof_use, $is_spec);
if ($binded_to && !$is_bind_first) {
    quickPaymentPopupFrlbindup::getInstance()->init(array('prof_id' => $prof_use, 'is_spec' => $is_spec, 'ammount' => $freelancer_binds->getPriceUp($prof_use, $is_spec, $uid), 'autoshow' => $popup == 'bind_up'));
}
$is_binded_hide = $binded_to && !$freelancer_binds->isAllowBind($uid, $prof_use, $is_spec, false);
//------------------------------------------------------------------------------
unset($_SESSION['payed_frl_' . md5($_SERVER['REQUEST_URI'])]);
$first_pages = array();
if ($prof_group_id) {
    $first_pages = firstpage::GetAll($prof_group_id, array(), true);
示例#9
0
 /**
  * Проверяет по специализациям, может ли текущий пользователь ответить на проект.
  * 
  * @param int $projec_id ид проекта
  *
  * @return boolean
  */
 public static function offerSpecIsAllowed($projec_id)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects.php';
     // ПРО отвечают без ограничений
     if (is_pro()) {
         return true;
     }
     if (!get_uid(false)) {
         return false;
     }
     $is_send_offers = false;
     $spec_project = new_projects::getSpecs($projec_id);
     $user_spec = professions::GetProfsAddSpec($_SESSION['uid']);
     if (is_array($user_spec)) {
         $user_spec = array_merge($user_spec, $_SESSION['specs']);
     } else {
         $user_spec = $_SESSION['specs'];
     }
     if ($user_spec) {
         $user_spec = array_merge($user_spec, professions::GetMirroredProfs(professions::GetProfessionOrigin(implode(',', $user_spec))));
         $user_spec = array_unique($user_spec);
         //@todo запехать в один запрос
         foreach ($user_spec as $spec) {
             $prof_group[$spec] = professions::GetProfField($spec, 'prof_group');
         }
     }
     foreach ($spec_project as $specs) {
         if (is_array($prof_group) && in_array($specs['category_id'], $prof_group)) {
             $is_send_offers = true;
             // Разрашаем оставлять отзыв
             break;
         }
     }
     return $is_send_offers;
 }
示例#10
0
    $anchor = 0;
    $cat_menu_freelancers = true;
} else {
    // Подсчитываем количество избранных. Переписать в отдельный метод.
    //  $fav_count = 0;
    if (!$prof_link) {
        $prof_link = professions::GetProfField($prof_id, 'link');
    }
    $prof_name_arr = professions::GetProfTitle($prof_id);
    $prof_name = $prof_name_arr['name'];
    $prof_title = $prof_name_arr['title'] ? $prof_name_arr['title'] : $prof_name;
    $prof_type = professions::GetProfType($prof_id);
    //$prof_group_name = professions::GetProfGroupName($prof_id);
    $prof_descr = professions::GetProfField($prof_id, 'descr');
    $prof_descr_text = professions::GetProfField($prof_id, 'descr_text');
    $anchor = professions::GetProfessionOrigin($prof_id);
    $g_page_id = "1|" . $prof_id;
    if ($page == 1) {
        if (empty($prof_name_arr['title'])) {
            $page_title = $prof_title . " - фриланс, удаленная работа на FL.ru";
            $page_keyw = $prof_title . ", Поиск работы, Предложение работы, Портфолио фри-лансеров, FL.ru";
        } else {
            $page_title = $page_keyw = $prof_name_arr['title'] . " - фриланс, удаленная работа%prepositional_cityname% на FL.ru";
            $page_keyw = $prof_name_arr['title'] . ", Поиск работы, Предложение работы, Портфолио фри-лансеров, FL.ru";
        }
    } else {
        $page_title = $prof_name . ' - Страница ' . $page . ' - фриланс, удаленная работа%prepositional_cityname% на FL.ru';
        $page_keyw = $prof_name . ', Страница ' . $page . ', FL.ru';
    }
    if ($page == 1) {
        $page_descr = $prof_title . " Удаленная работа. Поиск работы. Предложение работы. Портфолио фри-лансеров. FL.ru";
示例#11
0
if (!$uid || is_emp()) {
    include $_SERVER['DOCUMENT_ROOT'] . '/403.php';
    exit;
}
$profession_id = __paramInit('int', null, 'profession', null);
if ($profession_id !== null) {
    $redirect_to = '/projects/';
    if ($profession_id > 0) {
        require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/projects_filter.php';
        //Создаем фильтр для проектов
        $f_category[1][$profession_id] = 1;
        $prj_filter = new projects_filters();
        $prj_filter->Save($uid, '', '', 2, true, $f_category, '', '', '', false, $rerror, $error, 0, 0, false, false, false, false, false, false, false, false, 4, false, false);
        setcookie('new_pf0', 1, time() + 60 * 60 * 24 * 30, '/');
        //Сохраняем как основную специализацию
        $or_spec = professions::GetProfessionOrigin($profession_id);
        $frl = new freelancer();
        $frl->spec = $profession_id;
        $frl->spec_orig = $or_spec;
        professions::setLastModifiedSpec($uid, $profession_id);
        $frl->Update($uid, $error);
        $_SESSION['specs'] = $frl->GetAllSpecs($uid);
    }
    //Если есть редирект то он приоритетней
    if ($_SESSION['ref_uri']) {
        $redirect_to = urldecode($_SESSION['ref_uri']);
    }
    $_user_action = isset($_REQUEST['user_action']) && $_REQUEST['user_action'] ? substr(htmlspecialchars($_REQUEST['user_action']), 0, 25) : '';
    $_user_action = trim($_user_action);
    switch ($_user_action) {
        case 'tu':
示例#12
0
 /** 
  * Возвращает номер позиции юзера в каталоге
  * 
  * @param integer $user_id       ИД Пользователя
  * @param integer $user_spec		специализация юзера.
  * @param integer $rating		рейтинг юзера.
  * @param integer $prof_id		рейтинг юзера.
  * @param integer $is_pro	    Пользователь ПРО или не ПРО.
  * @return NULL|multitype
  */
 function GetCatalogPosition($user_id, $user_spec, $rating, $prof_id, $is_pro, $not_exact = false)
 {
     global $DB;
     $R = 'rating_get(fu.rating, fu.is_pro, fu.is_verify, fu.is_profi)';
     $pos = NULL;
     $memBuff = new memBuff();
     if (!$prof_id) {
         if (!$not_exact) {
             $pos_table = professions::GetCatalogPositionsTable();
             //такого не должно быть, но на всякий
             if (!$pos_table) {
                 return NULL;
             }
             $out = $DB->row("SELECT 0 as prof_id, 'В общем каталоге' as prof_name, pos FROM {$pos_table} WHERE uid = ?", $user_id);
             if ($out) {
                 return $out;
             }
         }
         $sql = "SELECT 0 as prof_id, 'В общем каталоге' as prof_name, COUNT(fu.uid) + 1 as pos\n               FROM fu\n             INNER JOIN\n               portf_choise pc\n                 ON pc.user_id = fu.uid\n\n                AND pc.prof_id = fu.spec_orig\n              WHERE fu.is_banned = '0'\n                AND (fu.is_pro = true " . ($is_pro ? 'AND' : 'OR') . " ({$R} > {$rating} OR ({$R} = {$rating} AND fu.uid < {$user_id})))";
         if (!($out = $memBuff->getSql($error, $sql, 300))) {
             return NULL;
         }
         return $out[0];
     }
     $or_prof = $prof_id;
     $or_prof = professions::GetProfessionOrigin($prof_id);
     $freelancer_binds = new freelancer_binds();
     $date_binded = $freelancer_binds->getBindDate($user_id, $or_prof);
     $bind_select = $bind_join = $spec_where = '';
     if ($date_binded) {
         $bind_join = "INNER JOIN freelancer_binds ON freelancer_binds.user_id = fu.uid AND freelancer_binds.prof_id = {$or_prof} AND freelancer_binds.is_spec = TRUE AND freelancer_binds.date_stop > NOW() AND freelancer_binds.date_start > '{$date_binded}'";
     } else {
         //Ищем всех закрепленных
         $bind_select = "SELECT fu.uid, fb.prof_id as spec FROM fu \n                LEFT JOIN freelancer_binds fb ON fb.user_id = fu.uid AND fb.date_stop > NOW()\n                LEFT JOIN spec_add_choise bsa ON bsa.user_id = fu.uid\n                WHERE fu.is_banned = '0' \n                    AND fb.prof_id={$or_prof} AND (fu.spec_orig = {$or_prof} OR bsa.prof_id = {$or_prof})\n                    AND fu.uid<>{$user_id} AND fu.cat_show = TRUE\n                UNION ALL ";
         $spec_where = "AND (fu.is_pro = true " . ($is_pro ? 'AND' : 'OR') . " ({$R} > {$rating} OR ({$R} = {$rating} AND fu.uid <> {$user_id})" . ($user_spec == $or_prof ? ") AND fu.spec_orig={$or_prof}" : " OR fu.spec_orig={$or_prof})") . ")";
     }
     $user_where = "\n            fu.is_banned = '0' \n            AND fu.uid <> {$user_id} \n            AND fu.cat_show = TRUE \n            AND fu.last_time > now() - '6 months'::interval\n        " . $spec_where;
     $sql = "SELECT \n                p.id as prof_id,\n                p.name as prof_name,\n                COUNT(DISTINCT s.uid) + 1 as pos,\n                link\n           \n           FROM professions p\n         LEFT JOIN\n           (\n            {$bind_select}\n                \n             SELECT uid, spec_orig as spec\n               FROM fu\n               {$bind_join}\n              WHERE " . $user_where . "\n                \n             UNION ALL\n             \n              SELECT fu.uid, sa.prof_id FROM fu\n              INNER JOIN spec_add_choise sa ON sa.user_id = fu.uid\n              {$bind_join}\n               WHERE fu.is_pro = true AND " . $user_where . "\n                   \n           ) AS s ON s.spec = p.id\n    \n          WHERE p.id = {$or_prof}\n          GROUP BY p.id, p.name, link";
     $out = $memBuff->getSql($error, $sql, 300, true, freelancer::getCatalogMemTags($or_prof, true));
     return $out ? $out[0] : null;
 }
示例#13
0
 /**
  * Редактирование работы в портфолио.
  *
  * @see self::addPortf();
  * 
  * @param integer $fid     		 ИД 
  * @param string  $name    		 Название работы
  * @param string  $pict    		 Основное изображение
  * @param string  $sm_pict 		 Уменьшенное изображение
  * @param string  $link    		 Ссылка на работу
  * @param string  $descr   		 Описание работы
  * @param integer $prof    		 Специализация работы
  * @param integer $cost    		 Стоимость работы
  * @param integer $cost_type 	 Тип стоимости
  * @param integer $time_type 	 Тип времени работы
  * @param integer $time_value 	 Время рабты
  * @param integer $prev_type  	 Тип превью
  * @param mixed   $file_error    Ошибка файла если есть 
  * @param mixed   $preview_error Превью ошибка
  * @param integer $new_position  Новая позиция
  * @param integer $in_shop       Работа в магазине  
  * @param integer $is_video      Есть ли видео 
  * @param string  $video_link    Ссылка на видео
  * @param boolean $upd_prev           Нужно ли обновить превью из основного изображения
  * @param integer $moduser_id         UID изменяющего пользователя (админа). если null - то берется $fid
  * @param string  $pict_filename      Основное изображение для новой загрузки файлов
  * @param string  $prev_pict_filename Уменьшенное изображение для новой загрузки файлов
  * @param string  $login              логин пользователя на случай если редактирует админ
  * @param string  $modified_reason    причина редактирования
  *
  * @return string Сообщение об ошибке
  */
 public function EditPortf($fid, $name, $pict, $sm_pict, $link, $descr, $prof, $cost, $cost_type, $time_type, $time_value, $prev_type, $prj_id, &$file_error, &$preview_error, $new_position, $in_shop = 0, $video_link = '', $upd_prev = false, $moduser_id = null, $pict_filename = '', $prev_pict_filename = '', $login = '', $modified_reason = '')
 {
     global $DB;
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
     $prfs = new professions();
     $profs = $prfs->GetAllProfessionsPortf($fid);
     foreach ($profs as $pf) {
         if ($pf['checked']) {
             $check_prof[] = $pf['id'];
         }
     }
     $check_prof[] = professions::CLIENTS_PROF_ID;
     $check_prof[] = professions::BEST_PROF_ID;
     if (!in_array($prof, $check_prof)) {
         return false;
     }
     $old_pict = $this->GetField($prj_id, 'pict');
     $old_prev_pict = $this->GetField($prj_id, 'prev_pict');
     $sp = $this->GetField($prj_id, 'show_preview');
     $dir = $login ? $login : get_login($fid);
     $l_dir = substr($dir, 0, 2) . '/' . $dir;
     $mp = false;
     $filename = '';
     $fullDir = 'users/' . $l_dir . '/upload/';
     $moduser_id = $moduser_id ? $moduser_id : $fid;
     // если превью не загружено и требуется обновить превью на основе основного изображения
     if (!$sm_pict->size > 0 && $upd_prev) {
         $sm_pict = new CFile();
         $sm_pict->GetInfo($fullDir . $old_pict);
         // оригинальное большое изображение
         if ($sm_pict->size > 0) {
             $sm_pict->table = 'file_template';
             $sm_pict->quality = 100;
             if ($sm_pict->resizeImage($fullDir . 'sm_' . $sm_pict->name, 200, 200, 'auto', true)) {
                 // уменьшаем
                 $filename = 'sm_' . $sm_pict->name;
                 $static_preview = $filename;
                 $mp = true;
             }
         }
     }
     /**
      * Отдельно загруженное превью.
      */
     if (($sm_pict->size > 0 || $prev_pict_filename) && !$upd_prev) {
         $preview_error = '';
         if ($sm_pict->size > 0) {
             $sm_pict->max_image_size = array('width' => 200, 'height' => 200, 'less' => 0);
             $sm_pict->resize = 1;
             $sm_pict->proportional = 1;
             $sm_pict->prefix_file_name = 'sm_';
             $sm_pict->max_size = 102400;
             $filename = $sm_pict->MoveUploadedFile($dir . '/upload');
             $preview_error = $sm_pict->StrError();
             // генерируем неанимированное gif превью для ответов в проектах (только для gif файлов)
             // файл будет такой: st_sm_f_имя файла.gif
             if ($sm_pict->image_size['type'] == 1) {
                 $static_preview = 'st_' . $sm_pict->name;
                 $sm_pict->resizeImage($sm_pict->path . $static_preview, 200, 200, 'auto', true);
             } else {
                 $static_preview = $sm_pict->name;
             }
         } else {
             $filename = $prev_pict_filename;
             $static_preview = $prev_pict_filename;
         }
         if ($preview_error) {
             return $preview_error;
         } elseif ($old_prev_pict) {
             $cfile = new CFile();
             $cfile->Delete(0, "users/{$l_dir}/upload/", $old_prev_pict);
             // удаляем ранее загруженное превью
             $mp = true;
         } else {
             $mp = true;
         }
         $sql = 'SELECT show_preview FROM portf_choise WHERE user_id=?i AND prof_id=?i';
         $res = $DB->row($sql, $fid, $prof);
         $show_preview = $res['show_preview'];
         if ($show_preview == 't') {
             $sp = 't';
         }
     }
     /*else
       $filename = $old_prev_pict;*/
     if ($pict->size > 0 || $pict_filename) {
         $sql = 'SELECT prev_pict FROM portfolio WHERE id=?i AND user_id=?i';
         $res = $DB->row($sql, $prj_id, $fid);
         if ($pict->size > 0) {
             $pict->max_size = 10485760;
             $pictname = $pict->MoveUploadedFile($dir . '/upload');
             if (!isNulArray($pict->error)) {
                 $file_error = true;
                 return $pict->StrError;
             }
         } else {
             $pict = new CFile($fullDir . $pict_filename);
             $pictname = $pict_filename;
         }
         /*if (is_array($pictname))
           list($pictname, $filename) = $pictname;*/
         if ($upd_prev && !in_array($pict->getext(), $GLOBALS['graf_array'])) {
             $filename = null;
             $static_preview = null;
             $need_delete_preview = true;
         }
         if (isNulArray($pict->error) && in_array($pict->getext(), $GLOBALS['graf_array']) && !$filename && $res['prev_pict'] == '' || $upd_prev && in_array($pict->getext(), $GLOBALS['graf_array'])) {
             //print "2";exit;
             /**
              * Делаем превью.
              */
             $pict->proportional = 1;
             //$pict->imgtosmall()
             /*
                             if (!$pict->img_to_small("sm_".$pictname,array('width'=>200,'height'=>200)))
                             {
                $mp = false;
                             }
                             else
                             {
                $mp = true;
                $filename = "sm_".$pictname;
                             }
             */
             $pict->table = 'file_template';
             $pict->quality = 100;
             if ($pict->resizeImage($fullDir . 'sm_' . $pict->name, 200, 200, 'auto', true)) {
                 // уменьшаем
                 $filename = 'sm_' . $pict->name;
                 $static_preview = $filename;
                 $mp = true;
             }
             $sql = 'SELECT show_preview FROM portf_choise WHERE user_id=?i AND prof_id=?i';
             $res = $DB->row($sql, $fid, $prof);
             $show_preview = $res['show_preview'];
             if ($show_preview == 't') {
                 $sp = 't';
                 if (!$mp) {
                     $file_error .= 'Невозможно уменьшить картинку.';
                     $sp = 'f';
                 }
             }
         }
         if (isNulArray($pict->error) && $res['prev_pict'] == '') {
             if (!$cfile) {
                 $cfile = new CFile();
                 if ($old_prev_pict && $sm_pict->name) {
                     $cfile->Delete(0, "users/{$l_dir}/upload/", $old_prev_pict);
                     // удаляем ранее загруженное превью
                     $need_delete_preview = true;
                 }
             }
             if ($old_pict) {
                 $cfile->Delete(0, "users/{$l_dir}/upload/", $old_pict);
             }
             // удаляем ранее загруженное превью
         }
     } else {
         $pictname = $old_pict;
     }
     // для картинок: если превью загружено отдельно - делаем отдельное привью из оригинальной большой картинки
     $sPreview = $filename ? $filename : $old_prev_pict;
     if ($pictname != substr($sPreview, 3, strlen($sPreview))) {
         $sm_pict = new CFile();
         if (($pict->size > 0 || $pict_filename) && $old_pict) {
             $sm_pict->Delete(0, "users/{$l_dir}/upload/", 'tn_' . $old_pict);
         }
         $sm_pict->GetInfo($fullDir . $pictname);
         if ($sm_pict->size > 0) {
             $ext = $sm_pict->getext();
             if (in_array($ext, $GLOBALS['graf_array']) && $ext != 'swf') {
                 $sm_pict->table = 'file_template';
                 $sm_pict->quality = 100;
                 $sm_pict->resizeImage($fullDir . 'tn_' . $sm_pict->name, 200, 200, 'auto', true);
             }
         }
     } else {
         $sm_pict = new CFile();
         $sm_pict->Delete(0, "users/{$l_dir}/upload/", 'tn_' . $pictname);
     }
     if ($in_shop == 1) {
         $in_shop = 't';
     } else {
         $in_shop = 'f';
     }
     $prof = professions::GetProfessionOrigin($prof);
     $sql = '';
     if ($fid == $_SESSION['uid'] && !hasPermissions('users')) {
         // автор, не админ, не про меняет заголовок либо текст - отправить на модерирование
         $sModer = ' , moderator_status = ' . (!is_pro() ? '0' : '-2') . ' ';
         if (!is_pro()) {
             /*require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/stop_words.php' );
               require_once( $_SERVER['DOCUMENT_ROOT'] . '/classes/user_content.php' );
               
               $stop_words    = new stop_words();
               $nStopWordsCnt = $stop_words->calculate( $name, $descr );
               
               $DB->insert( 'moderation', array('rec_id' => $prj_id, 'rec_type' => user_content::MODER_PORTFOLIO, 'stop_words_cnt' => $nStopWordsCnt) );*/
         }
     }
     if ($mp) {
         $sql .= "UPDATE portfolio SET name='{$name}', link='{$link}', descr='{$descr}', cost='{$cost}', cost_type='{$cost_type}', time_type='{$time_type}', time_value='{$time_value}', prev_type='{$prev_type}', pict='{$pictname}', prev_pict='{$filename}', static_preview='{$static_preview}', prof_id='{$prof}'" . ($new_position !== NULL ? ", norder='{$new_position}'" : '') . ", edit_date = NOW(), edit_id = {$moduser_id}, modified_reason = '{$modified_reason}' {$sModer} WHERE (id='{$prj_id}' AND user_id='{$fid}') RETURNING norder";
     } else {
         $sql .= "UPDATE portfolio SET show_preview = '{$sp}', name='{$name}', link='{$link}', descr='{$descr}', cost='{$cost}', cost_type='{$cost_type}', time_type='{$time_type}', time_value='{$time_value}', prev_type='{$prev_type}', pict='{$pictname}', " . ($need_delete_preview ? "prev_pict='',static_preview=''," : '') . " prof_id='{$prof}'" . ($new_position !== NULL ? ", norder='{$new_position}'" : '') . ", in_shop='{$in_shop}', video_link='{$video_link}', edit_date = NOW(), edit_id = {$moduser_id}, modified_reason = '{$modified_reason}' {$sModer} WHERE (id='{$prj_id}' AND user_id='{$fid}') RETURNING norder";
     }
     $DB->squery($sql);
     return $error;
 }
示例#14
0
 /**
  * Считаем количество фрилансеров различных разрядов СБР
  *
  * @return array Данные подсчета
  */
 function getRankCount($prof_id = 0)
 {
     $memBuff = new memBuff();
     if ($prof_id) {
         $or_prof = professions::GetProfessionOrigin($prof_id);
         $tbl_s = "\n                ( SELECT * FROM fu WHERE spec_orig = '{$or_prof}' UNION ALL\n                  SELECT fu.* FROM fu INNER JOIN spec_add_choise sp ON sp.user_id = fu.uid AND sp.prof_id = '{$or_prof}' WHERE fu.is_pro = true\n                  UNION ALL\n                  SELECT fu.* FROM fu INNER JOIN spec_paid_choise spc ON spc.user_id = fu.uid AND spc.prof_id = '{$or_prof}' AND spc.paid_to > now()\n                ) as s\n            ";
     } else {
         $tbl_s = "fu s";
         $join_pc = "\n              INNER JOIN\n                portf_choise pc\n                  ON pc.prof_id = s.spec_orig\n                 AND pc.user_id = s.uid\n            ";
     }
     $sql = "\n          SELECT SUM((r.rank=3)::int) as rank3, SUM((r.rank=2)::int) as rank2, SUM((r.rank=1)::int) as rank1\n            FROM rating r\n          INNER JOIN\n            {$tbl_s}\n              ON s.uid = r.user_id\n             AND s.is_banned = '0'\n          {$join_pc}\n           WHERE r.rank > 0\n        ";
     $rank = $memBuff->getSql($error, $sql, 3600);
     if ($error || !$rank) {
         return NULL;
     }
     return $rank[0];
 }
 public function setSelectFilter($filter)
 {
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/professions.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/project_exrates.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/teams.php';
     require_once $_SERVER['DOCUMENT_ROOT'] . '/classes/freelancer.php';
     $project_exRates = project_exrates::GetAll();
     $set_select[] = '*';
     // Разделы/Подразделы
     if ($filter['prof']) {
         if (count($filter['prof'][0]) > 0) {
             $p1 = professions::getProfIdForGroups(array_keys($filter['prof'][0]), true);
         }
         if (count($filter['prof'][1]) > 0) {
             $p2 = professions::GetProfessionOrigin(implode(',', array_keys($filter['prof'][1])));
         }
         $specs = explode(',', ($p2 ? $p2 : '') . ($p1 && $p2 ? ', ' : '') . ($p1 ? $p1 : ''));
         $this->_engine->setFilter('specs', $specs);
         $this->_sortby = 'is_pro DESC, spec_origin IN (' . implode(',', $specs) . ') rating DESC, @id';
     }
     //Стоимость
     if ($filter['cost']) {
         foreach ($filter['cost'] as $val) {
             if ($val['cost_from'] || $val['cost_to']) {
                 switch ($val['type_date']) {
                     default:
                     case 4:
                         if ($prof_id) {
                             $cf = 'pcost_hour';
                             $ct = 'pcost_type_hour';
                         } else {
                             $cf = 'cost_hour';
                             $ct = 'cost_type_hour';
                         }
                         break;
                     case 3:
                         $cf = 'cost_from';
                         $ct = 'cost_type';
                         break;
                     case 1:
                         $cf = 'cost_month';
                         $ct = 'cost_type_month';
                         break;
                     case 2:
                         $cf = 'cost_1000';
                         $ct = 'cost_type';
                         break;
                 }
                 $cr = (int) $val['cost_type'];
                 $cex = array(freelancer::USD => project_exrates::USD, freelancer::EUR => project_exrates::EUR, freelancer::RUR => project_exrates::RUR, freelancer::FM => project_exrates::FM);
                 if (($cost_from = (double) $val['cost_from']) < 0) {
                     $cost_from = 0;
                 }
                 if (($cost_to = (double) $val['cost_to']) < 0) {
                     $cost_to = 0;
                 }
                 if ($cost_to < $cost_from && $cost_to != 0) {
                     $cost_to = $cost_from;
                 }
                 if ($cost_to || $cost_from) {
                     $cost_sql = '';
                     for ($i = 0; $i < 4; ++$i) {
                         $exfr = round($cost_from * $project_exRates[$cex[$cr] . $cex[$i]], 4);
                         $exto = round($cost_to * $project_exRates[$cex[$cr] . $cex[$i]], 4);
                         $cost[] = "({$ct} = {$i} AND {$cf} >= {$exfr}" . ($cost_to ? " AND {$cf} <= {$exto}" : '') . ')';
                     }
                     $select[] = implode(' OR ', $cost);
                 }
             }
         }
         if ($select) {
             $set_select[] = 'IF( ( ' . implode(' OR ', $select) . ' ), 1, 0) as cost_filter';
             unset($select);
             $this->_engine->setFilter('cost_filter', array(1));
         }
     }
     // Опыт работы
     if ($filter['exp'][0] > 0 || $filter['exp'][1] > 0) {
         if ($filter['exp'][1] == 0 && $filter['exp'][0] > 0) {
             $select[] = "( exp >= {$filter['exp'][0]} )";
         } elseif ($filter['exp'][1] > 0 && $filter['exp'][0] == 0) {
             $select[] = "( exp <= {$filter['exp'][1]} )";
         } else {
             $select[] = "( exp >= {$filter['exp'][0]} AND exp <= {$filter['exp'][1]} )";
         }
         $set_select[] = 'IF( ( ' . implode(' OR ', $select) . ' ), 1, 0) as exp_filter';
         unset($select);
         $this->_engine->setFilter('exp_filter', array(1));
     }
     //Возраст
     if ($filter['age'][1] > 0 || $filter['age'][0] > 0) {
         $age_from = $filter['age'][0];
         $age_to = $filter['age'][1];
         if ($age_to == 0 && $age_from > 0) {
             $select[] = "( age >= {$age_from} )";
         } elseif ($age_to > 0 && $age_from == 0) {
             $select[] = "( age <= {$age_to} )";
         } else {
             $select[] = "( age >= {$age_from} AND age <= {$age_to} )";
         }
         $set_select[] = 'IF( ( ' . implode(' OR ', $select) . ' ), 1, 0) as age_filter';
         unset($select);
         $this->_engine->setFilter('age_filter', array(1));
     }
     // Местоположение
     if ($filter['country']) {
         $this->_engine->setFilter('country', array($filter['country']));
     }
     if ($filter['city']) {
         $this->_engine->setFilter('city', array($filter['city']));
     }
     // Ищет работу в офисе
     if ($filter['in_office']) {
         $this->_engine->setFilter('in_office', array(1));
     }
     // У меня в избранных
     if ($filter['in_fav']) {
         $teams = new teams();
         if ($tt = $teams->teamsFavorites($uid, $error)) {
             foreach ($tt as $t) {
                 $select[] = " ( uid = {$t['uid']} ) ";
             }
             $set_select[] = 'IF(( ' . implode(' OR ', $select) . ' ), 1, 0) as is_fav';
             unset($select);
             $this->_engine->setFilter('is_fav', array(1));
         }
     }
     //С PRO аккаунтом
     if ($filter['is_pro']) {
         $this->_engine->setFilter('is_pro', array(1));
     }
     //С положительными рекомендациями
     if ($filter['sbr_is_positive']) {
         $select[] = '( sbr_opi_plus > 0 )';
         $set_select[] = 'IF(( ' . implode(' OR ', $select) . ' ), 1, 0) as sbr_positive_filter';
         unset($select);
         $this->_engine->setFilter('sbr_positive_filter', array(1));
     }
     //Без отрицательных рекомендаций
     if ($filter['sbr_not_negative']) {
         $select[] = '( sbr_opi_minus = 0 )';
         $set_select[] = 'IF(( ' . implode(' OR ', $select) . ' ), 1, 0) as sbr_not_negative_filter';
         unset($select);
         $this->_engine->setFilter('sbr_not_negative_filter', array(1));
     }
     //С положительными мнениями
     /*if($filter['opi_is_positive']) {
           $select[] = '( ops_emp_plus > 0 )';
           
           $set_select[] = "IF(( ".implode(" OR ", $select)." ), 1, 0) as opi_positive_filter";
           unset($select);
           
           $this->_engine->setFilter("opi_positive_filter", array(1));
       }
       
       //Без отрицательных мнений
       if($filter['opi_not_negative']) {
           $select[] = '( ops_emp_minus = 0 )';
           
           $set_select[] = "IF(( ".implode(" OR ", $select)." ), 1, 0) as opi_not_negative_filter";
           unset($select);
           
           $this->_engine->setFilter("opi_not_negative_filter", array(1));
       }*/
     // Только с примерами работ
     if ($filter['is_preview']) {
         $select[] = '( o_wrk_factor_a > 0 )';
         $set_select[] = 'IF(( ' . implode(' OR ', $select) . ' ), 1, 0) as preview_filter';
         unset($select);
         $this->_engine->setFilter('preview_filter', array(1));
     }
     // Только свободные
     if ($filter['only_free']) {
         $select[] = '( status_type = 0)';
         $set_select[] = 'IF(( ' . implode(' OR ', $select) . ' ), 1, 0) as onlyfree_filter';
         unset($select);
         $this->_engine->setFilter('onlyfree_filter', array(1));
     }
     //С успешным СБР
     if ($filter['success_sbr'][0] == 1) {
         $select[] = '( sbr_sum > 0 )';
         for ($i = 1; $i < 4; ++$i) {
             if ($filter['success_sbr'][$i] == 1) {
                 $rank[] = "( rank = {$i} )";
             }
         }
         if ($rank) {
             $select[] = '( ' . implode(' OR ', $rank) . ' )';
         }
         $set_select[] = 'IF(( ' . implode(' AND ', $select) . ' ), 1, 0) as sbr_rank_filter';
         unset($select);
         $this->_engine->setFilter('sbr_rank_filter', array(1));
     }
     if ($set_select) {
         $this->_engine->setSelect(implode(', ', $set_select));
     }
 }