diff --git a/filemanager/inc/class.filemanager_ui.inc.php b/filemanager/inc/class.filemanager_ui.inc.php index 9b34d8be29..faef24ed7f 100644 --- a/filemanager/inc/class.filemanager_ui.inc.php +++ b/filemanager/inc/class.filemanager_ui.inc.php @@ -1179,12 +1179,18 @@ class filemanager_ui } if (egw_vfs::$is_root) { - $tpl->setElementAttribute('sudo', 'label', 'Logout'); - $tpl->setElementAttribute('sudo', 'help','Log out as superuser'); + $tpl->setElementAttribute('sudouser', 'label', 'Logout'); + $tpl->setElementAttribute('sudouser', 'help','Log out as superuser'); // Need a more complex submit because button type is buttononly, which doesn't submit - $tpl->setElementAttribute('sudo', 'onclick','widget.getInstanceManager().submit(widget)'); + $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"login")'); } + elseif ($button == 'sudo') + { + $tpl->setElementAttribute('sudouser', 'label', 'Superuser'); + $tpl->setElementAttribute('sudouser', 'help','Enter setup user and password to get root rights'); + $tpl->setElementAttribute('sudouser', 'onclick','app.filemanager.set_sudoButton(widget,"logout")'); + } if (($extra_tabs = egw_vfs::getExtraInfo($path,$content))) { // add to existing tabs in template diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 6cb20a894d..bbdfbf2bb4 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -773,5 +773,32 @@ app.classes.filemanager = AppJS.extend( event.preventDefault(); event.stopPropagation(); return false; + }, + + /** + * Set Sudo button's label and change its onclick handler according to its action + * + * @param {widget object} _widget sudo buttononly + * @param {string} _action string of action type {login|logout} + */ + set_sudoButton: function (_widget, _action) + { + var widget = _widget || this.et2.getWidgetById('sudouser'); + if (widget) + { + switch (_action) + { + case 'login': + widget.set_label('Logout'); + this.et2._inst.submit(widget); + break; + + default: + widget.set_label('Superuser'); + widget.onclick = function(){ + jQuery('.superuser').css('display','inline'); + } + } + } } });