File indexing completed on 2025-02-09 07:14:41
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 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 Default_Model_ProjectPlings extends Default_Model_DbTable_ProjectPlings 0024 { 0025 0026 public function fetchPlingsForMember($memberId) 0027 { 0028 $sql = " 0029 SELECT 0030 f.project_id 0031 ,f.member_id 0032 ,f.created_at 0033 ,p.member_id as project_member_id 0034 ,p.username as project_username 0035 ,p.project_category_id 0036 ,p.status 0037 ,p.title 0038 ,p.description 0039 ,p.image_small 0040 ,p.project_created_at 0041 ,p.project_changed_at 0042 ,p.laplace_score 0043 ,p.cat_title 0044 ,p.count_likes 0045 ,p.count_dislikes 0046 ,p.laplace_score 0047 FROM project_plings f 0048 INNER JOIN stat_projects p ON p.project_id = f.project_id 0049 WHERE (p.status = 100) and f.is_active = 1 AND f.is_deleted= 0 AND (f.member_id = :member_id) 0050 order by f.created_at desc 0051 "; 0052 0053 $resultSet = $this->_db->fetchAll($sql, array('member_id' => $memberId)); 0054 return new Zend_Paginator(new Zend_Paginator_Adapter_Array($resultSet )); 0055 } 0056 0057 public function fetchPlingsForSupporter($memberId) 0058 { 0059 0060 $sql = " 0061 SELECT 0062 f.member_id 0063 , count(1) as cntplings 0064 ,(select profile_image_url from member m where m.member_id = f.member_id ) as profile_image_url 0065 ,(select username from member m where m.member_id = f.member_id ) as username 0066 ,(select max(active_time) from support s where s.member_id = f.member_id and status_id = 2) as active_time 0067 FROM project_plings f 0068 INNER JOIN stat_projects p ON p.project_id = f.project_id 0069 WHERE (p.status = 100) AND f.is_active = 1 and f.is_deleted= 0 AND (p.member_id = :member_id) 0070 group by f.member_id 0071 order by cntplings desc 0072 0073 "; 0074 0075 $resultSet = $this->_db->fetchAll($sql, array('member_id' => $memberId)); 0076 return new Zend_Paginator(new Zend_Paginator_Adapter_Array($resultSet )); 0077 } 0078 0079 public function fetchPlingsForProject($project_id) 0080 { 0081 0082 $sql = " 0083 SELECT 0084 f.project_id 0085 ,f.member_id 0086 ,f.created_at 0087 ,m.profile_image_url 0088 ,m.created_at as member_created_at 0089 ,m.username 0090 FROM project_plings f 0091 inner join member m on f.member_id = m.member_id and m.is_active=1 AND m.is_deleted=0 0092 WHERE f.project_id = :project_id and f.is_deleted = 0 0093 order by f.created_at desc 0094 "; 0095 $resultSet = $this->_db->fetchAll($sql, array('project_id' => $project_id)); 0096 return $resultSet; 0097 } 0098 }