3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
6 * Members list filters and paginator
10 * Copyright © 2009-2012 The Galette Team
12 * This file is part of Galette (http://galette.tuxfamily.org).
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2009-2012 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
34 * @link http://galette.tuxfamily.org
35 * @since march, 3rd 2009
38 namespace Galette\Filters
;
40 use Galette\Common\KLogger
as KLogger
;
41 use Galette\Core\Pagination
as Pagination
;
42 use Galette\Entity\Group
as Group
;
43 use Galette\Repository\Members
as Members
;
46 * Members list filters and paginator
52 * @author Johan Cwiklinski <johan@x-tnd.be>
53 * @copyright 2009-2012 The Galette Team
54 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
55 * @link http://galette.tuxfamily.org
58 class MembersList
extends Pagination
62 private $_field_filter;
63 private $_membership_filter;
64 private $_account_status_filter;
65 private $_email_filter;
66 private $_group_filter;
69 private $_unreachable;
73 protected $memberslist_fields = array(
77 'account_status_filter',
88 public function __construct()
94 * Returns the field we want to default set order to
96 * @return string field name
98 protected function getDefaultOrder()
104 * Reinit default parameters
108 public function reinit()
111 $this->_filter_str
= null;
112 $this->_field_filter
= null;
113 $this->_membership_filter
= null;
114 $this->_account_status_filter
= null;
115 $this->_email_filter
= Members
::FILTER_DC_EMAIL
;
116 $this->_group_filter
= null;
117 $this->_selected
= array();
121 * Global getter method
123 * @param string $name name of the property we want to retrive
125 * @return object the called property
127 public function __get($name)
132 '[MembersList] Getting property `' . $name . '`',
136 if ( in_array($name, $this->pagination_fields
) ) {
137 return parent
::__get($name);
139 if (in_array($name, $this->memberslist_fields
)) {
140 if ( $name === 'query' ) {
148 '[MembersList] Unable to get proprety `' .$name . '`',
156 * Global setter method
158 * @param string $name name of the property we want to assign a value to
159 * @param object $value a relevant value for the property
163 public function __set($name, $value)
167 if ( in_array($name, $this->pagination_fields
) ) {
168 parent
::__set($name, $value);
171 '[MembersList] Setting property `' . $name . '`',
178 if (is_array($value)) {
180 $this->$name = $value;
183 '[MembersList] Value for property `' . $name .
184 '` should be an array (' . gettype($value) . ' given)',
191 $this->$name = $value;
194 case 'membership_filter':
195 case 'account_status_filter':
196 if ( is_numeric($value) ) {
198 $this->$name = $value;
201 '[MembersList] Value for property `' . $name .
202 '` should be an integer (' . gettype($value) . ' given)',
209 case Members
::FILTER_DC_EMAIL
:
210 case Members
::FILTER_W_EMAIL
:
211 case Members
::FILTER_WO_EMAIL
:
212 $this->_email_filter
= $value;
216 '[MembersList] Value for email filter should be either ' .
217 Members
::FILTER_DC_EMAIL
. ', ' .
218 Members
::FILTER_W_EMAIL
. ' or ' .
219 Members
::FILTER_WO_EMAIL
. ' (' . $value . ' given)',
226 if ( is_numeric($value) ) {
227 //check group existence
229 $res = $g->load($value);
230 if ( $res === true ) {
231 $this->_group_filter
= $value;
234 'Group #' . $value . ' does not exists!',
240 '[MembersList] Value for group filter should be an '
241 .'integer (' . gettype($value) . ' given',
247 $this->$name = $value;
251 '[MembersList] Unable to set proprety `' . $name . '`',
262 * @param Zend_Db_Select $select Original select
266 public function setLimit($select)
268 return $this->setLimits($select);
274 * @param int $c Count
278 public function setCounter($c)
280 $this->counter
= (int)$c;
285 * Set commons filters for templates
287 * @param Smarty $tpl Smarty template reference
291 public function setTplCommonsFilters($tpl)
294 'filter_field_options',
296 Members
::FILTER_NAME
=> _T("Name"),
297 Members
::FILTER_COMPANY_NAME
=> _T("Company name"),
298 Members
::FILTER_ADRESS
=> _T("Address"),
299 Members
::FILTER_MAIL
=> _T("Email,URL,IM"),
300 Members
::FILTER_JOB
=> _T("Job"),
301 Members
::FILTER_INFOS
=> _T("Infos")
306 'filter_membership_options',
308 Members
::MEMBERSHIP_ALL
=> _T("All members"),
309 Members
::MEMBERSHIP_UP2DATE
=> _T("Up to date members"),
310 Members
::MEMBERSHIP_NEARLY
=> _T("Close expiries"),
311 Members
::MEMBERSHIP_LATE
=> _T("Latecomers"),
312 Members
::MEMBERSHIP_NEVER
=> _T("Never contributed"),
313 Members
::MEMBERSHIP_STAFF
=> _T("Staff members"),
314 Members
::MEMBERSHIP_ADMIN
=> _T("Administrators")
319 'filter_accounts_options',
321 Members
::ALL_ACCOUNTS
=> _T("All accounts"),
322 Members
::ACTIVE_ACCOUNT
=> _T("Active accounts"),
323 Members
::INACTIVE_ACCOUNT
=> _T("Inactive accounts")