File indexing completed on 2025-02-09 07:14:33
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_DbTable_LoginHistory extends Zend_Db_Table_Abstract 0024 { 0025 0026 protected $_name = "login_history"; 0027 protected $_rowClass = 'Default_Model_DbRow_LoginHistory'; 0028 0029 /** @var Zend_Cache_Core */ 0030 protected $cache; 0031 0032 /** 0033 * @inheritDoc 0034 */ 0035 public function init() 0036 { 0037 parent::init(); // TODO: Change the autogenerated stub 0038 $this->cache = Zend_Registry::get('cache'); 0039 } 0040 0041 /** 0042 * @param int|array $memberId 0043 * 0044 * @return array 0045 * @throws Zend_Cache_Exception 0046 * @throws Zend_Db_Statement_Exception 0047 */ 0048 public function fetchLastLoginData($memberId) 0049 { 0050 /** @var Zend_Cache_Core $cache */ 0051 $cache = $this->cache; 0052 $cacheName = __FUNCTION__ . '_' . md5($memberId); 0053 0054 $data = null; 0055 0056 //if (false === ($data = $cache->load($cacheName))) { 0057 $sql = ' 0058 SELECT node.* 0059 FROM login_history AS node 0060 WHERE node.member_id = '.$memberId.' 0061 ORDER BY node.id DESC 0062 LIMIT 10 0063 '; 0064 $data = $this->_db->query($sql)->fetchAll(); 0065 if (count($data) == 0) { 0066 return array(); 0067 } else { 0068 return $data; 0069 } 0070 //$cache->save($data, $cacheName, array(), 3600); 0071 //} 0072 } 0073 }