mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 11:52:59 +01:00
- LSldapObject : Ajout des méthodes suivantes :
-> getSubDnValue() -> getSubDnName() - LSview/LSselect : utilisation de la méthode getSubDnName() plutôt que le code en local - config.inc.php : -> Modification du paramètre ldapServer['subDn'] -> Ajout du paramètre LSaccess pour la composition du menu hors config subDn -> Suppression ldapServer['LSobjets'] : suppression du pré-chargement (cf.ci-dessous) - LSsession : -> Rédéfinition de la méthode de construction du menu de l'interface (bug #1665) -> Mise en cache de LSaccess -> top.tpl : le bouton de rafraichissement subDn devient un bouton de rafraichissement génerale de LSsession (config / LSaccess / subDn) -> Suppression du pré-chargement des objets et donc de la méthode loadLSobjects() -> Ajout d'une méthode in_menu() utilisé entre par la méthode canAccess() pour valider les accès aux objets - create.php : Correction d'un bug de chargement d'objet. - config.error_code.php : Correction bug encodage - index_ajax.php : -> Correction de bugs de chargement d'objets -> Suppression du code de gestion des retours d'erreur multiplié et inutile
This commit is contained in:
parent
a8931db30d
commit
7f82e8eb49
9 changed files with 657 additions and 557 deletions
|
@ -248,7 +248,7 @@ $GLOBALS['LSerror_code'] = array (
|
||||||
'level' => 'c'
|
'level' => 'c'
|
||||||
),
|
),
|
||||||
1011 => array (
|
1011 => array (
|
||||||
'msg' => _("LSsession : Vous n'êtes pas authorisé à effectuer cette action."),
|
'msg' => _("LSsession : Vous n'êtes pas authorisé à effectuer cette action."),
|
||||||
'level' => 'c'
|
'level' => 'c'
|
||||||
),
|
),
|
||||||
1012 => array (
|
1012 => array (
|
||||||
|
|
|
@ -54,10 +54,15 @@ $GLOBALS['LSconfig'] = array(
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'cacheLSrights' => false,
|
'cacheLSrights' => true,
|
||||||
'cacheSearch' => true,
|
'cacheSearch' => true,
|
||||||
'authobject' => 'LSeepeople',
|
'authobject' => 'LSeepeople',
|
||||||
'authobject_pwdattr' => 'userPassword',
|
'authobject_pwdattr' => 'userPassword',
|
||||||
|
'LSaccess' => array(
|
||||||
|
'LSeepeople',
|
||||||
|
'LSeegroup',
|
||||||
|
'LSeecompany'
|
||||||
|
),
|
||||||
'recoverPassword' => array(
|
'recoverPassword' => array(
|
||||||
'mailAttr' => 'mail',
|
'mailAttr' => 'mail',
|
||||||
'recoveryHashAttr' => 'lsRecoveryHash',
|
'recoveryHashAttr' => 'lsRecoveryHash',
|
||||||
|
@ -71,12 +76,7 @@ $GLOBALS['LSconfig'] = array(
|
||||||
'msg' => "Votre nouveau mot de passe : %{mdp}"
|
'msg' => "Votre nouveau mot de passe : %{mdp}"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'emailSender' => 'noreply@lsexample.net',
|
'emailSender' => 'noreply@lsexample.net'
|
||||||
'LSobjects' => array (
|
|
||||||
'LSeepeople',
|
|
||||||
'LSeegroup',
|
|
||||||
'LSeecompany'
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,7 +36,7 @@ if($LSsession -> startLSsession()) {
|
||||||
|
|
||||||
if (isset($LSobject)) {
|
if (isset($LSobject)) {
|
||||||
// Création d'un LSobject
|
// Création d'un LSobject
|
||||||
if (class_exists($LSobject)) {
|
if ($GLOBALS['LSsession'] -> loadLSobject($LSobject)) {
|
||||||
if ( $GLOBALS['LSsession'] -> canCreate($LSobject) ) {
|
if ( $GLOBALS['LSsession'] -> canCreate($LSobject) ) {
|
||||||
$object = new $LSobject();
|
$object = new $LSobject();
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@ class LSldapObject {
|
||||||
var $other_values=array();
|
var $other_values=array();
|
||||||
var $submitError=true;
|
var $submitError=true;
|
||||||
var $_whoami=NULL;
|
var $_whoami=NULL;
|
||||||
|
var $_subDn_value=NULL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
|
@ -929,6 +930,38 @@ class LSldapObject {
|
||||||
function isNew() {
|
function isNew() {
|
||||||
return (!$this -> dn);
|
return (!$this -> dn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la valeur (DN) du subDn de l'objet
|
||||||
|
*
|
||||||
|
* @return string La valeur du subDn de l'object
|
||||||
|
*/
|
||||||
|
function getSubDnValue() {
|
||||||
|
if ($this -> _subDn_value) {
|
||||||
|
return $this -> _subDn_value;
|
||||||
|
}
|
||||||
|
$dn = $this -> getValue('dn');
|
||||||
|
$subDn_value='';
|
||||||
|
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
|
||||||
|
foreach ($subDnLdapServer as $subDn => $subDn_name) {
|
||||||
|
if (isCompatibleDNs($subDn,$dn)&&($subDn!=$dn)) {
|
||||||
|
$subDn_value=$subDn;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this -> _subDn_value = $subDn_value;
|
||||||
|
return $subDn_value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne la nom du subDn de l'objet
|
||||||
|
*
|
||||||
|
* @return string Le nom du subDn de l'object
|
||||||
|
*/
|
||||||
|
function getSubDnName() {
|
||||||
|
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
|
||||||
|
return $subDnLdapServer[$this -> getSubDnValue()];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -144,31 +144,6 @@ class LSsession {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Chargement des objects LdapSaisie
|
|
||||||
*
|
|
||||||
* Chargement des LSobjects contenue dans la variable
|
|
||||||
* $this -> ldapServer['LSobjects']
|
|
||||||
*
|
|
||||||
* @retval boolean true si le chargement a réussi, false sinon.
|
|
||||||
*/
|
|
||||||
function loadLSobjects() {
|
|
||||||
|
|
||||||
$this -> loadLSclass('LSldapObject');
|
|
||||||
|
|
||||||
if(!is_array($this -> ldapServer['LSobjects'])) {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1001,"LSobjects['loads']");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($this -> ldapServer['LSobjects'] as $object) {
|
|
||||||
if ( !$this -> loadLSobject($object) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chargement d'un addons d'LdapSaisie
|
* Chargement d'un addons d'LdapSaisie
|
||||||
*
|
*
|
||||||
|
@ -245,30 +220,36 @@ class LSsession {
|
||||||
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
|
$this -> ldapServerId = $_SESSION['LSsession']['ldapServerId'];
|
||||||
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
$this -> tmp_file = $_SESSION['LSsession']['tmp_file'];
|
||||||
|
|
||||||
if ( $this -> cacheLSrights() ) {
|
if ( $this -> cacheLSrights() && !isset($_REQUEST['LSsession_refresh']) ) {
|
||||||
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
|
$this -> ldapServer = $_SESSION['LSsession']['ldapServer'];
|
||||||
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
|
$this -> LSrights = $_SESSION['LSsession']['LSrights'];
|
||||||
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
|
$this -> LSaccess = $_SESSION['LSsession']['LSaccess'];
|
||||||
if (!$this -> LSldapConnect())
|
if (!$this -> LSldapConnect())
|
||||||
return;
|
return;
|
||||||
$this -> loadLSobjects();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$this -> setLdapServer($this -> ldapServerId);
|
$this -> setLdapServer($this -> ldapServerId);
|
||||||
if (!$this -> LSldapConnect())
|
if (!$this -> LSldapConnect())
|
||||||
return;
|
return;
|
||||||
$this -> loadLSobjects();
|
|
||||||
$this -> loadLSrights();
|
$this -> loadLSrights();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_topDn_refresh'])) ) {
|
if ( $this -> cacheSudDn() && (!isset($_REQUEST['LSsession_refresh'])) ) {
|
||||||
$this -> _subDnLdapServer = $_SESSION['LSsession_subDnLdapServer'];
|
$this -> _subDnLdapServer = $_SESSION['LSsession_subDnLdapServer'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this -> loadLSobject($this -> ldapServer['authobject']);
|
if (!$this -> loadLSobject($this -> ldapServer['authobject'])) {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$this -> ldapServer['authobject']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$this -> LSuserObject = new $this -> ldapServer['authobject']();
|
$this -> LSuserObject = new $this -> ldapServer['authobject']();
|
||||||
$this -> LSuserObject -> loadData($this -> dn);
|
$this -> LSuserObject -> loadData($this -> dn);
|
||||||
$this -> loadLSaccess();
|
|
||||||
|
if ( !$this -> cacheLSrights() || isset($_REQUEST['LSsession_refresh']) ) {
|
||||||
|
$this -> loadLSaccess();
|
||||||
|
}
|
||||||
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
|
$GLOBALS['Smarty'] -> assign('LSsession_username',$this -> LSuserObject -> getDisplayValue());
|
||||||
|
|
||||||
if ($_POST['LSsession_topDn']) {
|
if ($_POST['LSsession_topDn']) {
|
||||||
|
@ -293,8 +274,6 @@ class LSsession {
|
||||||
$this -> setLdapServer(0);
|
$this -> setLdapServer(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this -> loadLSobjects();
|
|
||||||
|
|
||||||
// Connexion au serveur LDAP
|
// Connexion au serveur LDAP
|
||||||
if ($this -> LSldapConnect()) {
|
if ($this -> LSldapConnect()) {
|
||||||
|
|
||||||
|
@ -564,9 +543,9 @@ class LSsession {
|
||||||
foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
|
foreach($this ->ldapServer['subDn'] as $subDn_name => $subDn_config) {
|
||||||
if ($subDn_name == 'LSobject') {
|
if ($subDn_name == 'LSobject') {
|
||||||
if (is_array($subDn_config)) {
|
if (is_array($subDn_config)) {
|
||||||
foreach($subDn_config as $LSobject_name => $LSoject_topDn) {
|
foreach($subDn_config as $LSobject_name => $LSoject_config) {
|
||||||
if ($LSoject_topDn) {
|
if ($LSoject_config['topDn']) {
|
||||||
$topDn = $LSoject_topDn;
|
$topDn = $LSoject_config['topDn'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$topDn = NULL;
|
$topDn = NULL;
|
||||||
|
@ -595,7 +574,9 @@ class LSsession {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$return[$subDn_config] = $subDn_name;
|
if ((isCompatibleDNs($subDn_config['dn'],$this -> ldapServer['ldap_config']['basedn']))&&($subDn_config['dn']!="")) {
|
||||||
|
$return[$subDn_config['dn']] = $subDn_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this -> cacheSudDn()) {
|
if ($this -> cacheSudDn()) {
|
||||||
|
@ -616,15 +597,11 @@ class LSsession {
|
||||||
* @return array() Tableau des subDn trié
|
* @return array() Tableau des subDn trié
|
||||||
*/
|
*/
|
||||||
function getSortSubDnLdapServer() {
|
function getSortSubDnLdapServer() {
|
||||||
if(isset($_SESSION['LSsession']['LSview_subDnLdapServer']) && $this -> cacheSudDn()) {
|
|
||||||
return $_SESSION['LSsession']['LSview_subDnLdapServer'];
|
|
||||||
}
|
|
||||||
$subDnLdapServer = $this -> getSubDnLdapServer();
|
$subDnLdapServer = $this -> getSubDnLdapServer();
|
||||||
if (!$subDnLdapServer) {
|
if (!$subDnLdapServer) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
uksort($subDnLdapServer,"compareDn");
|
uksort($subDnLdapServer,"compareDn");
|
||||||
$_SESSION['LSsession']['LSview_subDnLdapServer']=$subDnLdapServer;
|
|
||||||
return $subDnLdapServer;
|
return $subDnLdapServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -851,7 +828,7 @@ class LSsession {
|
||||||
}
|
}
|
||||||
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
|
$GLOBALS['Smarty'] -> assign('LSsession_css',$Css_txt);
|
||||||
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess);
|
$GLOBALS['Smarty'] -> assign('LSaccess',$this -> LSaccess[$this -> topDn]);
|
||||||
|
|
||||||
// Niveau
|
// Niveau
|
||||||
$listTopDn = $this -> getSubDnLdapServer();
|
$listTopDn = $this -> getSubDnLdapServer();
|
||||||
|
@ -942,26 +919,91 @@ class LSsession {
|
||||||
* @retval void
|
* @retval void
|
||||||
*/
|
*/
|
||||||
function loadLSaccess() {
|
function loadLSaccess() {
|
||||||
if ($this -> canAccess($this -> LSuserObject -> getType(),$this -> dn)) {
|
$LSaccess=array();
|
||||||
$LSaccess = array(
|
if (is_array($this -> ldapServer['subDn'])) {
|
||||||
'SELF' => array(
|
foreach($this -> ldapServer['subDn'] as $name => $config) {
|
||||||
'label' => _('Mon compte'),
|
if ($name=='LSobject') {
|
||||||
'DNs' => $this -> dn
|
if (is_array($config)) {
|
||||||
)
|
|
||||||
);
|
// Définition des subDns
|
||||||
}
|
foreach($config as $objectType => $objectConf) {
|
||||||
else {
|
if ($this -> loadLSobject($objectType)) {
|
||||||
$LSaccess = array();
|
if ($subdnobject = new $objectType()) {
|
||||||
}
|
$tbl = $subdnobject -> getSelectArray();
|
||||||
foreach ($GLOBALS['LSobjects'] as $objecttype => $objectconf) {
|
if (is_array($tbl)) {
|
||||||
if ($this -> canAccess($objecttype) ) {
|
// Définition des accès
|
||||||
$LSaccess[$objecttype] = array (
|
$access=array();
|
||||||
'label' => $objectconf['label'],
|
if (is_array($objectConf['LSobjects'])) {
|
||||||
'Dns' => 'All'
|
foreach($objectConf['LSobjects'] as $type) {
|
||||||
);
|
if ($this -> loadLSobject($type)) {
|
||||||
|
if ($this -> canAccess($type)) {
|
||||||
|
$access[$type] = $GLOBALS['LSobjects'][$type]['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach($tbl as $dn => $dn_name) {
|
||||||
|
$LSaccess[$dn]=$access;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$objectType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((isCompatibleDNs($this -> ldapServer['ldap_config']['basedn'],$config['dn']))&&($config['dn']!='')) {
|
||||||
|
$access=array();
|
||||||
|
if (is_array($config['LSobjects'])) {
|
||||||
|
foreach($config['LSobjects'] as $objectType) {
|
||||||
|
if ($this -> loadLSobject($objectType)) {
|
||||||
|
if ($this -> canAccess($objectType)) {
|
||||||
|
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$LSaccess[$config['dn']]=$access;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if(is_array($this -> ldapServer['LSaccess'])) {
|
||||||
|
$access=array();
|
||||||
|
foreach($this -> ldapServer['LSaccess'] as $objectType) {
|
||||||
|
if ($this -> loadLSobject($objectType)) {
|
||||||
|
if ($this -> canAccess($objectType)) {
|
||||||
|
$access[$objectType] = $GLOBALS['LSobjects'][$objectType]['label'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$LSaccess[$this -> topDn] = $access;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach($LSaccess as $dn => $access) {
|
||||||
|
$LSaccess[$dn] = array_merge(
|
||||||
|
array(
|
||||||
|
'SELF' => _('Mon compte')
|
||||||
|
),
|
||||||
|
$access
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
$this -> LSaccess = $LSaccess;
|
$this -> LSaccess = $LSaccess;
|
||||||
|
$_SESSION['LSsession']['LSaccess'] = $LSaccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1013,10 +1055,24 @@ class LSsession {
|
||||||
* @retval boolean True si l'utilisateur a accès, false sinon
|
* @retval boolean True si l'utilisateur a accès, false sinon
|
||||||
*/
|
*/
|
||||||
function canAccess($LSobject,$dn=NULL,$right=NULL,$attr=NULL) {
|
function canAccess($LSobject,$dn=NULL,$right=NULL,$attr=NULL) {
|
||||||
if (!$this -> loadLSobject($LSobject))
|
if (!$this -> loadLSobject($LSobject)) {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
if ($dn) {
|
if ($dn) {
|
||||||
$whoami = $this -> whoami($dn);
|
$whoami = $this -> whoami($dn);
|
||||||
|
if ($dn==$this -> LSuserObject -> getValue('dn')) {
|
||||||
|
if (!$this -> in_menu('SELF')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$obj = new $LSobject();
|
||||||
|
$obj -> dn = $dn;
|
||||||
|
if (!$this -> in_menu($LSobject,$obj -> getSubDnValue())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.$this -> topDn;
|
$objectdn=$GLOBALS['LSobjects'][$LSobject]['container_dn'].','.$this -> topDn;
|
||||||
|
@ -1272,7 +1328,7 @@ class LSsession {
|
||||||
*
|
*
|
||||||
* @param[in] $subDn string subDn
|
* @param[in] $subDn string subDn
|
||||||
*
|
*
|
||||||
* @return string Le nom du subDn ou '' sinon
|
* @retval string Le nom du subDn ou '' sinon
|
||||||
*/
|
*/
|
||||||
function getSubDnName($subDn=false) {
|
function getSubDnName($subDn=false) {
|
||||||
if (!$subDn) {
|
if (!$subDn) {
|
||||||
|
@ -1291,10 +1347,9 @@ class LSsession {
|
||||||
*
|
*
|
||||||
* @param[in] $type string Le type d'objet
|
* @param[in] $type string Le type d'objet
|
||||||
*
|
*
|
||||||
* @return boolean true si le type d'objet est un subDnObject, false sinon
|
* @retval boolean true si le type d'objet est un subDnObject, false sinon
|
||||||
*/
|
*/
|
||||||
function isSubDnLSobject($type) {
|
function isSubDnLSobject($type) {
|
||||||
debug('seach : '.$type);
|
|
||||||
$result = false;
|
$result = false;
|
||||||
if (is_array($this -> ldapServer['subDn']['LSobject'])) {
|
if (is_array($this -> ldapServer['subDn']['LSobject'])) {
|
||||||
foreach($this -> ldapServer['subDn']['LSobject'] as $key => $value) {
|
foreach($this -> ldapServer['subDn']['LSobject'] as $key => $value) {
|
||||||
|
@ -1305,6 +1360,18 @@ class LSsession {
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retourne si un type d'objet est dans le menu courant
|
||||||
|
*
|
||||||
|
* @retval boolean true si le type d'objet est dans le menu, false sinon
|
||||||
|
*/
|
||||||
|
function in_menu($LSobject,$topDn=NULL) {
|
||||||
|
if (!$topDn) {
|
||||||
|
$topDn=$this -> topDn;
|
||||||
|
}
|
||||||
|
return isset($this -> LSaccess[$topDn][$LSobject]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -20,7 +20,6 @@ if (!isset($_ERRORS)) {
|
||||||
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
$GLOBALS['LSsession'] -> setLdapServer($_REQUEST['server']);
|
||||||
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
if ( $GLOBALS['LSsession'] -> LSldapConnect() ) {
|
||||||
session_start();
|
session_start();
|
||||||
$GLOBALS['LSsession'] -> loadLSobjects();
|
|
||||||
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
|
$list = $GLOBALS['LSsession'] -> getSubDnLdapServerOptions($_SESSION['LSsession_topDn']);
|
||||||
if (is_string($list)) {
|
if (is_string($list)) {
|
||||||
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
$list="<select name='LSsession_topDn' id='LSsession_topDn'>".$list."</select>";
|
||||||
|
@ -29,15 +28,6 @@ if (!isset($_ERRORS)) {
|
||||||
'levelLabel' => $GLOBALS['LSsession'] -> getLevelLabel()
|
'levelLabel' => $GLOBALS['LSsession'] -> getLevelLabel()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (is_array($list)){
|
|
||||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$data = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -47,71 +37,77 @@ if (!isset($_ERRORS)) {
|
||||||
switch($_REQUEST['action']) {
|
switch($_REQUEST['action']) {
|
||||||
case 'onAddFieldBtnClick':
|
case 'onAddFieldBtnClick':
|
||||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
|
||||||
$object = new $_REQUEST['objecttype']();
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
||||||
$object -> loadData($_REQUEST['objectdn']);
|
$object = new $_REQUEST['objecttype']();
|
||||||
$form = $object -> getForm($_REQUEST['idform']);
|
$object -> loadData($_REQUEST['objectdn']);
|
||||||
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
|
$form = $object -> getForm($_REQUEST['idform']);
|
||||||
if ( $emptyField ) {
|
$emptyField=$form -> getEmptyField($_REQUEST['attribute']);
|
||||||
$data = array(
|
if ( $emptyField ) {
|
||||||
'html' => $form -> getEmptyField($_REQUEST['attribute']),
|
$data = array(
|
||||||
'img' => $_REQUEST['img'],
|
'html' => $form -> getEmptyField($_REQUEST['attribute']),
|
||||||
);
|
'img' => $_REQUEST['img'],
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data = array('LSerror' => $GLOBALS['LSerror']->getErrors());
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'refreshField':
|
case 'refreshField':
|
||||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) {
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) ) {
|
||||||
$object = new $_REQUEST['objecttype']();
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
||||||
//$object -> loadData($_REQUEST['objectdn']);
|
$object = new $_REQUEST['objecttype']();
|
||||||
$form = $object -> getForm($_REQUEST['idform']);
|
$form = $object -> getForm($_REQUEST['idform']);
|
||||||
$field=$form -> getElement($_REQUEST['attribute']);
|
$field=$form -> getElement($_REQUEST['attribute']);
|
||||||
$val = $field -> getDisplay(true);
|
$val = $field -> getDisplay(true);
|
||||||
if ( $val ) {
|
if ( $val ) {
|
||||||
$data = array(
|
$data = array(
|
||||||
'html' => $val['html']
|
'html' => $val['html']
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data = array(
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
||||||
'LSerror' => $GLOBALS['LSerror']->getErrors()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'generatePassword':
|
case 'generatePassword':
|
||||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) {
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['viewBtnId'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['idform'])) ) {
|
||||||
$object = new $_REQUEST['objecttype']();
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
||||||
$form = $object -> getForm($_REQUEST['idform']);
|
$object = new $_REQUEST['objecttype']();
|
||||||
$field=$form -> getElement($_REQUEST['attribute']);
|
$form = $object -> getForm($_REQUEST['idform']);
|
||||||
$val = $field -> generatePassword();
|
$field=$form -> getElement($_REQUEST['attribute']);
|
||||||
if ( $val ) {
|
$val = $field -> generatePassword();
|
||||||
$data = array(
|
if ( $val ) {
|
||||||
'generatePassword' => $val,
|
$data = array(
|
||||||
'fieldId' => $_REQUEST['fieldId'],
|
'generatePassword' => $val,
|
||||||
'viewBtnId' => $_REQUEST['viewBtnId']
|
'fieldId' => $_REQUEST['fieldId'],
|
||||||
);
|
'viewBtnId' => $_REQUEST['viewBtnId']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data = array(
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
||||||
'LSerror' => $GLOBALS['LSerror']->getErrors()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'verifyPassword':
|
case 'verifyPassword':
|
||||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) {
|
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['fieldId'])) && (isset($_REQUEST['fieldValue'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['objectdn'])) ) {
|
||||||
$object = new $_REQUEST['objecttype']();
|
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
||||||
$form = $object -> getForm($_REQUEST['idform']);
|
$object = new $_REQUEST['objecttype']();
|
||||||
$object -> loadData($_REQUEST['objectdn']);
|
$form = $object -> getForm($_REQUEST['idform']);
|
||||||
$field=$form -> getElement($_REQUEST['attribute']);
|
$object -> loadData($_REQUEST['objectdn']);
|
||||||
$val = $field -> verifyPassword($_REQUEST['fieldValue']);
|
$field=$form -> getElement($_REQUEST['attribute']);
|
||||||
$data = array(
|
$val = $field -> verifyPassword($_REQUEST['fieldValue']);
|
||||||
'verifyPassword' => $val,
|
$data = array(
|
||||||
'fieldId' => $_REQUEST['fieldId']
|
'verifyPassword' => $val,
|
||||||
);
|
'fieldId' => $_REQUEST['fieldId']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$_REQUEST['objecttype']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -126,27 +122,32 @@ if (!isset($_ERRORS)) {
|
||||||
$object = new $conf['objectType']();
|
$object = new $conf['objectType']();
|
||||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||||
$objRel = new $relationConf['LSobject']();
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||||
$list = $objRel -> $relationConf['list_function']($object);
|
$objRel = new $relationConf['LSobject']();
|
||||||
$_SESSION['LSselect'][$relationConf['LSobject']]=array();
|
$list = $objRel -> $relationConf['list_function']($object);
|
||||||
if (is_array($list)) {
|
$_SESSION['LSselect'][$relationConf['LSobject']]=array();
|
||||||
foreach($list as $o) {
|
if (is_array($list)) {
|
||||||
$_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn();
|
foreach($list as $o) {
|
||||||
|
$_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$data = array(
|
||||||
|
'href' => $_REQUEST['href'],
|
||||||
|
'id' => $_REQUEST['id']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||||
}
|
}
|
||||||
$data = array(
|
|
||||||
'href' => $_REQUEST['href'],
|
|
||||||
'id' => $_REQUEST['id']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -170,38 +171,43 @@ if (!isset($_ERRORS)) {
|
||||||
$object = new $conf['objectType']();
|
$object = new $conf['objectType']();
|
||||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
||||||
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
|
if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) {
|
||||||
$objRel = new $relationConf['LSobject']();
|
if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) {
|
||||||
if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) {
|
$objRel = new $relationConf['LSobject']();
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) {
|
||||||
$list = $objRel -> $relationConf['list_function']($object);
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||||
if (is_array($list)) {
|
$list = $objRel -> $relationConf['list_function']($object);
|
||||||
foreach($list as $o) {
|
if (is_array($list)) {
|
||||||
$data['html'].= "<li class='LSrelation'>".$o -> getDisplayValue()."</li>\n";
|
foreach($list as $o) {
|
||||||
|
$data['html'].= "<li class='LSrelation'>".$o -> getDisplayValue()."</li>\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$data['html'] = "<li>"._('Liste vide.')."</li>\n";
|
||||||
|
}
|
||||||
|
$data['id'] = $_REQUEST['id'];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$data['html'] = "<li>"._('Liste vide.')."</li>\n";
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||||
}
|
}
|
||||||
$data['id'] = $_REQUEST['id'];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$relationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$relationName);
|
$GLOBALS['LSerror'] -> addErrorCode(1014,$relationName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
}
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1014,$relationName);
|
else {
|
||||||
}
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -225,37 +231,42 @@ if (!isset($_ERRORS)) {
|
||||||
$object = new $conf['objectType']();
|
$object = new $conf['objectType']();
|
||||||
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
if (($object -> loadData($conf['objectDn'])) && (isset($object->config['relations'][$conf['relationName']]))) {
|
||||||
$relationConf = $object->config['relations'][$conf['relationName']];
|
$relationConf = $object->config['relations'][$conf['relationName']];
|
||||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
if ($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$conf['relationName'])) {
|
||||||
$objRel = new $relationConf['LSobject']();
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||||
$list = $objRel -> $relationConf['list_function']($object);
|
$objRel = new $relationConf['LSobject']();
|
||||||
if (is_array($list)) {
|
$list = $objRel -> $relationConf['list_function']($object);
|
||||||
$ok=false;
|
if (is_array($list)) {
|
||||||
foreach($list as $o) {
|
$ok=false;
|
||||||
if($o -> getDisplayValue() == $_REQUEST['value']) {
|
foreach($list as $o) {
|
||||||
if (!$o -> deleteOneMember($object)) {
|
if($o -> getDisplayValue() == $_REQUEST['value']) {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
if (!$o -> deleteOneMember($object)) {
|
||||||
}
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||||
else {
|
}
|
||||||
$ok = true;
|
else {
|
||||||
|
$ok = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!$ok) {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!$ok) {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1015,$conf['relationName']);
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']);
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$conf['relationName']);
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$relationConf['LSobject']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -316,9 +327,6 @@ if (!isset($_ERRORS)) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
$GLOBALS['LSerror'] -> addErrorCode(1012);
|
||||||
$data = array(
|
|
||||||
'LSerror' => $GLOBALS['LSerror']->getErrors()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ if($LSsession -> startLSsession()) {
|
||||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||||
|
|
||||||
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
|
|
||||||
|
|
||||||
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
|
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
|
||||||
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
|
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
|
||||||
if (isCompatibleDNs($_SESSION['LSsession']['LSsearch'][$LSobject]['topDn'],$GLOBALS['LSsession'] -> topDn)) {
|
if (isCompatibleDNs($_SESSION['LSsession']['LSsearch'][$LSobject]['topDn'],$GLOBALS['LSsession'] -> topDn)) {
|
||||||
|
@ -67,6 +65,7 @@ if($LSsession -> startLSsession()) {
|
||||||
$selectedTopDn = $GLOBALS['LSsession'] -> topDn;
|
$selectedTopDn = $GLOBALS['LSsession'] -> topDn;
|
||||||
$orderby = false;
|
$orderby = false;
|
||||||
$ordersense = 'ASC';
|
$ordersense = 'ASC';
|
||||||
|
$subDnLdapServer = $GLOBALS['LSsession'] -> getSubDnLdapServer();
|
||||||
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
|
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,12 +210,7 @@ if($LSsession -> startLSsession()) {
|
||||||
|
|
||||||
$subDn_name=false;
|
$subDn_name=false;
|
||||||
if ($doSubDn) {
|
if ($doSubDn) {
|
||||||
reset($subDnLdapServer);
|
$subDn_name = $thisObject -> getSubDnName();
|
||||||
while (!$subDn_name && next($subDnLdapServer)) {
|
|
||||||
if (isCompatibleDNs(key($subDnLdapServer),$thisObject -> getValue('dn'))) {
|
|
||||||
$subDn_name=current($subDnLdapServer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$objectList[]=array(
|
$objectList[]=array(
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
{if $LSsession_subDn!=""}
|
{if $LSsession_subDn!=""}
|
||||||
<form action="index.php" method='post' id='LSsession_topDn_form'>
|
<form action="index.php" method='post' id='LSsession_topDn_form'>
|
||||||
<label>{$label_level}
|
<label>{$label_level}
|
||||||
<a href="index.php?LSsession_topDn_refresh"><img src='templates/images/refresh.png' alt='{$_refresh}' title='{$_refresh}' /></a>
|
<a href="index.php?LSsession_refresh"><img src='templates/images/refresh.png' alt='{$_refresh}' title='{$_refresh}' /></a>
|
||||||
<select name='LSsession_topDn' id='LSsession_topDn'>
|
<select name='LSsession_topDn' id='LSsession_topDn'>
|
||||||
{html_options values=$LSsession_subDn_indexes output=$LSsession_subDn_names selected=$LSsession_subDn}
|
{html_options values=$LSsession_subDn_indexes output=$LSsession_subDn_names selected=$LSsession_subDn}
|
||||||
</select>
|
</select>
|
||||||
|
@ -33,8 +33,8 @@
|
||||||
</form>
|
</form>
|
||||||
{/if}
|
{/if}
|
||||||
<ul class='menu'>
|
<ul class='menu'>
|
||||||
{foreach from=$LSaccess item=item key=LSobject_type}
|
{foreach from=$LSaccess item=label key=LSobject_type}
|
||||||
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$item.label}</a></li>
|
<li class='menu'><a href='view.php?LSobject={$LSobject_type}' class='menu'>{$label}</a></li>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
718
trunk/view.php
718
trunk/view.php
|
@ -30,402 +30,400 @@ if($LSsession -> startLSsession()) {
|
||||||
$LSobject = $_REQUEST['LSobject'];
|
$LSobject = $_REQUEST['LSobject'];
|
||||||
$dn = $_REQUEST['dn'];
|
$dn = $_REQUEST['dn'];
|
||||||
|
|
||||||
if ( $LSobject == 'SELF' ) {
|
if ($GLOBALS['LSsession'] -> in_menu($LSobject)) {
|
||||||
$LSobject = $GLOBALS['LSsession']-> LSuserObject -> getType();
|
|
||||||
$dn = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( $GLOBALS['LSsession'] -> loadLSobject($LSobject) ) {
|
if ( $LSobject == 'SELF' ) {
|
||||||
// Affichage d'un objet
|
$LSobject = $GLOBALS['LSsession']-> LSuserObject -> getType();
|
||||||
if ( $dn!='' ) {
|
$dn = $GLOBALS['LSsession']-> LSuserObject -> getValue('dn');
|
||||||
if ($GLOBALS['LSsession'] -> canAccess($LSobject,$dn)) {
|
}
|
||||||
if ( $GLOBALS['LSsession'] -> canEdit($LSobject,$dn) ) {
|
|
||||||
$LSview_actions[] = array(
|
|
||||||
'label' => _('Modifier'),
|
|
||||||
'url' =>'modify.php?LSobject='.$LSobject.'&dn='.$dn,
|
|
||||||
'action' => 'modify'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($GLOBALS['LSsession'] -> canCreate($LSobject)) {
|
if ( $GLOBALS['LSsession'] -> loadLSobject($LSobject) ) {
|
||||||
$LSview_actions[] = array(
|
// Affichage d'un objet
|
||||||
'label' => _('Copier'),
|
if ( $dn!='' ) {
|
||||||
'url' =>'create.php?LSobject='.$LSobject.'&load='.$dn,
|
if ($GLOBALS['LSsession'] -> canAccess($LSobject,$dn)) {
|
||||||
'action' => 'copy'
|
if ( $GLOBALS['LSsession'] -> canEdit($LSobject,$dn) ) {
|
||||||
);
|
$LSview_actions[] = array(
|
||||||
}
|
'label' => _('Modifier'),
|
||||||
|
'url' =>'modify.php?LSobject='.$LSobject.'&dn='.$dn,
|
||||||
|
'action' => 'modify'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if ($GLOBALS['LSsession'] -> canRemove($LSobject,$dn)) {
|
if ($GLOBALS['LSsession'] -> canCreate($LSobject)) {
|
||||||
$LSview_actions[] = array(
|
$LSview_actions[] = array(
|
||||||
'label' => _('Supprimer'),
|
'label' => _('Copier'),
|
||||||
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$dn,
|
'url' =>'create.php?LSobject='.$LSobject.'&load='.$dn,
|
||||||
'action' => 'delete'
|
'action' => 'copy'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($GLOBALS['LSsession']-> LSuserObject -> getValue('dn') != $dn) {
|
if ($GLOBALS['LSsession'] -> canRemove($LSobject,$dn)) {
|
||||||
$object = new $LSobject();
|
$LSview_actions[] = array(
|
||||||
$object -> loadData($dn);
|
'label' => _('Supprimer'),
|
||||||
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayValue());
|
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$dn,
|
||||||
|
'action' => 'delete'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($GLOBALS['LSsession']-> LSuserObject -> getValue('dn') != $dn) {
|
||||||
|
$object = new $LSobject();
|
||||||
|
$object -> loadData($dn);
|
||||||
|
$GLOBALS['Smarty'] -> assign('pagetitle',$object -> getDisplayValue());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$object = &$GLOBALS['LSsession']-> LSuserObject;
|
||||||
|
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$view = $object -> getView();
|
||||||
|
$view -> displayView();
|
||||||
|
|
||||||
|
// Relations
|
||||||
|
if (is_array($object -> config['relations'])) {
|
||||||
|
$LSrelations=array();
|
||||||
|
foreach($object -> config['relations'] as $relationName => $relationConf) {
|
||||||
|
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) {
|
||||||
|
$return=array('label' => $relationConf['label']);
|
||||||
|
|
||||||
|
$id=rand();
|
||||||
|
$return['id']=$id;
|
||||||
|
$_SESSION['LSrelation'][$id] = array(
|
||||||
|
'relationName' => $relationName,
|
||||||
|
'objectType' => $object -> getType(),
|
||||||
|
'objectDn' => $object -> getDn(),
|
||||||
|
);
|
||||||
|
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$relationName)) {
|
||||||
|
$return['actions'][] = array(
|
||||||
|
'label' => _('Modifier'),
|
||||||
|
'url' => 'select.php?LSobject='.$relationConf['LSobject'],
|
||||||
|
'action' => 'modify'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
||||||
|
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||||
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||||
|
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
||||||
|
if($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
||||||
|
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
||||||
|
$objRel = new $relationConf['LSobject']();
|
||||||
|
$list = $objRel -> $relationConf['list_function']($object);
|
||||||
|
if (is_array($list)) {
|
||||||
|
foreach($list as $o) {
|
||||||
|
$return['objectList'][] = $o -> getDisplayValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$return['objectList']=array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
||||||
|
}
|
||||||
|
$LSrelations[]=$return;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
||||||
|
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||||
|
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||||
|
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$object = &$GLOBALS['LSsession']-> LSuserObject;
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||||
$GLOBALS['Smarty'] -> assign('pagetitle',_('Mon compte'));
|
}
|
||||||
|
}
|
||||||
|
// Affichage d'une liste d'un type d'objet
|
||||||
|
else {
|
||||||
|
$objectList=array();
|
||||||
|
$object = new $LSobject();
|
||||||
|
|
||||||
|
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
||||||
|
|
||||||
|
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
|
||||||
|
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
|
||||||
|
$params = $_SESSION['LSsession']['LSsearch'][$LSobject]['params'];
|
||||||
|
$pattern = $_SESSION['LSsession']['LSsearch'][$LSobject]['pattern'];
|
||||||
|
$recur = $_SESSION['LSsession']['LSsearch'][$LSobject]['recur'];
|
||||||
|
if ($recur) {
|
||||||
|
$topDn = $GLOBALS['LSsession'] -> topDn;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
||||||
|
}
|
||||||
|
$approx = $_SESSION['LSsession']['LSsearch'][$LSobject]['approx'];
|
||||||
|
$orderby = $_SESSION['LSsession']['LSsearch'][$LSobject]['orderby'];
|
||||||
|
$ordersense = $_SESSION['LSsession']['LSsearch'][$LSobject]['ordersense'];
|
||||||
|
$doSubDn = $_SESSION['LSsession']['LSsearch'][$LSobject]['doSubDn'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$filter = NULL;
|
||||||
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
||||||
|
$params = array('scope' => 'one');
|
||||||
|
$pattern = false;
|
||||||
|
$recur = false;
|
||||||
|
$approx = false;
|
||||||
|
$orderby = false;
|
||||||
|
$ordersense = 'ASC';
|
||||||
|
$subDnLdapServer = $GLOBALS['LSsession'] -> getSubDnLdapServer();
|
||||||
|
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$view = $object -> getView();
|
if (isset($_REQUEST['LSview_search_submit'])) {
|
||||||
$view -> displayView();
|
if (isset($_REQUEST['LSview_pattern']) && ($_REQUEST['LSview_pattern']!=$pattern)) {
|
||||||
|
$pattern = $_REQUEST['LSview_pattern'];
|
||||||
|
}
|
||||||
|
|
||||||
// Relations
|
$approx = (isset($_REQUEST['LSview_approx']));
|
||||||
if (is_array($object -> config['relations'])) {
|
|
||||||
$LSrelations=array();
|
|
||||||
foreach($object -> config['relations'] as $relationName => $relationConf) {
|
|
||||||
if ($GLOBALS['LSsession'] -> relationCanAccess($object -> getValue('dn'),$relationName)) {
|
|
||||||
$return=array('label' => $relationConf['label']);
|
|
||||||
|
|
||||||
$id=rand();
|
if ($pattern && $pattern!='') {
|
||||||
$return['id']=$id;
|
$filter='(|';
|
||||||
$_SESSION['LSrelation'][$id] = array(
|
if ($approx) {
|
||||||
'relationName' => $relationName,
|
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||||
'objectType' => $object -> getType(),
|
$filter.='('.$attr_name.'~='.$pattern.')';
|
||||||
'objectDn' => $object -> getDn(),
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach ($object -> attrs as $attr_name => $attr_val) {
|
||||||
|
$filter.='('.$attr_name.'=*'.$pattern.'*)';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$filter.=')';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$filter = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_REQUEST['LSview_recur'])) {
|
||||||
|
$recur = true;
|
||||||
|
$params['scope'] = 'sub';
|
||||||
|
$topDn = $GLOBALS['LSsession'] -> topDn;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$recur = false;
|
||||||
|
$params['scope'] = 'one';
|
||||||
|
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sort=false;
|
||||||
|
if ((isset($_REQUEST['orderby']))) {
|
||||||
|
$possible_values= array('displayValue','subDn');
|
||||||
|
if (in_array($_REQUEST['orderby'],$possible_values)) {
|
||||||
|
$sort=true;
|
||||||
|
if ($orderby==$_REQUEST['orderby']) {
|
||||||
|
$ordersense = ($ordersense=='ASC')?'DESC':'ASC';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$ordersense = 'ASC';
|
||||||
|
}
|
||||||
|
$orderby=$_REQUEST['orderby'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_subDn',$doSubDn);
|
||||||
|
|
||||||
|
// Sauvegarde en Session
|
||||||
|
$_SESSION['LSsession']['LSsearch'][$LSobject] = array(
|
||||||
|
'filter' => $filter,
|
||||||
|
'topDn' => $topDn,
|
||||||
|
'params' => $params,
|
||||||
|
'pattern' => $pattern,
|
||||||
|
'recur' => $recur,
|
||||||
|
'approx' => $approx,
|
||||||
|
'orderby' => $orderby,
|
||||||
|
'ordersense' => $ordersense,
|
||||||
|
'doSubDn' => $doSubDn
|
||||||
|
);
|
||||||
|
|
||||||
|
$GLOBALS['Smarty']->assign('LSview_search_pattern',$pattern);
|
||||||
|
|
||||||
|
if ($recur) {
|
||||||
|
$GLOBALS['Smarty']->assign('LSview_search_recur',true);
|
||||||
|
}
|
||||||
|
if ($approx) {
|
||||||
|
$GLOBALS['Smarty']->assign('LSview_search_approx',true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hidden fields
|
||||||
|
$GLOBALS['Smarty']->assign('LSview_search_hidden_fields',array(
|
||||||
|
'LSobject' => $LSobject,
|
||||||
|
'LSview_search_submit' => 1
|
||||||
|
));
|
||||||
|
|
||||||
|
// Hash de la recherche déterminer à partir des paramètres de la recherche
|
||||||
|
$hash = mhash (MHASH_MD5,
|
||||||
|
print_r(
|
||||||
|
array(
|
||||||
|
'LSobject' => $LSobject,
|
||||||
|
'filter' => $filter,
|
||||||
|
'topDn' => $topDn,
|
||||||
|
'params' => $params
|
||||||
|
),
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (($GLOBALS['LSsession'] -> cacheSearch()) && isset($_SESSION['LSsession']['LSsearch'][$hash]) && (!isset($_REQUEST['refresh']))) {
|
||||||
|
// On affiche à partir du cache
|
||||||
|
$searchData=$_SESSION['LSsession']['LSsearch'][$hash];
|
||||||
|
debug('Recherche : From cache');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
debug('Recherche : Load');
|
||||||
|
if ($GLOBALS['LSsession'] -> canCreate($LSobject)) {
|
||||||
|
$LSview_actions[] = array (
|
||||||
|
'label' => _('Nouveau'),
|
||||||
|
'url' => 'create.php?LSobject='.$LSobject,
|
||||||
|
'action' => 'create'
|
||||||
|
);
|
||||||
|
$canCopy=true;
|
||||||
|
}
|
||||||
|
$LSview_actions[] = array (
|
||||||
|
'label' => _('Rafraîchir'),
|
||||||
|
'url' => 'view.php?LSobject='.$LSobject.'&refresh',
|
||||||
|
'action' => 'refresh'
|
||||||
|
);
|
||||||
|
|
||||||
|
$list=$object -> listObjects($filter,$topDn,$params);
|
||||||
|
|
||||||
|
|
||||||
|
$nbObjects=0;
|
||||||
|
foreach($list as $thisObject) {
|
||||||
|
if ($GLOBALS['LSsession'] -> canAccess($LSobject,$thisObject->getValue('dn'))) {
|
||||||
|
$subDn_name=false;
|
||||||
|
if ($doSubDn) {
|
||||||
|
$subDn_name = $thisObject -> getSubDnName();
|
||||||
|
}
|
||||||
|
$nbObjects++;
|
||||||
|
unset($actions);
|
||||||
|
|
||||||
|
$actions[] = array(
|
||||||
|
'label' => _('Voir'),
|
||||||
|
'url' =>'view.php?LSobject='.$LSobject.'&dn='.$thisObject -> getValue('dn'),
|
||||||
|
'action' => 'view'
|
||||||
);
|
);
|
||||||
if ($GLOBALS['LSsession'] -> relationCanEdit($object -> getValue('dn'),$relationName)) {
|
|
||||||
$return['actions'][] = array(
|
if ($GLOBALS['LSsession'] -> canEdit($LSobject,$thisObject->getValue('dn'))) {
|
||||||
|
$actions[]=array(
|
||||||
'label' => _('Modifier'),
|
'label' => _('Modifier'),
|
||||||
'url' => 'select.php?LSobject='.$relationConf['LSobject'],
|
'url' => 'modify.php?LSobject='.$LSobject.'&dn='.$thisObject->getValue('dn'),
|
||||||
'action' => 'modify'
|
'action' => 'modify'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSselect.js');
|
if ($canCopy) {
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
$actions[] = array(
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
'label' => _('Copier'),
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSrelation.js');
|
'url' =>'create.php?LSobject='.$LSobject.'&load='.$thisObject -> getValue('dn'),
|
||||||
if($GLOBALS['LSsession'] -> loadLSobject($relationConf['LSobject'])) {
|
'action' => 'copy'
|
||||||
if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) {
|
);
|
||||||
$objRel = new $relationConf['LSobject']();
|
|
||||||
$list = $objRel -> $relationConf['list_function']($object);
|
|
||||||
if (is_array($list)) {
|
|
||||||
foreach($list as $o) {
|
|
||||||
$return['objectList'][] = $o -> getDisplayValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$return['objectList']=array();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1013,$relationName);
|
|
||||||
}
|
|
||||||
$LSrelations[]=$return;
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1016,array('relation' => $relationName,'LSobject' => $relationConf['LSobject']));
|
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$thisObject -> getValue('dn'))) {
|
||||||
|
$actions[] = array (
|
||||||
|
'label' => _('Supprimer'),
|
||||||
|
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$thisObject -> getValue('dn'),
|
||||||
|
'action' => 'delete'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSrelations',$LSrelations);
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$LSview_actions);
|
$objectList[]=array(
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
'dn' => $thisObject->getValue('dn'),
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
'displayValue' => $thisObject->getDisplayValue(),
|
||||||
$GLOBALS['LSsession'] -> setTemplate('view.tpl');
|
'actions' => $actions,
|
||||||
}
|
'subDn' => $subDn_name
|
||||||
else {
|
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Affichage d'une liste d'un type d'objet
|
|
||||||
else {
|
|
||||||
$objectList=array();
|
|
||||||
$object = new $LSobject();
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('pagetitle',$object -> getLabel());
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_objectname',$object -> getLabel());
|
|
||||||
|
|
||||||
$subDnLdapServer = $GLOBALS['LSsession'] -> getSortSubDnLdapServer();
|
|
||||||
|
|
||||||
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject])) {
|
|
||||||
$filter = $_SESSION['LSsession']['LSsearch'][$LSobject]['filter'];
|
|
||||||
$params = $_SESSION['LSsession']['LSsearch'][$LSobject]['params'];
|
|
||||||
$pattern = $_SESSION['LSsession']['LSsearch'][$LSobject]['pattern'];
|
|
||||||
$recur = $_SESSION['LSsession']['LSsearch'][$LSobject]['recur'];
|
|
||||||
if ($recur) {
|
|
||||||
$topDn = $GLOBALS['LSsession'] -> topDn;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
|
||||||
}
|
|
||||||
$approx = $_SESSION['LSsession']['LSsearch'][$LSobject]['approx'];
|
|
||||||
$orderby = $_SESSION['LSsession']['LSsearch'][$LSobject]['orderby'];
|
|
||||||
$ordersense = $_SESSION['LSsession']['LSsearch'][$LSobject]['ordersense'];
|
|
||||||
$doSubDn = $_SESSION['LSsession']['LSsearch'][$LSobject]['doSubDn'];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$filter = NULL;
|
|
||||||
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
|
||||||
$params = array('scope' => 'one');
|
|
||||||
$pattern = false;
|
|
||||||
$recur = false;
|
|
||||||
$approx = false;
|
|
||||||
$orderby = false;
|
|
||||||
$ordersense = 'ASC';
|
|
||||||
$doSubDn = (($subDnLdapServer)&&(!$GLOBALS['LSsession']->isSubDnLSobject($LSobject)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_REQUEST['LSview_search_submit'])) {
|
|
||||||
if (isset($_REQUEST['LSview_pattern']) && ($_REQUEST['LSview_pattern']!=$pattern)) {
|
|
||||||
$pattern = $_REQUEST['LSview_pattern'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$approx = (isset($_REQUEST['LSview_approx']));
|
|
||||||
|
|
||||||
if ($pattern && $pattern!='') {
|
|
||||||
$filter='(|';
|
|
||||||
if ($approx) {
|
|
||||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
|
||||||
$filter.='('.$attr_name.'~='.$pattern.')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach ($object -> attrs as $attr_name => $attr_val) {
|
|
||||||
$filter.='('.$attr_name.'=*'.$pattern.'*)';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$filter.=')';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$filter = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($_REQUEST['LSview_recur'])) {
|
|
||||||
$recur = true;
|
|
||||||
$params['scope'] = 'sub';
|
|
||||||
$topDn = $GLOBALS['LSsession'] -> topDn;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$recur = false;
|
|
||||||
$params['scope'] = 'one';
|
|
||||||
$topDn = $object -> config['container_dn'].','.$GLOBALS['LSsession'] -> topDn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sort=false;
|
|
||||||
if ((isset($_REQUEST['orderby']))) {
|
|
||||||
$possible_values= array('displayValue','subDn');
|
|
||||||
if (in_array($_REQUEST['orderby'],$possible_values)) {
|
|
||||||
$sort=true;
|
|
||||||
if ($orderby==$_REQUEST['orderby']) {
|
|
||||||
$ordersense = ($ordersense=='ASC')?'DESC':'ASC';
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$ordersense = 'ASC';
|
|
||||||
}
|
|
||||||
$orderby=$_REQUEST['orderby'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_subDn',$doSubDn);
|
|
||||||
|
|
||||||
// Sauvegarde en Session
|
|
||||||
$_SESSION['LSsession']['LSsearch'][$LSobject] = array(
|
|
||||||
'filter' => $filter,
|
|
||||||
'topDn' => $topDn,
|
|
||||||
'params' => $params,
|
|
||||||
'pattern' => $pattern,
|
|
||||||
'recur' => $recur,
|
|
||||||
'approx' => $approx,
|
|
||||||
'orderby' => $orderby,
|
|
||||||
'ordersense' => $ordersense,
|
|
||||||
'doSubDn' => $doSubDn
|
|
||||||
);
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_pattern',$pattern);
|
|
||||||
|
|
||||||
if ($recur) {
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_recur',true);
|
|
||||||
}
|
|
||||||
if ($approx) {
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_approx',true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hidden fields
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_hidden_fields',array(
|
|
||||||
'LSobject' => $LSobject,
|
|
||||||
'LSview_search_submit' => 1
|
|
||||||
));
|
|
||||||
|
|
||||||
// Hash de la recherche déterminer à partir des paramètres de la recherche
|
|
||||||
$hash = mhash (MHASH_MD5,
|
|
||||||
print_r(
|
|
||||||
array(
|
|
||||||
'LSobject' => $LSobject,
|
|
||||||
'filter' => $filter,
|
|
||||||
'topDn' => $topDn,
|
|
||||||
'params' => $params
|
|
||||||
),
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (($GLOBALS['LSsession'] -> cacheSearch()) && isset($_SESSION['LSsession']['LSsearch'][$hash]) && (!isset($_REQUEST['refresh']))) {
|
|
||||||
// On affiche à partir du cache
|
|
||||||
$searchData=$_SESSION['LSsession']['LSsearch'][$hash];
|
|
||||||
debug('Recherche : From cache');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
debug('Recherche : Load');
|
|
||||||
if ($GLOBALS['LSsession'] -> canCreate($LSobject)) {
|
|
||||||
$LSview_actions[] = array (
|
|
||||||
'label' => _('Nouveau'),
|
|
||||||
'url' => 'create.php?LSobject='.$LSobject,
|
|
||||||
'action' => 'create'
|
|
||||||
);
|
|
||||||
$canCopy=true;
|
|
||||||
}
|
|
||||||
$LSview_actions[] = array (
|
|
||||||
'label' => _('Rafraîchir'),
|
|
||||||
'url' => 'view.php?LSobject='.$LSobject.'&refresh',
|
|
||||||
'action' => 'refresh'
|
|
||||||
);
|
|
||||||
|
|
||||||
$list=$object -> listObjects($filter,$topDn,$params);
|
|
||||||
$nbObjects=count($list);
|
|
||||||
$searchData['LSobject_list_nbresult']=$nbObjects;
|
|
||||||
|
|
||||||
$c=0;
|
|
||||||
|
|
||||||
foreach($list as $thisObject) {
|
|
||||||
if ($GLOBALS['LSsession'] -> canAccess($LSobject,$thisObject->getValue('dn'))) {
|
|
||||||
$subDn_name=false;
|
|
||||||
if ($doSubDn) {
|
|
||||||
reset($subDnLdapServer);
|
|
||||||
while (!$subDn_name && next($subDnLdapServer)) {
|
|
||||||
if (isCompatibleDNs(key($subDnLdapServer),$thisObject -> getValue('dn'))) {
|
|
||||||
$subDn_name=current($subDnLdapServer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$c++;
|
|
||||||
unset($actions);
|
|
||||||
|
|
||||||
$actions[] = array(
|
|
||||||
'label' => _('Voir'),
|
|
||||||
'url' =>'view.php?LSobject='.$LSobject.'&dn='.$thisObject -> getValue('dn'),
|
|
||||||
'action' => 'view'
|
|
||||||
);
|
|
||||||
|
|
||||||
if ($GLOBALS['LSsession'] -> canEdit($LSobject,$thisObject->getValue('dn'))) {
|
|
||||||
$actions[]=array(
|
|
||||||
'label' => _('Modifier'),
|
|
||||||
'url' => 'modify.php?LSobject='.$LSobject.'&dn='.$thisObject->getValue('dn'),
|
|
||||||
'action' => 'modify'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($canCopy) {
|
|
||||||
$actions[] = array(
|
|
||||||
'label' => _('Copier'),
|
|
||||||
'url' =>'create.php?LSobject='.$LSobject.'&load='.$thisObject -> getValue('dn'),
|
|
||||||
'action' => 'copy'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($GLOBALS['LSsession'] -> canRemove($thisObject -> getType(),$thisObject -> getValue('dn'))) {
|
|
||||||
$actions[] = array (
|
|
||||||
'label' => _('Supprimer'),
|
|
||||||
'url' => 'remove.php?LSobject='.$LSobject.'&dn='.$thisObject -> getValue('dn'),
|
|
||||||
'action' => 'delete'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
$objectList[]=array(
|
|
||||||
'dn' => $thisObject->getValue('dn'),
|
|
||||||
'displayValue' => $thisObject->getDisplayValue(),
|
|
||||||
'actions' => $actions,
|
|
||||||
'subDn' => $subDn_name
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
debug($thisObject->getValue('dn'));
|
$searchData['LSobject_list_nbresult']=$nbObjects;
|
||||||
|
|
||||||
|
$searchData['objectList']=$objectList;
|
||||||
|
$searchData['LSview_actions'] = $LSview_actions;
|
||||||
|
if ($GLOBALS['LSsession'] -> cacheSearch()) {
|
||||||
|
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$searchData['objectList']=$objectList;
|
|
||||||
$searchData['LSview_actions'] = $LSview_actions;
|
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$searchData['LSobject_list_nbresult']);
|
||||||
if ($GLOBALS['LSsession'] -> cacheSearch()) {
|
|
||||||
|
// Order by if $sort
|
||||||
|
if ($sort) {
|
||||||
|
function sortBy($a,$b) {
|
||||||
|
global $ordersense;
|
||||||
|
global $orderby;
|
||||||
|
|
||||||
|
if ($ordersense=='ASC') {
|
||||||
|
$sense = -1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$sense = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($a == $b) return 0;
|
||||||
|
$sort = array($a[$orderby],$b[$orderby]);
|
||||||
|
sort($sort);
|
||||||
|
if ($sort[0]==$a[$orderby])
|
||||||
|
return 1*$sense;
|
||||||
|
return -1*$sense;
|
||||||
|
}
|
||||||
|
if (!uasort($searchData['objectList'],'sortBy')) {
|
||||||
|
debug('Erreur durant le trie.');
|
||||||
|
}
|
||||||
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
||||||
}
|
}
|
||||||
}
|
$GLOBALS['Smarty']->assign('LSobject_list_orderby',$orderby);
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_ordersense',$ordersense);
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_nbresult',$searchData['LSobject_list_nbresult']);
|
// Pagination
|
||||||
|
if ($searchData['LSobject_list_nbresult'] > NB_LSOBJECT_LIST) {
|
||||||
|
if (isset($_REQUEST['page'])) {
|
||||||
|
$searchData['objectList'] = array_slice($searchData['objectList'], ($_REQUEST['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_REQUEST['page']);
|
||||||
|
|
||||||
// Order by if $sort
|
|
||||||
if ($sort) {
|
|
||||||
function sortBy($a,$b) {
|
|
||||||
global $ordersense;
|
|
||||||
global $orderby;
|
|
||||||
|
|
||||||
if ($ordersense=='ASC') {
|
|
||||||
$sense = -1;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$sense = 1;
|
$searchData['objectList'] = array_slice($searchData['objectList'], 0, NB_LSOBJECT_LIST);
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
||||||
}
|
}
|
||||||
|
$searchData['LSobject_list_nbpage']=ceil($searchData['LSobject_list_nbresult'] / NB_LSOBJECT_LIST);
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',$searchData['LSobject_list_nbpage']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($a == $b) return 0;
|
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||||
$sort = array($a[$orderby],$b[$orderby]);
|
|
||||||
sort($sort);
|
$GLOBALS['Smarty']->assign('LSview_search',array(
|
||||||
if ($sort[0]==$a[$orderby])
|
'action' => $_SERVER['PHP_SELF'],
|
||||||
return 1*$sense;
|
'submit' => _('Rechercher'),
|
||||||
return -1*$sense;
|
'LSobject' => $LSobject
|
||||||
}
|
));
|
||||||
if (!uasort($searchData['objectList'],'sortBy')) {
|
|
||||||
debug('Erreur durant le trie.');
|
$GLOBALS['Smarty']->assign('LSview_search_recur_label',_('Recherche récursive'));
|
||||||
}
|
$GLOBALS['Smarty']->assign('LSview_search_approx_label',_('Recherche approximative'));
|
||||||
$_SESSION['LSsession']['LSsearch'][$hash]=$searchData;
|
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_without_result_label',_("Cette recherche n'a retourné aucun résultat."));
|
||||||
|
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
||||||
|
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list',$searchData['objectList']);
|
||||||
|
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$LSobject);
|
||||||
|
$GLOBALS['Smarty'] -> assign('LSview_actions',$searchData['LSview_actions']);
|
||||||
|
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
||||||
}
|
}
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_orderby',$orderby);
|
}
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_ordersense',$ordersense);
|
else {
|
||||||
|
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject);
|
||||||
// Pagination
|
|
||||||
if ($searchData['LSobject_list_nbresult'] > NB_LSOBJECT_LIST) {
|
|
||||||
if (isset($_REQUEST['page'])) {
|
|
||||||
$searchData['objectList'] = array_slice($searchData['objectList'], ($_REQUEST['page']) * NB_LSOBJECT_LIST, NB_LSOBJECT_LIST);
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',$_REQUEST['page']);
|
|
||||||
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$searchData['objectList'] = array_slice($searchData['objectList'], 0, NB_LSOBJECT_LIST);
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_currentpage',0);
|
|
||||||
}
|
|
||||||
$searchData['LSobject_list_nbpage']=ceil($searchData['LSobject_list_nbresult'] / NB_LSOBJECT_LIST);
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_nbpage',$searchData['LSobject_list_nbpage']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search',array(
|
|
||||||
'action' => $_SERVER['PHP_SELF'],
|
|
||||||
'submit' => _('Rechercher'),
|
|
||||||
'LSobject' => $LSobject
|
|
||||||
));
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_recur_label',_('Recherche récursive'));
|
|
||||||
$GLOBALS['Smarty']->assign('LSview_search_approx_label',_('Recherche approximative'));
|
|
||||||
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_without_result_label',_("Cette recherche n'a retourné aucun résultat."));
|
|
||||||
$GLOBALS['Smarty']->assign('_Actions',_('Actions'));
|
|
||||||
$GLOBALS['Smarty']->assign('_Modifier',_('Modifier'));
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list',$searchData['objectList']);
|
|
||||||
$GLOBALS['Smarty']->assign('LSobject_list_objecttype',$LSobject);
|
|
||||||
$GLOBALS['Smarty'] -> assign('LSview_actions',$searchData['LSview_actions']);
|
|
||||||
$GLOBALS['LSsession'] -> setTemplate('viewList.tpl');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$GLOBALS['LSerror'] -> addErrorCode(1004,$LSobject);
|
$GLOBALS['LSerror'] -> addErrorCode(1011);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
Loading…
Reference in a new issue