mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 09:23:28 +01:00
Fix some problems with read-only wizard:
- New definitions aren't read-only - Hide 'Just me' checkbox when read-only, to avoid confusion - Wizard stays read-only if you go to previous step - Disable Change context menu for definitions the user has no permission to change
This commit is contained in:
parent
4ab5f97ed0
commit
79baa55fe2
@ -68,7 +68,11 @@ class importexport_definitions_bo {
|
||||
$readonlys["edit[{$row['definition_id']}]"] = $readonlys["delete[{$row['definition_id']}]"] =
|
||||
($row['owner'] != $GLOBALS['egw_info']['user']['account_id']) &&
|
||||
!$GLOBALS['egw_info']['user']['apps']['admin'];
|
||||
if($readonlys["edit[{$row['definition_id']}]"]) $ro_count++;
|
||||
if($readonlys["edit[{$row['definition_id']}]"])
|
||||
{
|
||||
$row['class'] .= 'rowNoEdit';
|
||||
$ro_count++;
|
||||
}
|
||||
}
|
||||
$readonlys['delete_selected'] = $ro_count == count($rows);
|
||||
return $total;
|
||||
|
@ -195,7 +195,6 @@ class importexport_definitions_ui
|
||||
'url' => 'menuaction=importexport.importexport_definitions_ui.edit&definition=$id',
|
||||
'popup' => '500x500',
|
||||
'group' => $group,
|
||||
'disableClass' => 'rowNoEdit',
|
||||
),
|
||||
'add' => array(
|
||||
'caption' => 'Add',
|
||||
@ -234,6 +233,7 @@ class importexport_definitions_ui
|
||||
'nm_action' => 'open_popup',
|
||||
)
|
||||
),
|
||||
'disableClass' => 'rowNoEdit',
|
||||
),
|
||||
'select_all' => array(
|
||||
'caption' => 'Whole query',
|
||||
@ -454,6 +454,13 @@ class importexport_definitions_ui
|
||||
|
||||
// post process submitted step
|
||||
if($content['step']) {
|
||||
if(!$this->can_edit($content))
|
||||
{
|
||||
// Each step changes definition, reload it
|
||||
$bodefinitions = new importexport_definitions_bo();
|
||||
$definition = $bodefinitions->read($content);
|
||||
$content = $definition + array('step' => $content['step'], 'button' => $content['button']);
|
||||
}
|
||||
if(!key_exists($content['step'],$this->steps))
|
||||
$next_step = $this->plugin->$content['step']($content);
|
||||
else
|
||||
@ -477,8 +484,7 @@ class importexport_definitions_ui
|
||||
{
|
||||
$this->wizard_content_template = $this->$next_step($content,$sel_options,$readonlys,$preserv);
|
||||
}
|
||||
if($content['owner'] && $content['owner'] != $GLOBALS['egw_info']['user']['account_id'] ||
|
||||
!$content['owner'] && !$GLOBALS['egw_info']['user']['apps']['admin'])
|
||||
if(!$this->can_edit($content))
|
||||
{
|
||||
$readonlys[$this->wizard_content_template] = true;
|
||||
$preserve = $content;
|
||||
@ -499,7 +505,7 @@ class importexport_definitions_ui
|
||||
|
||||
$this->wizard_content_template = $this->wizard_step10($content, $sel_options, $readonlys, $preserv);
|
||||
|
||||
if($content['owner'] && $content['owner'] != $GLOBALS['egw_info']['user']['account_id'])
|
||||
if(!$this->can_edit($content))
|
||||
{
|
||||
$readonlys[$this->wizard_content_template] = true;
|
||||
$preserve = $content;
|
||||
@ -752,11 +758,14 @@ class importexport_definitions_ui
|
||||
// return from step90
|
||||
if ($content['step'] == 'wizard_step90')
|
||||
{
|
||||
$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', EGW_ACL_READ,'importexport') ?
|
||||
($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) :
|
||||
null;
|
||||
$content['allowed_users'] = $content['just_me'] ? '' : implode(',',$content['allowed_users']);
|
||||
unset($content['just_me']);
|
||||
if($this->can_edit($content))
|
||||
{
|
||||
$content['owner'] = $content['just_me'] || !$GLOBALS['egw']->acl->check('share_definitions', EGW_ACL_READ,'importexport') ?
|
||||
($content['owner'] ? $content['owner'] : $GLOBALS['egw_info']['user']['account_id']) :
|
||||
null;
|
||||
$content['allowed_users'] = $content['just_me'] ? '' : implode(',',$content['allowed_users']);
|
||||
unset($content['just_me']);
|
||||
}
|
||||
|
||||
// workaround for some ugly bug related to readonlys;
|
||||
switch (array_search('pressed', $content['button']))
|
||||
@ -787,6 +796,11 @@ class importexport_definitions_ui
|
||||
$content['just_me'] = true;
|
||||
}
|
||||
|
||||
// Hide 'just me' checkbox, users get confused by read-only
|
||||
if($readonlys['just_me'] || !$this->can_edit($content))
|
||||
{
|
||||
$content['no_just_me'] = true;
|
||||
}
|
||||
unset ($preserv['button']);
|
||||
$GLOBALS['egw']->js->set_onload("disable_button('exec[button][next]');");
|
||||
if(is_object($this->response)) {
|
||||
@ -838,6 +852,30 @@ class importexport_definitions_ui
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user is allowed to edit the definition
|
||||
*
|
||||
*/
|
||||
protected function can_edit(Array $definition)
|
||||
{
|
||||
if($definition['owner'] && $definition['owner'] == $GLOBALS['egw_info']['user']['account_id'])
|
||||
{
|
||||
// Definition belongs to user
|
||||
return true;
|
||||
}
|
||||
elseif($definition['definition_id'] && !$definition['owner'] && $GLOBALS['egw_info']['user']['apps']['admin'])
|
||||
{
|
||||
// Definition is unowned, and user is an admin
|
||||
return true;
|
||||
}
|
||||
elseif(!$definition['definition_id'])
|
||||
{
|
||||
// Definition is in-progress, not saved yet
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Site configuration
|
||||
*/
|
||||
|
File diff suppressed because one or more lines are too long
@ -25,9 +25,9 @@
|
||||
<button statustext="export ALL selected definitions" label="Export" id="export_selected" image="fileexport"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row class="row">
|
||||
<row class="row $row_cont[class]">
|
||||
<image src="${row}[type]" no_lang="1" onclick="window.open(egw::link('/index.php','menuaction=importexport.importexport_${row_cont[type]}_ui.{$row_cont[type]}_dialog&appname=${row_cont[application]}&definition=${row_cont[name]}'),'_blank','dependent=yes,width=850,height=440,scrollbars=yes,status=yes'); return false;" class="lr_padding button"/>
|
||||
<description id="${row}[name]" no_lang="1" options="," class="lr_padding"/>
|
||||
<description id="${row}[name]" no_lang="1" class="lr_padding"/>
|
||||
<description id="${row}[application]" class="lr_padding"/>
|
||||
<listbox type="select-account" id="${row}[allowed_users]" no_lang="1" readonly="true" rows="5" options="both" class="lr_padding"/>
|
||||
<menulist>
|
||||
@ -78,7 +78,7 @@
|
||||
</menulist>
|
||||
<hbox>
|
||||
<button label="Save" onclick="nm_submit_popup(this); return false;"/>
|
||||
<buttononly label="Cancel" onclick="nm_hide_popup(this,'responsible_popup');"/>
|
||||
<buttononly label="Cancel" onclick="nm_hide_popup(this,'owner_popup');"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</box>
|
||||
@ -90,7 +90,7 @@
|
||||
<listbox type="select-account" id="allowed" rows="5" options="groups" class="action_popup-content"/>
|
||||
<hbox>
|
||||
<button label="Save" onclick="nm_submit_popup(this); return false;"/>
|
||||
<buttononly label="Cancel" onclick="nm_hide_popup(this,'responsible_popup');"/>
|
||||
<buttononly label="Cancel" onclick="nm_hide_popup(this,'allowed_popup');"/>
|
||||
</hbox>
|
||||
</vbox>
|
||||
</box>
|
||||
|
Loading…
Reference in New Issue
Block a user