Пример #1
0
 private function getProfessionText()
 {
     $prof_text = '';
     $prof_group_id = $this->options['prof_group_id'];
     $prof_id = $this->options['prof_id'];
     if ($prof_group_id) {
         $prof_text = professions::GetProfGroupTitle($prof_group_id);
     } elseif ($prof_id) {
         $group_id = professions::GetGroupIdByProf($prof_id);
         $prof_text = professions::GetProfGroupTitle($group_id);
         $prof_text .= ' — ';
         $prof_text .= professions::GetProfName($prof_id);
     } else {
         $prof_text = 'Каталог фрилансеров';
     }
     return $prof_text;
 }
Пример #2
0
 /**
  * Возвращает название раздела для истории платежей
  * @param type $prof_id
  * @param type $is_spec
  * @return type
  */
 private function getProfessionText($prof_id, $is_spec)
 {
     $prof_text = '';
     if ($prof_id) {
         if ($is_spec) {
             $group_id = professions::GetGroupIdByProf($prof_id);
             $prof_group_title = professions::GetProfGroupTitle($group_id);
             $prof_title = professions::GetProfName($prof_id);
             $prof_text = sprintf(self::DESCR_PROF, $prof_group_title, $prof_title);
         } else {
             $prof_group_title = professions::GetProfGroupTitle($prof_id);
             $prof_text = sprintf(self::DESCR_PROFGROUP, $prof_group_title);
         }
     } else {
         $prof_text = self::DESCR_CATALOG;
     }
     return $prof_text;
 }
