File indexing completed on 2024-12-15 05:21:37
0001 <?php 0002 0003 /** 0004 * ocs-apiserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-apiserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class Application_Model_Project extends Application_Model_DbTable_Project 0024 { 0025 0026 const FILTER_NAME_PROJECT_ID_NOT_IN = 'project_id_not_in'; 0027 const FILTER_NAME_RANKING = 'ranking'; 0028 const FILTER_NAME_CATEGORY = 'category'; 0029 const FILTER_NAME_PACKAGETYPE = 'package_type'; 0030 const FILTER_NAME_MEMBER = 'member'; 0031 const FILTER_NAME_ORDER = 'order'; 0032 const FILTER_NAME_LOCATION = 'location'; 0033 0034 const ITEM_TYPE_DUMMY = 0; 0035 const ITEM_TYPE_PRODUCT = 1; 0036 const ITEM_TYPE_UPDATE = 2; 0037 0038 protected function _getCatIds($catids) 0039 { 0040 $sqlwhereCat = ""; 0041 $sqlwhereSubCat = ""; 0042 0043 $idCategory = explode(',', $catids); 0044 if (false === is_array($idCategory)) { 0045 $idCategory = array($idCategory); 0046 } 0047 0048 $sqlwhereCat .= implode(',', $idCategory); 0049 0050 $modelCategory = new Application_Model_DbTable_ProjectCategory(); 0051 $subCategories = $modelCategory->fetchChildElements($idCategory); 0052 0053 if (count($subCategories) > 0) { 0054 foreach ($subCategories as $element) { 0055 $sqlwhereSubCat .= "{$element['project_category_id']},"; 0056 } 0057 } 0058 0059 return $sqlwhereSubCat . $sqlwhereCat; 0060 } 0061 0062 /** 0063 * @param array $data 0064 * 0065 * @return Zend_Db_Table_Rowset_Abstract 0066 */ 0067 protected function generateRowSet($data) 0068 { 0069 $classRowSet = $this->getRowsetClass(); 0070 0071 return new $classRowSet(array( 0072 'table' => $this, 0073 'rowClass' => $this->getRowClass(), 0074 'stored' => true, 0075 'data' => $data 0076 )); 0077 } 0078 0079 0080 0081 /** 0082 * @param $projectId 0083 * 0084 * @return array 0085 */ 0086 public function getGalleryPictureSources($projectId) 0087 { 0088 $galleryPictureTable = new Application_Model_DbTable_ProjectGalleryPicture(); 0089 $stmt = $galleryPictureTable->select()->where('project_id = ?', $projectId)->order(array('sequence')); 0090 0091 $pics = array(); 0092 foreach ($galleryPictureTable->fetchAll($stmt) as $pictureRow) { 0093 $pics[] = $pictureRow['picture_src']; 0094 } 0095 0096 return $pics; 0097 } 0098 0099 0100 0101 0102 0103 0104 }