File indexing completed on 2025-02-09 07:14:33

0001 <?php
0002 /**
0003  *  ocs-webserver
0004  *
0005  *  Copyright 2016 by pling GmbH.
0006  *
0007  *    This file is part of ocs-webserver.
0008  *
0009  *    This program is free software: you can redistribute it and/or modify
0010  *    it under the terms of the GNU Affero General Public License as
0011  *    published by the Free Software Foundation, either version 3 of the
0012  *    License, or (at your option) any later version.
0013  *
0014  *    This program is distributed in the hope that it will be useful,
0015  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0017  *    GNU Affero General Public License for more details.
0018  *
0019  *    You should have received a copy of the GNU Affero General Public License
0020  *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
0021  **/
0022 class Default_Model_DbTable_HiveUser extends Local_Model_Table
0023 {
0024     protected $_keyColumnsForRow = array('id');
0025     protected $_key = 'id';
0026     protected $_name = "hive_user";
0027     
0028     /**
0029      * @param int $category_id
0030      * @return Num of rows
0031      **/
0032     public function fetchCountUsers()
0033     {
0034     
0035       $sql = "
0036                 SELECT
0037                     count(1) AS 'count'
0038                 FROM
0039                     hive_user
0040                 WHERE
0041                     userdb = 0
0042             AND is_imported = 0
0043                 GROUP BY userdb
0044                ";
0045     
0046       $result = $this->_db->fetchRow($sql);
0047     
0048       return $result['count'];
0049     
0050     }
0051     
0052     /**
0053      * @param int $category_id
0054      * @return Num of rows
0055      **/
0056     public function fetchCountAllProjectsForCategory($category_id)
0057     {
0058     
0059       $sql = "
0060                 SELECT
0061                     count(1) AS 'count'
0062                 FROM
0063                     hive_content
0064                 WHERE
0065                     type = ?
0066             AND deletedat = 0
0067                 GROUP BY type
0068                ";
0069     
0070       $sql = $this->_db->quoteInto($sql, $category_id, 'INTEGER');
0071     
0072       $result = $this->_db->fetchRow($sql);
0073     
0074       return $result['count'];
0075     
0076     }
0077     
0078     /**
0079      * @param int $category_id
0080      * @return Num of rows
0081      **/
0082     public function fetchAllUsers($startIndex = 0, $limit = 5)
0083     {
0084     
0085       $sql = "
0086                 SELECT
0087                     *,from_unixtime(createtime) as created_at,from_unixtime(lastvisit) as last_online,co.country as country_text
0088                 FROM
0089                     hive_user
0090           JOIN hive_country co ON co.id = hive_user.country
0091                 WHERE
0092                     userdb = 0
0093                     AND is_imported = 0
0094           LIMIT ".$limit." OFFSET ".$startIndex."
0095                ";
0096     
0097       $result = $this->_db->fetchAll($sql);
0098     
0099       return $result;
0100     
0101     }
0102     
0103     
0104 }