diff --git a/public_html/includes/class/class.LSform.php b/public_html/includes/class/class.LSform.php index 1651c98a..b33e87e5 100644 --- a/public_html/includes/class/class.LSform.php +++ b/public_html/includes/class/class.LSform.php @@ -83,7 +83,7 @@ class LSform { */ function display(){ if ($this -> idForm == 'view') { - self :: loadDependenciesDisplayView(); + self :: loadDependenciesDisplayView($this -> $ldapObject); } else { LSsession :: addJSscript('LSformElement_field.js'); @@ -188,14 +188,35 @@ class LSform { * * @retval void */ - public static function loadDependenciesDisplayView() { + public static function loadDependenciesDisplayView($ldapObject=false) { LSsession :: addCssFile('LSform.css'); LSsession :: addJSscript('LSform.js'); - LSsession :: addJSconfigParam('LSview_labels', array( + $customActionLabels = array (); + if (is_a($ldapObject,'LSldapObject')) { + $objectname=$ldapObject -> getDisplayName(); + $customActionsConfig = LSconfig :: get('LSobjects.'.$ldapObject->type_name.'.customActions'); + if (is_array($customActionsConfig)) { + foreach($customActionsConfig as $name => $config) { + if (isset($config['question_format'])) { + $customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData(__($config['question_format']),$objectname); + } + else { + $customActionLabels['custom_action_'.$name.'_confirm_text'] = getFData( + _('Do you really want to execute custom action %{customAction} on %{objectname} ?'), + array( + 'objectname' => $objectname, + 'customAction' => $name + ) + ); + } + } + } + } + LSsession :: addJSconfigParam('LSview_labels', array_merge(array( 'delete_confirm_text' => _("Do you really want to delete"), 'delete_confirm_title' => _("Caution"), 'delete_confirm_validate' => _("Delete") - )); + ),$customActionLabels)); if (LSsession :: loadLSclass('LSconfirmBox')) { LSconfirmBox :: loadDependenciesDisplay(); } @@ -210,7 +231,7 @@ class LSform { * @retval void */ function displayView(){ - self :: loadDependenciesDisplayView(); + self :: loadDependenciesDisplayView($this -> ldapObject); $LSform_object = array( 'type' => $this -> ldapObject -> getType(), diff --git a/public_html/includes/js/LSview.js b/public_html/includes/js/LSview.js index d8ff8b52..666e7462 100644 --- a/public_html/includes/js/LSview.js +++ b/public_html/includes/js/LSview.js @@ -95,6 +95,36 @@ var LSview = new Class({ removeFromA: function(a) { document.location = a.href+'&valid'; + }, + + onCustomActionBtnClick: function(event,a) { + Event(event).stop(); + if (!this._confirmBoxOpen) { + this._confirmBoxOpen = 1; + var getName = new RegExp('customAction=([^&]*)'); + var name = getName.exec(a.href)[1]; + if (name) { + var title = a.innerHTML; + if ($type(this.labels['custom_action_'+name+'_confirm_text'])) { + var text = this.labels['custom_action_'+name+'_confirm_text'] + } + else { + var objectname = $('LSview_title').innerHTML; + var text = getFData('Do you really want to execute custom action %{customAction} on %{objectname} ?',{customAction: name, objectname: objectname }); + } + this.confirmBox = new LSconfirmBox({ + text: text, + title: title, + startElement: a, + onConfirm: this.executeCustomActionFromA.bind(this,a), + onClose: this.onConfirmBoxClose.bind(this) + }); + } + } + }, + + executeCustomActionFromA: function(a) { + document.location = a.href+'&valid'; } }); diff --git a/public_html/templates/default/view.tpl b/public_html/templates/default/view.tpl index 037ce136..b73dc626 100644 --- a/public_html/templates/default/view.tpl +++ b/public_html/templates/default/view.tpl @@ -4,7 +4,7 @@ diff --git a/public_html/view.php b/public_html/view.php index 34927ea2..b5be65a2 100644 --- a/public_html/view.php +++ b/public_html/view.php @@ -70,7 +70,8 @@ if(LSsession :: startLSsession()) { $LSview_actions[] = array ( 'label' => ((isset($config['label']))?__($config['label']):__($name)), 'url' => 'custom_action.php?LSobject='.$LSobject.'&dn='.$dn.'&customAction='.$name, - 'action' => ((isset($config['icon']))?$config['icon']:'generate') + 'action' => ((isset($config['icon']))?$config['icon']:'generate'), + 'class' => 'LScustomActions' ); } }