* Timesheet - only admins can select admin only statuses

This commit is contained in:
nathangray 2018-07-27 11:19:15 -06:00
parent 459f55d556
commit 7ed5c42b3d
2 changed files with 27 additions and 3 deletions

View File

@ -277,6 +277,30 @@ class timesheet_bo extends Api\Storage
} }
} }
/**
* Get status labels with admin statuses (optionally) filtered out
*
* @param boolean $admin
*
* @return Array
*/
protected function get_status_labels($admin = null)
{
if(is_null($admin))
{
$admin = isset($GLOBALS['egw_info']['user']['apps']['admin']);
}
$labels = array();
foreach($this->status_labels as $status_id => $label)
{
if($admin || !$admin && !$this->status_labels_config[$status_id]['admin'])
{
$labels[$status_id] = $label;
}
}
return $labels;
}
/** /**
* get list of specified grants as uid => Username pairs * get list of specified grants as uid => Username pairs
* *

View File

@ -444,7 +444,7 @@ class timesheet_ui extends timesheet_bo
$edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']); $edit_grants[$content['ts_owner']] = Api\Accounts::username($content['ts_owner']);
} }
$sel_options['ts_owner'] = $edit_grants; $sel_options['ts_owner'] = $edit_grants;
$sel_options['ts_status'] = $this->status_labels; $sel_options['ts_status'] = $this->get_status_labels($only_admin_edit);
if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS) if($this->config_data['history'] && $content['ts_status'] == self::DELETED_STATUS)
{ {
$sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted'; $sel_options['ts_status'][self::DELETED_STATUS] = 'Deleted';
@ -1051,9 +1051,9 @@ class timesheet_ui extends timesheet_bo
'icon' => 'apply', 'icon' => 'apply',
'caption' => 'Modify status', 'caption' => 'Modify status',
'group' => $group, 'group' => $group,
'children' => $this->status_labels, 'children' => $this->get_status_labels(),
'prefix' => 'to_status_', 'prefix' => 'to_status_',
'enabled' => (boolean)$this->status_labels, 'enabled' => (boolean)$this->get_status_labels(),
), ),
); );