Пример #3
0
                 $check[] = $catID . '_' . $subcatID;
             }
         }
         if (count($check)) {
             $uniq = array_unique($check);
             foreach ($uniq as $val) {
                 list($cat, $subcat) = explode("_", $val);
                 $cats[] = array('category_id' => $cat, 'subcategory_id' => $subcat);
             }
             $tmpPrj->setCategories($cats);
         } else {
             $error['category'] = 'Не выбран раздел';
         }
     } else {
         $subcat = $freelancer->spec;
         $cat = professions::GetGroupIdByProf($subcat);
         $cats[] = array('category_id' => $cat, 'subcategory_id' => $subcat);
         $tmpPrj->setCategories($cats);
     }
     $tmpPrj->setProjectField('country', __paramValue('int', $_POST['project_location_columns'][0]));
     $tmpPrj->setProjectField('city', __paramValue('int', $_POST['project_location_columns'][1]));
 }
 if ($project['kind'] == projects::KIND_PROJECT) {
     $tmpPrj->setProjectField('pro_only', 't');
 } else {
     $tmpPrj->setProjectField('pro_only', __paramInit('bool', NULL, 'pro_only') ? 't' : 'f');
 }
 $tmpPrj->setProjectField('verify_only', __paramInit('bool', NULL, 'verify_only') ? 't' : 'f');
 $tmpPrj->setProjectField('videolnk', __paramValue('html', antispam($_POST['videolnk']), 60, true));
 $tmpPrj->setProjectField('strong_top', __paramInit('int', NULL, 'strong_top'));
 $tmpPrj->setProjectField('prefer_sbr', __paramInit('bool', NULL, 'prefer_sbr') ? 't' : 'f');
 /**
  * Провека параметров и подготовка настроек 
  * для обновлении или добавления
  * 
  * @param type $data
  * @return type
  */
 public function isValid($data)
 {
     require_once ABS_PATH . '/freelancers/widgets/FreelancersPreviewWidget.php';
     require_once ABS_PATH . '/classes/freelancer.php';
     $this->is_valid = false;
     $max_pos = FreelancersPreviewWidget::MAX_ITEMS;
     $this->group_id = isset($data['group']) ? intval($data['group']) : 0;
     $this->prof_id = isset($data['prof']) ? intval($data['prof']) : 0;
     $hash = isset($data['hash']) ? $data['hash'] : null;
     //Проверка группы/раздела именно тех на странице которых был открыт попап
     if ($hash !== paramsHash(array($this->group_id, $this->prof_id))) {
         return $this->is_valid;
     }
     $value = isset($data['value']) ? $data['value'] : '';
     $this->uid = isset($data['uid']) && $data['uid'] > 0 ? $data['uid'] : null;
     $this->pos = isset($data['pos']) && $data['pos'] > 0 && $data['pos'] <= $max_pos ? intval($data['pos']) : null;
     if (!$this->uid || !$this->pos || empty($value)) {
         return $this->is_valid;
     }
     $user = new freelancer();
     $user->GetUserByUID($this->uid);
     if ($user->uid <= 0) {
         return $this->is_valid;
     }
     $pattern = implode('|', FreelancersPreviewEditorPopup::$types);
     $matches = array();
     if (preg_match("/^({$pattern})_([0-9]+)\$/", $value, $matches)) {
         $this->type = self::$type_from_string[$matches[1]];
         $this->src_id = $matches[2];
         switch ($this->type) {
             case self::TYPE_PF:
                 require_once ABS_PATH . '/classes/portfolio.php';
                 $portfolio = new portfolio();
                 $this->is_valid = (bool) $portfolio->isExistActive($this->uid, $this->src_id);
                 break;
             case self::TYPE_TU:
                 require_once ABS_PATH . '/classes/tservices/tservices.php';
                 $tservices = new tservices($this->uid);
                 $this->is_valid = (bool) $tservices->isExistActive($this->src_id);
                 break;
         }
         if ($this->is_valid) {
             $res = $this->getRowByUidAndPos($this->uid, $this->pos, $this->group_id, $this->prof_id);
             $this->id = $res ? $res['id'] : 0;
             //Уже есть данная позиция
             //то готовим данные для обновления
             if ($this->id > 0) {
                 $this->data = array('src_id' => $this->src_id, 'type' => $this->type, 'is_default' => false);
                 $this->is_default = $res['is_default'] == 't';
                 //Первое добавление позиции
                 //то готовим новые данные для добавления
             } else {
                 $exist_data = isset($_SESSION[self::SESS_EXIST_PREVIEW_DATA]) ? $_SESSION[self::SESS_EXIST_PREVIEW_DATA] : null;
                 for ($idx = 1; $idx <= $max_pos; $idx++) {
                     if ($idx == $this->pos) {
                         $this->data[$idx] = array('src_id' => $this->src_id, 'type' => $this->type, 'user_id' => $this->uid, 'pos' => $idx, 'group_id' => $this->group_id, 'prof_id' => $this->prof_id, 'is_default' => false);
                     } elseif (isset($exist_data['ids'][$idx - 1])) {
                         $this->data[$idx] = array('src_id' => $exist_data['ids'][$idx - 1], 'type' => $exist_data['type'], 'user_id' => $this->uid, 'pos' => $idx, 'group_id' => $this->group_id, 'prof_id' => $this->prof_id, 'is_default' => false);
                     }
                 }
             }
             //Устанавливаем по возможности
             //текущии настройки для общего каталога / раздела
             /*
               - общий каталог поумолчанию из основного подраздела (специализации), но может и настраиваться по своему
               - раздел каталога поумолчанию из последнего отредактированного подраздела, но может настраиваться по своему
               - подраздел (специализация) настраивается по своему 
             */
             if ($this->prof_id > 0 && $this->group_id == 0 && count($this->data)) {
                 $is_exist_setting_for_catalog = false;
                 $is_exist_setting_for_group = false;
                 require_once ABS_PATH . '/classes/professions.php';
                 $group_id = professions::GetGroupIdByProf($this->prof_id);
                 $exist_data = $this->getExistData($group_id);
                 $current_settings = array();
                 if ($exist_data) {
                     foreach ($exist_data as $el) {
                         //Существующие текущие настройки раздела
                         if ($el['prof_id'] == $this->prof_id && $el['group_id'] == 0) {
                             unset($el['id']);
                             if ($el['pos'] == $this->pos) {
                                 $el['src_id'] = $this->src_id;
                                 $el['type'] = $this->type;
                             }
                             $current_settings[$el['pos']] = $el;
                             //Существующие настройки для общего каталога
                         } elseif ($el['prof_id'] == 0 && $el['group_id'] == 0 && $el['is_default'] == 'f') {
                             $is_exist_setting_for_catalog = true;
                             //Существующие настройки для группы
                         } elseif ($el['prof_id'] == 0 && $el['group_id'] == $group_id && $el['is_default'] == 'f') {
                             $is_exist_setting_for_group = true;
                         }
                     }
                 }
                 //Если настройки для каталога нет и эта основная
                 //специализация то ее добавляем в общий каталог
                 $data_extended = array();
                 $current_settings = $this->id > 0 ? $current_settings : $current_settings + $this->data;
                 if (!$is_exist_setting_for_catalog) {
                     $is_main_prof = (bool) $this->db()->val('SELECT 1 FROM freelancer 
                              WHERE uid = ?i AND spec = ?i LIMIT 1', $this->uid, $this->prof_id);
                     if ($is_main_prof) {
                         foreach ($current_settings as $el) {
                             $el['prof_id'] = 0;
                             $el['group_id'] = 0;
                             $el['is_default'] = true;
                             $data_extended[] = $el;
                         }
                     }
                 }
                 //Если нет настроек для группы раздела то добавляем текущии
                 //настройки как поумолчанию для группы
                 if (!$is_exist_setting_for_group) {
                     foreach ($current_settings as $el) {
                         $el['prof_id'] = 0;
                         $el['group_id'] = $group_id;
                         $el['is_default'] = true;
                         $data_extended[] = $el;
                     }
                 }
                 if ($data_extended) {
                     $this->data_extra_update = $data_extended;
                 }
             }
         }
     }
     return $this->is_valid;
 }
Пример #5
0
 /**
  * Вощвращает строку с описанием операции для истории счета
  * @param type $prof_id
  */
 public static function getOperationDescr($prof_id, $prof_group_id)
 {
     $prof_name = '';
     if ($prof_id == -1) {
         $prof_name = 'общем разделе';
     } elseif ($prof_id == 0) {
         $group_title = professions::GetProfGroupTitle($prof_group_id);
         $prof_name = 'разделе ' . $group_title;
     } else {
         $group_id = professions::GetGroupIdByProf($prof_id);
         $group_title = professions::GetProfGroupTitle($group_id);
         $prof_title .= professions::GetProfName($prof_id);
         $prof_name = 'разделе ' . $group_title . ' &mdash; ' . $prof_title;
     }
     return $prof_name;
 }