_('Do you really want to delete'), 'close_confirm_title' => _('Warning'), 'close_confirm_validate' => _('Delete') )); } /* * Méthode chargeant les informations des LSrelations d'un objet et définissant * les variables templates pour l'affichage dans une LSview. * * @param[in] LSldapObject L'objet dont on cherche les LSrelations * * @retval void */ public static function displayInLSview($object) { if (($object instanceof LSldapObject) && (is_array($object -> config['LSrelation']))) { $LSrelations=array(); $LSrelations_JSparams=array(); foreach($object -> config['LSrelation'] as $relationName => $relationConf) { if (LSsession :: relationCanAccess($object -> getValue('dn'),$object->getType(),$relationName)) { $return=array( 'label' => __($relationConf['label']), 'LSobject' => $relationConf['LSobject'] ); if (isset($relationConf['emptyText'])) { $return['emptyText'] = __($relationConf['emptyText']); } else { $return['emptyText'] = _('No object.'); } $id=rand(); $return['id']=$id; $LSrelations_JSparams[$id]=array( 'emptyText' => $return['emptyText'] ); $_SESSION['LSrelation'][$id] = array( 'relationName' => $relationName, 'objectType' => $object -> getType(), 'objectDn' => $object -> getDn(), ); if (LSsession :: relationCanEdit($object -> getValue('dn'),$object->getType(),$relationName)) { $return['actions'][] = array( 'label' => _('Modify'), 'url' => 'select.php?LSobject='.$relationConf['LSobject'].'&multiple=1'.((isset($relationConf['canEdit_attribute']))?'&editableAttr='.$relationConf['canEdit_attribute']:''), 'action' => 'modify' ); } if (LSsession :: loadLSclass('LSrelation')) { LSrelation :: loadDependenciesDisplay(); } if(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) { $o_infos = array( 'text' => $o -> getDisplayName(NULL,true), 'dn' => $o -> getDn() ); if (isset($relationConf['canEdit_function'])) { $o_infos['canEdit']= $o -> $relationConf['canEdit_function'](); } else { $o_infos['canEdit']=true; } $return['objectList'][] = $o_infos; } } else { $return['objectList']=array(); } } else { LSerror :: addErrorCode('LSrelations_01',$relationName); } $LSrelations[]=$return; } else { LSerror :: addErrorCode('LSrelations_04',array('relation' => $relationName,'LSobject' => $relationConf['LSobject'])); } } } LStemplate :: assign('LSrelations',$LSrelations); LSsession :: addJSconfigParam('LSrelations',$LSrelations_JSparams); } } public static function ajax_refreshSession(&$return) { if ((isset($_REQUEST['id'])) && (isset($_REQUEST['href'])) ) { if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) { $conf = $_SESSION['LSrelation'][$_REQUEST['id']]; if (LSsession ::loadLSobject($conf['objectType'])) { $object = new $conf['objectType'](); if (($object -> loadData($conf['objectDn'])) && (isset($object->config['LSrelation'][$conf['relationName']]))) { $relationConf = $object->config['LSrelation'][$conf['relationName']]; if (LSsession ::loadLSobject($relationConf['LSobject'])) { if (LSsession :: relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) { if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { $objRel = new $relationConf['LSobject'](); $list = $objRel -> $relationConf['list_function']($object); $_SESSION['LSselect'][$relationConf['LSobject']]=array(); if (is_array($list)) { foreach($list as $o) { $_SESSION['LSselect'][$relationConf['LSobject']][] = $o -> getDn(); } } $return = array( 'href' => $_REQUEST['href'], 'id' => $_REQUEST['id'] ); } else { LSerror :: addErrorCode('LSrelations_01',$relationName); } } else { LSerror :: addErrorCode('LSsession_11'); } } } else { LSerror :: addErrorCode('LSsession_12'); } } else { LSerror :: addErrorCode('LSsession_12'); } } else { LSerror :: addErrorCode('LSsession_12'); } } } public static function ajax_refreshList(&$data) { if (isset($_REQUEST['id'])) { if (isset($_SESSION['LSrelation'][$_REQUEST['id']])) { $conf = $_SESSION['LSrelation'][$_REQUEST['id']]; if (LSsession ::loadLSobject($conf['objectType'])) { $object = new $conf['objectType'](); if (($object -> loadData($conf['objectDn'])) && (isset($object->config['LSrelation'][$conf['relationName']]))) { $relationConf = $object->config['LSrelation'][$conf['relationName']]; if (LSsession ::loadLSobject($relationConf['LSobject'])) { if (LSsession :: relationCanEdit($object -> getValue('dn'),$object -> getType(),$conf['relationName'])) { if (is_array($_SESSION['LSselect'][$relationConf['LSobject']])) { if (method_exists($relationConf['LSobject'],$relationConf['update_function'])) { $objRel = new $relationConf['LSobject'](); if($objRel -> $relationConf['update_function']($object,$_SESSION['LSselect'][$relationConf['LSobject']])) { if (method_exists($relationConf['LSobject'],$relationConf['list_function'])) { $list = $objRel -> $relationConf['list_function']($object); if (is_array($list)&&(!empty($list))) { $data['html']=""; foreach($list as $o) { if (isset($relationConf['canEdit_function'])) { if ($o -> $relationConf['canEdit_function']()) { $class=' LSrelation_editable'; } else { $class=''; } } else { $class=' LSrelation_editable'; } $data['html'].= "