mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
Fix/improve LSobject & LSsearch customActions code
This commit is contained in:
parent
5b7b22dde1
commit
3151721838
1 changed files with 38 additions and 28 deletions
|
@ -571,12 +571,13 @@ function handle_LSobject_search_customAction($request) {
|
||||||
$title = isset($config['label'])?__($config['label']):$customAction;
|
$title = isset($config['label'])?__($config['label']):$customAction;
|
||||||
|
|
||||||
// Check search customAction function
|
// Check search customAction function
|
||||||
if (!isset($config['function']) || !is_callable($config['function'])) {
|
$function = LSconfig :: get('function', null, null, $config);
|
||||||
|
if (!is_callable($function)) {
|
||||||
LSerror :: addErrorCode(
|
LSerror :: addErrorCode(
|
||||||
'LSsession_13',
|
'LSsession_13',
|
||||||
array(
|
array(
|
||||||
'customAction' => $title,
|
'customAction' => $title,
|
||||||
'function' => (isset($config['function'])?getCallableName($config['function']):_('undefined'))
|
'function' => ($function?getCallableName($function):_('undefined'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
LSsession :: displayTemplate();
|
LSsession :: displayTemplate();
|
||||||
|
@ -589,16 +590,23 @@ function handle_LSobject_search_customAction($request) {
|
||||||
LStemplate :: assign('pagetitle', $title);
|
LStemplate :: assign('pagetitle', $title);
|
||||||
|
|
||||||
// Run search customAction (if validated or no confirmation need)
|
// Run search customAction (if validated or no confirmation need)
|
||||||
if (isset($_GET['valid']) || $config['noConfirmation']) {
|
if (isset($_GET['valid']) || LSconfig :: get('noConfirmation', false, 'bool', $config)) {
|
||||||
if (call_user_func_array($config['function'], array(&$LSsearch))) {
|
if (call_user_func_array($function, array(&$LSsearch))) {
|
||||||
if (isset($config['disableOnSuccessMsg']) && $config['disableOnSuccessMsg'] != true) {
|
if (!LSconfig :: get('disableOnSuccessMsg', false, 'bool', $config)) {
|
||||||
LSsession :: addInfo(
|
LSsession :: addInfo(
|
||||||
(isset($config['onSuccessMsgFormat']) && $config['onSuccessMsgFormat'])?
|
getFData(
|
||||||
getFData(__($config['onSuccessMsgFormat']), $objectname):
|
__(
|
||||||
getFData(_('The custom action %{title} have been successfully execute on this search.'), $title)
|
LSconfig :: get(
|
||||||
|
'onSuccessMsgFormat',
|
||||||
|
___('The custom action %{title} have been successfully execute on this search.'),
|
||||||
|
'string', $config
|
||||||
|
)
|
||||||
|
),
|
||||||
|
$title
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!isset($config['redirectToObjectList']) || $config['redirectToObjectList']) {
|
if (LSconfig :: get('redirectToObjectList', true, 'bool', $config)) {
|
||||||
LSurl :: redirect("object/$LSobject?refresh");
|
LSurl :: redirect("object/$LSobject?refresh");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1355,12 +1363,13 @@ function handle_LSobject_customAction($request) {
|
||||||
$title = isset($config['label'])?__($config['label']):$customAction;
|
$title = isset($config['label'])?__($config['label']):$customAction;
|
||||||
|
|
||||||
// Check customAction function
|
// Check customAction function
|
||||||
if (!isset($config['function']) || !is_callable($config['function'])) {
|
$function = LSconfig :: get('function', null, null, $config);
|
||||||
|
if (!is_callable($function)) {
|
||||||
LSerror :: addErrorCode(
|
LSerror :: addErrorCode(
|
||||||
'LSsession_13',
|
'LSsession_13',
|
||||||
array(
|
array(
|
||||||
'customAction' => $title,
|
'customAction' => $title,
|
||||||
'function' => (isset($config['function'])?getCallableName($config['function']):_('undefined'))
|
'function' => ($function?getCallableName($function):_('undefined'))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
LSsession :: displayTemplate();
|
LSsession :: displayTemplate();
|
||||||
|
@ -1372,31 +1381,32 @@ function handle_LSobject_customAction($request) {
|
||||||
LStemplate :: assign('pagetitle', $title.' : '.$objectname);
|
LStemplate :: assign('pagetitle', $title.' : '.$objectname);
|
||||||
|
|
||||||
// Run customAction (if validated or noConfirmation required)
|
// Run customAction (if validated or noConfirmation required)
|
||||||
if (isset($_GET['valid']) || (isset($config['noConfirmation']) && $config['noConfirmation'])) {
|
if (isset($_GET['valid']) || LSconfig :: get('noConfirmation', false, 'bool', $config)) {
|
||||||
LStemplate :: assign('pagetitle', $title.' : '.$objectname);
|
LStemplate :: assign('pagetitle', $title.' : '.$objectname);
|
||||||
if (call_user_func_array($config['function'], array(&$object))) {
|
if (call_user_func_array($function, array(&$object))) {
|
||||||
if ($config['disableOnSuccessMsg'] != true) {
|
$msg_format = LSconfig :: get('onSuccessMsgFormat', null, 'string', $config);
|
||||||
if ($config['onSuccessMsgFormat']) {
|
if ($msg_format) {
|
||||||
LSsession :: addInfo(getFData(__($config['onSuccessMsgFormat']), $objectname));
|
$msg = getFData(__($msg_format), $objectname);
|
||||||
}
|
} else {
|
||||||
else {
|
$msg = getFData(
|
||||||
LSsession :: addInfo(
|
_('The custom action %{customAction} have been successfully execute on %{objectname}.'),
|
||||||
getFData(
|
array('objectname' => $objectname, 'customAction' => $customAction)
|
||||||
_('The custom action %{customAction} have been successfully execute on %{objectname}.'),
|
);
|
||||||
array('objectname' => $objectname, 'customAction' => $customAction)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (isset($config['redirectToObjectList']) && $config['redirectToObjectList']) {
|
LSsession :: addInfo($msg);
|
||||||
|
|
||||||
|
if (LSconfig :: get('redirectToObjectList', false, 'bool', $config)) {
|
||||||
LSurl :: redirect("object/$LSobject?refresh");
|
LSurl :: redirect("object/$LSobject?refresh");
|
||||||
}
|
}
|
||||||
else if (!isset($config['noRedirect']) || !$config['noRedirect']) {
|
else if (LSconfig :: get('noRedirect', false, 'bool', $config)) {
|
||||||
LSurl :: redirect("object/$LSobject/".urlencode($dn));
|
LSurl :: redirect("object/$LSobject/".urlencode($dn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LSerror :: addErrorCode('LSldapObject_31', array('objectname' => $objectname, 'customAction' => $customAction));
|
LSerror :: addErrorCode(
|
||||||
|
'LSldapObject_31',
|
||||||
|
array('objectname' => $objectname, 'customAction' => $customAction)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// Custom action executed: show its template (if not already redirect)
|
// Custom action executed: show its template (if not already redirect)
|
||||||
LSsession :: displayTemplate();
|
LSsession :: displayTemplate();
|
||||||
|
|
Loading…
Reference in a new issue