Exemplo n.º 1
0
 /**
  * Получение списока проектов
  * 
  * @param  array $aParams массив входящих данных
  * @return array $aResult ответ
  */
 protected function x____projects_list($aParams = array())
 {
     $this->_validDevice($aParams);
     require_once ABS_PATH . '/classes/projects_filter.php';
     require_once ABS_PATH . '/classes/projects.php';
     $nUid = get_uid(false);
     $nPage = self::$_aPlatform[$this->_sPlatform]['filter_page'];
     // какой фильтр получать
     $prj_filter = new projects_filters();
     $filter = $prj_filter->GetFilter($nUid, $error, $nPage);
     if (is_array($filter) && $filter && $filter['active'] == 't' && $filter['use_main_filter'] == 't') {
         $filter = $prj_filter->GetFilter($nUid, $error, 0);
     }
     $nKind = intvalPgSql($aParams['kind']);
     $nKind = !empty($nKind) ? $nKind : $this->_mCfg['default_kind'];
     $nPage = intvalPgSql($aParams['page']);
     $nPage = !empty($nPage) ? $nPage : 1;
     $oPrj = new new_projects();
     $oPrj->page_size = $this->_mCfg['items_per_page'];
     if (is_emp()) {
         $aProjects = $oPrj->GetCurPrjs($nUid, '', true, false, $nKind);
         $nPrgCnt = count($aProjects);
     } else {
         $aProjects = $oPrj->getProjects($nPrgCnt, $nKind, $nPage, true, $filter, true, false, NULL, false, NULL, true);
     }
     $aResult = array('projects_list' => array());
     if (is_array($aProjects) && $aProjects) {
         $aItems = array();
         $aIds = array();
         $nCnt = 0;
         foreach ($aProjects as $aOne) {
             $aResult['projects_list'][$nCnt] = $this->_getProjectData($aOne);
             $aItems[$aOne['id']] =& $aResult['projects_list'][$nCnt];
             $aIds[] = $aOne['id'];
             $nCnt++;
         }
         $aSpecs = new_projects::getSpecs($aIds);
         if (is_array($aSpecs) && $aSpecs) {
             foreach ($aSpecs as $aOne) {
                 $aItems[$aOne['project_id']]['category_id'] = $aOne['category_id'];
                 $aItems[$aOne['project_id']]['subcategory_id'] = $aOne['subcategory_id'];
             }
         }
         $aResult['projects_total'] = intval($nPrgCnt);
     }
     return $aResult;
 }