Example #1
0
 /**
  * Возвращает все наши профессии привязанные к определенной HH-специализации
  *
  * @param array $ids   ид. HH-специализаций (массив или строка ид. разделенных запятыми)
  * @return array   массив с индексами-идентификаторами найденных профессий
  */
 function getProfessionsByHHSpecs($ids)
 {
     global $DB;
     if (!is_array($ids)) {
         $ids = preg_split('/\\D+/', $ids);
     }
     $ids = implode(',', intarrPgSql($ids));
     $sql = "SELECT DISTINCT prof_id FROM hh_specializations_professions WHERE hh_spec_id IN ({$ids})";
     $memBuff = new memBuff();
     if ($rows = $memBuff->getSql($error, $sql, self::MEM_LIFE)) {
         foreach ($rows as $row) {
             $ret[$row['prof_id']] = 1;
         }
     }
     return $ret;
 }
Example #2
0
 /**
  * Уснаваливает статус документа.
  * 
  * @param array|int $ids  один или несколько ид. документов.
  * @param int       $mode статус (1:отправлен, 2:получен, 3:подписан, 4:опубликовано)
  *
  * @return bool успешно?
  */
 public function setDocStatus($ids, $mode)
 {
     $ids = implode(',', intarrPgSql($ids));
     $act_time = self::$docs_ss[$mode][1];
     $sql = "UPDATE sbr_docs SET status = {$mode}, {$act_time} = COALESCE({$act_time}, now()) WHERE id IN ({$ids})";
     return $this->_eventQuery($sql);
 }
Example #3
0
 /**
  * Удалить черновики.
  * 
  * @param int|array $ids ид. сделок.
  *
  * @return bool true, если успешно и сделки действительно были удалены из базы (нельзя удалять не черновики).
  */
 public function delete($ids)
 {
     if ($this->uid != get_uid(false)) {
         return false;
     }
     $ids = intarrPgSql($ids);
     $ids = implode(',', $ids);
     $sql = "DELETE FROM sbr WHERE id IN ({$ids}) AND emp_id = {$this->uid}";
     return ($res = pg_query(self::connect(), $sql)) && pg_affected_rows($res);
 }
Example #4
0
 /**
  * Возвращает ленту проектов.
  * 
  * @param int   $kind      тип проектов (-1=5=Все проекты; 2=Конкурсы; 4=В офис; 6=Только для про)
  * @param array $filter    массив с фильтром проектов (тот же, что для projects::getProjects(), но разделы в таком виде: [[1,2,3], [44,55,66]], где по индексу 0 -- разделы, по 1 -- подразделы)
  * @param int   $page_size кол-во проектов на странице.
  *
  * @return array
  */
 protected function x____getProjects($args)
 {
     list($kind, $filter, $page_size) = $args;
     require_once ABS_PATH . '/classes/projects.php';
     require_once ABS_PATH . '/classes/projects_filter.php';
     require_once ABS_PATH . '/classes/professions.php';
     $result = null;
     $projects = new new_projects();
     $kind = $kind ? (int) $kind : $this->_mCfg['default_kind'];
     $page_size = (int) $page_size;
     $limit = $page_size > $this->_mCfg['max_page_size'] ? $this->_mCfg['max_page_size'] : ($page_size < $this->_mCfg['min_page_size'] ? $this->_mCfg['page_size'] : $page_size);
     if ($filter) {
         $filter['active'] = $this->ex2pg(EXTERNAL_TRUE, EXTERNAL_DT_BOOL);
         $filter['wo_cost'] = $this->ex2pg($filter['wo_cost'], EXTERNAL_DT_BOOL);
         $filter['only_sbr'] = $this->ex2pg($filter['prefer_sbr'], EXTERNAL_DT_BOOL);
         if ($filter['my_specs']) {
             $filter['my_specs'] = $this->ex2pg($filter['my_specs'], EXTERNAL_DT_BOOL);
             $filter['user_specs'] = professions::GetProfessionsByUser($this->_sess->_uid, false, true);
         }
         if (isset($filter['categories']) && is_array($filter['categories'])) {
             $filter['categories'] = intarrPgSql($filter['categories']);
             $cats = $filter['categories'];
             $filter['categories'] = array();
             foreach ($cats as $i => $arr) {
                 if ($i > 1) {
                     break;
                 }
                 if (is_array($arr) && !isNulArray($arr)) {
                     if ($i == 1) {
                         $arr = professions::GetMirroredProfs(implode(',', $arr));
                     }
                     $filter['categories'][$i] = array_fill_keys($arr, $i);
                 }
             }
         }
         list($filter['cost_from'], $filter['cost_to']) = projects_filters::preCosts($filter['cost_from'], $filter['cost_to']);
     }
     if ($prjs = $projects->getLastProjects($kind, $filter, $limit, true)) {
         foreach ($prjs as $key => $p) {
             $row = $this->pg2exRow($this->_mCfg['fields'], $p);
             if ($row['logo']) {
                 $row['logo'] = WDCPREFIX . '/' . $row['logo'];
             }
             if ($attach = $projects->getAllAttach($p['id'])) {
                 $row['attach'] = array();
                 foreach ($attach as $a) {
                     $att = $this->pg2exRow($this->_mCfg['attach-fields'], $a);
                     $att['link'] = WDCPREFIX . '/' . $a['path'] . $a['name'];
                     $row['attach'][] = $att;
                 }
             }
             $result[$key] = $row;
         }
     }
     return $result;
 }
Example #5
0
 /**
  * Заполняет массив $this->post_msg данными из пользовательского запроса.
  * @see sbr_stages::addMsg()
  * @see sbr_stages::editMsg()
  * 
  * @param array $request   $_GET | $_POST
  * @param array $files   $_FILES
  */
 private function _new_msgInitFromRequest($request, $files)
 {
     foreach ($request as $field => $value) {
         if ($field == 'id') {
             continue;
         }
         if (is_scalar($value)) {
             $value = stripslashes($value);
         }
         switch ($field) {
             case 'msgtext':
                 if (!trim($value)) {
                     $this->error['msgs'][$field] = 'Сообщение не должно быть пустым';
                 }
                 break;
             case 'msg_id':
                 $this->post_msg['id'] = $value;
                 break;
             case 'parent_id':
                 $value = intvalPgSql($value);
                 break;
             case 'delattach':
                 $value = intarrPgSql($value);
                 break;
             case 'yt_link':
                 if (trim($value)) {
                     if (!($val = video_validate($value))) {
                         $this->error['msgs'][$field] = 'Неверная ссылка';
                     } else {
                         $value = $val;
                     }
                 }
                 break;
             default:
                 break;
         }
         $this->post_msg[$field] = $value;
     }
     $this->post_msg['stage_id'] = $this->data['id'];
     if ($files) {
         foreach ($files as $i => $attach) {
             $file = new CFile($attach['id']);
             $file->table = 'file_sbr';
             if ($file->_remoteCopy($this->sbr->getUploadDir() . $file->name)) {
                 $this->uploaded_files[] = $file;
             }
         }
     }
     if ($this->uploaded_files) {
         unset($this->error['msgs']['msgtext']);
         if (count($this->error['msgs']) == 0) {
             unset($this->error['msgs']);
         }
     }
 }