2 commits - lib/client lib/kolab_client_task.php public_html/skins
Aleksander Machniak
machniak at kolabsys.com
Fri Oct 5 12:45:44 CEST 2012
lib/client/kolab_client_task_settings.php | 64 +++++++++++++++++++-----------
lib/kolab_client_task.php | 2
public_html/skins/default/style.css | 5 +-
3 files changed, 47 insertions(+), 24 deletions(-)
New commits:
commit 26e2332619f7e0c909460e3f21049164243e5433
Author: Aleksander Machniak <alec at alec.pl>
Date: Fri Oct 5 12:45:18 2012 +0200
Fixes in Settings for read-only access to object types
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;
commit b231ceb9d286625668e239570e15ef2315eb69ac
Author: Aleksander Machniak <alec at alec.pl>
Date: Fri Oct 5 12:07:31 2012 +0200
Fix PHP warning when using array_combine() with an empty array
diff --git a/lib/client/kolab_client_task_settings.php b/lib/client/kolab_client_task_settings.php
index bd3ea99..7ebfcee 100644
--- a/lib/client/kolab_client_task_settings.php
+++ b/lib/client/kolab_client_task_settings.php
@@ -820,7 +820,10 @@ class kolab_client_task_settings extends kolab_client_task
if (!empty($response['list'])) {
// remove objectClass
$attributes = array_diff($response['list'], array('objectClass'));
- $attributes = array_combine(array_map('strtolower', $attributes), $attributes);
+ $attributes = array_map('strtolower', $attributes);
+ if (count($attributes)) {
+ $attributes = array_combine($attributes, $attributes);
+ }
}
$this->output->set_env('attributes', $attributes);
More information about the commits
mailing list