2011-03-25 18:05:26 +01:00
< ? php
/*******************************************************************************
* Copyright ( C ) 2007 Easter - eggs
* http :// ldapsaisie . labs . libre - entreprise . org
*
* Author : See AUTHORS file in top - level directory .
*
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program ; if not , write to the Free Software
* Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
******************************************************************************/
require_once 'core.php' ;
if ( LSsession :: startLSsession ()) {
if (( isset ( $_GET [ 'LSobject' ])) && ( isset ( $_GET [ 'dn' ])) && ( isset ( $_GET [ 'customAction' ]))) {
2012-05-03 14:40:53 +02:00
$LSobject = urldecode ( $_GET [ 'LSobject' ]);
$dn = urldecode ( $_GET [ 'dn' ]);
$customAction = urldecode ( $_GET [ 'customAction' ]);
if ( LSsession :: loadLSobject ( $LSobject )) {
if ( LSsession :: canExecuteCustomAction ( $dn , $LSobject , $customAction ) ) {
$object = new $LSobject ();
if ( $object -> loadData ( $dn )) {
$config = LSconfig :: get ( 'LSobjects.' . $LSobject . '.customActions.' . $customAction );
2011-03-25 18:05:26 +01:00
if ( isset ( $config [ 'function' ]) && is_callable ( $config [ 'function' ])) {
if ( isset ( $config [ 'label' ])) {
$title = __ ( $config [ 'label' ]);
}
else {
2012-05-03 14:40:53 +02:00
$title = __ ( $customAction );
2011-03-25 18:05:26 +01:00
}
2011-07-06 15:53:51 +02:00
if ( isset ( $_GET [ 'valid' ]) || $config [ 'noConfirmation' ]) {
2011-03-25 18:05:26 +01:00
$objectname = $object -> getDisplayName ();
$GLOBALS [ 'Smarty' ] -> assign ( 'pagetitle' , $title . ' : ' . $objectname );
if ( $config [ 'function' ]( $object )) {
2011-05-20 18:11:42 +02:00
if ( $config [ 'disableOnSuccessMsg' ] != true ) {
if ( $config [ 'onSuccessMsgFormat' ]) {
2012-03-13 10:29:31 +01:00
LSsession :: addInfo ( getFData ( __ ( $config [ 'onSuccessMsgFormat' ]), $objectname ));
2011-05-20 18:11:42 +02:00
}
else {
2012-05-03 14:40:53 +02:00
LSsession :: addInfo ( getFData ( _ ( 'The custom action %{customAction} have been successfully execute on %{objectname}.' ), array ( 'objectname' => $objectname , 'customAction' => $customAction )));
2011-05-20 18:11:42 +02:00
}
2011-03-25 18:05:26 +01:00
}
2011-12-15 11:22:51 +01:00
if ( $config [ 'redirectToObjectList' ]) {
2012-05-03 14:40:53 +02:00
LSsession :: redirect ( 'view.php?LSobject=' . $LSobject . '&refresh' );
2011-12-15 11:22:51 +01:00
}
else {
2012-05-03 14:40:53 +02:00
LSsession :: redirect ( 'view.php?LSobject=' . $LSobject . '&dn=' . urlencode ( $dn ));
2011-12-15 11:22:51 +01:00
}
2011-03-25 18:05:26 +01:00
}
else {
2012-05-03 14:40:53 +02:00
LSerror :: addErrorCode ( 'LSldapObject_31' , array ( 'objectname' => $objectname , 'customAction' => $customAction ));
2011-03-25 18:05:26 +01:00
}
}
else {
$objectname = $object -> getDisplayName ();
$question = (
isset ( $config [ 'question_format' ]) ?
getFData ( __ ( $config [ 'question_format' ]), $objectname ) :
getFData (
_ ( 'Do you really want to execute custom action %{customAction} on %{objectname} ?' ),
array (
'objectname' => $objectname ,
2012-05-03 14:40:53 +02:00
'customAction' => $customAction
2011-03-25 18:05:26 +01:00
)
)
);
$GLOBALS [ 'Smarty' ] -> assign ( 'pagetitle' , $title . ' : ' . $objectname );
$GLOBALS [ 'Smarty' ] -> assign ( 'question' , $question );
2012-05-03 14:40:53 +02:00
$GLOBALS [ 'Smarty' ] -> assign ( 'validation_url' , 'custom_action.php?LSobject=' . urlencode ( $LSobject ) . '&dn=' . urlencode ( $dn ) . '&customAction=' . urlencode ( $customAction ) . '&valid' );
2011-03-25 18:05:26 +01:00
$GLOBALS [ 'Smarty' ] -> assign ( 'validation_label' , _ ( 'Validate' ));
}
LSsession :: setTemplate ( 'question.tpl' );
}
else {
LSerror :: addErrorCode ( 'LSsession_13' );
}
}
else {
LSerror :: addErrorCode ( 'LSsession_12' );
}
}
else {
LSerror :: addErrorCode ( 'LSsession_11' );
}
}
else {
LSerror :: addErrorCode ( 'LSldapObject_01' );
}
}
else {
LSerror :: addErrorCode ( 'LSsession_12' );
}
}
else {
LSsession :: setTemplate ( 'login.tpl' );
}
// Affichage des retours d'erreurs
LSsession :: displayTemplate ();
?>