mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
Code cleaning: fix tabs
This commit is contained in:
parent
febb83e39d
commit
40fdc92451
47 changed files with 1814 additions and 1795 deletions
|
@ -69,7 +69,7 @@ $GLOBALS['LS_SUPANN_EPUI_FORMAT'] = "%{uniqueId}@univ.fr";
|
||||||
* '[key2]' => '[label2],
|
* '[key2]' => '[label2],
|
||||||
* [...]
|
* [...]
|
||||||
* )
|
* )
|
||||||
* ),
|
* ),
|
||||||
* );
|
* );
|
||||||
*
|
*
|
||||||
* [ETIQUETTE] : l'étiquette de la valeur (correspondant le plus souvent ou mainteneur de la nomenclature)
|
* [ETIQUETTE] : l'étiquette de la valeur (correspondant le plus souvent ou mainteneur de la nomenclature)
|
||||||
|
@ -92,57 +92,57 @@ $GLOBALS['LS_SUPANN_EPUI_FORMAT'] = "%{uniqueId}@univ.fr";
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$GLOBALS['supannNomenclatures'] = array (
|
$GLOBALS['supannNomenclatures'] = array (
|
||||||
'SUPANN' => array (
|
'SUPANN' => array (
|
||||||
'civilite' => array(
|
'civilite' => array(
|
||||||
'Mme' => ___('Mrs.'),
|
'Mme' => ___('Mrs.'),
|
||||||
'M.' => ___('Mr.'),
|
'M.' => ___('Mr.'),
|
||||||
),
|
),
|
||||||
'affiliation' => array (
|
'affiliation' => array (
|
||||||
'researcher' => 'Chercheur (researcher)',
|
'researcher' => 'Chercheur (researcher)',
|
||||||
'retired' => 'Retraité (retired)',
|
'retired' => 'Retraité (retired)',
|
||||||
'emeritus' => 'Professeur émérite (emeritus)',
|
'emeritus' => 'Professeur émérite (emeritus)',
|
||||||
'teacher' => 'Professeur (teacher)',
|
'teacher' => 'Professeur (teacher)',
|
||||||
'registered-reader' => 'Lecteur enregistré dans une bibliothèque (registered-reader)',
|
'registered-reader' => 'Lecteur enregistré dans une bibliothèque (registered-reader)',
|
||||||
),
|
),
|
||||||
'mailPriveLabel' => array (
|
'mailPriveLabel' => array (
|
||||||
'SECOURS' => ___('Backup'),
|
'SECOURS' => ___('Backup'),
|
||||||
'PERSO' => ___('Personal'),
|
'PERSO' => ___('Personal'),
|
||||||
'PARENTS' => ___('Parents'),
|
'PARENTS' => ___('Parents'),
|
||||||
'PRO' => ___('Professional'),
|
'PRO' => ___('Professional'),
|
||||||
),
|
),
|
||||||
'adressePostalePriveeLabel' => array (
|
'adressePostalePriveeLabel' => array (
|
||||||
'TEMP' => ___('Temporary'),
|
'TEMP' => ___('Temporary'),
|
||||||
'PERSO' => ___('Personal'),
|
'PERSO' => ___('Personal'),
|
||||||
'PARENTS' => ___('Parents'),
|
'PARENTS' => ___('Parents'),
|
||||||
'PRO' => ___('Professional'),
|
'PRO' => ___('Professional'),
|
||||||
),
|
),
|
||||||
'telephonePriveLabel' => array (
|
'telephonePriveLabel' => array (
|
||||||
'MOBPERSO' => ___('Personal mobile'),
|
'MOBPERSO' => ___('Personal mobile'),
|
||||||
'FIXEPERSO' => ___('Personal landline'),
|
'FIXEPERSO' => ___('Personal landline'),
|
||||||
'FIXEPARENTS' => ___('Parents landline'),
|
'FIXEPARENTS' => ___('Parents landline'),
|
||||||
'MOBPARENTS' => ___('Parents mobile'),
|
'MOBPARENTS' => ___('Parents mobile'),
|
||||||
'MOBPRO' => ___('Professional mobile'),
|
'MOBPRO' => ___('Professional mobile'),
|
||||||
'FIXEPRO' => ___('Professional landline'),
|
'FIXEPRO' => ___('Professional landline'),
|
||||||
'SECOURS' => ___('Backup'),
|
'SECOURS' => ___('Backup'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'eduPerson' => array(
|
'eduPerson' => array(
|
||||||
'affiliation' => array (
|
'affiliation' => array (
|
||||||
'student' => "Étudiant (student)",
|
'student' => "Étudiant (student)",
|
||||||
'faculty' => "Membre du corps professoral (faculty)",
|
'faculty' => "Membre du corps professoral (faculty)",
|
||||||
'staff' => "Personne exerçant une activité administrative, technique ou de support, autre que l'enseignement et la recherche (staff)",
|
'staff' => "Personne exerçant une activité administrative, technique ou de support, autre que l'enseignement et la recherche (staff)",
|
||||||
'employee' => "Personne employée par l'établissement (employee)",
|
'employee' => "Personne employée par l'établissement (employee)",
|
||||||
'member' => "Membre de l'établissement (member)",
|
'member' => "Membre de l'établissement (member)",
|
||||||
'affiliate' => "Partenaire en relation avec l'établissement, sans en être membre (affiliate)",
|
'affiliate' => "Partenaire en relation avec l'établissement, sans en être membre (affiliate)",
|
||||||
'alum' => "Ancien étudiant (alum)",
|
'alum' => "Ancien étudiant (alum)",
|
||||||
'library-walk-in' => "Personne physiquement présente dans une bibliothèque (library-walk-in)",
|
'library-walk-in' => "Personne physiquement présente dans une bibliothèque (library-walk-in)",
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
'oidc' => array(
|
'oidc' => array(
|
||||||
'oidc_genre' => array(
|
'oidc_genre' => array(
|
||||||
'female' => ___('Female'),
|
'female' => ___('Female'),
|
||||||
'male' => ___('Male'),
|
'male' => ___('Male'),
|
||||||
'other' => ___('Other'),
|
'other' => ___('Other'),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -34,33 +34,33 @@ LSerror :: defineError('LSACCESSRIGHTSMATRIXVIEW_SUPPORT_01',
|
||||||
* @retval boolean true if LSaccessRightsMatrixView addon is totally supported, false in other case
|
* @retval boolean true if LSaccessRightsMatrixView addon is totally supported, false in other case
|
||||||
*/
|
*/
|
||||||
function LSaddon_LSaccessRightsMatrixView_support() {
|
function LSaddon_LSaccessRightsMatrixView_support() {
|
||||||
$retval = True;
|
$retval = True;
|
||||||
$MUST_DEFINE_ARRAY= array(
|
$MUST_DEFINE_ARRAY= array(
|
||||||
'LSaccessRightsMatrixView_allowed_LSprofiles',
|
'LSaccessRightsMatrixView_allowed_LSprofiles',
|
||||||
);
|
);
|
||||||
foreach($MUST_DEFINE_ARRAY as $array) {
|
foreach($MUST_DEFINE_ARRAY as $array) {
|
||||||
if ( !isset($GLOBALS[$array]) || !is_array($GLOBALS[$array])) {
|
if ( !isset($GLOBALS[$array]) || !is_array($GLOBALS[$array])) {
|
||||||
LSerror :: addErrorCode('LSACCESSRIGHTSMATRIXVIEW_SUPPORT_01',$array);
|
LSerror :: addErrorCode('LSACCESSRIGHTSMATRIXVIEW_SUPPORT_01',$array);
|
||||||
$retval=false;
|
$retval=false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($retval)
|
if ($retval)
|
||||||
$retval = LSsession :: registerLSaddonView(
|
$retval = LSsession :: registerLSaddonView(
|
||||||
'LSaccessRightsMatrixView',
|
'LSaccessRightsMatrixView',
|
||||||
'accessRightsMatrix',
|
'accessRightsMatrix',
|
||||||
_('Access rights matrix'),
|
_('Access rights matrix'),
|
||||||
'LSaccessRightsMatrixView',
|
'LSaccessRightsMatrixView',
|
||||||
$GLOBALS['LSaccessRightsMatrixView_allowed_LSprofiles']
|
$GLOBALS['LSaccessRightsMatrixView_allowed_LSprofiles']
|
||||||
);
|
);
|
||||||
|
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
function LSaccessRightsMatrixView() {
|
function LSaccessRightsMatrixView() {
|
||||||
$LSprofiles = array(
|
$LSprofiles = array(
|
||||||
'user' => _('All connected users'),
|
'user' => _('All connected users'),
|
||||||
);
|
);
|
||||||
// Authenticable user objects types
|
// Authenticable user objects types
|
||||||
$authObjTypes = LSauth :: getAuthObjectTypes();
|
$authObjTypes = LSauth :: getAuthObjectTypes();
|
||||||
foreach ($authObjTypes as $objType => $objParams)
|
foreach ($authObjTypes as $objType => $objParams)
|
||||||
|
@ -68,9 +68,9 @@ function LSaccessRightsMatrixView() {
|
||||||
$LSprofiles[$objType] = LSldapObject :: getLabel($objType);
|
$LSprofiles[$objType] = LSldapObject :: getLabel($objType);
|
||||||
|
|
||||||
// Custom configured LSprofiles
|
// Custom configured LSprofiles
|
||||||
if (isset(LSsession :: $ldapServer["LSprofiles"]) && is_array(LSsession :: $ldapServer["LSprofiles"]))
|
if (isset(LSsession :: $ldapServer["LSprofiles"]) && is_array(LSsession :: $ldapServer["LSprofiles"]))
|
||||||
foreach(LSsession :: $ldapServer["LSprofiles"] as $LSprofile => $LSprofile_conf)
|
foreach(LSsession :: $ldapServer["LSprofiles"] as $LSprofile => $LSprofile_conf)
|
||||||
$LSprofiles[$LSprofile] = (isset($LSprofile_conf['label'])?__($LSprofile_conf['label']):$LSprofile);
|
$LSprofiles[$LSprofile] = (isset($LSprofile_conf['label'])?__($LSprofile_conf['label']):$LSprofile);
|
||||||
|
|
||||||
// List object types
|
// List object types
|
||||||
$objectTypes = array();
|
$objectTypes = array();
|
||||||
|
@ -99,72 +99,72 @@ function LSaccessRightsMatrixView() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$LSobjects = array();
|
$LSobjects = array();
|
||||||
foreach ($objectTypes as $LSobject) {
|
foreach ($objectTypes as $LSobject) {
|
||||||
if (!LSsession :: loadLSobject($LSobject))
|
if (!LSsession :: loadLSobject($LSobject))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// List attributes and rigths on their
|
// List attributes and rigths on their
|
||||||
$attrs = array();
|
$attrs = array();
|
||||||
foreach(LSconfig :: get("LSobjects.$LSobject.attrs", array()) as $attr_name => $attr_config) {
|
foreach(LSconfig :: get("LSobjects.$LSobject.attrs", array()) as $attr_name => $attr_config) {
|
||||||
$raw_attr_rights = LSconfig :: get('rights', array(), 'array', $attr_config);
|
$raw_attr_rights = LSconfig :: get('rights', array(), 'array', $attr_config);
|
||||||
$attr_rights = array();
|
$attr_rights = array();
|
||||||
if (array_key_exists($LSobject, $authObjTypes))
|
if (array_key_exists($LSobject, $authObjTypes))
|
||||||
$attr_rights['self'] = LSconfig :: get('self', False, null, $raw_attr_rights);
|
$attr_rights['self'] = LSconfig :: get('self', False, null, $raw_attr_rights);
|
||||||
foreach(array_keys($LSprofiles) as $LSprofile) {
|
foreach(array_keys($LSprofiles) as $LSprofile) {
|
||||||
$attr_rights[$LSprofile] = LSconfig :: get($LSprofile, False, null, $raw_attr_rights);
|
$attr_rights[$LSprofile] = LSconfig :: get($LSprofile, False, null, $raw_attr_rights);
|
||||||
}
|
}
|
||||||
$attrs[$attr_name] = array (
|
$attrs[$attr_name] = array (
|
||||||
'label' => __(LSconfig :: get('label', $attr_name, 'string', $attr_config)),
|
'label' => __(LSconfig :: get('label', $attr_name, 'string', $attr_config)),
|
||||||
'rights' => $attr_rights,
|
'rights' => $attr_rights,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List relations and rigths on their
|
// List relations and rigths on their
|
||||||
$relations = array();
|
$relations = array();
|
||||||
foreach(LSconfig :: get("LSobjects.$LSobject.LSrelation", array()) as $relation_name => $relation_config) {
|
foreach(LSconfig :: get("LSobjects.$LSobject.LSrelation", array()) as $relation_name => $relation_config) {
|
||||||
$raw_relation_rights = LSconfig :: get('rights', array(), 'array', $relation_config);
|
$raw_relation_rights = LSconfig :: get('rights', array(), 'array', $relation_config);
|
||||||
$relation_rights = array();
|
$relation_rights = array();
|
||||||
if (array_key_exists($LSobject, $authObjTypes))
|
if (array_key_exists($LSobject, $authObjTypes))
|
||||||
$relation_rights['self'] = LSconfig :: get('self', False, null, $raw_relation_rights);
|
$relation_rights['self'] = LSconfig :: get('self', False, null, $raw_relation_rights);
|
||||||
foreach(array_keys($LSprofiles) as $LSprofile) {
|
foreach(array_keys($LSprofiles) as $LSprofile) {
|
||||||
$relation_rights[$LSprofile] = LSconfig :: get($LSprofile, False, null, $raw_relation_rights);
|
$relation_rights[$LSprofile] = LSconfig :: get($LSprofile, False, null, $raw_relation_rights);
|
||||||
}
|
}
|
||||||
$relations[$relation_name] = array (
|
$relations[$relation_name] = array (
|
||||||
'label' => __(LSconfig :: get('label', $relation_name, 'string', $relation_config)),
|
'label' => __(LSconfig :: get('label', $relation_name, 'string', $relation_config)),
|
||||||
'rights' => $relation_rights,
|
'rights' => $relation_rights,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List customActions and rigths on their
|
// List customActions and rigths on their
|
||||||
$customActions = array();
|
$customActions = array();
|
||||||
foreach(LSconfig :: get("LSobjects.$LSobject.customActions", array()) as $action_name => $action_config) {
|
foreach(LSconfig :: get("LSobjects.$LSobject.customActions", array()) as $action_name => $action_config) {
|
||||||
$raw_action_rights = LSconfig :: get('rights', array(), 'array', $action_config);
|
$raw_action_rights = LSconfig :: get('rights', array(), 'array', $action_config);
|
||||||
$action_rights = array();
|
$action_rights = array();
|
||||||
if (array_key_exists($LSobject, $authObjTypes))
|
if (array_key_exists($LSobject, $authObjTypes))
|
||||||
$action_rights['self'] = in_array('self', $raw_action_rights);
|
$action_rights['self'] = in_array('self', $raw_action_rights);
|
||||||
foreach(array_keys($LSprofiles) as $LSprofile)
|
foreach(array_keys($LSprofiles) as $LSprofile)
|
||||||
$action_rights[$LSprofile] = in_array($LSprofile, $raw_action_rights);
|
$action_rights[$LSprofile] = in_array($LSprofile, $raw_action_rights);
|
||||||
$customActions[$action_name] = array (
|
$customActions[$action_name] = array (
|
||||||
'label' => __(LSconfig :: get('label', $action_name, 'string', $action_config)),
|
'label' => __(LSconfig :: get('label', $action_name, 'string', $action_config)),
|
||||||
'rights' => $action_rights,
|
'rights' => $action_rights,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// List customSearchActions and rigths on their
|
// List customSearchActions and rigths on their
|
||||||
$customSearchActions = array();
|
$customSearchActions = array();
|
||||||
foreach(LSconfig :: get("LSobjects.$LSobject.LSsearch.customActions", array()) as $action_name => $action_config) {
|
foreach(LSconfig :: get("LSobjects.$LSobject.LSsearch.customActions", array()) as $action_name => $action_config) {
|
||||||
$raw_action_rights = LSconfig :: get('rights', array(), 'array', $action_config);
|
$raw_action_rights = LSconfig :: get('rights', array(), 'array', $action_config);
|
||||||
$action_rights = array();
|
$action_rights = array();
|
||||||
if (array_key_exists($LSobject, $authObjTypes))
|
if (array_key_exists($LSobject, $authObjTypes))
|
||||||
$action_rights['self'] = in_array('self', $raw_action_rights);
|
$action_rights['self'] = in_array('self', $raw_action_rights);
|
||||||
foreach(array_keys($LSprofiles) as $LSprofile)
|
foreach(array_keys($LSprofiles) as $LSprofile)
|
||||||
$action_rights[$LSprofile] = in_array($LSprofile, $raw_action_rights);
|
$action_rights[$LSprofile] = in_array($LSprofile, $raw_action_rights);
|
||||||
$customSearchActions[$action_name] = array (
|
$customSearchActions[$action_name] = array (
|
||||||
'label' => __(LSconfig :: get('label', $action_name, 'string', $action_config)),
|
'label' => __(LSconfig :: get('label', $action_name, 'string', $action_config)),
|
||||||
'rights' => $action_rights,
|
'rights' => $action_rights,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle LSform layout
|
// Handle LSform layout
|
||||||
$layout = false;
|
$layout = false;
|
||||||
|
@ -187,30 +187,30 @@ function LSaccessRightsMatrixView() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$LSobjects[$LSobject] = array (
|
$LSobjects[$LSobject] = array (
|
||||||
'label' => __(LSconfig :: get("LSobjects.$LSobject.label", $LSobject, 'string')),
|
'label' => __(LSconfig :: get("LSobjects.$LSobject.label", $LSobject, 'string')),
|
||||||
'attrs' => $attrs,
|
'attrs' => $attrs,
|
||||||
'relations' => $relations,
|
'relations' => $relations,
|
||||||
'customActions' => $customActions,
|
'customActions' => $customActions,
|
||||||
'customSearchActions' => $customSearchActions,
|
'customSearchActions' => $customSearchActions,
|
||||||
'layout' => $layout,
|
'layout' => $layout,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine current LSobject
|
// Determine current LSobject
|
||||||
reset($LSobjects);
|
reset($LSobjects);
|
||||||
$LSobject = (isset($_REQUEST['LSobject']) && array_key_exists($_REQUEST['LSobject'], $LSobjects)?$_REQUEST['LSobject']:key($LSobjects));
|
$LSobject = (isset($_REQUEST['LSobject']) && array_key_exists($_REQUEST['LSobject'], $LSobjects)?$_REQUEST['LSobject']:key($LSobjects));
|
||||||
|
|
||||||
if (array_key_exists($LSobject, $authObjTypes))
|
if (array_key_exists($LSobject, $authObjTypes))
|
||||||
$LSprofiles = array_merge(array('self' => _('The user him-self')), $LSprofiles);
|
$LSprofiles = array_merge(array('self' => _('The user him-self')), $LSprofiles);
|
||||||
|
|
||||||
LSlog :: get_logger('LSaddon_LSaccessRightsMatrixView') -> debug($LSobjects);
|
LSlog :: get_logger('LSaddon_LSaccessRightsMatrixView') -> debug($LSobjects);
|
||||||
|
|
||||||
LStemplate :: assign('pagetitle', _('Access rights matrix'));
|
LStemplate :: assign('pagetitle', _('Access rights matrix'));
|
||||||
LStemplate :: assign('LSprofiles', $LSprofiles);
|
LStemplate :: assign('LSprofiles', $LSprofiles);
|
||||||
LStemplate :: assign('LSobjects', $LSobjects);
|
LStemplate :: assign('LSobjects', $LSobjects);
|
||||||
LStemplate :: assign('LSobject', $LSobject);
|
LStemplate :: assign('LSobject', $LSobject);
|
||||||
|
|
||||||
LStemplate :: addCssFile('LSaccessRightsMatrixView.css');
|
LStemplate :: addCssFile('LSaccessRightsMatrixView.css');
|
||||||
LSsession :: setTemplate('LSaccessRightsMatrixView.tpl');
|
LSsession :: setTemplate('LSaccessRightsMatrixView.tpl');
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,10 +164,10 @@ function mailquota_show_usage(&$LSldapObject) {
|
||||||
|
|
||||||
function mailquota_formatValue($value) {
|
function mailquota_formatValue($value) {
|
||||||
$sizeFacts = array(
|
$sizeFacts = array(
|
||||||
1073741824 => 'Go',
|
1073741824 => 'Go',
|
||||||
1048576 => 'Mo',
|
1048576 => 'Mo',
|
||||||
1024 => 'Ko',
|
1024 => 'Ko',
|
||||||
1 => 'o',
|
1 => 'o',
|
||||||
);
|
);
|
||||||
krsort($sizeFacts);
|
krsort($sizeFacts);
|
||||||
foreach($sizeFacts as $sill => $label) {
|
foreach($sizeFacts as $sill => $label) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ function LSaddon_showTechInfo_support() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function showTechInfo($object) {
|
function showTechInfo($object) {
|
||||||
$dn = $object -> getDn();
|
$dn = $object -> getDn();
|
||||||
|
|
||||||
// Retreive internal attributes
|
// Retreive internal attributes
|
||||||
$internal_attrs = LSldap :: getAttrs(
|
$internal_attrs = LSldap :: getAttrs(
|
||||||
|
@ -111,7 +111,7 @@ function showTechInfo($object) {
|
||||||
// Sort other internal attributes by name
|
// Sort other internal attributes by name
|
||||||
ksort($internal_attrs);
|
ksort($internal_attrs);
|
||||||
|
|
||||||
LStemplate :: assign('pagetitle', getFData(_('%{name}: Technical information'), $object -> getDisplayName()));
|
LStemplate :: assign('pagetitle', getFData(_('%{name}: Technical information'), $object -> getDisplayName()));
|
||||||
|
|
||||||
$LSview_actions=array();
|
$LSview_actions=array();
|
||||||
$LSview_actions['return'] = array (
|
$LSview_actions['return'] = array (
|
||||||
|
@ -125,14 +125,14 @@ function showTechInfo($object) {
|
||||||
LSform :: loadDependenciesDisplayView();
|
LSform :: loadDependenciesDisplayView();
|
||||||
}
|
}
|
||||||
|
|
||||||
LStemplate :: assign('object', $object);
|
LStemplate :: assign('object', $object);
|
||||||
LStemplate :: assign('object_classes', $object_classes);
|
LStemplate :: assign('object_classes', $object_classes);
|
||||||
LStemplate :: assign('structural_object_class', $structural_object_class);
|
LStemplate :: assign('structural_object_class', $structural_object_class);
|
||||||
LStemplate :: assign('special_internal_attributes', $special_internal_attributes);
|
LStemplate :: assign('special_internal_attributes', $special_internal_attributes);
|
||||||
LStemplate :: assign('other_internal_attrs', $internal_attrs);
|
LStemplate :: assign('other_internal_attrs', $internal_attrs);
|
||||||
|
|
||||||
LStemplate :: addCssFile('showTechInfo.css');
|
LStemplate :: addCssFile('showTechInfo.css');
|
||||||
LSsession :: setTemplate('showTechInfo.tpl');
|
LSsession :: setTemplate('showTechInfo.tpl');
|
||||||
// Display template
|
// Display template
|
||||||
LSsession :: displayTemplate();
|
LSsession :: displayTemplate();
|
||||||
exit();
|
exit();
|
||||||
|
|
|
@ -47,147 +47,162 @@ LSerror :: defineError('SUPANN_04',
|
||||||
___("SUPANN: Fail to load nomenclature %{nomenclature}.")
|
___("SUPANN: Fail to load nomenclature %{nomenclature}.")
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verification du support SUPANN par ldapSaisie
|
* Verification du support SUPANN par ldapSaisie
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*
|
*
|
||||||
* @retval boolean true si SUPANN est pleinement supporté, false sinon
|
* @retval boolean true si SUPANN est pleinement supporté, false sinon
|
||||||
*/
|
*/
|
||||||
function LSaddon_supann_support() {
|
function LSaddon_supann_support() {
|
||||||
$retval = true;
|
$retval = true;
|
||||||
|
|
||||||
$MUST_DEFINE_STRING= array(
|
$MUST_DEFINE_STRING = array(
|
||||||
'LS_SUPANN_LASTNAME_ATTR',
|
'LS_SUPANN_LASTNAME_ATTR',
|
||||||
'LS_SUPANN_FIRSTNAME_ATTR',
|
'LS_SUPANN_FIRSTNAME_ATTR',
|
||||||
'LS_SUPANN_LSOBJECT_ENTITE_TYPE',
|
'LS_SUPANN_LSOBJECT_ENTITE_TYPE',
|
||||||
'LS_SUPANN_LSOBJECT_ENTITE_FORMAT_SHORTNAME',
|
'LS_SUPANN_LSOBJECT_ENTITE_FORMAT_SHORTNAME',
|
||||||
'LS_SUPANN_ETABLISSEMENT_UAI',
|
'LS_SUPANN_ETABLISSEMENT_UAI',
|
||||||
'LS_SUPANN_ETABLISSEMENT_DN',
|
'LS_SUPANN_ETABLISSEMENT_DN',
|
||||||
'LS_SUPANN_EPPN_FORMAT',
|
'LS_SUPANN_EPPN_FORMAT',
|
||||||
'LS_SUPANN_EPUI_FORMAT',
|
'LS_SUPANN_EPUI_FORMAT',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($MUST_DEFINE_STRING as $string) {
|
foreach($MUST_DEFINE_STRING as $string) {
|
||||||
if ( isset($GLOBALS[$string]) && is_string($GLOBALS[$string])) {
|
if ( isset($GLOBALS[$string]) && is_string($GLOBALS[$string])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
|
foreach(LSconfig :: get('ldap_servers') as $id => $infos) {
|
||||||
if ( !isset($infos['globals'][$string]) || !is_string($infos['globals'][$string])) {
|
if ( !isset($infos['globals'][$string]) || !is_string($infos['globals'][$string])) {
|
||||||
LSerror :: addErrorCode('SUPANN_SUPPORT_01',$string);
|
LSerror :: addErrorCode('SUPANN_SUPPORT_01',$string);
|
||||||
$retval=false;
|
$retval = false;
|
||||||
continue 2;
|
continue 2;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$MUST_DEFINE_ARRAY= array(
|
|
||||||
'LS_SUPANN_LSOBJECT_PARRAIN_TYPES',
|
|
||||||
'supannNomenclatures',
|
|
||||||
);
|
|
||||||
foreach($MUST_DEFINE_ARRAY as $array) {
|
|
||||||
if ( !isset($GLOBALS[$array]) || !is_array($GLOBALS[$array])) {
|
|
||||||
LSerror :: addErrorCode('SUPANN_SUPPORT_03',$array);
|
|
||||||
$retval=false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
|
||||||
if ( ! LSsession :: loadLSobject( $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'] ) ) {
|
|
||||||
LSerror :: addErrorCode('SUPANN_SUPPORT_02', $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$MUST_DEFINE_ARRAY = array(
|
||||||
|
'LS_SUPANN_LSOBJECT_PARRAIN_TYPES',
|
||||||
|
'supannNomenclatures',
|
||||||
|
);
|
||||||
|
foreach($MUST_DEFINE_ARRAY as $array) {
|
||||||
|
if ( !isset($GLOBALS[$array]) || !is_array($GLOBALS[$array])) {
|
||||||
|
LSerror :: addErrorCode('SUPANN_SUPPORT_03',$array);
|
||||||
|
$retval=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
||||||
|
if ( ! LSsession :: loadLSobject( $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'] ) ) {
|
||||||
|
LSerror :: addErrorCode('SUPANN_SUPPORT_02', $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Fonctions de génération de valeurs d'attributs
|
* Fonctions de génération de valeurs d'attributs
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generation du displayName
|
* Generation du displayName
|
||||||
*
|
*
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
*
|
*
|
||||||
* @param[in] $ldapObject L'objet ldap
|
* @param[in] $ldapObject L'objet ldap
|
||||||
*
|
*
|
||||||
* @retval string Le displayName ou false si il y a un problème durant la génération
|
* @retval string Le displayName ou false si il y a un problème durant la génération
|
||||||
*/
|
*/
|
||||||
function generate_displayName($ldapObject) {
|
function generate_displayName($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => $GLOBALS['LS_SUPANN_LASTNAME_ATTR'], 'attr' => 'cn'));
|
LSerror :: addErrorCode(
|
||||||
return;
|
'SUPANN_01',
|
||||||
}
|
array('dependency' => $GLOBALS['LS_SUPANN_LASTNAME_ATTR'], 'attr' => 'cn')
|
||||||
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ]) != 'LSattribute' ) {
|
);
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'], 'attr' => 'cn'));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ]) != 'LSattribute' ) {
|
||||||
|
LSerror :: addErrorCode(
|
||||||
$noms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ] -> getValue();
|
'SUPANN_01',
|
||||||
$prenoms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ] -> getValue();
|
array('dependency' => $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'], 'attr' => 'cn')
|
||||||
|
);
|
||||||
return ($prenoms[0].' '.$noms[0]);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$noms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ] -> getValue();
|
||||||
* Generation du CN
|
$prenoms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ] -> getValue();
|
||||||
*
|
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
||||||
*
|
|
||||||
* @param[in] $ldapObject L'objet ldap
|
|
||||||
*
|
|
||||||
* @retval string Le CN ou false si il y a un problème durant la génération
|
|
||||||
*/
|
|
||||||
function generate_cn($ldapObject) {
|
|
||||||
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ]) != 'LSattribute' ) {
|
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => $GLOBALS['LS_SUPANN_LASTNAME_ATTR'], 'attr' => 'cn'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ]) != 'LSattribute' ) {
|
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'], 'attr' => 'cn'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$noms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ] -> getValue();
|
return ($prenoms[0].' '.$noms[0]);
|
||||||
$prenoms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ] -> getValue();
|
}
|
||||||
|
|
||||||
return (withoutAccents($noms[0]).' '.withoutAccents($prenoms[0]));
|
/**
|
||||||
|
* Generation du CN
|
||||||
|
*
|
||||||
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @param[in] $ldapObject L'objet ldap
|
||||||
|
*
|
||||||
|
* @retval string Le CN ou false si il y a un problème durant la génération
|
||||||
|
*/
|
||||||
|
function generate_cn($ldapObject) {
|
||||||
|
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ]) != 'LSattribute' ) {
|
||||||
|
LSerror :: addErrorCode(
|
||||||
|
'SUPANN_01',
|
||||||
|
array('dependency' => $GLOBALS['LS_SUPANN_LASTNAME_ATTR'], 'attr' => 'cn')
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( get_class($ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ]) != 'LSattribute' ) {
|
||||||
|
LSerror :: addErrorCode(
|
||||||
|
'SUPANN_01',
|
||||||
|
array('dependency' => $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'], 'attr' => 'cn')
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
$noms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_LASTNAME_ATTR'] ] -> getValue();
|
||||||
* Generation des valeurs de l'attribut eduPersonOrgUnitDN à partir des
|
$prenoms = $ldapObject -> attrs[ $GLOBALS['LS_SUPANN_FIRSTNAME_ATTR'] ] -> getValue();
|
||||||
* valeurs de l'attribut supannEntiteAffectation.
|
|
||||||
*
|
|
||||||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
|
||||||
*
|
|
||||||
* @param[in] $ldapObject L'objet ldap
|
|
||||||
*
|
|
||||||
* @retval array Les valeurs de l'attribut eduPersonOrgUnitDN ou false
|
|
||||||
* si il y a un problème durant la génération
|
|
||||||
*/
|
|
||||||
function generate_eduPersonOrgUnitDN($ldapObject) {
|
|
||||||
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectation' ]) != 'LSattribute' ) {
|
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectation', 'attr' => 'eduPersonOrgUnitDN'));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectation' ] -> getUpdateData();
|
return (withoutAccents($noms[0]).' '.withoutAccents($prenoms[0]));
|
||||||
|
}
|
||||||
|
|
||||||
$basedn=LSconfig :: get('LSobjects.'.$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'].'.container_dn').','.LSsession::getTopDn();
|
/**
|
||||||
if ($basedn=="") {
|
* Generation des valeurs de l'attribut eduPersonOrgUnitDN à partir des
|
||||||
LSerror :: addErrorCode('SUPANN_02','eduPersonOrgUnitDN');
|
* valeurs de l'attribut supannEntiteAffectation.
|
||||||
return;
|
*
|
||||||
}
|
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
$retval=array();
|
* @param[in] $ldapObject L'objet ldap
|
||||||
foreach ($affectations as $aff) {
|
*
|
||||||
$retval[]="supannCodeEntite=".$aff.",$basedn";
|
* @retval array Les valeurs de l'attribut eduPersonOrgUnitDN ou false
|
||||||
}
|
* si il y a un problème durant la génération
|
||||||
|
*/
|
||||||
return $retval;
|
function generate_eduPersonOrgUnitDN($ldapObject) {
|
||||||
|
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectation' ]) != 'LSattribute' ) {
|
||||||
|
LSerror :: addErrorCode(
|
||||||
|
'SUPANN_01',
|
||||||
|
array('dependency' => 'supannEntiteAffectation', 'attr' => 'eduPersonOrgUnitDN')
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectation' ] -> getUpdateData();
|
||||||
|
|
||||||
|
$basedn = LSconfig :: get('LSobjects.'.$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'].'.container_dn').','.LSsession::getTopDn();
|
||||||
|
if ($basedn == "") {
|
||||||
|
LSerror :: addErrorCode('SUPANN_02','eduPersonOrgUnitDN');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$retval = array();
|
||||||
|
foreach ($affectations as $aff) {
|
||||||
|
$retval[] = "supannCodeEntite=".$aff.",$basedn";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generation de la valeur de l'attribut eduPersonPrimaryOrgUnitDN
|
* Generation de la valeur de l'attribut eduPersonPrimaryOrgUnitDN
|
||||||
* à partir de la valeur de l'attribut supannEntiteAffectationPrincipale.
|
* à partir de la valeur de l'attribut supannEntiteAffectationPrincipale.
|
||||||
|
@ -199,28 +214,28 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array La valeur de l'attribut eduPersonPrimaryOrgUnitDN
|
* @retval array La valeur de l'attribut eduPersonPrimaryOrgUnitDN
|
||||||
* ou false si il y a un problème durant la génération
|
* ou false si il y a un problème durant la génération
|
||||||
*/
|
*/
|
||||||
function generate_eduPersonPrimaryOrgUnitDN($ldapObject) {
|
function generate_eduPersonPrimaryOrgUnitDN($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectationPrincipale', 'attr' => 'eduPersonPrimaryOrgUnitDN'));
|
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEntiteAffectationPrincipale', 'attr' => 'eduPersonPrimaryOrgUnitDN'));
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ] -> getUpdateData();
|
|
||||||
|
|
||||||
$basedn=LSconfig :: get('LSobjects.'.$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'].'.container_dn').','.LSsession::getTopDn();
|
|
||||||
if ($basedn=="") {
|
|
||||||
LSerror :: addErrorCode('SUPANN_02','eduPersonPrimaryOrgUnitDN');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$retval=array();
|
|
||||||
foreach ($affectations as $aff) {
|
|
||||||
$retval[]="supannCodeEntite=".$aff.",$basedn";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$affectations = $ldapObject -> attrs[ 'supannEntiteAffectationPrincipale' ] -> getUpdateData();
|
||||||
|
|
||||||
|
$basedn = LSconfig :: get('LSobjects.'.$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'].'.container_dn').','.LSsession::getTopDn();
|
||||||
|
if ($basedn == "") {
|
||||||
|
LSerror :: addErrorCode('SUPANN_02','eduPersonPrimaryOrgUnitDN');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$retval = array();
|
||||||
|
foreach ($affectations as $aff) {
|
||||||
|
$retval[]="supannCodeEntite=".$aff.",$basedn";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generation de la valeur de l'attribut eduPersonOrgDN
|
* Generation de la valeur de l'attribut eduPersonOrgDN
|
||||||
* à partir de la valeur de l'attribut supannEtablissement.
|
* à partir de la valeur de l'attribut supannEtablissement.
|
||||||
|
@ -235,22 +250,22 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array La valeur de l'attribut eduPersonOrgDN ou false
|
* @retval array La valeur de l'attribut eduPersonOrgDN ou false
|
||||||
* si il y a un problème durant la génération
|
* si il y a un problème durant la génération
|
||||||
*/
|
*/
|
||||||
function generate_eduPersonOrgDN($ldapObject) {
|
function generate_eduPersonOrgDN($ldapObject) {
|
||||||
if ( get_class($ldapObject -> attrs[ 'supannEtablissement' ]) != 'LSattribute' ) {
|
if ( get_class($ldapObject -> attrs[ 'supannEtablissement' ]) != 'LSattribute' ) {
|
||||||
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEtablissement', 'attr' => 'eduPersonOrgDN'));
|
LSerror :: addErrorCode('SUPANN_01',array('dependency' => 'supannEtablissement', 'attr' => 'eduPersonOrgDN'));
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
$eta = $ldapObject -> attrs[ 'supannEtablissement' ] -> getUpdateData();
|
|
||||||
|
|
||||||
$retval=array();
|
|
||||||
if ($eta[0] == '{UAI}'.$GLOBALS['LS_SUPANN_ETABLISSEMENT_UAI']) {
|
|
||||||
$retval[] = $GLOBALS['LS_SUPANN_ETABLISSEMENT_DN'];
|
|
||||||
}
|
|
||||||
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$eta = $ldapObject -> attrs[ 'supannEtablissement' ] -> getUpdateData();
|
||||||
|
|
||||||
|
$retval=array();
|
||||||
|
if ($eta[0] == '{UAI}'.$GLOBALS['LS_SUPANN_ETABLISSEMENT_UAI']) {
|
||||||
|
$retval[] = $GLOBALS['LS_SUPANN_ETABLISSEMENT_DN'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Fonction de parsing des valeurs spécifiques SUPANN
|
* Fonction de parsing des valeurs spécifiques SUPANN
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
@ -266,15 +281,15 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval array Un tableau cle->valeur contenant label et value ou False
|
* @retval array Un tableau cle->valeur contenant label et value ou False
|
||||||
**/
|
**/
|
||||||
function supannParseLabeledValue($value) {
|
function supannParseLabeledValue($value) {
|
||||||
if (preg_match('/^\{([^\}]*)\}(.*)$/',$value,$m)) {
|
if (preg_match('/^\{([^\}]*)\}(.*)$/', $value, $m)) {
|
||||||
return array(
|
return array(
|
||||||
'label'=>$m[1],
|
'label' => $m[1],
|
||||||
'value'=>$m[2]
|
'value' => $m[2]
|
||||||
);
|
);
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse une valeur composite SUPANN
|
* Parse une valeur composite SUPANN
|
||||||
|
@ -289,16 +304,16 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval array Un tableau contenant key->value ou false en cas d'erreur
|
* @retval array Un tableau contenant key->value ou false en cas d'erreur
|
||||||
**/
|
**/
|
||||||
function supannParseCompositeValue($val) {
|
function supannParseCompositeValue($val) {
|
||||||
if (preg_match_all('/\[([^=]*)=([^\]]*)\]/',$val,$matches)) {
|
if (preg_match_all('/\[([^=]*)=([^\]]*)\]/',$val,$matches)) {
|
||||||
$parseValue=array();
|
$parseValue = array();
|
||||||
for($i=0;$i<count($matches[0]);$i++) {
|
for($i=0; $i<count($matches[0]); $i++) {
|
||||||
$parseValue[$matches[1][$i]]=$matches[2][$i];
|
$parseValue[$matches[1][$i]] = array$matches[2][$i];
|
||||||
}
|
|
||||||
return $parseValue;
|
|
||||||
}
|
}
|
||||||
return;
|
return $parseValue;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Fonctions relatives aux entités
|
* Fonctions relatives aux entités
|
||||||
|
@ -311,16 +326,16 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval string Le nom de l'entite
|
* @retval string Le nom de l'entite
|
||||||
**/
|
**/
|
||||||
function supanGetEntiteNameById($id) {
|
function supanGetEntiteNameById($id) {
|
||||||
if (LSsession::loadLSobject($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
if (LSsession::loadLSobject($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
||||||
$e = new $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']();
|
$e = new $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']();
|
||||||
$list=$e -> listObjectsName("(supannCodeEntite=$id)",NULL,array('onlyAccessible' => false),$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_FORMAT_SHORTNAME']);
|
$list=$e -> listObjectsName("(supannCodeEntite=$id)",NULL,array('onlyAccessible' => false),$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_FORMAT_SHORTNAME']);
|
||||||
if (count($list)==1) {
|
if (count($list)==1) {
|
||||||
return array_pop($list);
|
return array_pop($list);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return getFData(__("Entity %{id} (unrecognized)"),$id);
|
|
||||||
}
|
}
|
||||||
|
return getFData(__("Entity %{id} (unrecognized)"), $id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valide l'ID d'une entite
|
* Valide l'ID d'une entite
|
||||||
|
@ -329,16 +344,16 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval boolean True si une entité avec cet ID existe, False sinon
|
* @retval boolean True si une entité avec cet ID existe, False sinon
|
||||||
**/
|
**/
|
||||||
function supannValidateEntityId($id) {
|
function supannValidateEntityId($id) {
|
||||||
if (LSsession::loadLSobject($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
if (LSsession::loadLSobject($GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'])) {
|
||||||
$e = new $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']();
|
$e = new $GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE']();
|
||||||
$list=$e -> listObjectsName("(supannCodeEntite=$id)",NULL,array('onlyAccessible' => False));
|
$list=$e -> listObjectsName("(supannCodeEntite=$id)",NULL,array('onlyAccessible' => False));
|
||||||
if (count($list)==1) {
|
if (count($list)==1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cherche des entités répond au pattern de recherche passé en paramètres
|
* Cherche des entités répond au pattern de recherche passé en paramètres
|
||||||
|
@ -351,29 +366,30 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array Tableau du résultat de la recherche mettant en relation
|
* @retval array Tableau du résultat de la recherche mettant en relation
|
||||||
* l'identifiant des entités trouvés avec leur nom d'affichage.
|
* l'identifiant des entités trouvés avec leur nom d'affichage.
|
||||||
**/
|
**/
|
||||||
function supannSearchEntityByPattern($pattern, $max_matches=10) {
|
function supannSearchEntityByPattern($pattern, $max_matches=10) {
|
||||||
$retval=array();
|
$retval = array();
|
||||||
if (LSsession::loadLSclass('LSsearch')) {
|
if (LSsession::loadLSclass('LSsearch')) {
|
||||||
$search=new LSsearch(
|
$search=new LSsearch(
|
||||||
$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'],
|
$GLOBALS['LS_SUPANN_LSOBJECT_ENTITE_TYPE'],
|
||||||
'SUPANN:supannSearchEntityByPattern',
|
'SUPANN:supannSearchEntityByPattern',
|
||||||
array(
|
array(
|
||||||
'pattern' => $pattern,
|
'pattern' => $pattern,
|
||||||
'attributes' => array('supannCodeEntite'),
|
'attributes' => array('supannCodeEntite'),
|
||||||
'sizelimit' => $max_matches,
|
'sizelimit' => $max_matches,
|
||||||
'onlyAccessible' => false
|
'onlyAccessible' => false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$search -> run();
|
$search -> run();
|
||||||
|
|
||||||
foreach($search -> getSearchEntries() as $e) {
|
foreach($search -> getSearchEntries() as $e) {
|
||||||
$code=$e->get('supannCodeEntite');
|
$code = $e->get('supannCodeEntite');
|
||||||
if (is_array($code)) $code=$code[0];
|
if (is_array($code))
|
||||||
$retval[$code]=$e->displayName;
|
$code = $code[0];
|
||||||
}
|
$retval[$code] = $e->displayName;
|
||||||
}
|
}
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Fonctions relatives aux parrains
|
* Fonctions relatives aux parrains
|
||||||
|
@ -386,27 +402,27 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval array Le nom, le type et le DN du parrain (Format: array('dn' => [DN], 'type' => [type], 'name' => [name]))
|
* @retval array Le nom, le type et le DN du parrain (Format: array('dn' => [DN], 'type' => [type], 'name' => [name]))
|
||||||
**/
|
**/
|
||||||
function supanGetParrainInfoByDN($dn) {
|
function supanGetParrainInfoByDN($dn) {
|
||||||
$matched = array(
|
$matched = array(
|
||||||
'dn' => $dn,
|
'dn' => $dn,
|
||||||
'type' => null,
|
'type' => null,
|
||||||
'name' => getFData(__("Godfather %{dn} (unrecognized)"), $dn),
|
'name' => getFData(__("Godfather %{dn} (unrecognized)"), $dn),
|
||||||
|
);
|
||||||
|
foreach($GLOBALS['LS_SUPANN_LSOBJECT_PARRAIN_TYPES'] as $type) {
|
||||||
|
if (!LSsession::loadLSobject($type)) continue;
|
||||||
|
$obj = new $type();
|
||||||
|
$list = $obj -> listObjectsName(
|
||||||
|
NULL, $dn,
|
||||||
|
array('onlyAccessible' => false, 'scope' => 'base'),
|
||||||
);
|
);
|
||||||
foreach($GLOBALS['LS_SUPANN_LSOBJECT_PARRAIN_TYPES'] as $type) {
|
if (count($list)==1) {
|
||||||
if (!LSsession::loadLSobject($type)) continue;
|
$matched['type'] = $type;
|
||||||
$obj = new $type();
|
$matched['name'] = array_pop($list);
|
||||||
$list = $obj -> listObjectsName(
|
break;
|
||||||
NULL, $dn,
|
|
||||||
array('onlyAccessible' => false, 'scope' => 'base'),
|
|
||||||
);
|
|
||||||
if (count($list)==1) {
|
|
||||||
$matched['type'] = $type;
|
|
||||||
$matched['name'] = array_pop($list);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $matched;
|
|
||||||
}
|
}
|
||||||
|
return $matched;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Valide le DN d'un parrain
|
* Valide le DN d'un parrain
|
||||||
|
@ -415,10 +431,10 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval boolean True si un parrain avec ce DN existe, False sinon
|
* @retval boolean True si un parrain avec ce DN existe, False sinon
|
||||||
**/
|
**/
|
||||||
function supannValidateParrainDN($dn) {
|
function supannValidateParrainDN($dn) {
|
||||||
$info = supanGetParrainInfoByDN($dn);
|
$info = supanGetParrainInfoByDN($dn);
|
||||||
return !is_null($info['type']);
|
return !is_null($info['type']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cherche des parrains répondant au pattern de recherche passé en paramètres
|
* Cherche des parrains répondant au pattern de recherche passé en paramètres
|
||||||
|
@ -430,30 +446,30 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array Tableau du résultat de la recherche mettant en relation
|
* @retval array Tableau du résultat de la recherche mettant en relation
|
||||||
* le DN des parrains trouvés avec leur nom d'affichage.
|
* le DN des parrains trouvés avec leur nom d'affichage.
|
||||||
**/
|
**/
|
||||||
function supannSearchParrainByPattern($pattern, $max_matches=10) {
|
function supannSearchParrainByPattern($pattern, $max_matches=10) {
|
||||||
$retval=array();
|
$retval = array();
|
||||||
if (LSsession::loadLSclass('LSsearch')) {
|
if (LSsession::loadLSclass('LSsearch')) {
|
||||||
foreach($GLOBALS['LS_SUPANN_LSOBJECT_PARRAIN_TYPES'] as $type) {
|
foreach($GLOBALS['LS_SUPANN_LSOBJECT_PARRAIN_TYPES'] as $type) {
|
||||||
if (!LSsession::loadLSobject($type)) continue;
|
if (!LSsession::loadLSobject($type)) continue;
|
||||||
|
|
||||||
$search=new LSsearch(
|
$search=new LSsearch(
|
||||||
$type,
|
$type,
|
||||||
'SUPANN:supannSearchParrainByPattern',
|
'SUPANN:supannSearchParrainByPattern',
|
||||||
array(
|
array(
|
||||||
'pattern' => $pattern,
|
'pattern' => $pattern,
|
||||||
'sizelimit' => $max_matches,
|
'sizelimit' => $max_matches,
|
||||||
'onlyAccessible' => false
|
'onlyAccessible' => false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$search -> run();
|
$search -> run();
|
||||||
|
|
||||||
foreach($search -> getSearchEntries() as $obj) {
|
foreach($search -> getSearchEntries() as $obj) {
|
||||||
$retval[$obj->dn] = $obj->displayName;
|
$retval[$obj->dn] = $obj->displayName;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -469,38 +485,38 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval booleab True si valide, False sinon
|
* @retval booleab True si valide, False sinon
|
||||||
**/
|
**/
|
||||||
function supannValidateNomenclatureValue($table, $label, $value) {
|
function supannValidateNomenclatureValue($table, $label, $value) {
|
||||||
if (!supannLoadNomenclature($table))
|
if (!supannLoadNomenclature($table))
|
||||||
return false;
|
return false;
|
||||||
if ($label) {
|
if ($label) {
|
||||||
$label = strtoupper($label);
|
$label = strtoupper($label);
|
||||||
if (
|
if (
|
||||||
isset($GLOBALS['supannNomenclatures'][$label]) &&
|
isset($GLOBALS['supannNomenclatures'][$label]) &&
|
||||||
isset($GLOBALS['supannNomenclatures'][$label][$table]) &&
|
isset($GLOBALS['supannNomenclatures'][$label][$table]) &&
|
||||||
isset($GLOBALS['supannNomenclatures'][$label][$table][$value])
|
isset($GLOBALS['supannNomenclatures'][$label][$table][$value])
|
||||||
) {
|
) {
|
||||||
return array(
|
return array(
|
||||||
'table' => $table,
|
'table' => $table,
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
'translated' => $GLOBALS['supannNomenclatures'][$label][$table][$value],
|
'translated' => $GLOBALS['supannNomenclatures'][$label][$table][$value],
|
||||||
);
|
);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) {
|
|
||||||
if (!array_key_exists($table, $tables) || !array_key_exists($value, $tables[$table]))
|
|
||||||
continue;
|
|
||||||
return array(
|
|
||||||
'table' => $table,
|
|
||||||
'label' => $label,
|
|
||||||
'value' => $value,
|
|
||||||
'translated' => $tables[$table][$value],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
foreach($GLOBALS['supannNomenclatures'] as $label => $tables) {
|
||||||
|
if (!array_key_exists($table, $tables) || !array_key_exists($value, $tables[$table]))
|
||||||
|
continue;
|
||||||
|
return array(
|
||||||
|
'table' => $table,
|
||||||
|
'label' => $label,
|
||||||
|
'value' => $value,
|
||||||
|
'translated' => $tables[$table][$value],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne le label d'une valeur en fonction de la table de nomenclature
|
* Retourne le label d'une valeur en fonction de la table de nomenclature
|
||||||
|
@ -513,12 +529,12 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array Le label de la valeur. En cas de valeur nor-reconnue, retourne
|
* @retval array Le label de la valeur. En cas de valeur nor-reconnue, retourne
|
||||||
* la valeur en spécifiant qu'elle n'est pas reconnue.
|
* la valeur en spécifiant qu'elle n'est pas reconnue.
|
||||||
**/
|
**/
|
||||||
function supannGetNomenclatureLabel($table, $label, $value) {
|
function supannGetNomenclatureLabel($table, $label, $value) {
|
||||||
$translated = supannValidateNomenclatureValue($table, $label, $value);
|
$translated = supannValidateNomenclatureValue($table, $label, $value);
|
||||||
if ($translated)
|
if ($translated)
|
||||||
return $translated['translated'];
|
return $translated['translated'];
|
||||||
return getFData(__("%{value} (unrecognized value)"), $value);
|
return getFData(__("%{value} (unrecognized value)"), $value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les valeurs possibles d'une table de nomenclature pour chaque fournisseur
|
* Retourne les valeurs possibles d'une table de nomenclature pour chaque fournisseur
|
||||||
|
@ -528,17 +544,17 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array Tableau contenant pour chaque fournisseur, les valeurs possibles de
|
* @retval array Tableau contenant pour chaque fournisseur, les valeurs possibles de
|
||||||
* la table de nomenclature
|
* la table de nomenclature
|
||||||
**/
|
**/
|
||||||
function supannGetNomenclatureTable($table) {
|
function supannGetNomenclatureTable($table) {
|
||||||
$retval = array();
|
$retval = array();
|
||||||
if (!supannLoadNomenclature($table))
|
if (!supannLoadNomenclature($table))
|
||||||
return $retval;
|
return $retval;
|
||||||
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
||||||
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
||||||
$retval[$provider] = $GLOBALS['supannNomenclatures'][$provider][$table];
|
$retval[$provider] = $GLOBALS['supannNomenclatures'][$provider][$table];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les valeurs possibles d'une table de nomenclature
|
* Retourne les valeurs possibles d'une table de nomenclature
|
||||||
|
@ -551,21 +567,21 @@ LSerror :: defineError('SUPANN_04',
|
||||||
* @retval array Tableau contenant les valeurs possibles de la table
|
* @retval array Tableau contenant les valeurs possibles de la table
|
||||||
* de nomenclature
|
* de nomenclature
|
||||||
**/
|
**/
|
||||||
function supannGetNomenclaturePossibleValues($table, $add_provider_label=True) {
|
function supannGetNomenclaturePossibleValues($table, $add_provider_label=True) {
|
||||||
$retval = array();
|
$retval = array();
|
||||||
if (!supannLoadNomenclature($table))
|
if (!supannLoadNomenclature($table))
|
||||||
return $retval;
|
return $retval;
|
||||||
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
foreach(array_keys($GLOBALS['supannNomenclatures']) as $provider) {
|
||||||
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
if (isset($GLOBALS['supannNomenclatures'][$provider][$table])) {
|
||||||
foreach($GLOBALS['supannNomenclatures'][$provider][$table] as $value => $label) {
|
foreach($GLOBALS['supannNomenclatures'][$provider][$table] as $value => $label) {
|
||||||
if ($add_provider_label)
|
if ($add_provider_label)
|
||||||
$value = "{$provider}$value";
|
$value = "{$provider}$value";
|
||||||
$retval[$value] = __($label);
|
$retval[$value] = __($label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return $retval;
|
|
||||||
}
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cherche des valeurs d'une nomenclature répondant au pattern de recherche passé en paramètres
|
* Cherche des valeurs d'une nomenclature répondant au pattern de recherche passé en paramètres
|
||||||
|
@ -576,26 +592,26 @@ LSerror :: defineError('SUPANN_04',
|
||||||
*
|
*
|
||||||
* @retval array Tableau du résultat de la recherche
|
* @retval array Tableau du résultat de la recherche
|
||||||
**/
|
**/
|
||||||
function supannSearchNomenclatureValueByPattern($table, $pattern, $max_matches=10) {
|
function supannSearchNomenclatureValueByPattern($table, $pattern, $max_matches=10) {
|
||||||
$retval=array();
|
$retval = array();
|
||||||
$pattern = withoutAccents(strtolower($pattern));
|
$pattern = withoutAccents(strtolower($pattern));
|
||||||
foreach(supannGetNomenclatureTable($table) as $label => $values) {
|
foreach(supannGetNomenclatureTable($table) as $label => $values) {
|
||||||
foreach($values as $value => $txt) {
|
foreach($values as $value => $txt) {
|
||||||
if (strpos(withoutAccents(strtolower($txt)), $pattern) === false)
|
if (strpos(withoutAccents(strtolower($txt)), $pattern) === false)
|
||||||
continue;
|
continue;
|
||||||
$retval[] = array(
|
$retval[] = array(
|
||||||
'label' => $label,
|
'label' => $label,
|
||||||
'value' => '{'.$label.'}'.$value,
|
'value' => '{'.$label.'}'.$value,
|
||||||
'translated' => $txt
|
'translated' => $txt
|
||||||
);
|
);
|
||||||
if (count($retval) >= $max_matches)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (count($retval) >= $max_matches)
|
if (count($retval) >= $max_matches)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return $retval;
|
if (count($retval) >= $max_matches)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les valeurs possibles de l'attribut supannCivilite.
|
* Retourne les valeurs possibles de l'attribut supannCivilite.
|
||||||
|
@ -653,14 +669,14 @@ function supannGetAffiliationPossibleValues($options=null, $name=null, $ldapObje
|
||||||
global $_supannCheckEduPersonAffiliation_checked;
|
global $_supannCheckEduPersonAffiliation_checked;
|
||||||
$_supannCheckEduPersonAffiliation_checked = false;
|
$_supannCheckEduPersonAffiliation_checked = false;
|
||||||
function supannCheckEduPersonAffiliation(&$ldapObject) {
|
function supannCheckEduPersonAffiliation(&$ldapObject) {
|
||||||
global $_supannCheckEduPersonAffiliation_checked;
|
global $_supannCheckEduPersonAffiliation_checked;
|
||||||
$values = $ldapObject->getValue('eduPersonAffiliation');
|
$values = $ldapObject->getValue('eduPersonAffiliation');
|
||||||
|
|
||||||
if (!$_supannCheckEduPersonAffiliation_checked && in_array('affiliate', $values) && in_array('member', $values)) {
|
if (!$_supannCheckEduPersonAffiliation_checked && in_array('affiliate', $values) && in_array('member', $values)) {
|
||||||
$_supannCheckEduPersonAffiliation_checked = true;
|
$_supannCheckEduPersonAffiliation_checked = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -680,11 +696,11 @@ function supannCheckEduPersonAffiliation(&$ldapObject) {
|
||||||
* @retval boolean True si la valeur est valide, False sinon
|
* @retval boolean True si la valeur est valide, False sinon
|
||||||
**/
|
**/
|
||||||
function supannCheckEduPersonPrimaryAffiliation(&$ldapObject) {
|
function supannCheckEduPersonPrimaryAffiliation(&$ldapObject) {
|
||||||
$primary = $ldapObject->getValue('eduPersonPrimaryAffiliation');
|
$primary = $ldapObject->getValue('eduPersonPrimaryAffiliation');
|
||||||
$affiliations = $ldapObject->getValue('eduPersonAffiliation');
|
$affiliations = $ldapObject->getValue('eduPersonAffiliation');
|
||||||
if (!array_intersect($primary, $affiliations))
|
if (!array_intersect($primary, $affiliations))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -896,7 +912,7 @@ function supannLoadNomenclature($table) {
|
||||||
* si il y a un problème durant la génération
|
* si il y a un problème durant la génération
|
||||||
*/
|
*/
|
||||||
function generate_eduPersonPrincipalName($ldapObject) {
|
function generate_eduPersonPrincipalName($ldapObject) {
|
||||||
return $ldapObject -> getFData($GLOBALS['LS_SUPANN_EPPN_FORMAT']);
|
return $ldapObject -> getFData($GLOBALS['LS_SUPANN_EPPN_FORMAT']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -124,9 +124,9 @@ class LSattr_html extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -111,28 +111,28 @@ class LSattr_html_select_list extends LSattr_html{
|
||||||
$attrInfos=static :: getLSattributePossibleValues($val_label, $options, $name, $ldapObject);
|
$attrInfos=static :: getLSattributePossibleValues($val_label, $options, $name, $ldapObject);
|
||||||
$retInfos=static :: _array_merge($retInfos,$attrInfos);
|
$retInfos=static :: _array_merge($retInfos,$attrInfos);
|
||||||
}
|
}
|
||||||
elseif (is_array($val_label)) {
|
elseif (is_array($val_label)) {
|
||||||
if (!isset($val_label['possible_values']) || !is_array($val_label['possible_values']) || !isset($val_label['label']))
|
if (!isset($val_label['possible_values']) || !is_array($val_label['possible_values']) || !isset($val_label['label']))
|
||||||
continue;
|
continue;
|
||||||
$subRetInfos=array();
|
$subRetInfos=array();
|
||||||
foreach($val_label['possible_values'] as $vk => $vl) {
|
foreach($val_label['possible_values'] as $vk => $vl) {
|
||||||
if ($vk==='OTHER_OBJECT') {
|
if ($vk==='OTHER_OBJECT') {
|
||||||
$objInfos=static :: getLSobjectPossibleValues($vl,$options,$name);
|
$objInfos=static :: getLSobjectPossibleValues($vl,$options,$name);
|
||||||
$subRetInfos=static :: _array_merge($subRetInfos,$objInfos);
|
$subRetInfos=static :: _array_merge($subRetInfos,$objInfos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$vk = $ldapObject->getFData($vk);
|
$vk = $ldapObject->getFData($vk);
|
||||||
$vl = $ldapObject->getFData(($translate_labels?__($vl):$vl));
|
$vl = $ldapObject->getFData(($translate_labels?__($vl):$vl));
|
||||||
$subRetInfos[$vk] = $vl;
|
$subRetInfos[$vk] = $vl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static :: _sort($subRetInfos,$options);
|
static :: _sort($subRetInfos,$options);
|
||||||
$subRetLabel = $ldapObject->getFData(($translate_labels?__($val_label['label']):$val_label['label']));
|
$subRetLabel = $ldapObject->getFData(($translate_labels?__($val_label['label']):$val_label['label']));
|
||||||
$retInfos[] = array (
|
$retInfos[] = array (
|
||||||
'label' => $subRetLabel,
|
'label' => $subRetLabel,
|
||||||
'possible_values' => $subRetInfos
|
'possible_values' => $subRetInfos
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$val_key = $ldapObject->getFData($val_key);
|
$val_key = $ldapObject->getFData($val_key);
|
||||||
$val_label = $ldapObject->getFData(($translate_labels?__($val_label):$val_label));
|
$val_label = $ldapObject->getFData(($translate_labels?__($val_label):$val_label));
|
||||||
|
|
|
@ -103,9 +103,9 @@ class LSattr_ldap extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -735,9 +735,9 @@ class LSattribute extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -98,9 +98,9 @@ class LSauth extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -31,64 +31,64 @@ class LSauthMethod_CAS extends LSauthMethod {
|
||||||
private $configured = false;
|
private $configured = false;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
LSauth :: disableLoginForm();
|
LSauth :: disableLoginForm();
|
||||||
|
|
||||||
if (!parent :: __construct())
|
if (!parent :: __construct())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (LSsession :: includeFile(PHP_CAS_PATH, true)) {
|
if (LSsession :: includeFile(PHP_CAS_PATH, true)) {
|
||||||
if (defined('PHP_CAS_DEBUG_FILE')) {
|
if (defined('PHP_CAS_DEBUG_FILE')) {
|
||||||
self :: log_debug('LSauthMethod_CAS : enable debug file '.PHP_CAS_DEBUG_FILE);
|
self :: log_debug('LSauthMethod_CAS : enable debug file '.PHP_CAS_DEBUG_FILE);
|
||||||
phpCAS::setDebug(PHP_CAS_DEBUG_FILE);
|
phpCAS::setDebug(PHP_CAS_DEBUG_FILE);
|
||||||
}
|
}
|
||||||
self :: log_debug('LSauthMethod_CAS : initialise phpCAS :: client with CAS server URL https://'.LSAUTH_CAS_SERVER_HOSTNAME.':'.LSAUTH_CAS_SERVER_PORT.(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: ''));
|
self :: log_debug('LSauthMethod_CAS : initialise phpCAS :: client with CAS server URL https://'.LSAUTH_CAS_SERVER_HOSTNAME.':'.LSAUTH_CAS_SERVER_PORT.(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: ''));
|
||||||
phpCAS::client (
|
phpCAS::client (
|
||||||
constant(LSAUTH_CAS_VERSION),
|
constant(LSAUTH_CAS_VERSION),
|
||||||
LSAUTH_CAS_SERVER_HOSTNAME,
|
LSAUTH_CAS_SERVER_HOSTNAME,
|
||||||
LSAUTH_CAS_SERVER_PORT,
|
LSAUTH_CAS_SERVER_PORT,
|
||||||
(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: ''),
|
(defined('LSAUTH_CAS_SERVER_URI')?LSAUTH_CAS_SERVER_URI: ''),
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// Configure CAS server SSL validation
|
// Configure CAS server SSL validation
|
||||||
$cas_server_ssl_validation_configured = false;
|
$cas_server_ssl_validation_configured = false;
|
||||||
if (defined('LSAUTH_CAS_SERVER_NO_SSL_VALIDATION') && LSAUTH_CAS_SERVER_NO_SSL_VALIDATION) {
|
if (defined('LSAUTH_CAS_SERVER_NO_SSL_VALIDATION') && LSAUTH_CAS_SERVER_NO_SSL_VALIDATION) {
|
||||||
self :: log_debug('LSauthMethod_CAS : disable CAS server SSL validation => /!\ NOT RECOMMENDED IN PRODUCTION ENVIRONMENT /!\\');
|
self :: log_debug('LSauthMethod_CAS : disable CAS server SSL validation => /!\ NOT RECOMMENDED IN PRODUCTION ENVIRONMENT /!\\');
|
||||||
phpCAS::setNoCasServerValidation();
|
phpCAS::setNoCasServerValidation();
|
||||||
$cas_server_ssl_validation_configured = true;
|
$cas_server_ssl_validation_configured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('LSAUTH_CAS_SERVER_SSL_CACERT')) {
|
if (defined('LSAUTH_CAS_SERVER_SSL_CACERT')) {
|
||||||
self :: log_debug('LSauthMethod_CAS : validate CAS server SSL certificate using '.LSAUTH_CAS_SERVER_SSL_CACERT.' CA certificate file.');
|
self :: log_debug('LSauthMethod_CAS : validate CAS server SSL certificate using '.LSAUTH_CAS_SERVER_SSL_CACERT.' CA certificate file.');
|
||||||
phpCAS::setCasServerCACert(LSAUTH_CAS_SERVER_SSL_CACERT);
|
phpCAS::setCasServerCACert(LSAUTH_CAS_SERVER_SSL_CACERT);
|
||||||
$cas_server_ssl_validation_configured = true;
|
$cas_server_ssl_validation_configured = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check CAS server SSL validation is now configured
|
// Check CAS server SSL validation is now configured
|
||||||
if (!$cas_server_ssl_validation_configured) {
|
if (!$cas_server_ssl_validation_configured) {
|
||||||
LSerror :: addErrorCode('LSauthMethod_CAS_02');
|
LSerror :: addErrorCode('LSauthMethod_CAS_02');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined('LSAUTH_CAS_CURL_SSLVERION')) {
|
if (defined('LSAUTH_CAS_CURL_SSLVERION')) {
|
||||||
self :: log_debug('LSauthMethod_CAS : use specific SSL version '.LSAUTH_CAS_CURL_SSLVERION);
|
self :: log_debug('LSauthMethod_CAS : use specific SSL version '.LSAUTH_CAS_CURL_SSLVERION);
|
||||||
phpCAS::setExtraCurlOption(CURLOPT_SSLVERSION,LSAUTH_CAS_CURL_SSLVERION);
|
phpCAS::setExtraCurlOption(CURLOPT_SSLVERSION,LSAUTH_CAS_CURL_SSLVERION);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LSAUTH_CAS_DISABLE_LOGOUT) {
|
if (LSAUTH_CAS_DISABLE_LOGOUT) {
|
||||||
self :: log_debug('LSauthMethod_CAS : disable logout');
|
self :: log_debug('LSauthMethod_CAS : disable logout');
|
||||||
LSauth :: disableLogoutBtn();
|
LSauth :: disableLogoutBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set configured flag
|
// Set configured flag
|
||||||
$this -> configured = true;
|
$this -> configured = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSerror :: addErrorCode('LSauthMethod_CAS_01');
|
LSerror :: addErrorCode('LSauthMethod_CAS_01');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Auth Data
|
* Check Auth Data
|
||||||
|
@ -98,38 +98,38 @@ class LSauthMethod_CAS extends LSauthMethod {
|
||||||
* @retval Array|false Array of authentication data or False
|
* @retval Array|false Array of authentication data or False
|
||||||
**/
|
**/
|
||||||
public function getAuthData() {
|
public function getAuthData() {
|
||||||
if ($this -> configured) {
|
if ($this -> configured) {
|
||||||
// Launch Auth
|
// Launch Auth
|
||||||
self :: log_debug('LSauthMethod_CAS : force authentication');
|
self :: log_debug('LSauthMethod_CAS : force authentication');
|
||||||
phpCAS::forceAuthentication();
|
phpCAS::forceAuthentication();
|
||||||
|
|
||||||
$this -> authData = array(
|
$this -> authData = array(
|
||||||
'username' => phpCAS::getUser()
|
'username' => phpCAS::getUser()
|
||||||
);
|
);
|
||||||
self :: log_debug('LSauthMethod_CAS : auth data : '.varDump($this -> authData));
|
self :: log_debug('LSauthMethod_CAS : auth data : '.varDump($this -> authData));
|
||||||
return $this -> authData;
|
return $this -> authData;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logout
|
* Logout
|
||||||
*
|
*
|
||||||
* @retval boolean True on success or False
|
* @retval boolean True on success or False
|
||||||
**/
|
**/
|
||||||
public function logout() {
|
public function logout() {
|
||||||
if($this -> configured) {
|
if($this -> configured) {
|
||||||
if (LSauth :: displayLogoutBtn()) {
|
if (LSauth :: displayLogoutBtn()) {
|
||||||
phpCAS :: forceAuthentication();
|
phpCAS :: forceAuthentication();
|
||||||
self :: log_debug("LSauthMethod_CAS :: logout() : trigger CAS logout");
|
self :: log_debug("LSauthMethod_CAS :: logout() : trigger CAS logout");
|
||||||
phpCAS :: logout();
|
phpCAS :: logout();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
self :: log_warning("LSauthMethod_CAS :: logout() : logout is disabled");
|
self :: log_warning("LSauthMethod_CAS :: logout() : logout is disabled");
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,23 +31,23 @@ class LSauthMethod_anonymous extends LSauthMethod {
|
||||||
protected static $api_mode_supported = true;
|
protected static $api_mode_supported = true;
|
||||||
|
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
LSauth :: disableLoginForm();
|
LSauth :: disableLoginForm();
|
||||||
LSauth :: disableSelfAccess();
|
LSauth :: disableSelfAccess();
|
||||||
|
|
||||||
if (!parent :: __construct())
|
if (!parent :: __construct())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')) || (constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT') === True)) {
|
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT')) || (constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT') === True)) {
|
||||||
self :: log_debug('logout : '.constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT'));
|
self :: log_debug('logout : '.constant('LSAUTHMETHOD_ANONYMOUS_DISABLE_LOGOUT'));
|
||||||
LSauth :: disableLogoutBtn();
|
LSauth :: disableLogoutBtn();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_USER')) || (constant('LSAUTHMETHOD_ANONYMOUS_USER') == "")) {
|
if ( (!defined('LSAUTHMETHOD_ANONYMOUS_USER')) || (constant('LSAUTHMETHOD_ANONYMOUS_USER') == "")) {
|
||||||
LSerror :: addErrorCode('LSauthMethod_anonymous_01');
|
LSerror :: addErrorCode('LSauthMethod_anonymous_01');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check Auth Data
|
* Check Auth Data
|
||||||
|
@ -57,9 +57,9 @@ class LSauthMethod_anonymous extends LSauthMethod {
|
||||||
* @retval Array|false Array of authentication data or False
|
* @retval Array|false Array of authentication data or False
|
||||||
**/
|
**/
|
||||||
public function getAuthData() {
|
public function getAuthData() {
|
||||||
$this -> authData = array(
|
$this -> authData = array(
|
||||||
'username' => LSAUTHMETHOD_ANONYMOUS_USER
|
'username' => LSAUTHMETHOD_ANONYMOUS_USER
|
||||||
);
|
);
|
||||||
return $this -> authData;
|
return $this -> authData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,5 +69,5 @@ class LSauthMethod_anonymous extends LSauthMethod {
|
||||||
* Error Codes
|
* Error Codes
|
||||||
*/
|
*/
|
||||||
LSerror :: defineError('LSauthMethod_anonymous_01',
|
LSerror :: defineError('LSauthMethod_anonymous_01',
|
||||||
___("LSauthMethod_anonymous : You must define the LSAUTHMETHOD_ANONYMOUS_USER contant in the configuration file.")
|
___("LSauthMethod_anonymous : You must define the LSAUTHMETHOD_ANONYMOUS_USER contant in the configuration file.")
|
||||||
);
|
);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class LSauthMethod_basic extends LSauthMethod {
|
||||||
* @retval LSldapObject|false The LSldapObject of the user authificated or false
|
* @retval LSldapObject|false The LSldapObject of the user authificated or false
|
||||||
*/
|
*/
|
||||||
public function authenticate() {
|
public function authenticate() {
|
||||||
$authobjects = LSauth :: username2LSobjects($this -> authData['username']);
|
$authobjects = LSauth :: username2LSobjects($this -> authData['username']);
|
||||||
if (!$authobjects) {
|
if (!$authobjects) {
|
||||||
LSerror :: addErrorCode('LSauth_01');
|
LSerror :: addErrorCode('LSauth_01');
|
||||||
self :: log_debug('No user found with username="'.$this -> authData['username'].'" => Invalid username');
|
self :: log_debug('No user found with username="'.$this -> authData['username'].'" => Invalid username');
|
||||||
|
@ -64,7 +64,7 @@ class LSauthMethod_basic extends LSauthMethod {
|
||||||
$matched[] = $dn;
|
$matched[] = $dn;
|
||||||
else
|
else
|
||||||
self :: log_trace("Invalid password provided for '$dn'");
|
self :: log_trace("Invalid password provided for '$dn'");
|
||||||
if (!$matched) {
|
if (!$matched) {
|
||||||
LSerror :: addErrorCode('LSauth_01');
|
LSerror :: addErrorCode('LSauth_01');
|
||||||
self :: log_debug('Invalid password provided');
|
self :: log_debug('Invalid password provided');
|
||||||
return false;
|
return false;
|
||||||
|
@ -74,9 +74,9 @@ class LSauthMethod_basic extends LSauthMethod {
|
||||||
LSerror :: addErrorCode('LSauth_02');
|
LSerror :: addErrorCode('LSauth_02');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Authentication succeeded
|
// Authentication succeeded
|
||||||
self :: log_debug('Authentication succeeded for username "'.$this -> authData['username'].'" ("'.$matched[0].'")');
|
self :: log_debug('Authentication succeeded for username "'.$this -> authData['username'].'" ("'.$matched[0].'")');
|
||||||
return $authobjects[$matched[0]];
|
return $authobjects[$matched[0]];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,9 +85,9 @@ class LSform extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -326,9 +326,9 @@ class LSformElement extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a parameter (or default value)
|
* Return a parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The parameter value or default value if not set
|
* @retval mixed The parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -357,8 +357,8 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
|
||||||
/**
|
/**
|
||||||
* Check one component's values
|
* Check one component's values
|
||||||
*
|
*
|
||||||
* @param[] $c The component name
|
* @param[] $c The component name
|
||||||
* @param[] $value The values of the component
|
* @param[] $value The values of the component
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
|
@ -375,8 +375,8 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
|
||||||
/**
|
/**
|
||||||
* Check one component's value
|
* Check one component's value
|
||||||
*
|
*
|
||||||
* @param[] $c The component name
|
* @param[] $c The component name
|
||||||
* @param[] $value The value to check
|
* @param[] $value The value to check
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
|
@ -431,10 +431,10 @@ class LSformElement_jsonCompositeAttribute extends LSformElement {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter for a specific component (or default value)
|
* Return a configuration parameter for a specific component (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $component The component name
|
* @param[] $component The component name
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -53,13 +53,13 @@ class LSformElement_postaladdress extends LSformElement_textarea {
|
||||||
else {
|
else {
|
||||||
LSerror::addErrorCode('LSformElement_postaladdress_01', $map_url_pattern_generate_function);
|
LSerror::addErrorCode('LSformElement_postaladdress_01', $map_url_pattern_generate_function);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($map_url_pattern_format) {
|
elseif ($map_url_pattern_format) {
|
||||||
$pattern = $this -> attr_html -> attribute -> ldapObject -> getFData($map_url_pattern_format);
|
$pattern = $this -> attr_html -> attribute -> ldapObject -> getFData($map_url_pattern_format);
|
||||||
$pattern = str_replace("\n"," ",$pattern);
|
$pattern = str_replace("\n"," ",$pattern);
|
||||||
$pattern = urlencode($pattern);
|
$pattern = urlencode($pattern);
|
||||||
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', $pattern);
|
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', $pattern);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', LSformElement_postaladdress__generate_pattern($this));
|
$this -> attr_html -> attribute -> ldapObject -> registerOtherValue('pattern', LSformElement_postaladdress__generate_pattern($this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabeledValue {
|
class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannLabelNomenclatureTable = 'adressePostalePriveeLabel';
|
var $supannLabelNomenclatureTable = 'adressePostalePriveeLabel';
|
||||||
var $valueFieldType = 'textarea';
|
var $valueFieldType = 'textarea';
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,12 +45,12 @@ class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabel
|
||||||
*
|
*
|
||||||
* @retval array Un tableau cle->valeur contenant value, translated et label
|
* @retval array Un tableau cle->valeur contenant value, translated et label
|
||||||
**/
|
**/
|
||||||
public function parseValue($value) {
|
public function parseValue($value) {
|
||||||
$retval = parent :: parseValue($value);
|
$retval = parent :: parseValue($value);
|
||||||
$retval['value'] = str_replace('$', "\n", $retval['value']);
|
$retval['value'] = str_replace('$', "\n", $retval['value']);
|
||||||
$retval['translated'] = str_replace('$', "\n", $retval['translated']);
|
$retval['translated'] = str_replace('$', "\n", $retval['translated']);
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,15 +62,15 @@ class LSformElement_supannAdressePostalePrivee extends LSformElement_supannLabel
|
||||||
* @see LSformElement::getPostData()
|
* @see LSformElement::getPostData()
|
||||||
* @retval boolean true si la valeur est présente en POST, false sinon
|
* @retval boolean true si la valeur est présente en POST, false sinon
|
||||||
*/
|
*/
|
||||||
public function getPostData(&$return, $onlyIfPresent=false) {
|
public function getPostData(&$return, $onlyIfPresent=false) {
|
||||||
$retval = parent :: getPostData($return, $onlyIfPresent);
|
$retval = parent :: getPostData($return, $onlyIfPresent);
|
||||||
if (isset($return[$this -> name])) {
|
if (isset($return[$this -> name])) {
|
||||||
$fixed_values = array();
|
$fixed_values = array();
|
||||||
foreach($return[$this -> name] as $value)
|
foreach($return[$this -> name] as $value)
|
||||||
$fixed_values[] = str_replace("\n", "$", $value);
|
$fixed_values[] = str_replace("\n", "$", $value);
|
||||||
$return[$this -> name] = $fixed_values;
|
$return[$this -> name] = $fixed_values;
|
||||||
}
|
}
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannCodePopulation extends LSformElement_supannLabeledValue {
|
class LSformElement_supannCodePopulation extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannNomenclatureTable = 'codePopulation';
|
var $supannNomenclatureTable = 'codePopulation';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannEmpCorps extends LSformElement_supannLabeledValue {
|
class LSformElement_supannEmpCorps extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannNomenclatureTable = 'empCorps';
|
var $supannNomenclatureTable = 'empCorps';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,56 +35,56 @@ LSsession :: loadLSaddon('supann');
|
||||||
class LSformElement_supannEmpProfil extends LSformElement_supannCompositeAttribute {
|
class LSformElement_supannEmpProfil extends LSformElement_supannCompositeAttribute {
|
||||||
|
|
||||||
public function __construct(&$form, $name, $label, $params, &$attr_html){
|
public function __construct(&$form, $name, $label, $params, &$attr_html){
|
||||||
$this -> components = array (
|
$this -> components = array (
|
||||||
'etab' => array (
|
'etab' => array (
|
||||||
'label' => _('Establishment'),
|
'label' => _('Establishment'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'codeEtablissement',
|
'table' => 'codeEtablissement',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
),
|
),
|
||||||
'affil' => array (
|
'affil' => array (
|
||||||
'label' => _('eduPerson profil'),
|
'label' => _('eduPerson profil'),
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
'possible_values' => array('' => '-'),
|
'possible_values' => array('' => '-'),
|
||||||
'get_possible_values' => 'supannGetAffiliationPossibleValues',
|
'get_possible_values' => 'supannGetAffiliationPossibleValues',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'corps' => array (
|
'corps' => array (
|
||||||
'label' => _('Body of membership'),
|
'label' => _('Body of membership'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'empCorps',
|
'table' => 'empCorps',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'typeaffect' => array (
|
'typeaffect' => array (
|
||||||
'label' => _('Entity type'),
|
'label' => _('Entity type'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'typeEntite',
|
'table' => 'typeEntite',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'affect' => array (
|
'affect' => array (
|
||||||
'label' => _('Assignment entity'),
|
'label' => _('Assignment entity'),
|
||||||
'type' => 'codeEntite',
|
'type' => 'codeEntite',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'activite' => array (
|
'activite' => array (
|
||||||
'label' => _('Activity'),
|
'label' => _('Activity'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'supannActivite',
|
'table' => 'supannActivite',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'population' => array (
|
'population' => array (
|
||||||
'label' => _('Population'),
|
'label' => _('Population'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'codePopulation',
|
'table' => 'codePopulation',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
'datefin' => array (
|
'datefin' => array (
|
||||||
'label' => _('End date'),
|
'label' => _('End date'),
|
||||||
'type' => 'date',
|
'type' => 'date',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannMailPrive extends LSformElement_supannLabeledValue {
|
class LSformElement_supannMailPrive extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannLabelNomenclatureTable = 'mailPriveLabel';
|
var $supannLabelNomenclatureTable = 'mailPriveLabel';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,26 +35,26 @@ LSsession :: loadLSaddon('supann');
|
||||||
class LSformElement_supannRoleEntite extends LSformElement_supannCompositeAttribute {
|
class LSformElement_supannRoleEntite extends LSformElement_supannCompositeAttribute {
|
||||||
|
|
||||||
public function __construct(&$form, $name, $label, $params, &$attr_html){
|
public function __construct(&$form, $name, $label, $params, &$attr_html){
|
||||||
$this -> components = array (
|
$this -> components = array (
|
||||||
'role' => array (
|
'role' => array (
|
||||||
'label' => _('Role'),
|
'label' => _('Role'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'roleGenerique',
|
'table' => 'roleGenerique',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
),
|
),
|
||||||
'type' => array (
|
'type' => array (
|
||||||
'label' => _('Entity type'),
|
'label' => _('Entity type'),
|
||||||
'type' => 'table',
|
'type' => 'table',
|
||||||
'table' => 'typeEntite',
|
'table' => 'typeEntite',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
),
|
),
|
||||||
'code' => array (
|
'code' => array (
|
||||||
'label' => _('Entity'),
|
'label' => _('Entity'),
|
||||||
'type' => 'codeEntite',
|
'type' => 'codeEntite',
|
||||||
'required' => false
|
'required' => false
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
return parent :: __construct($form, $name, $label, $params, $attr_html);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannTelephonePrive extends LSformElement_supannLabeledValue {
|
class LSformElement_supannTelephonePrive extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannLabelNomenclatureTable = 'telephonePriveLabel';
|
var $supannLabelNomenclatureTable = 'telephonePriveLabel';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,6 @@ LSsession :: loadLSaddon('supann');
|
||||||
|
|
||||||
class LSformElement_supannTypeEntite extends LSformElement_supannLabeledValue {
|
class LSformElement_supannTypeEntite extends LSformElement_supannLabeledValue {
|
||||||
|
|
||||||
var $supannNomenclatureTable = 'typeEntite';
|
var $supannNomenclatureTable = 'typeEntite';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,11 +60,11 @@ class LSformRule_differentPassword extends LSformRule {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check attribute use LSldap_attr :: password type
|
// Check attribute use LSldap_attr :: password type
|
||||||
if (!$formElement -> attr_html -> attribute -> ldapObject -> attrs[$attr] -> ldap instanceof LSattr_ldap_password) {
|
if (!$formElement -> attr_html -> attribute -> ldapObject -> attrs[$attr] -> ldap instanceof LSattr_ldap_password) {
|
||||||
LSerror :: addErrorCode('LSformRule_differentPassword_05', $attr);
|
LSerror :: addErrorCode('LSformRule_differentPassword_05', $attr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($formElement -> attr_html -> attribute -> ldapObject -> attrs[$attr] -> ldap -> verify($value, $formElement -> form -> getValue($attr))) {
|
if ($formElement -> attr_html -> attribute -> ldapObject -> attrs[$attr] -> ldap -> verify($value, $formElement -> form -> getValue($attr))) {
|
||||||
LSdebug($formElement -> name . " : Password matched with attribute $attr");
|
LSdebug($formElement -> name . " : Password matched with attribute $attr");
|
||||||
|
|
|
@ -70,11 +70,11 @@ class LSformRule_password extends LSformRule {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (preg_match($r, $value)) {
|
if (preg_match($r, $value)) {
|
||||||
self :: log_debug("password match with regex '$r'");
|
self :: log_debug("password match with regex '$r'");
|
||||||
$valid++;
|
$valid++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
self :: log_debug("password does not match with regex '$r'");
|
self :: log_debug("password does not match with regex '$r'");
|
||||||
}
|
}
|
||||||
if ($valid < $minValidRegex) {
|
if ($valid < $minValidRegex) {
|
||||||
self :: log_warning("password match with only $valid regex on ".count($regex).". $minValidRegex valid regex is required");
|
self :: log_warning("password match with only $valid regex on ".count($regex).". $minValidRegex valid regex is required");
|
||||||
|
|
|
@ -68,9 +68,9 @@ class LSioFormat extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -160,9 +160,9 @@ class LSioFormatDriver extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a option parameter (or default value)
|
* Return a option parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The option parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The option parameter value or default value if not set
|
* @retval mixed The option parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -564,9 +564,9 @@ class LSldap extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -1965,9 +1965,9 @@ class LSldapObject extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -27,448 +27,450 @@
|
||||||
*/
|
*/
|
||||||
class LSlog {
|
class LSlog {
|
||||||
|
|
||||||
// Enable state
|
// Enable state
|
||||||
private static $enabled = false;
|
private static $enabled = false;
|
||||||
|
|
||||||
// Configured handlers
|
// Configured handlers
|
||||||
private static $handlers = array();
|
private static $handlers = array();
|
||||||
|
|
||||||
// Default handlers (if not configured)
|
// Default handlers (if not configured)
|
||||||
private static $default_handlers = array(
|
private static $default_handlers = array(
|
||||||
array (
|
array (
|
||||||
'handler' => 'file',
|
'handler' => 'file',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Current level
|
// Current level
|
||||||
private static $level;
|
private static $level;
|
||||||
private static $default_level = 'WARNING';
|
private static $default_level = 'WARNING';
|
||||||
|
|
||||||
// Levels
|
// Levels
|
||||||
private static $levels=array(
|
private static $levels=array(
|
||||||
'TRACE' => 0,
|
'TRACE' => 0,
|
||||||
'DEBUG' => 1,
|
'DEBUG' => 1,
|
||||||
'INFO' => 2,
|
'INFO' => 2,
|
||||||
'WARNING' => 3,
|
'WARNING' => 3,
|
||||||
'ERROR' => 4,
|
'ERROR' => 4,
|
||||||
'FATAL' => 5,
|
'FATAL' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Current existing loggers
|
// Current existing loggers
|
||||||
private static $loggers = array();
|
private static $loggers = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start/initialize logging
|
* Start/initialize logging
|
||||||
*
|
*
|
||||||
* @retval bool True on success, False otherwise
|
* @retval bool True on success, False otherwise
|
||||||
**/
|
**/
|
||||||
public static function start() {
|
public static function start() {
|
||||||
// Load configuration
|
// Load configuration
|
||||||
self :: $enabled = self :: getConfig('enable', false, 'bool');
|
self :: $enabled = self :: getConfig('enable', false, 'bool');
|
||||||
self :: setLevel();
|
self :: setLevel();
|
||||||
|
|
||||||
// Load default handlers class
|
// Load default handlers class
|
||||||
if (!LSsession :: loadLSclass('LSlog_handler', null, true)) {
|
if (!LSsession :: loadLSclass('LSlog_handler', null, true)) {
|
||||||
LSdebug('LSlog disabled');
|
LSdebug('LSlog disabled');
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load handlers
|
// Load handlers
|
||||||
$handlers = self :: getConfig('handlers');
|
$handlers = self :: getConfig('handlers');
|
||||||
if (!is_array($handlers)) $handlers = self :: $default_handlers;
|
if (!is_array($handlers)) $handlers = self :: $default_handlers;
|
||||||
LSdebug($handlers, true);
|
LSdebug($handlers, true);
|
||||||
$debug_handlers = array();
|
$debug_handlers = array();
|
||||||
foreach($handlers as $handler => $handler_config) {
|
foreach($handlers as $handler => $handler_config) {
|
||||||
if (!is_array($handler_config))
|
if (!is_array($handler_config))
|
||||||
$handler_config = array('handler' => $handler);
|
$handler_config = array('handler' => $handler);
|
||||||
else
|
else
|
||||||
$handler = (isset($handler_config['handler'])?$handler_config['handler']:'system');
|
$handler = (isset($handler_config['handler'])?$handler_config['handler']:'system');
|
||||||
|
|
||||||
if (!self :: add_handler($handler, $handler_config))
|
if (!self :: add_handler($handler, $handler_config))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$debug_handlers[] = $handler;
|
$debug_handlers[] = $handler;
|
||||||
}
|
}
|
||||||
LSdebug('LSlog enabled with level='.self :: $level.' and following handlers : '.implode(', ', $debug_handlers));
|
LSdebug('LSlog enabled with level='.self :: $level.' and following handlers : '.implode(', ', $debug_handlers));
|
||||||
|
|
||||||
set_exception_handler(array('LSlog', 'exception'));
|
set_exception_handler(array('LSlog', 'exception'));
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add handler
|
* Add handler
|
||||||
*
|
*
|
||||||
* @param[in] $handler string The handler name
|
* @param[in] $handler string The handler name
|
||||||
* @param[in] $handler_config array The handler configuration (optional)
|
* @param[in] $handler_config array The handler configuration (optional)
|
||||||
*
|
*
|
||||||
* @retval boolean True if handler added, false otherwise
|
* @retval boolean True if handler added, false otherwise
|
||||||
**/
|
**/
|
||||||
public static function add_handler($handler, $handler_config = array()) {
|
public static function add_handler($handler, $handler_config = array()) {
|
||||||
if (!LSconfig :: get('enabled', true, 'bool', $handler_config))
|
if (!LSconfig :: get('enabled', true, 'bool', $handler_config))
|
||||||
return true;
|
return true;
|
||||||
$handler_class = "LSlog_$handler";
|
$handler_class = "LSlog_$handler";
|
||||||
|
|
||||||
// Load handler class
|
// Load handler class
|
||||||
if (!LSsession :: loadLSclass($handler_class) || !class_exists($handler_class)) {
|
if (!LSsession :: loadLSclass($handler_class) || !class_exists($handler_class)) {
|
||||||
LSerror :: addErrorCode('LSlog_01', $handler);
|
LSerror :: addErrorCode('LSlog_01', $handler);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$handler_obj = new $handler_class($handler_config);
|
$handler_obj = new $handler_class($handler_config);
|
||||||
if ($handler_obj -> checkCompatibility()) {
|
if ($handler_obj -> checkCompatibility()) {
|
||||||
self :: $handlers[] = $handler_obj;
|
self :: $handlers[] = $handler_obj;
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
LSdebug("LSlog handler $handler not supported.");
|
LSdebug("LSlog handler $handler not supported.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable console handler (if not already enabled)
|
* Enable console handler (if not already enabled)
|
||||||
*
|
*
|
||||||
* @param[in] $level string|null The log level of the console handler
|
* @param[in] $level string|null The log level of the console handler
|
||||||
*
|
*
|
||||||
* @retval boolean True if log on console enabled, false otherwise
|
* @retval boolean True if log on console enabled, false otherwise
|
||||||
**/
|
**/
|
||||||
public static function logOnConsole($level=null) {
|
public static function logOnConsole($level=null) {
|
||||||
for ($i=0; $i < count(self :: $handlers); $i++) {
|
for ($i=0; $i < count(self :: $handlers); $i++) {
|
||||||
if (is_a(self :: $handlers[$i], 'LSlog_console')) {
|
if (is_a(self :: $handlers[$i], 'LSlog_console')) {
|
||||||
if (!is_null($level))
|
if (!is_null($level))
|
||||||
self :: $handlers[$i] -> setLevel($level);
|
self :: $handlers[$i] -> setLevel($level);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return self :: add_handler('console', array('level' => $level));
|
return self :: add_handler('console', array('level' => $level));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Disable console handler (if already enabled)
|
* Disable console handler (if already enabled)
|
||||||
*
|
*
|
||||||
* @retval void
|
|
||||||
**/
|
|
||||||
public static function disableLogOnConsole() {
|
|
||||||
for ($i=0; $i < count(self :: $handlers); $i++) {
|
|
||||||
if (is_a(self :: $handlers[$i], 'LSlog_console')) {
|
|
||||||
LSlog :: debug('Remove console handler');
|
|
||||||
unset(self :: $handlers[$i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set log level
|
|
||||||
*
|
|
||||||
* @param[in] $level string|null The log level (optional, default: from configuration or 'WARNING')
|
|
||||||
*
|
|
||||||
* @retval boolean True if log level set, false otherwise
|
|
||||||
**/
|
|
||||||
public static function setLevel($level=null) {
|
|
||||||
if (!$level) {
|
|
||||||
$level = self :: getConfig('level', self :: $default_level, 'string');
|
|
||||||
if (!array_key_exists($level, self :: $levels)) {
|
|
||||||
self :: $level = 'WARNING';
|
|
||||||
if ($level)
|
|
||||||
self :: warning("Invalid log level '$level' configured. Set log level to WARNING.");
|
|
||||||
$level = 'WARNING';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (!array_key_exists($level, self :: $levels))
|
|
||||||
return false;
|
|
||||||
self :: $level = $level;
|
|
||||||
|
|
||||||
// Set PHP error/exception handlers
|
|
||||||
if (in_array(self :: $level, array('DEBUG', 'TRACE')))
|
|
||||||
set_error_handler(array('LSlog', 'php_error'), E_ALL & ~E_STRICT);
|
|
||||||
else
|
|
||||||
set_error_handler(array('LSlog', 'php_error'), E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
|
||||||
return True;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a configuration variable value
|
|
||||||
*
|
|
||||||
* @param[in] $var string The configuration variable name
|
|
||||||
* @param[in] $default mixed The default value to return if configuration variable
|
|
||||||
* is not set (Default : null)
|
|
||||||
* @param[in] $cast string The type of expected value. The configuration variable
|
|
||||||
* value will be cast as this type. Could be : bool, int,
|
|
||||||
* float or string. (Optional, default : raw value)
|
|
||||||
*
|
|
||||||
* @retval mixed The configuration variable value
|
|
||||||
**/
|
|
||||||
public static function getConfig($var, $default=null, $cast=null) {
|
|
||||||
return LSconfig :: get($var, $default, $cast, ((isset($GLOBALS['LSlog']) && is_array($GLOBALS['LSlog']))?$GLOBALS['LSlog']:array()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log a message
|
|
||||||
*
|
|
||||||
* @param[in] $level string The message level
|
|
||||||
* @param[in] $message string The message
|
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
|
||||||
*
|
|
||||||
* @retval void
|
|
||||||
**/
|
|
||||||
public static function logging($level, $message, $logger=null) {
|
|
||||||
// Check LSlog is enabled
|
|
||||||
if (!self :: $enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Check/fix level
|
|
||||||
if (!array_key_exists($level, self :: $levels))
|
|
||||||
$level = self :: $default_level;
|
|
||||||
|
|
||||||
// Handle non-string message
|
|
||||||
if (!is_string($message)) {
|
|
||||||
if (is_object($message) && method_exists($message, '__toString'))
|
|
||||||
$message = strval($message);
|
|
||||||
else
|
|
||||||
$message = varDump($message);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (self :: $handlers as $handler) {
|
|
||||||
// Check handler level
|
|
||||||
if (!$handler -> checkLevel($level))
|
|
||||||
continue;
|
|
||||||
// Check handler logger filters
|
|
||||||
if (!$handler -> checkLogger($logger))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Logging on this handler
|
|
||||||
call_user_func(array($handler, 'logging'), $level, $message, $logger);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($level == 'FATAL') {
|
|
||||||
if (php_sapi_name() == "cli")
|
|
||||||
die($message);
|
|
||||||
elseif (class_exists('LStemplate'))
|
|
||||||
LStemplate :: fatal_error($message);
|
|
||||||
else
|
|
||||||
die($message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check level against configured level
|
|
||||||
*
|
|
||||||
* @param[in] $level string The level
|
|
||||||
* @param[in] $configured_level string|null The configured level (optional, default : self :: $level)
|
|
||||||
*
|
|
||||||
* @retval bool True if a message with this level have to be logged, False otherwise
|
|
||||||
**/
|
|
||||||
public static function checkLevel($level, $configured_level=null) {
|
|
||||||
if (is_null($configured_level) || !array_key_exists($configured_level, self :: $levels))
|
|
||||||
$configured_level = self :: $level;
|
|
||||||
|
|
||||||
// On unknown level, use default level
|
|
||||||
if (!array_key_exists($level, self :: $levels))
|
|
||||||
$level = self :: $default_level;
|
|
||||||
|
|
||||||
return (self :: $levels[$level] >= self :: $levels[$configured_level]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a log level exists
|
|
||||||
*
|
|
||||||
* @param[in] $level string The level
|
|
||||||
*
|
|
||||||
* @retval bool True if the specified log level exists, False otherwise
|
|
||||||
**/
|
|
||||||
public static function checkLevelExists($level) {
|
|
||||||
return array_key_exists($level, self :: $levels);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* PHP error logging helpers
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate current context backtrace
|
|
||||||
*
|
|
||||||
* @retval string Current context backtrace
|
|
||||||
**/
|
|
||||||
public static function get_debug_backtrace_context() {
|
|
||||||
$traces = debug_backtrace();
|
|
||||||
if (!is_array($traces) || count($traces) < 2)
|
|
||||||
return "unknown context";
|
|
||||||
|
|
||||||
$msg = array();
|
|
||||||
$j=0;
|
|
||||||
for ($i=count($traces)-1; $i >= 1; $i--) {
|
|
||||||
$j += 1;
|
|
||||||
$trace = array("#$j");
|
|
||||||
if (isset($traces[$i]['file']))
|
|
||||||
$trace[] = $traces[$i]['file'].(isset($traces[$i]['line'])?":".$traces[$i]['line']:"");
|
|
||||||
if (isset($traces[$i]['class']) && isset($traces[$i]['function']))
|
|
||||||
$trace[] = $traces[$i]['class'] . " " . $traces[$i]['type'] . " " . $traces[$i]['function']. "()";
|
|
||||||
elseif (isset($traces[$i]['function']))
|
|
||||||
$trace[] = $traces[$i]['function']. "()";
|
|
||||||
$msg[] = implode(" - ", $trace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode("\n", $msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Log an exception
|
|
||||||
*
|
|
||||||
* Could be used as PHP set_exception_handler callable
|
|
||||||
* @see https://www.php.net/set_exception_handler
|
|
||||||
*
|
|
||||||
* @param[in] $exception Exception The exception to log
|
|
||||||
* @param[in] $prefix string|null Custom message prefix (optional, default: "An exception occured :\n")
|
|
||||||
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
|
||||||
*
|
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public static function exception($exception, $prefix=null, $fatal=true, $logger=null) {
|
public static function disableLogOnConsole() {
|
||||||
$message = ($prefix?"$prefix :\n":"An exception occured :\n"). self :: get_debug_backtrace_context(). "\n" .
|
for ($i=0; $i < count(self :: $handlers); $i++) {
|
||||||
"## ".$exception->getFile().":".$exception->getLine(). " : ". $exception->getMessage();
|
if (is_a(self :: $handlers[$i], 'LSlog_console')) {
|
||||||
if (is_null($logger))
|
LSlog :: debug('Remove console handler');
|
||||||
self :: logging(($fatal?'FATAL':'ERROR'), $message);
|
unset(self :: $handlers[$i]);
|
||||||
else
|
}
|
||||||
self :: logging(($fatal?'FATAL':'ERROR'), $message, $logger);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PHP set_error_handler helper
|
* Set log level
|
||||||
*
|
*
|
||||||
* @see https://www.php.net/set_error_handler
|
* @param[in] $level string|null The log level (optional, default: from configuration or 'WARNING')
|
||||||
**/
|
*
|
||||||
public static function php_error($errno, $errstr, $errfile, $errline) {
|
* @retval boolean True if log level set, false otherwise
|
||||||
$errnos2error = array (
|
**/
|
||||||
1 => "ERROR",
|
public static function setLevel($level=null) {
|
||||||
2 => "WARNING",
|
if (!$level) {
|
||||||
4 => "PARSE",
|
$level = self :: getConfig('level', self :: $default_level, 'string');
|
||||||
8 => "NOTICE",
|
if (!array_key_exists($level, self :: $levels)) {
|
||||||
16 => "CORE_ERROR",
|
self :: $level = 'WARNING';
|
||||||
32 => "CORE_WARNING",
|
if ($level)
|
||||||
64 => "COMPILE_ERROR",
|
self :: warning("Invalid log level '$level' configured. Set log level to WARNING.");
|
||||||
128 => "COMPILE_WARNING",
|
$level = 'WARNING';
|
||||||
256 => "USER_ERROR",
|
}
|
||||||
512 => "USER_WARNING",
|
}
|
||||||
1024 => "USER_NOTICE",
|
else if (!array_key_exists($level, self :: $levels))
|
||||||
2048 => "STRICT",
|
return false;
|
||||||
4096 => "RECOVERABLE_ERROR",
|
self :: $level = $level;
|
||||||
8192 => "DEPRECATED",
|
|
||||||
16384 => "USER_DEPRECATED",
|
|
||||||
32767 => "ALL",
|
|
||||||
);
|
|
||||||
|
|
||||||
$errors2level = array (
|
// Set PHP error/exception handlers
|
||||||
"ERROR" => "ERROR",
|
if (in_array(self :: $level, array('DEBUG', 'TRACE')))
|
||||||
"WARNING" => "WARNING",
|
set_error_handler(array('LSlog', 'php_error'), E_ALL & ~E_STRICT);
|
||||||
"PARSE" => "FATAL",
|
else
|
||||||
"NOTICE" => "INFO",
|
set_error_handler(array('LSlog', 'php_error'), E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED);
|
||||||
"CORE_ERROR" => "ERROR",
|
return True;
|
||||||
"CORE_WARNING" => "WARNING",
|
}
|
||||||
"COMPILE_ERROR" => "ERROR",
|
|
||||||
"COMPILE_WARNING" => "WARNING",
|
|
||||||
"USER_ERROR" => "ERROR",
|
|
||||||
"USER_WARNING" => "WARNING",
|
|
||||||
"USER_NOTICE" => "INFO",
|
|
||||||
"STRICT" => "WARNING",
|
|
||||||
"RECOVERABLE_ERROR" => "WARNING",
|
|
||||||
"DEPRECATED" => "DEBUG",
|
|
||||||
"USER_DEPRECATED" => "DEBUG",
|
|
||||||
"ALL" => "ERROR",
|
|
||||||
"UNKNOWN" => "ERROR",
|
|
||||||
);
|
|
||||||
$error = (isset($errnos2error[$errno])?$errnos2error[$errno]:'UNKNOWN');
|
|
||||||
$level = (isset($errors2level[$error])?$errors2level[$error]:'ERROR');
|
|
||||||
self :: logging($level, "A PHP $error occured (#$errno) : $errstr [$errfile:$errline]");
|
|
||||||
return False;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get logger for a specific name
|
* Get a configuration variable value
|
||||||
*
|
*
|
||||||
* @param[in] $name The logger name
|
* @param[in] $var string The configuration variable name
|
||||||
*
|
* @param[in] $default mixed The default value to return if configuration variable
|
||||||
* @retval LSlog_logger The logger
|
* is not set (Default : null)
|
||||||
**/
|
* @param[in] $cast string The type of expected value. The configuration variable
|
||||||
public static function &get_logger($name) {
|
* value will be cast as this type. Could be : bool, int,
|
||||||
if (!LSsession :: loadLSclass('LSlog_logger'))
|
* float or string. (Optional, default : raw value)
|
||||||
self :: fatal('Fail to load LSlog_logger class.');
|
*
|
||||||
if (isset(self :: $loggers[$name]))
|
* @retval mixed The configuration variable value
|
||||||
return self :: $loggers[$name];
|
**/
|
||||||
self :: $loggers[$name] = new LSlog_logger(
|
public static function getConfig($var, $default=null, $cast=null) {
|
||||||
$name,
|
return LSconfig :: get($var, $default, $cast, ((isset($GLOBALS['LSlog']) && is_array($GLOBALS['LSlog']))?$GLOBALS['LSlog']:array()));
|
||||||
self :: getConfig("loggers.$name", array())
|
}
|
||||||
);
|
|
||||||
return self :: $loggers[$name];
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Public logging methods
|
* Log a message
|
||||||
*/
|
*
|
||||||
|
* @param[in] $level string The message level
|
||||||
|
* @param[in] $message string The message
|
||||||
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function logging($level, $message, $logger=null) {
|
||||||
|
// Check LSlog is enabled
|
||||||
|
if (!self :: $enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
/**
|
// Check/fix level
|
||||||
* Log a message with level TRACE
|
if (!array_key_exists($level, self :: $levels))
|
||||||
*
|
$level = self :: $default_level;
|
||||||
* @param[in] $message The message to log
|
|
||||||
*
|
|
||||||
* @retval void
|
|
||||||
**/
|
|
||||||
public static function trace($message) {
|
|
||||||
self :: logging('TRACE', $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Handle non-string message
|
||||||
* Log a message with level DEBUG
|
if (!is_string($message)) {
|
||||||
*
|
if (is_object($message) && method_exists($message, '__toString'))
|
||||||
* @param[in] $message The message to log
|
$message = strval($message);
|
||||||
*
|
else
|
||||||
* @retval void
|
$message = varDump($message);
|
||||||
**/
|
}
|
||||||
public static function debug($message) {
|
|
||||||
self :: logging('DEBUG', $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
foreach (self :: $handlers as $handler) {
|
||||||
* Log a message with level INFO
|
// Check handler level
|
||||||
*
|
if (!$handler -> checkLevel($level))
|
||||||
* @param[in] $message The message to log
|
continue;
|
||||||
*
|
// Check handler logger filters
|
||||||
* @retval void
|
if (!$handler -> checkLogger($logger))
|
||||||
**/
|
continue;
|
||||||
public static function info($message) {
|
|
||||||
self :: logging('INFO', $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Logging on this handler
|
||||||
* Log a message with level WARNING
|
call_user_func(array($handler, 'logging'), $level, $message, $logger);
|
||||||
*
|
}
|
||||||
* @param[in] $message The message to log
|
|
||||||
*
|
|
||||||
* @retval void
|
|
||||||
**/
|
|
||||||
public static function warning($message) {
|
|
||||||
self :: logging('WARNING', $message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if ($level == 'FATAL') {
|
||||||
* Log a message with level ERROR
|
if (php_sapi_name() == "cli")
|
||||||
*
|
die($message);
|
||||||
* @param[in] $message The message to log
|
elseif (class_exists('LStemplate'))
|
||||||
*
|
LStemplate :: fatal_error($message);
|
||||||
* @retval void
|
else
|
||||||
**/
|
die($message);
|
||||||
public static function error($message) {
|
}
|
||||||
self :: logging('ERROR', $message);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level FATAL
|
* Check level against configured level
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $level string The level
|
||||||
*
|
* @param[in] $configured_level string|null The configured level (optional, default : self :: $level)
|
||||||
* @retval void
|
*
|
||||||
**/
|
* @retval bool True if a message with this level have to be logged, False otherwise
|
||||||
public static function fatal($message) {
|
**/
|
||||||
self :: logging('FATAL', $message);
|
public static function checkLevel($level, $configured_level=null) {
|
||||||
}
|
if (is_null($configured_level) || !array_key_exists($configured_level, self :: $levels))
|
||||||
|
$configured_level = self :: $level;
|
||||||
|
|
||||||
|
// On unknown level, use default level
|
||||||
|
if (!array_key_exists($level, self :: $levels))
|
||||||
|
$level = self :: $default_level;
|
||||||
|
|
||||||
|
return (self :: $levels[$level] >= self :: $levels[$configured_level]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a log level exists
|
||||||
|
*
|
||||||
|
* @param[in] $level string The level
|
||||||
|
*
|
||||||
|
* @retval bool True if the specified log level exists, False otherwise
|
||||||
|
**/
|
||||||
|
public static function checkLevelExists($level) {
|
||||||
|
return array_key_exists($level, self :: $levels);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PHP error logging helpers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate current context backtrace
|
||||||
|
*
|
||||||
|
* @retval string Current context backtrace
|
||||||
|
**/
|
||||||
|
public static function get_debug_backtrace_context() {
|
||||||
|
$traces = debug_backtrace();
|
||||||
|
if (!is_array($traces) || count($traces) < 2)
|
||||||
|
return "unknown context";
|
||||||
|
|
||||||
|
$msg = array();
|
||||||
|
$j=0;
|
||||||
|
for ($i=count($traces)-1; $i >= 1; $i--) {
|
||||||
|
$j += 1;
|
||||||
|
$trace = array("#$j");
|
||||||
|
if (isset($traces[$i]['file']))
|
||||||
|
$trace[] = $traces[$i]['file'].(isset($traces[$i]['line'])?":".$traces[$i]['line']:"");
|
||||||
|
if (isset($traces[$i]['class']) && isset($traces[$i]['function']))
|
||||||
|
$trace[] = $traces[$i]['class'] . " " . $traces[$i]['type'] . " " . $traces[$i]['function']. "()";
|
||||||
|
elseif (isset($traces[$i]['function']))
|
||||||
|
$trace[] = $traces[$i]['function']. "()";
|
||||||
|
$msg[] = implode(" - ", $trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode("\n", $msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log an exception
|
||||||
|
*
|
||||||
|
* Could be used as PHP set_exception_handler callable
|
||||||
|
* @see https://www.php.net/set_exception_handler
|
||||||
|
*
|
||||||
|
* @param[in] $exception Exception The exception to log
|
||||||
|
* @param[in] $prefix string|null Custom message prefix (optional, default: "An exception occured :\n")
|
||||||
|
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
||||||
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function exception($exception, $prefix=null, $fatal=true, $logger=null) {
|
||||||
|
$message =
|
||||||
|
($prefix?"$prefix :\n":"An exception occured :\n").
|
||||||
|
self :: get_debug_backtrace_context(). "\n" .
|
||||||
|
"## ".$exception->getFile().":".$exception->getLine(). " : ". $exception->getMessage();
|
||||||
|
if (is_null($logger))
|
||||||
|
self :: logging(($fatal?'FATAL':'ERROR'), $message);
|
||||||
|
else
|
||||||
|
self :: logging(($fatal?'FATAL':'ERROR'), $message, $logger);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP set_error_handler helper
|
||||||
|
*
|
||||||
|
* @see https://www.php.net/set_error_handler
|
||||||
|
**/
|
||||||
|
public static function php_error($errno, $errstr, $errfile, $errline) {
|
||||||
|
$errnos2error = array (
|
||||||
|
1 => "ERROR",
|
||||||
|
2 => "WARNING",
|
||||||
|
4 => "PARSE",
|
||||||
|
8 => "NOTICE",
|
||||||
|
16 => "CORE_ERROR",
|
||||||
|
32 => "CORE_WARNING",
|
||||||
|
64 => "COMPILE_ERROR",
|
||||||
|
128 => "COMPILE_WARNING",
|
||||||
|
256 => "USER_ERROR",
|
||||||
|
512 => "USER_WARNING",
|
||||||
|
1024 => "USER_NOTICE",
|
||||||
|
2048 => "STRICT",
|
||||||
|
4096 => "RECOVERABLE_ERROR",
|
||||||
|
8192 => "DEPRECATED",
|
||||||
|
16384 => "USER_DEPRECATED",
|
||||||
|
32767 => "ALL",
|
||||||
|
);
|
||||||
|
|
||||||
|
$errors2level = array (
|
||||||
|
"ERROR" => "ERROR",
|
||||||
|
"WARNING" => "WARNING",
|
||||||
|
"PARSE" => "FATAL",
|
||||||
|
"NOTICE" => "INFO",
|
||||||
|
"CORE_ERROR" => "ERROR",
|
||||||
|
"CORE_WARNING" => "WARNING",
|
||||||
|
"COMPILE_ERROR" => "ERROR",
|
||||||
|
"COMPILE_WARNING" => "WARNING",
|
||||||
|
"USER_ERROR" => "ERROR",
|
||||||
|
"USER_WARNING" => "WARNING",
|
||||||
|
"USER_NOTICE" => "INFO",
|
||||||
|
"STRICT" => "WARNING",
|
||||||
|
"RECOVERABLE_ERROR" => "WARNING",
|
||||||
|
"DEPRECATED" => "DEBUG",
|
||||||
|
"USER_DEPRECATED" => "DEBUG",
|
||||||
|
"ALL" => "ERROR",
|
||||||
|
"UNKNOWN" => "ERROR",
|
||||||
|
);
|
||||||
|
$error = (isset($errnos2error[$errno])?$errnos2error[$errno]:'UNKNOWN');
|
||||||
|
$level = (isset($errors2level[$error])?$errors2level[$error]:'ERROR');
|
||||||
|
self :: logging($level, "A PHP $error occured (#$errno) : $errstr [$errfile:$errline]");
|
||||||
|
return False;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get logger for a specific name
|
||||||
|
*
|
||||||
|
* @param[in] $name The logger name
|
||||||
|
*
|
||||||
|
* @retval LSlog_logger The logger
|
||||||
|
**/
|
||||||
|
public static function &get_logger($name) {
|
||||||
|
if (!LSsession :: loadLSclass('LSlog_logger'))
|
||||||
|
self :: fatal('Fail to load LSlog_logger class.');
|
||||||
|
if (isset(self :: $loggers[$name]))
|
||||||
|
return self :: $loggers[$name];
|
||||||
|
self :: $loggers[$name] = new LSlog_logger(
|
||||||
|
$name,
|
||||||
|
self :: getConfig("loggers.$name", array())
|
||||||
|
);
|
||||||
|
return self :: $loggers[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public logging methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level TRACE
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function trace($message) {
|
||||||
|
self :: logging('TRACE', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level DEBUG
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function debug($message) {
|
||||||
|
self :: logging('DEBUG', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level INFO
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function info($message) {
|
||||||
|
self :: logging('INFO', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level WARNING
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function warning($message) {
|
||||||
|
self :: logging('WARNING', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level ERROR
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function error($message) {
|
||||||
|
self :: logging('ERROR', $message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a message with level FATAL
|
||||||
|
*
|
||||||
|
* @param[in] $message The message to log
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public static function fatal($message) {
|
||||||
|
self :: logging('FATAL', $message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,38 +27,38 @@
|
||||||
*/
|
*/
|
||||||
class LSlog_console extends LSlog_handler {
|
class LSlog_console extends LSlog_handler {
|
||||||
|
|
||||||
// File-descriptors for stdout/stderr
|
// File-descriptors for stdout/stderr
|
||||||
private $stdout;
|
private $stdout;
|
||||||
private $stderr;
|
private $stderr;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$this -> stdout = fopen('php://stdout', 'w');
|
$this -> stdout = fopen('php://stdout', 'w');
|
||||||
$this -> stderr = fopen('php://stderr', 'w');
|
$this -> stderr = fopen('php://stderr', 'w');
|
||||||
if ($this -> enabled)
|
if ($this -> enabled)
|
||||||
self :: log_trace("$this Enabled", get_class($this));
|
self :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
return fwrite(
|
return fwrite(
|
||||||
(in_array($level, array('INFO', 'DEBUG', 'TRACE'))?$this -> stdout:$this -> stderr),
|
(in_array($level, array('INFO', 'DEBUG', 'TRACE'))?$this -> stdout:$this -> stderr),
|
||||||
$this -> format($level, $message, $logger)."\n"
|
$this -> format($level, $message, $logger)."\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,54 +27,54 @@
|
||||||
*/
|
*/
|
||||||
class LSlog_email extends LSlog_handler {
|
class LSlog_email extends LSlog_handler {
|
||||||
|
|
||||||
// The configured email recipient
|
// The configured email recipient
|
||||||
private $recipient = null;
|
private $recipient = null;
|
||||||
|
|
||||||
// Default datetime prefix (enabled/disabled)
|
// Default datetime prefix (enabled/disabled)
|
||||||
protected $default_datetime_prefix = false;
|
protected $default_datetime_prefix = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$this -> recipient = self :: getConfig('recipient');
|
$this -> recipient = self :: getConfig('recipient');
|
||||||
if ($this -> enabled)
|
if ($this -> enabled)
|
||||||
self :: log_trace("$this Enabled", get_class($this));
|
self :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of details for the string representation of the LSlog_email
|
* Return list of details for the string representation of the LSlog_email
|
||||||
*
|
*
|
||||||
* @retval array List of details for the string representation of the LSlog_email
|
* @retval array List of details for the string representation of the LSlog_email
|
||||||
*/
|
*/
|
||||||
public function __toStringDetails() {
|
public function __toStringDetails() {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array("recipient=".$this -> recipient),
|
array("recipient=".$this -> recipient),
|
||||||
parent :: __toStringDetails()
|
parent :: __toStringDetails()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
if ($this -> recipient)
|
if ($this -> recipient)
|
||||||
return error_log(
|
return error_log(
|
||||||
$this -> format($level, $message, $logger),
|
$this -> format($level, $message, $logger),
|
||||||
1,
|
1,
|
||||||
$this -> recipient
|
$this -> recipient
|
||||||
);
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,52 +27,52 @@
|
||||||
*/
|
*/
|
||||||
class LSlog_file extends LSlog_handler {
|
class LSlog_file extends LSlog_handler {
|
||||||
|
|
||||||
// The configured logfile path
|
// The configured logfile path
|
||||||
private $path;
|
private $path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
// For reto-compatibilty, use LSlog.filename as default log path value
|
// For reto-compatibilty, use LSlog.filename as default log path value
|
||||||
$this -> path = self :: getConfig('path', LSlog :: getConfig('filename', 'tmp/LS.log'));
|
$this -> path = self :: getConfig('path', LSlog :: getConfig('filename', 'tmp/LS.log'));
|
||||||
if (substr($this -> path, 0, 1) != '/')
|
if (substr($this -> path, 0, 1) != '/')
|
||||||
$this -> path = LS_ROOT_DIR."/".$this -> path;
|
$this -> path = LS_ROOT_DIR."/".$this -> path;
|
||||||
if ($this -> enabled)
|
if ($this -> enabled)
|
||||||
self :: log_trace("$this Enabled", get_class($this));
|
self :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of details for the string representation of the LSlog_file
|
* Return list of details for the string representation of the LSlog_file
|
||||||
*
|
*
|
||||||
* @retval array List of details for the string representation of the LSlog_file
|
* @retval array List of details for the string representation of the LSlog_file
|
||||||
*/
|
*/
|
||||||
public function __toStringDetails() {
|
public function __toStringDetails() {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array("path=".$this -> path),
|
array("path=".$this -> path),
|
||||||
parent :: __toStringDetails()
|
parent :: __toStringDetails()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
return error_log(
|
return error_log(
|
||||||
$this -> format($level, $message, $logger)."\n",
|
$this -> format($level, $message, $logger)."\n",
|
||||||
3,
|
3,
|
||||||
$this -> path
|
$this -> path
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,43 +29,43 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
|
||||||
*/
|
*/
|
||||||
class LSlog_handler extends LSlog_staticLoggerClass {
|
class LSlog_handler extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
// The handler configuration
|
// The handler configuration
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
// Log level
|
// Log level
|
||||||
protected $level;
|
protected $level;
|
||||||
|
|
||||||
// Default log formats
|
// Default log formats
|
||||||
protected $default_format = '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{logger} - %{level} - %{message}';
|
protected $default_format = '%{requesturi} - %{remoteaddr} - %{ldapservername} - %{authuser} - %{logger} - %{level} - %{message}';
|
||||||
protected $default_cli_format = '%{clibinpath} - %{logger} - %{level} - %{message}';
|
protected $default_cli_format = '%{clibinpath} - %{logger} - %{level} - %{message}';
|
||||||
|
|
||||||
// Default datetime prefix (enabled/disabled)
|
// Default datetime prefix (enabled/disabled)
|
||||||
protected $default_datetime_prefix = true;
|
protected $default_datetime_prefix = true;
|
||||||
|
|
||||||
// Default datetime format
|
// Default datetime format
|
||||||
protected $default_datetime_format = 'Y/m/d H:i:s';
|
protected $default_datetime_format = 'Y/m/d H:i:s';
|
||||||
|
|
||||||
// Loggers filters
|
// Loggers filters
|
||||||
protected $loggers = array();
|
protected $loggers = array();
|
||||||
protected $excluded_loggers = array();
|
protected $excluded_loggers = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
$this -> config = $config;
|
$this -> config = $config;
|
||||||
$this -> level = $this -> getConfig('level', null, 'string');
|
$this -> level = $this -> getConfig('level', null, 'string');
|
||||||
$this -> loggers = $this -> getConfig('loggers', array());
|
$this -> loggers = $this -> getConfig('loggers', array());
|
||||||
if (!is_array($this -> loggers))
|
if (!is_array($this -> loggers))
|
||||||
$this -> loggers = array($this -> loggers);
|
$this -> loggers = array($this -> loggers);
|
||||||
$this -> excluded_loggers = $this -> getConfig('excluded_loggers', array());
|
$this -> excluded_loggers = $this -> getConfig('excluded_loggers', array());
|
||||||
if (!is_array($this -> excluded_loggers))
|
if (!is_array($this -> excluded_loggers))
|
||||||
$this -> excluded_loggers = array($this -> excluded_loggers);
|
$this -> excluded_loggers = array($this -> excluded_loggers);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow conversion of LSlog_handler to string
|
* Allow conversion of LSlog_handler to string
|
||||||
|
@ -81,176 +81,176 @@ class LSlog_handler extends LSlog_staticLoggerClass {
|
||||||
*
|
*
|
||||||
* @retval array List of details for the string representation of the LSlog_handler
|
* @retval array List of details for the string representation of the LSlog_handler
|
||||||
*/
|
*/
|
||||||
public function __toStringDetails() {
|
public function __toStringDetails() {
|
||||||
return array(
|
return array(
|
||||||
"level=".($this -> level?$this -> level:'default'),
|
"level=".($this -> level?$this -> level:'default'),
|
||||||
"loggers=".($this -> loggers?implode(',', $this -> loggers):'all'),
|
"loggers=".($this -> loggers?implode(',', $this -> loggers):'all'),
|
||||||
"excluded loggers=".($this -> excluded_loggers?implode(',', $this -> excluded_loggers):'no'),
|
"excluded loggers=".($this -> excluded_loggers?implode(',', $this -> excluded_loggers):'no'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get handler info
|
* Get handler info
|
||||||
*
|
*
|
||||||
* @param[in] $key string The info name
|
* @param[in] $key string The info name
|
||||||
*
|
*
|
||||||
* @retval mixed The info value
|
* @retval mixed The info value
|
||||||
**/
|
**/
|
||||||
public function __get($key) {
|
public function __get($key) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'enabled':
|
case 'enabled':
|
||||||
return $this -> getConfig('enabled', true, 'bool');
|
return $this -> getConfig('enabled', true, 'bool');
|
||||||
case 'format':
|
case 'format':
|
||||||
if (php_sapi_name() == "cli")
|
if (php_sapi_name() == "cli")
|
||||||
$format = $this -> getConfig('cli_format', $this -> default_cli_format, 'string');
|
$format = $this -> getConfig('cli_format', $this -> default_cli_format, 'string');
|
||||||
else
|
else
|
||||||
$format = $this -> getConfig('format', $this -> default_format, 'string');
|
$format = $this -> getConfig('format', $this -> default_format, 'string');
|
||||||
// Add datetime prefix (if enabled)
|
// Add datetime prefix (if enabled)
|
||||||
if ($this -> getConfig('datetime_prefix', $this -> default_datetime_prefix, 'boolean')) {
|
if ($this -> getConfig('datetime_prefix', $this -> default_datetime_prefix, 'boolean')) {
|
||||||
$format = date($this -> getConfig('datetime_format', $this -> default_datetime_format, 'string'))." - $format";
|
$format = date($this -> getConfig('datetime_format', $this -> default_datetime_format, 'string'))." - $format";
|
||||||
}
|
}
|
||||||
return $format;
|
return $format;
|
||||||
}
|
}
|
||||||
// Unknown key, log warning
|
// Unknown key, log warning
|
||||||
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check system compatibility with this handler
|
* Check system compatibility with this handler
|
||||||
*
|
*
|
||||||
* Note : LSlog do not generate no error about imcompatibly, it's
|
* Note : LSlog do not generate no error about imcompatibly, it's
|
||||||
* just omit this handler if system is incompatible. You have to
|
* just omit this handler if system is incompatible. You have to
|
||||||
* trigger it with this method if you want.
|
* trigger it with this method if you want.
|
||||||
*
|
*
|
||||||
* @retval bool True if system is compatible, False otherwise
|
* @retval bool True if system is compatible, False otherwise
|
||||||
**/
|
**/
|
||||||
public function checkCompatibility() {
|
public function checkCompatibility() {
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a configuration variable value
|
* Get a configuration variable value
|
||||||
*
|
*
|
||||||
* @param[in] $var string The configuration variable name
|
* @param[in] $var string The configuration variable name
|
||||||
* @param[in] $default mixed The default value to return if configuration variable
|
* @param[in] $default mixed The default value to return if configuration variable
|
||||||
* is not set (Default : null)
|
* is not set (Default : null)
|
||||||
* @param[in] $cast string The type of expected value. The configuration variable
|
* @param[in] $cast string The type of expected value. The configuration variable
|
||||||
* value will be cast as this type. Could be : bool, int,
|
* value will be cast as this type. Could be : bool, int,
|
||||||
* float or string. (Optional, default : raw value)
|
* float or string. (Optional, default : raw value)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration variable value
|
* @retval mixed The configuration variable value
|
||||||
**/
|
**/
|
||||||
public function getConfig($var, $default=null, $cast=null) {
|
public function getConfig($var, $default=null, $cast=null) {
|
||||||
return LSconfig :: get($var, $default, $cast, $this -> config);
|
return LSconfig :: get($var, $default, $cast, $this -> config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set log level
|
* Set log level
|
||||||
*
|
*
|
||||||
* @param[in] $level string The level
|
* @param[in] $level string The level
|
||||||
*
|
*
|
||||||
* @retval bool True if log level set, False otherwise
|
* @retval bool True if log level set, False otherwise
|
||||||
**/
|
**/
|
||||||
public function setLevel($level) {
|
public function setLevel($level) {
|
||||||
if (!is_null($level) && !LSlog :: checkLevelExists($level)) {
|
if (!is_null($level) && !LSlog :: checkLevelExists($level)) {
|
||||||
self :: log_error("Invalid log level '$level'");
|
self :: log_error("Invalid log level '$level'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
self :: log_debug("Log handler ".get_called_class()." level set to ".(is_null($level)?'default':$level));
|
self :: log_debug("Log handler ".get_called_class()." level set to ".(is_null($level)?'default':$level));
|
||||||
$this -> level = $level;
|
$this -> level = $level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check level against configured level
|
* Check level against configured level
|
||||||
*
|
*
|
||||||
* @param[in] $level string The level
|
* @param[in] $level string The level
|
||||||
*
|
*
|
||||||
* @retval bool True if a message with this level have to be logged, False otherwise
|
* @retval bool True if a message with this level have to be logged, False otherwise
|
||||||
**/
|
**/
|
||||||
public function checkLevel($level) {
|
public function checkLevel($level) {
|
||||||
return LSlog :: checkLevel($level, $this -> level);
|
return LSlog :: checkLevel($level, $this -> level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check logger against configured loggers filters
|
* Check logger against configured loggers filters
|
||||||
*
|
*
|
||||||
* @param[in] $logger string The logger
|
* @param[in] $logger string The logger
|
||||||
*
|
*
|
||||||
* @retval bool True if message of this logger have to be logged, False otherwise
|
* @retval bool True if message of this logger have to be logged, False otherwise
|
||||||
**/
|
**/
|
||||||
public function checkLogger($logger) {
|
public function checkLogger($logger) {
|
||||||
if (!$this -> loggers && !$this -> excluded_loggers)
|
if (!$this -> loggers && !$this -> excluded_loggers)
|
||||||
return true;
|
return true;
|
||||||
if ($this -> loggers && in_array($logger, $this -> loggers))
|
if ($this -> loggers && in_array($logger, $this -> loggers))
|
||||||
return true;
|
return true;
|
||||||
if ($this -> excluded_loggers && !in_array($logger, $this -> excluded_loggers))
|
if ($this -> excluded_loggers && !in_array($logger, $this -> excluded_loggers))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a message
|
* Format a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval string The formated message to log
|
* @retval string The formated message to log
|
||||||
**/
|
**/
|
||||||
protected function format($level, $message, $logger=null) {
|
protected function format($level, $message, $logger=null) {
|
||||||
global $argv;
|
global $argv;
|
||||||
return getFData(
|
return getFData(
|
||||||
$this -> format,
|
$this -> format,
|
||||||
array(
|
array(
|
||||||
'level' => $level,
|
'level' => $level,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'logger' => ($logger?$logger:'default'),
|
'logger' => ($logger?$logger:'default'),
|
||||||
'clibinpath' => (isset($argv)?basename($argv[0]):'unknown bin path'),
|
'clibinpath' => (isset($argv)?basename($argv[0]):'unknown bin path'),
|
||||||
'requesturi' => (isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'unknown request URI'),
|
'requesturi' => (isset($_SERVER['REQUEST_URI'])?$_SERVER['REQUEST_URI']:'unknown request URI'),
|
||||||
'remoteaddr' => (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'unknown remote address'),
|
'remoteaddr' => (isset($_SERVER['REMOTE_ADDR'])?$_SERVER['REMOTE_ADDR']:'unknown remote address'),
|
||||||
'ldapservername' => self :: getLdapServerName(),
|
'ldapservername' => self :: getLdapServerName(),
|
||||||
'authuser' => self :: getAuthenticatedUserDN(),
|
'authuser' => self :: getAuthenticatedUserDN(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to retreive current LDAP server name
|
* Helper to retreive current LDAP server name
|
||||||
*
|
*
|
||||||
* @retval string Current LDAP server name
|
* @retval string Current LDAP server name
|
||||||
**/
|
**/
|
||||||
private static function getLdapServerName() {
|
private static function getLdapServerName() {
|
||||||
if (LSsession :: $ldapServer) {
|
if (LSsession :: $ldapServer) {
|
||||||
if (isset(LSsession :: $ldapServer['name']))
|
if (isset(LSsession :: $ldapServer['name']))
|
||||||
return LSsession :: $ldapServer['name'];
|
return LSsession :: $ldapServer['name'];
|
||||||
else
|
else
|
||||||
return "#".LSsession :: $ldapServerId;
|
return "#".LSsession :: $ldapServerId;
|
||||||
}
|
}
|
||||||
return "Not connected";
|
return "Not connected";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper to retreive current authenticated user DN
|
* Helper to retreive current authenticated user DN
|
||||||
*
|
*
|
||||||
* @retval string Current authenticated user DN
|
* @retval string Current authenticated user DN
|
||||||
**/
|
**/
|
||||||
private static function getAuthenticatedUserDN() {
|
private static function getAuthenticatedUserDN() {
|
||||||
$auth_dn = LSsession :: getLSuserObjectDn();
|
$auth_dn = LSsession :: getLSuserObjectDn();
|
||||||
if ($auth_dn)
|
if ($auth_dn)
|
||||||
return LSsession :: getLSuserObjectDn();
|
return LSsession :: getLSuserObjectDn();
|
||||||
return "Anonymous";
|
return "Anonymous";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,32 +29,32 @@ LSsession :: loadLSclass('LSlog_staticLoggerClass');
|
||||||
*/
|
*/
|
||||||
class LSlog_logger extends LSlog_staticLoggerClass {
|
class LSlog_logger extends LSlog_staticLoggerClass {
|
||||||
|
|
||||||
// Name
|
// Name
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
// The handler configuration
|
// The handler configuration
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
// Enabled/disabled
|
// Enabled/disabled
|
||||||
private $enabled;
|
private $enabled;
|
||||||
|
|
||||||
// Level
|
// Level
|
||||||
private $level;
|
private $level;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $name string The logger name
|
* @param[in] $name string The logger name
|
||||||
* @param[in] $config array The handler configuration (optional, default: array())
|
* @param[in] $config array The handler configuration (optional, default: array())
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($name, $config=array()) {
|
public function __construct($name, $config=array()) {
|
||||||
$this -> name = $name;
|
$this -> name = $name;
|
||||||
$this -> config = $config;
|
$this -> config = $config;
|
||||||
$this -> enabled = $this -> getConfig('enabled', true, 'boolean');
|
$this -> enabled = $this -> getConfig('enabled', true, 'boolean');
|
||||||
$this -> level = $this -> getConfig('level');
|
$this -> level = $this -> getConfig('level');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allow conversion of LSlog_logger to string
|
* Allow conversion of LSlog_logger to string
|
||||||
|
@ -65,153 +65,153 @@ class LSlog_logger extends LSlog_staticLoggerClass {
|
||||||
return "<".get_class($this)." ".$this -> name.">";
|
return "<".get_class($this)." ".$this -> name.">";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a configuration variable value
|
* Get a configuration variable value
|
||||||
*
|
*
|
||||||
* @param[in] $var string The configuration variable name
|
* @param[in] $var string The configuration variable name
|
||||||
* @param[in] $default mixed The default value to return if configuration variable
|
* @param[in] $default mixed The default value to return if configuration variable
|
||||||
* is not set (Default : null)
|
* is not set (Default : null)
|
||||||
* @param[in] $cast string The type of expected value. The configuration variable
|
* @param[in] $cast string The type of expected value. The configuration variable
|
||||||
* value will be cast as this type. Could be : bool, int,
|
* value will be cast as this type. Could be : bool, int,
|
||||||
* float or string. (Optional, default : raw value)
|
* float or string. (Optional, default : raw value)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration variable value
|
* @retval mixed The configuration variable value
|
||||||
**/
|
**/
|
||||||
public function getConfig($var, $default=null, $cast=null) {
|
public function getConfig($var, $default=null, $cast=null) {
|
||||||
return LSconfig :: get($var, $default, $cast, $this -> config);
|
return LSconfig :: get($var, $default, $cast, $this -> config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get logger info
|
* Get logger info
|
||||||
*
|
*
|
||||||
* @param[in] $key string The info name
|
* @param[in] $key string The info name
|
||||||
*
|
*
|
||||||
* @retval mixed The info value
|
* @retval mixed The info value
|
||||||
**/
|
**/
|
||||||
public function __get($key) {
|
public function __get($key) {
|
||||||
switch ($key) {
|
switch ($key) {
|
||||||
case 'name':
|
case 'name':
|
||||||
return $this -> name;
|
return $this -> name;
|
||||||
case 'enabled':
|
case 'enabled':
|
||||||
return $this -> enabled;
|
return $this -> enabled;
|
||||||
case 'level':
|
case 'level':
|
||||||
return $this -> level;
|
return $this -> level;
|
||||||
}
|
}
|
||||||
// Unknown key, log warning
|
// Unknown key, log warning
|
||||||
self :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
self :: log_warning("$this -> __get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check level against configured level
|
* Check level against configured level
|
||||||
*
|
*
|
||||||
* @param[in] $level string The level
|
* @param[in] $level string The level
|
||||||
*
|
*
|
||||||
* @retval bool True if a message with this level have to be logged, False otherwise
|
* @retval bool True if a message with this level have to be logged, False otherwise
|
||||||
**/
|
**/
|
||||||
public function checkLevel($level) {
|
public function checkLevel($level) {
|
||||||
// If no level configured, always log
|
// If no level configured, always log
|
||||||
if (!$this -> enabled || !$this -> level)
|
if (!$this -> enabled || !$this -> level)
|
||||||
return True;
|
return True;
|
||||||
return LSlog :: checkLevel($level, $this -> level);
|
return LSlog :: checkLevel($level, $this -> level);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message) {
|
public function logging($level, $message) {
|
||||||
if (!$this -> enabled || !$this -> checkLevel($level))
|
if (!$this -> enabled || !$this -> checkLevel($level))
|
||||||
return;
|
return;
|
||||||
LSlog :: logging($level, $message, $this -> name);
|
LSlog :: logging($level, $message, $this -> name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Public logging methods
|
* Public logging methods
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level DEBUG
|
* Log a message with level DEBUG
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function trace($message) {
|
public function trace($message) {
|
||||||
$this -> logging('TRACE', $message);
|
$this -> logging('TRACE', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level DEBUG
|
* Log a message with level DEBUG
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function debug($message) {
|
public function debug($message) {
|
||||||
$this -> logging('DEBUG', $message);
|
$this -> logging('DEBUG', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level INFO
|
* Log a message with level INFO
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function info($message) {
|
public function info($message) {
|
||||||
$this -> logging('INFO', $message);
|
$this -> logging('INFO', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level WARNING
|
* Log a message with level WARNING
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function warning($message) {
|
public function warning($message) {
|
||||||
$this -> logging('WARNING', $message);
|
$this -> logging('WARNING', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level ERROR
|
* Log a message with level ERROR
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function error($message) {
|
public function error($message) {
|
||||||
$this -> logging('ERROR', $message);
|
$this -> logging('ERROR', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message with level FATAL
|
* Log a message with level FATAL
|
||||||
*
|
*
|
||||||
* @param[in] $message The message to log
|
* @param[in] $message The message to log
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function fatal($message) {
|
public function fatal($message) {
|
||||||
$this -> logging('FATAL', $message);
|
$this -> logging('FATAL', $message);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an exception
|
* Log an exception
|
||||||
*
|
*
|
||||||
* @param[in] $exception Exception The exception to log
|
* @param[in] $exception Exception The exception to log
|
||||||
* @param[in] $prefix string|null Custom message prefix (optional, see LSlog :: exception())
|
* @param[in] $prefix string|null Custom message prefix (optional, see LSlog :: exception())
|
||||||
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function exception($exception, $prefix=null, $fatal=true) {
|
public function exception($exception, $prefix=null, $fatal=true) {
|
||||||
if (!$this -> enabled)
|
if (!$this -> enabled)
|
||||||
return;
|
return;
|
||||||
LSlog :: exception($exception, $prefix, $fatal, $this -> name);
|
LSlog :: exception($exception, $prefix, $fatal, $this -> name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,15 +40,15 @@ class LSlog_staticLoggerClass {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an exception via class logger
|
* Log an exception via class logger
|
||||||
*
|
*
|
||||||
* @param[in] $exception Exception The exception to log
|
* @param[in] $exception Exception The exception to log
|
||||||
* @param[in] $prefix string|null Custom message prefix (optional, see self :: log_exception())
|
* @param[in] $prefix string|null Custom message prefix (optional, see self :: log_exception())
|
||||||
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
protected static function log_exception($exception, $prefix=null, $fatal=true) {
|
protected static function log_exception($exception, $prefix=null, $fatal=true) {
|
||||||
LSlog :: get_logger(get_called_class()) -> exception($exception, $prefix, $fatal);
|
LSlog :: get_logger(get_called_class()) -> exception($exception, $prefix, $fatal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,91 +27,91 @@
|
||||||
*/
|
*/
|
||||||
class LSlog_syslog extends LSlog_handler {
|
class LSlog_syslog extends LSlog_handler {
|
||||||
|
|
||||||
// Force syslog priority
|
// Force syslog priority
|
||||||
private $priority = null;
|
private $priority = null;
|
||||||
|
|
||||||
// Levels to syslog priority mapping
|
// Levels to syslog priority mapping
|
||||||
private static $levels2priority = array (
|
private static $levels2priority = array (
|
||||||
'EMERG' => LOG_EMERG, // system is unusable
|
'EMERG' => LOG_EMERG, // system is unusable
|
||||||
'ALERT' => LOG_ALERT, // action must be taken immediately
|
'ALERT' => LOG_ALERT, // action must be taken immediately
|
||||||
'CRITICAL' => LOG_CRIT, // critical conditions
|
'CRITICAL' => LOG_CRIT, // critical conditions
|
||||||
'ERROR' => LOG_ERR, // error conditions
|
'ERROR' => LOG_ERR, // error conditions
|
||||||
'WARNING' => LOG_WARNING, // warning conditions
|
'WARNING' => LOG_WARNING, // warning conditions
|
||||||
'NOTICE' => LOG_NOTICE, // normal, but significant, condition
|
'NOTICE' => LOG_NOTICE, // normal, but significant, condition
|
||||||
'INFO' => LOG_INFO, // informational message
|
'INFO' => LOG_INFO, // informational message
|
||||||
'DEBUG' => LOG_DEBUG, // debug-level message
|
'DEBUG' => LOG_DEBUG, // debug-level message
|
||||||
'TRACE' => LOG_DEBUG, // also debug-level message
|
'TRACE' => LOG_DEBUG, // also debug-level message
|
||||||
);
|
);
|
||||||
|
|
||||||
// Default syslog priority (used if level is not provided or invalid)
|
// Default syslog priority (used if level is not provided or invalid)
|
||||||
private static $default_priority = LOG_WARNING;
|
private static $default_priority = LOG_WARNING;
|
||||||
|
|
||||||
// Default datetime prefix (enabled/disabled)
|
// Default datetime prefix (enabled/disabled)
|
||||||
protected $default_datetime_prefix = false;
|
protected $default_datetime_prefix = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
$this -> priority = static :: getConfig('priority');
|
$this -> priority = static :: getConfig('priority');
|
||||||
if ($this -> enabled)
|
if ($this -> enabled)
|
||||||
self :: log_trace("$this Enabled", get_class($this));
|
self :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return list of details for the string representation of the LSlog_email
|
* Return list of details for the string representation of the LSlog_email
|
||||||
*
|
*
|
||||||
* @retval array List of details for the string representation of the LSlog_email
|
* @retval array List of details for the string representation of the LSlog_email
|
||||||
*/
|
*/
|
||||||
public function __toStringDetails() {
|
public function __toStringDetails() {
|
||||||
return array_merge(
|
return array_merge(
|
||||||
array("priority=".$this -> priority),
|
array("priority=".$this -> priority),
|
||||||
parent :: __toStringDetails()
|
parent :: __toStringDetails()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check system compatibility with this handler
|
* Check system compatibility with this handler
|
||||||
*
|
*
|
||||||
* @retval bool True if system is compatible, False otherwise
|
* @retval bool True if system is compatible, False otherwise
|
||||||
**/
|
**/
|
||||||
public function checkCompatibility() {
|
public function checkCompatibility() {
|
||||||
return function_exists('syslog');
|
return function_exists('syslog');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
return syslog(
|
return syslog(
|
||||||
$this -> level2priority($level),
|
$this -> level2priority($level),
|
||||||
$this -> format($level, $message, $logger)
|
$this -> format($level, $message, $logger)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get syslog corresponding priority to a specific log level
|
* Get syslog corresponding priority to a specific log level
|
||||||
*
|
*
|
||||||
* @param[in] $level string The log level
|
* @param[in] $level string The log level
|
||||||
*
|
*
|
||||||
* @retval int Syslog corresponding priority
|
* @retval int Syslog corresponding priority
|
||||||
**/
|
**/
|
||||||
private function level2priority($level) {
|
private function level2priority($level) {
|
||||||
if ($this -> priority && $level != $this -> priority)
|
if ($this -> priority && $level != $this -> priority)
|
||||||
return $this -> level2priority($this -> priority);
|
return $this -> level2priority($this -> priority);
|
||||||
if (array_key_exists($level, static :: $levels2priority))
|
if (array_key_exists($level, static :: $levels2priority))
|
||||||
return static :: $levels2priority[$level];
|
return static :: $levels2priority[$level];
|
||||||
return static :: $default_priority;
|
return static :: $default_priority;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,34 +27,34 @@
|
||||||
*/
|
*/
|
||||||
class LSlog_system extends LSlog_handler {
|
class LSlog_system extends LSlog_handler {
|
||||||
|
|
||||||
// Default datetime prefix (enabled/disabled)
|
// Default datetime prefix (enabled/disabled)
|
||||||
protected $default_datetime_prefix = false;
|
protected $default_datetime_prefix = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param[in] $config array The handler configuration
|
* @param[in] $config array The handler configuration
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function __construct($config) {
|
public function __construct($config) {
|
||||||
parent :: __construct($config);
|
parent :: __construct($config);
|
||||||
if ($this -> enabled)
|
if ($this -> enabled)
|
||||||
self :: log_trace("$this Enabled", get_class($this));
|
self :: log_trace("$this Enabled", get_class($this));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message
|
* Log a message
|
||||||
*
|
*
|
||||||
* @param[in] $level string The message level
|
* @param[in] $level string The message level
|
||||||
* @param[in] $message string The message
|
* @param[in] $message string The message
|
||||||
* @param[in] $logger string|null The logger name (optional, default: null)
|
* @param[in] $logger string|null The logger name (optional, default: null)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function logging($level, $message, $logger=null) {
|
public function logging($level, $message, $logger=null) {
|
||||||
error_log(
|
error_log(
|
||||||
$this -> format($level, $message, $logger)
|
$this -> format($level, $message, $logger)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,9 +73,9 @@ class LSrelation extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
@ -123,7 +123,7 @@ class LSrelation extends LSlog_staticLoggerClass {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// Unknown key, log warning
|
// Unknown key, log warning
|
||||||
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1236,12 +1236,12 @@ class LSsearch extends LSlog_staticLoggerClass {
|
||||||
return $this -> _canCopy;
|
return $this -> _canCopy;
|
||||||
}
|
}
|
||||||
elseif ($key=='predefinedFilters') {
|
elseif ($key=='predefinedFilters') {
|
||||||
$retval=array();
|
$retval=array();
|
||||||
if (is_array($this -> config['predefinedFilters'])) {
|
if (is_array($this -> config['predefinedFilters'])) {
|
||||||
foreach($this -> config['predefinedFilters'] as $filter => $label) {
|
foreach($this -> config['predefinedFilters'] as $filter => $label) {
|
||||||
$retval[$filter]=__($label);
|
$retval[$filter]=__($label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
elseif ($key=='extraDisplayedColumns') {
|
elseif ($key=='extraDisplayedColumns') {
|
||||||
|
|
|
@ -264,9 +264,9 @@ class LSsearchEntry extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $param The configuration parameter
|
* @param[] $param The configuration parameter
|
||||||
* @param[] $default The default value (default : null)
|
* @param[] $default The default value (default : null)
|
||||||
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
* @param[] $cast Cast resulting value in specific type (default : disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -83,10 +83,11 @@ class LSselect extends LSlog_staticLoggerClass {
|
||||||
/**
|
/**
|
||||||
* Return a configuration parameter (or default value)
|
* Return a configuration parameter (or default value)
|
||||||
*
|
*
|
||||||
* @param[] $id string The LSselect ID
|
* @param[] $id string The LSselect ID
|
||||||
* @param[] $param string The configuration parameter
|
* @param[] $param string The configuration parameter
|
||||||
* @param[] $default mixed The default value (optional, default : null)
|
* @param[] $default mixed The default value (optional, default : null)
|
||||||
* @param[] $cast Cast string|null resulting value in specific type (optional, default : null=disabled)
|
* @param[] $cast Cast string|null resulting value in specific type
|
||||||
|
* (optional, default : null=disabled)
|
||||||
*
|
*
|
||||||
* @retval mixed The configuration parameter value or default value if not set
|
* @retval mixed The configuration parameter value or default value if not set
|
||||||
**/
|
**/
|
||||||
|
|
|
@ -246,15 +246,15 @@ class LSsession {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log an exception via class logger
|
* Log an exception via class logger
|
||||||
*
|
*
|
||||||
* @param[in] $exception Exception The exception to log
|
* @param[in] $exception Exception The exception to log
|
||||||
* @param[in] $prefix string|null Custom message prefix (optional, see self :: log_exception())
|
* @param[in] $prefix string|null Custom message prefix (optional, see self :: log_exception())
|
||||||
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
* @param[in] $fatal boolean Log exception as a fatal error (optional, default: true)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
protected static function log_exception($exception, $prefix=null, $fatal=true) {
|
protected static function log_exception($exception, $prefix=null, $fatal=true) {
|
||||||
if (class_exists('LSlog')) {
|
if (class_exists('LSlog')) {
|
||||||
LSlog :: get_logger(get_called_class()) -> exception($exception, $prefix, $fatal);
|
LSlog :: get_logger(get_called_class()) -> exception($exception, $prefix, $fatal);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -73,7 +73,7 @@ class LSurlRequest extends LSlog_staticLoggerClass {
|
||||||
return urldecode($this->url_params[$key]);
|
return urldecode($this->url_params[$key]);
|
||||||
}
|
}
|
||||||
// Unknown key, log warning
|
// Unknown key, log warning
|
||||||
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
self :: log_warning("__get($key): invalid property requested\n".LSlog :: get_debug_backtrace_context());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,7 +69,7 @@ function getFData($format,$data,$meth=NULL) {
|
||||||
else {
|
else {
|
||||||
$val = $data[$ch[1]];
|
$val = $data[$ch[1]];
|
||||||
}
|
}
|
||||||
$val=_getFData_extractAndModify($val,$ch);
|
$val=_getFData_extractAndModify($val,$ch);
|
||||||
$format[$i]=str_replace($ch[0],$val,$format[$i]);
|
$format[$i]=str_replace($ch[0],$val,$format[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ function getFData($format,$data,$meth=NULL) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = $value[0];
|
$value = $value[0];
|
||||||
}
|
}
|
||||||
$value=_getFData_extractAndModify($value,$ch);
|
$value=_getFData_extractAndModify($value,$ch);
|
||||||
$format[$i]=str_replace($ch[0],$value,$format[$i]);
|
$format[$i]=str_replace($ch[0],$value,$format[$i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -108,7 +108,7 @@ function getFData($format,$data,$meth=NULL) {
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = $value[0];
|
$value = $value[0];
|
||||||
}
|
}
|
||||||
$value=_getFData_extractAndModify($value,$ch);
|
$value=_getFData_extractAndModify($value,$ch);
|
||||||
$format[$i]=str_replace($ch[0],$value,$format[$i]);
|
$format[$i]=str_replace($ch[0],$value,$format[$i]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -120,7 +120,7 @@ function getFData($format,$data,$meth=NULL) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
while (preg_match($expr,$format[$i],$ch)) {
|
while (preg_match($expr,$format[$i],$ch)) {
|
||||||
$val=_getFData_extractAndModify($data,$ch);
|
$val=_getFData_extractAndModify($data,$ch);
|
||||||
$format[$i]=str_replace($ch[0],$val,$format[$i]);
|
$format[$i]=str_replace($ch[0],$val,$format[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue