summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-10-05 10:45:18 (GMT)
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2012-11-26 13:29:46 (GMT)
commitcb8040b34c3438a55f7fd3791165803924075c44 (patch)
tree4c924a6842d90b5d93c972de81a69322d685f40d
parentc547543b2264387e515159743cb6750c0fb4a628 (diff)
downloadkolab-wap-cb8040b34c3438a55f7fd3791165803924075c44.tar.gz
Fixes in Settings for read-only access to object types
-rw-r--r--lib/client/kolab_client_task_settings.php59
-rw-r--r--lib/kolab_client_task.php2
-rw-r--r--public_html/skins/default/style.css5
3 files changed, 43 insertions, 23 deletions
diff --git a/lib/client/kolab_client_task_settings.php b/lib/client/kolab_client_task_settings.php
index 7ebfcee..e0cb7fe 100644
--- a/lib/client/kolab_client_task_settings.php
+++ b/lib/client/kolab_client_task_settings.php
@@ -49,7 +49,6 @@ class kolab_client_task_settings extends kolab_client_task
}
// otherwise display object types list
else if (self::can_edit_types($caps_actions)) {
- $this->output->set_object('content', 'type', true);
$this->action_type_list();
unset($this->menu['type_list']);
@@ -203,6 +202,9 @@ class kolab_client_task_settings extends kolab_client_task
$post['search'] = $search_request;
$post['search_operator'] = 'OR';
}
+ else {
+ $this->output->set_object('content', 'type', true);
+ }
// object type
$type = self::get_input('type', 'POST');
@@ -444,7 +446,11 @@ class kolab_client_task_settings extends kolab_client_task
$data['objectclass'] = array('top');
}
- $name = 'type';
+ // Get the rights on the entry and attribute level
+ $data['effective_rights'] = $this->effective_rights('type', $data['id']);
+ $attribute_rights = (array) $data['effective_rights']['attribute'];
+ $entry_rights = (array) $data['effective_rights']['entry'];
+
$add_mode = empty($data['id']);
$fields = array(
'key' => array(
@@ -484,12 +490,6 @@ class kolab_client_task_settings extends kolab_client_task
unset($form_fields['used_for']);
}
-
- // Get the rights on the entry and attribute level
- $data['effective_rights'] = $this->effective_rights($name, $data['id']);
- $attribute_rights = $data['effective_rights']['attribute'];
- $entry_rights = $data['effective_rights']['entry'];
-
// See if "administrators" (those who can delete and add back on the entry
// level) may override the automatically generated contents of auto_form_fields.
//$admin_auto_fields_rw = $this->config_get('admin_auto_fields_rw', false, Conf::BOOL);
@@ -586,10 +586,12 @@ class kolab_client_task_settings extends kolab_client_task
'value' => array(
'body' => $this->translate('attribute.value'),
),
- 'actions' => array(
- ),
);
+ if (!empty($data['effective_rights']['entry'])) {
+ $cells['actions'] = array();
+ }
+
foreach ($cells as $idx => $cell) {
$cells[$idx]['class'] = $idx;
}
@@ -611,8 +613,10 @@ class kolab_client_task_settings extends kolab_client_task
// table header
$table['head'] = array(array('cells' => $cells));
- $yes = $this->translate('yes');
- $no = '';
+ $rights = (array)$data['effective_rights']['attribute']['attributes'];
+ $yes = $this->translate('yes');
+ $no = '';
+
// defined attributes
foreach ($attributes as $attr) {
$row = $cells;
@@ -652,11 +656,22 @@ class kolab_client_task_settings extends kolab_client_task
$row['value']['body'] = $value;
$row['readonly']['body'] = $valtype == 'auto-readonly' ? $yes : $no;
$row['optional']['body'] = $optional ? $yes : $no;
- $row['actions']['body'] =
- kolab_html::a(array('href' => '#delete', 'onclick' => "kadm.type_attr_delete('$attr')",
- 'class' => 'button delete', 'title' => $this->translate('delete')))
- . kolab_html::a(array('href' => '#edit', 'onclick' => "kadm.type_attr_edit('$attr')",
- 'class' => 'button edit', 'title' => $this->translate('edit')));
+
+ if (!empty($row['actions'])) {
+ $row['actions']['body'] = '';
+
+ if (in_array('delete', $rights)) {
+ $row['actions']['body'] .= kolab_html::a(array(
+ 'href' => '#delete', 'onclick' => "kadm.type_attr_delete('$attr')",
+ 'class' => 'button delete', 'title' => $this->translate('delete')));
+ }
+
+ if (in_array('write', $rights)) {
+ $row['actions']['body'] .= kolab_html::a(array(
+ 'href' => '#edit', 'onclick' => "kadm.type_attr_edit('$attr')",
+ 'class' => 'button edit', 'title' => $this->translate('edit')));
+ }
+ }
$rows[] = array(
'id' => 'attr_table_row_' . $attr,
@@ -698,10 +713,12 @@ class kolab_client_task_settings extends kolab_client_task
'attribute.key.invalid', 'attribute.required.error');
// Add attribute link
- $link = kolab_html::a(array(
- 'href' => '#add_attr', 'class' => 'add_attr',
- 'onclick' => "kadm.type_attr_add()",
- 'content' => $this->translate('attribute.add')), true);
+ if (in_array('write', $rights)) {
+ $link = kolab_html::a(array(
+ 'href' => '#add_attr', 'class' => 'add_attr',
+ 'onclick' => "kadm.type_attr_add()",
+ 'content' => $this->translate('attribute.add')), true);
+ }
return kolab_html::table($table) . $link;
}
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index fec0404..d60f1ea 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -1248,7 +1248,7 @@ class kolab_client_task
));
}
- if (!empty($data['id']) && in_array('delete', $data['effective_rights']['entry'])) {
+ if (!empty($data['id']) && in_array('delete', (array) $data['effective_rights']['entry'])) {
$id = $data['id'];
$form->add_button(array(
'value' => kolab_html::escape($this->translate('button.delete')),
diff --git a/public_html/skins/default/style.css b/public_html/skins/default/style.css
index 287aa33..de3e7ec 100644
--- a/public_html/skins/default/style.css
+++ b/public_html/skins/default/style.css
@@ -512,12 +512,15 @@ input.inactive {
}
.disabled,
-.readonly {
+.readonly,
+.select.readonly option {
color: #a0a0a0;
}
input.disabled,
input.readonly,
+select.disabled,
+select.readonly,
textarea.disabled,
textarea.readonly {
background-color: #f5f5f5;