2008-09-26 15:57:11 +02:00
|
|
|
<?php
|
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (C) 2007 Easter-eggs
|
2021-04-13 18:04:19 +02:00
|
|
|
* https://ldapsaisie.org
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
|
|
|
* Author: See AUTHORS file in top-level directory.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License version 2
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
/**
|
2015-01-08 15:00:56 +01:00
|
|
|
* Boolean LDAP attribute type
|
|
|
|
**/
|
2008-09-26 15:57:11 +02:00
|
|
|
class LSattr_ldap_boolean extends LSattr_ldap {
|
|
|
|
|
|
|
|
/**
|
2015-01-08 15:00:56 +01:00
|
|
|
* Return display value of attribute after treatment related to LDAP type
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @param mixed $data Attribute data
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2023-01-02 01:17:46 +01:00
|
|
|
* @return string|null Attribute display value
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function getDisplayValue($data) {
|
2008-10-15 12:46:09 +02:00
|
|
|
if ($this -> isTrue($data))
|
|
|
|
return 'yes';
|
|
|
|
if ($this -> isFalse($data))
|
|
|
|
return 'no';
|
2023-01-02 01:17:46 +01:00
|
|
|
return null;
|
2008-09-26 15:57:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-01-08 15:00:56 +01:00
|
|
|
* Return attribute value after treatment related to LDAP type
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @param mixed $data Attribute data
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2023-01-02 01:17:46 +01:00
|
|
|
* @return array Attribute data
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function getUpdateData($data) {
|
2020-11-30 19:37:44 +01:00
|
|
|
$data = ensureIsArray($data);
|
|
|
|
if ($data) {
|
|
|
|
if ($data[0] == 'yes') {
|
|
|
|
return array($this -> getTrue());
|
|
|
|
}
|
|
|
|
if ($data[0] == 'no') {
|
|
|
|
return array($this -> getFalse());
|
|
|
|
}
|
2008-09-26 15:57:11 +02:00
|
|
|
}
|
2008-10-15 12:46:09 +02:00
|
|
|
return array();
|
2008-09-26 15:57:11 +02:00
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2008-09-26 15:57:11 +02:00
|
|
|
/**
|
2015-01-08 15:00:56 +01:00
|
|
|
* Check if a value corresponding to True
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @param array|string|null $data Attribute data
|
2008-09-26 15:57:11 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @return boolean True or False
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function isTrue($data) {
|
2020-11-30 19:37:44 +01:00
|
|
|
$data = ensureIsArray($data);
|
|
|
|
if ($data && $data[0] == $this -> getTrue()) {
|
2008-09-26 15:57:11 +02:00
|
|
|
return true;
|
|
|
|
}
|
2020-11-30 19:37:44 +01:00
|
|
|
return false;
|
2008-09-26 15:57:11 +02:00
|
|
|
}
|
2020-04-29 15:54:21 +02:00
|
|
|
|
2008-10-15 12:46:09 +02:00
|
|
|
/**
|
2015-01-08 15:00:56 +01:00
|
|
|
* Check if a value corresponding to False
|
2008-10-15 12:46:09 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @param array|string|null $data Attribute data
|
2008-10-15 12:46:09 +02:00
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @return boolean True or False
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function isFalse($data) {
|
2020-11-30 19:37:44 +01:00
|
|
|
$data = ensureIsArray($data);
|
|
|
|
if ($data && $data[0] == $this -> getFalse()) {
|
2008-10-15 12:46:09 +02:00
|
|
|
return true;
|
|
|
|
}
|
2020-11-30 19:37:44 +01:00
|
|
|
return false;
|
2008-10-15 12:46:09 +02:00
|
|
|
}
|
2015-01-08 15:00:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return True value
|
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @return string The True value
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function getTrue() {
|
2019-03-11 22:21:25 +01:00
|
|
|
return $this -> getConfig('ldap_options.true_value', 'TRUE', 'string');
|
2015-01-08 15:00:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return False value
|
|
|
|
*
|
2022-12-31 05:52:31 +01:00
|
|
|
* @return string The False value
|
2015-01-08 15:00:56 +01:00
|
|
|
**/
|
2019-03-12 11:42:53 +01:00
|
|
|
public function getFalse() {
|
2019-03-11 22:21:25 +01:00
|
|
|
return $this -> getConfig('ldap_options.false_value', 'FALSE', 'string');
|
2015-01-08 15:00:56 +01:00
|
|
|
}
|
2019-03-11 22:21:25 +01:00
|
|
|
|
2008-09-26 15:57:11 +02:00
|
|
|
}
|