Commit 8d558d6f authored by Côme Chilliet's avatar Côme Chilliet

🚜 feat(simpleplugin) Move ObjectSelectAttribute to its own file

issue #6083
parent 8ca15366
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/*!
* \file class_ObjectSelectAttribute.inc
* Source code for ObjectSelectAttribute
*/
/*! \brief This class allows to handle a select attribute which allow to choose an object
*
*/
class ObjectSelectAttribute extends SelectAttribute
{
protected $objectType;
protected $objectAttrs = NULL;
protected $objectFilter = '';
function __construct ($label, $description, $ldapName, $required, $objectType, $objectAttrs = NULL, $objectFilter = '', $acl = "")
{
parent::__construct($label, $description, $ldapName, $required, [], "", NULL, $acl);
$this->objectType = $objectType;
$this->objectAttrs = $objectAttrs;
$this->objectFilter = $objectFilter;
}
function setParent (simplePlugin &$plugin)
{
parent::setParent($plugin);
if (is_object($this->plugin)) {
$this->updateChoices();
}
}
function updateChoices ()
{
$objects = objects::ls($this->objectType, $this->objectAttrs, NULL, $this->objectFilter);
$this->setChoices(array_keys($objects), array_values($objects));
}
}
<?php
/*
This code is part of FusionDirectory (http://www.fusiondirectory.org/)
Copyright (C) 2012-2016 FusionDirectory
Copyright (C) 2012-2020 FusionDirectory
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -20,7 +21,7 @@
/*!
* \file class_SelectAttribute.inc
* Source code for the Select attributes
* Source code for SelectAttribute
*/
/*! \brief This class allow to handle easily a Select LDAP attribute with a set of choices
......@@ -247,35 +248,3 @@ class SelectAttribute extends Attribute
}
}
}
/*! \brief This class allows to handle a select attribute which allow to choose an object
*
*/
class ObjectSelectAttribute extends SelectAttribute
{
protected $objectType;
protected $objectAttrs = NULL;
protected $objectFilter = '';
function __construct ($label, $description, $ldapName, $required, $objectType, $objectAttrs = NULL, $objectFilter = '', $acl = "")
{
parent::__construct($label, $description, $ldapName, $required, [], "", NULL, $acl);
$this->objectType = $objectType;
$this->objectAttrs = $objectAttrs;
$this->objectFilter = $objectFilter;
}
function setParent (simplePlugin &$plugin)
{
parent::setParent($plugin);
if (is_object($this->plugin)) {
$this->updateChoices();
}
}
function updateChoices ()
{
$objects = objects::ls($this->objectType, $this->objectAttrs, NULL, $this->objectFilter);
$this->setChoices(array_keys($objects), array_values($objects));
}
}
Markdown is supported
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