<?php
/**
  * Ahead WebSoft Technologies Pvt Ltd.
  * @copyright  Copyright 2006-2026 Ahead WebSoft Technologies Pvt Ltd.
  * @license    https://www.socialengine.com/policies
*/

class User_Model_DbTable_Avatars extends Engine_Db_Table {
  
  protected $_rowClass = 'User_Model_Avatar';
  
  public function getPaginator($params = array()) {
    return Zend_Paginator::factory($this->getAvatars($params));
  }
  
  public function getAvatars($params = array()) {
  
    $select = $this->select()->where('file_id <>?', 0)->order('order ASC');
    
    if(isset($params) && $params['enabled'] == 1)
      $select->where('enabled =?', 1);

		if(!empty($params['gender']))
      $select->where('gender = ?', $params['gender']);

    if(!empty($params['limit'])) {
      $select->limit($params['limit']);
    }
    if(!empty($params['fetchAll']))
      return $this->fetchAll($select);
    return $select;
  }
}
