Handle logout onClick handler for superuser button in filemanager file dialog

This commit is contained in:
Hadi Nategh 2014-08-22 12:01:07 +00:00
parent 673836332d
commit d762f4ee77
2 changed files with 36 additions and 3 deletions

View File

@ -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

View File

@ -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');
}
}
}
}
});