Skip to content
Snippets Groups Projects
Commit 6354158b authored by Patrick Barroca's avatar Patrick Barroca :grin:
Browse files

Merge branch 'dev#102749_gpes_recuperation_de_la_recherche_users_dans_groupes' into 'master'

dev#102749 : user groups filters

See merge request !3380
parents ccf2dd92 94afc828
Branches
Tags
1 merge request!3380dev#102749 : user groups filters
Pipeline #9247 passed with stage
in 52 minutes and 51 seconds
Showing
with 510 additions and 112 deletions
'102749' =>
['Label' => $this->_('Amélioration des groupes dynamiques'),
'Desc' => $this->_('Vous pouvez désormais utiliser tous les critères disponibles dans la liste des utiliseurs en tant que filtre des groupes dynamiques'),
'Image' => '',
'Video' => 'https://youtube.com/watch?v=B81l7kU-lqE',
'Category' => $this->_('Administration'),
'Right' => function($feature_description, $user) {return true;},
'Wiki' => 'http://wiki.bokeh-library-portal.org/index.php?title=Gestion_des_groupes',
'Test' => '',
'Date' => '2020-01-23'],
\ No newline at end of file
- ticket #102749 : Administration des groupes : Les groupes dynamiques utilisent désormais les même critères que la recherche d'utilisateurs
\ No newline at end of file
<?php
$adapter = Zend_Db_Table_Abstract::getDefaultAdapter();
try {
$adapter->query("alter table user_groups add column `filters` longtext not null default ''" );
} catch (Exception $e) {}
try {
$adapter->query("update user_groups set filters=concat('{\"search_role_level\":\"', role_level, '\", \"search_id_site\":\"', if(id_bib, id_bib, 'all'), '\"}') where group_type=1 and filters=''");
} catch (Exception $e) {}
......@@ -23,13 +23,13 @@
class Class_RendezVous_SearchCriteria_Location extends Class_SearchCriteria_Abstract {
protected
$_name = 'location_id',
$_value = self::DEFAULT_VALUE;
$_value = Class_SearchCriteria_Abstract::ALL_VALUES;
const NONE = "none";
public function buildElement() {
$options = ['label' => $this->_('Lieu'),
'multiOptions' => [static::DEFAULT_VALUE => $this->_('Tous'),
'multiOptions' => [static::ALL_VALUES => $this->_('Tous'),
static::NONE => $this->_('Indéterminé')]
+ Class_Lieu::getAllLibelles()
];
......
......@@ -30,6 +30,11 @@ abstract class Class_SearchCriteria {
$_search_params,
$_has_no_result = false;
public static function isCriteriaName($name) {
return Class_SearchCriteria_Abstract::isCriteriaName($name);
}
public function __construct($params) {
}
......@@ -49,6 +54,27 @@ abstract class Class_SearchCriteria {
}
public function replaceCriteria($class_name, $new) {
$this->_criteria = array_map(function ($criteria) use ($class_name, $new)
{
return (get_class($criteria) == $class_name)
? $new
: $criteria;
}, $this->_criteria);
return $this;
}
public function fetchAll($fields) {
$this->_buildSearchParams();
if ($this->_has_no_result)
return [];
return call_user_func([$this->_model_class, 'fetchAllBy'], $fields, $this->_search_params);
}
public function findPage($page=1, $page_size=20) {
$this->_buildSearchParams();
......@@ -93,6 +119,11 @@ abstract class Class_SearchCriteria {
->setAttrib('style', 'position: relative')
->setMethod('get');
return $this->addFormElementsTo($form, 'search_group', $this->_('Recherche'));
}
public function addFormElementsTo($form, $fieldset_name, $fieldset_legend) {
$names = (new Storm_Collection($this->_criteria))
->select(function($c) { return $c->getElement(); })
->eachDo(function($c) use ($form) { $form->addElement($c->getElement()); })
......@@ -102,9 +133,7 @@ abstract class Class_SearchCriteria {
if (!$names)
return $form;
$form->addDisplayGroup($names,
'search_group',
['legend' => $this->_('Recherche')]);
$form->addDisplayGroup($names, $fieldset_name, ['legend' => $fieldset_legend]);
return $form;
}
......@@ -160,6 +189,17 @@ abstract class Class_SearchCriteria {
}
public function modelMatch($model) {
return (new Storm_Collection($this->_criteria))
->detect(function($each) use($model)
{
return !$each->modelMatch($model);
})
? false
: true;
}
protected function _addCustomCriteriaFor($class_name, $params) {
$model = Class_CustomField_Model::getModel($class_name);
foreach($model->getFields() as $field)
......
......@@ -23,7 +23,7 @@
abstract class Class_SearchCriteria_Abstract {
use Trait_Translator;
const DEFAULT_VALUE = 'all';
const ALL_VALUES = 'all';
const NAME_PREFIX = 'search_';
protected
......@@ -32,6 +32,11 @@ abstract class Class_SearchCriteria_Abstract {
$_element;
public static function isCriteriaName($name) {
return preg_match('/^' . static::NAME_PREFIX . '.+/', $name);
}
public function __construct($params) {
if (isset($params[$this->getName()]))
$this->_value = $params[$this->getName()];
......@@ -61,7 +66,7 @@ abstract class Class_SearchCriteria_Abstract {
public function acceptSearchVisitor($visitor) {
if ($this->_value == static::DEFAULT_VALUE)
if ($this->_isAllValues())
return;
$visitor->addParam($this->_name, $this->_value);
......@@ -70,4 +75,16 @@ abstract class Class_SearchCriteria_Abstract {
public function describeOn($view) {
}
public function modelMatch($model) {
return $this->_isAllValues()
? true
: $model->callGetterByAttributeName($this->_name) == $this->_value;
}
protected function _isAllValues() {
return static::ALL_VALUES == $this->_value;
}
}
\ No newline at end of file
......@@ -76,6 +76,32 @@ class Class_SearchCriteria_DateRange extends Class_SearchCriteria_Abstract {
}
public function modelMatch($model) {
if ($this->_isAllValues())
return true;
if ((!$value = $model->callGetterByAttributeName($this->_name))
|| !(new ZendAfi_Validate_DateFormat())->isValid($value))
return false;
$time = strtotime(substr($value, 0, 10));
if ($this->_value_start
&& strtotime($this->_sqlFormat($this->_value_start)) > $time)
return false;
if ($this->_value_end
&& strtotime($this->_sqlFormat($this->_value_end)) < $time)
return false;
return true;
}
protected function _isAllValues() {
return !($this->_value_start || $this->_value_end);
}
protected function _filterDate($value) {
if (null === $value)
return;
......
......@@ -39,4 +39,9 @@ class Class_SearchCriteria_Order extends Class_SearchCriteria_Abstract {
false !== strpos($this->_value, ',')
? explode(',', $this->_value) : $this->_value);
}
public function modelMatch($model) {
return true;
}
}
......@@ -21,7 +21,7 @@
class Class_SearchCriteria_Select extends Class_SearchCriteria_Abstract {
protected $_value = Class_SearchCriteria_Abstract::DEFAULT_VALUE;
protected $_value = Class_SearchCriteria_Abstract::ALL_VALUES;
public function buildElement() {
return new Zend_Form_Element_Select($this->getName(), ['value' => $this->_value]);
......@@ -29,7 +29,7 @@ class Class_SearchCriteria_Select extends Class_SearchCriteria_Abstract {
public function describeOn($view) {
return ($this->_element && static::DEFAULT_VALUE != $this->_value)
return ($this->_element && !$this->_isAllValues())
? $this->_element->getLabel() . ' : ' . $this->_element->getMultiOption($this->_value)
: '';
}
......
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_SearchCriteria_SelectYesNo extends Class_SearchCriteria_Select {
const
YES = 'yes',
NO = 'no';
protected $_linked_model;
public function buildElement() {
return parent::buildElement()
->setMultiOptions([static::YES => $this->_('Oui'),
static::NO => $this->_('Non'),
static::ALL_VALUES => $this->_('Indifférent')]);
}
public function acceptSearchVisitor($visitor) {
if ($this->_isAllValues())
return;
if (!$ids = call_user_func([$this->_linked_model, 'findAllUserIds']))
return $this->_reactToNoLinkedData($visitor);
$ids = implode(',', $ids);
$operator = (static::NO == $this->_value) ? 'not in' : 'in';
$visitor->addWhereParam('id_user ' . $operator . ' (' . $ids . ')');
}
protected function _reactToNoLinkedData($visitor) {
static::YES == $this->_value
? $visitor->hasNoResult()
: null;
}
public function modelMatch($model) {
if ($this->_isAllValues())
return true;
$number = call_user_func([$this->_linked_model, 'countBy'], ['id_user' => $model->getId()]);
return (static::NO == $this->_value && $number == 0)
|| (static::YES == $this->_value && $number > 0);
}
}
......@@ -25,11 +25,14 @@ class Class_User_SearchCriteria extends Class_SearchCriteria {
public function __construct($params) {
$this->_criteria = [new Class_User_SearchCriteriaLibrary($params),
new Class_User_SearchCriteriaRoleLevel($params),
new Class_User_SearchCriteria_RoleLevel($params),
new Class_User_SearchCriteriaValidSubscription($params),
new Class_User_SearchCriteria_EndSubscriptionDate($params),
new Class_User_SearchCriteria_DateFin($params),
new Class_User_SearchCriteria_InLastSigbExport($params),
new Class_User_SearchCriteria_DateMaj($params),
// disabled until real birth date on database
// new Class_User_SearchCriteria_Age($params),
new Class_User_SearchCriteria_NumberOfReviews($params),
new Class_User_SearchCriteria_NumberOfBaskets($params),
new Class_User_SearchCriteriaSearchFor($params),
......@@ -39,6 +42,7 @@ class Class_User_SearchCriteria extends Class_SearchCriteria {
class Class_User_SearchCriteriaLibrary extends Class_SearchCriteria_Select {
protected $_name = 'id_site';
......@@ -51,45 +55,6 @@ class Class_User_SearchCriteriaLibrary extends Class_SearchCriteria_Select {
class Class_User_SearchCriteriaRoleLevel extends Class_SearchCriteria_Select {
protected $_name = 'role_level';
public function buildElement() {
$this->_headScript();
if ((!Class_Users::getIdentity()->isAdmin())
&& static::DEFAULT_VALUE == $this->_value)
$this->_value = ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB;
return parent::buildElement()
->setLabel($this->_('Niveau d\'accès'))
->setMultiOptions(['all' => $this->_('Tous')]
+ ZendAfi_Acl_AdminControllerRoles::getRolesLabelsWithOutSuperAdmin());
}
public function isAbonneSigb() {
return ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB == $this->_value;
}
protected function _headScript() {
$toggles = array_map(function($other)
{
return sprintf('formSelectToggleVisibilityForElement("#%s", $("#%s").closest("tr"), ["2"]);',
$this->getName(),
static::NAME_PREFIX . $other);
},
['valid_subscription',
'statut',
'date_fin_start']);
Class_ScriptLoader::getInstance()->addJQueryReady(implode($toggles));
}
}
class Class_User_SearchCriteriaValidSubscription extends Class_SearchCriteria_Abstract {
protected
......@@ -101,7 +66,7 @@ class Class_User_SearchCriteriaValidSubscription extends Class_SearchCriteria_Ab
parent::__construct($params);
$this->_should_filter = $this->_value
&& (new Class_User_SearchCriteriaRoleLevel($params))->isAbonneSigb();
&& (new Class_User_SearchCriteria_RoleLevel($params))->isAbonneSigb();
}
......@@ -112,6 +77,11 @@ class Class_User_SearchCriteriaValidSubscription extends Class_SearchCriteria_Ab
}
public function getAttributeName() {
return 'date_fin' ;
}
public function acceptSearchVisitor($visitor) {
if (!$this->_should_filter)
return;
......@@ -120,6 +90,13 @@ class Class_User_SearchCriteriaValidSubscription extends Class_SearchCriteria_Ab
}
public function modelMatch($user) {
return $user->isAbonne()
? $user->isAbonnementValid()
: true;
}
public function describeOn($view) {
return (0 != $this->_value)
? $this->_element->getLabel()
......@@ -129,10 +106,12 @@ class Class_User_SearchCriteriaValidSubscription extends Class_SearchCriteria_Ab
class Class_User_SearchCriteriaSearchFor extends Class_SearchCriteria_Abstract{
protected
$_name = 'search_for',
$_value = '';
$_value = '',
$_columns = ['login', 'nom', 'prenom', 'pseudo', 'mail', 'idabon'];
public function buildElement() {
return new Zend_Form_Element_Text($this->getName(),
......@@ -142,35 +121,43 @@ class Class_User_SearchCriteriaSearchFor extends Class_SearchCriteria_Abstract{
public function acceptSearchVisitor($visitor) {
$search_value = str_replace(["\000",
"\n",
"\r",
"\"",
"\'",
"'",
"\032"], '', $this->_value);
if (!$search_value)
if (!$search_value = $this->_sanitize($this->_value))
return;
$columns = array_fill_keys(['login',
'nom',
'prenom',
'pseudo',
'mail',
'idabon'],
$search_value);
foreach($columns as $column => $value)
$table_or[] = sprintf('%s LIKE "%%%s%%"', $column, $value);
foreach(array_fill_keys($this->_columns, $search_value) as $column => $value)
$table_or[] = $column . ' LIKE "%' . $value . '%"';
$visitor->addWhereParam(implode(' OR ', $table_or));
}
public function modelMatch($user) {
if (!$search_value = $this->_sanitize($this->_value))
return true;
return null !== (new Storm_Collection($this->_columns))
->detect(function($each) use($user, $search_value)
{
return false !== strpos($user->callGetterByAttributeName($each),
$search_value);
});
}
public function describeOn($view) {
return ($this->_value)
? ($this->_element->getLabel() . ' : ' . $this->_value)
: '';
}
protected function _sanitize($value) {
return str_replace(["\000",
"\n",
"\r",
"\"",
"\'",
"'",
"\032"], '', $value);
}
}
\ No newline at end of file
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_Age extends Class_SearchCriteria_Abstract {
use Trait_TimeSource;
protected
$_name = 'age',
$_start_name,
$_end_name,
$_from = '',
$_to = '';
public function __construct($params) {
$this->_start_name = $this->getName() . '_debut';
$this->_end_name = $this->getName() . '_fin';
parent::__construct($params);
$this->_from = isset($params[$this->_start_name])
? $params[$this->_start_name]
: '';
$this->_to = isset($params[$this->_end_name])
? $params[$this->_end_name]
: '';
$this->_element->loadDefault($params);
}
public function buildElement() {
return new ZendAfi_Form_Element_Range($this->getName(),
['label' => $this->_('Age à partir de '),
'separator' => $this->_(' jusqu\'à '),
'from_suffix' => '_debut',
'to_suffix' => '_fin']);
}
public function acceptSearchVisitor($visitor) {
if ($this->_isAllValues())
return;
if ($this->_hasFrom()) {
$date = $this->substractYearsToCurrentDate((int)$this->_from);
$visitor->addWhereParam('naissance <=\'' . $date.'\'');
}
if ($this->_hasTo()) {
$date = $this->substractYearsToCurrentDate((int)$this->_to);
$visitor->addWhereParam('naissance >=\'' . $date.'\'');
}
}
public function modelMatch($user) {
if ($this->_isAllValues())
return true;
if (!$user->getNaissance())
return false;
if ($this->_hasFrom()
&& ($date = $this->substractYearsToCurrentDate((int)$this->_from))
&& $user->getNaissance() < $date) {
return false;
}
if (!$this->_hasTo())
return true;
$date = $this->substractYearsToCurrentDate((int)$this->_to);
return $user->getNaissance() <= $date;
}
protected function _isAllValues() {
return !($this->_hasFrom() || $this->_hasTo());
}
protected function _hasFrom() {
return '' !== $this->_from;
}
protected function _hasTo() {
return '' !== $this->_to;
}
}
......@@ -26,6 +26,6 @@ class Class_User_SearchCriteria_DateFin extends Class_SearchCriteria_DateRange {
public function buildElement() {
return parent::buildElement()->setLabel($this->_('Date de fin d\'abonnement'));
return parent::buildElement()->setLabel($this->_('Abonnement échu'));
}
}
......@@ -28,4 +28,12 @@ class Class_User_SearchCriteria_DateMaj extends Class_SearchCriteria_DateRange {
public function buildElement() {
return parent::buildElement()->setLabel($this->_('Mis à jour'));
}
public function modelMatch($model) {
if (!$model->isNew())
return parent::modelMatch($model);
return !($this->_value_start || $this->_value_end);
}
}
<?php
/**
* Copyright (c) 2012-2019, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_EndSubscriptionDate extends Class_SearchCriteria_Abstract {
use Trait_TimeSource;
protected
$_name = 'end_subscription_days',
$_value = '',
$_should_filter = false;
public function __construct($params) {
parent::__construct($params);
$this->_should_filter = $this->_value
&& (new Class_User_SearchCriteria_RoleLevel($params))->isAbonneSigb();
}
public function buildElement() {
return new Zend_Form_Element_Text($this->getName(),
['label' => $this->_('Abonnement échu d\'ici (jours)'),
'value' => $this->_value]);
}
public function modelMatch($user) {
if (!$this->_should_filter)
return true;
return $user->getDateFin()
? $user->getDateFin() <= $this->addDaysToCurrentDate($this->_value)
: true;
}
public function acceptSearchVisitor($visitor) {
if (!$this->_should_filter)
return;
$visitor->addWhereParam('date_fin!=\'\' and date_fin <=\'' . $this->addDaysToCurrentDate($this->_value).'\'');
}
}
......@@ -26,7 +26,7 @@ class Class_User_SearchCriteria_InLastSigbExport extends Class_SearchCriteria_Se
public function buildElement() {
return parent::buildElement()
->setLabel($this->_('Présent dans le dernier export SIGB'))
->setMultiOptions([static::DEFAULT_VALUE => $this->_('Indifférent'),
->setMultiOptions([static::ALL_VALUES => $this->_('Indifférent'),
'0' => $this->_('Oui'),
'1' => $this->_('Non')]);
}
......
......@@ -19,27 +19,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_NumberOfBaskets extends Class_SearchCriteria_Select {
protected $_name = 'basket';
class Class_User_SearchCriteria_NumberOfBaskets extends Class_SearchCriteria_SelectYesNo {
protected
$_name = 'basket',
$_linked_model = Class_PanierNotice::class;
public function buildElement() {
return parent::buildElement()
->setLabel($this->_('A créé des paniers'))
->setMultiOptions(['yes' => $this->_('Oui'),
'no' => $this->_('Non'),
'all' => $this->_('Indifférent')])
;
}
public function acceptSearchVisitor($visitor) {
if (static::DEFAULT_VALUE == $this->_value)
return;
$ids = Class_PanierNotice::findAllUserIds();
$ids = implode(',', $ids);
$operator = ('no' == $this->_value) ? 'not in' : 'in';
$visitor->addWhereParam('id_user ' . $operator . ' (' . $ids . ')');
return parent::buildElement()->setLabel($this->_('A créé des paniers'));
}
}
......@@ -19,27 +19,12 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_NumberOfReviews extends Class_SearchCriteria_Select {
protected $_name = 'review';
class Class_User_SearchCriteria_NumberOfReviews extends Class_SearchCriteria_SelectYesNo {
protected
$_name = 'review',
$_linked_model = Class_AvisNotice::class;
public function buildElement() {
return parent::buildElement()
->setLabel($this->_('A rédigé des avis'))
->setMultiOptions(['yes' => $this->_('Oui'),
'no' => $this->_('Non'),
'all' => $this->_('Indifférent')])
;
}
public function acceptSearchVisitor($visitor) {
if (static::DEFAULT_VALUE == $this->_value)
return;
$ids = Class_AvisNotice::findAllUserIds();
$ids = implode(',', $ids);
$operator = ('no' == $this->_value) ? 'not in' : 'in';
$visitor->addWhereParam('id_user ' . $operator . ' (' . $ids . ')');
return parent::buildElement()->setLabel($this->_('A rédigé des avis')) ;
}
}
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_RequiredRoleLevel extends Class_User_SearchCriteria_RoleLevel {
public function buildElement() {
return ($element = parent::buildElement())
? $element->setMultiOptions(ZendAfi_Acl_AdminControllerRoles::getRolesLabelsWithOutSuperAdmin())
: null;
}
}
<?php
/**
* Copyright (c) 2012-2020, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class Class_User_SearchCriteria_RoleLevel extends Class_SearchCriteria_Select {
protected $_name = 'role_level';
public function buildElement() {
$this->_headScript();
if (!Class_Users::getIdentity())
return;
if ((!Class_Users::getIdentity()->isAdmin())
&& $this->_isAllValues())
$this->_value = ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB;
return parent::buildElement()
->setLabel($this->_('Niveau d\'accès'))
->setMultiOptions([static::ALL_VALUES => $this->_('Tous')]
+ ZendAfi_Acl_AdminControllerRoles::getRolesLabelsWithOutSuperAdmin());
}
public function isAbonneSigb() {
return ZendAfi_Acl_AdminControllerRoles::ABONNE_SIGB == $this->_value;
}
protected function _headScript() {
$toggles = array_map(function($other)
{
return sprintf('formSelectToggleVisibilityForElement("#%s", $("#%s").closest("tr"), ["2"]);',
$this->getName(),
static::NAME_PREFIX . $other);
},
['valid_subscription',
'end_subscription_days',
'statut',
'date_fin_start']);
Class_ScriptLoader::getInstance()->addJQueryReady(implode($toggles));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment