summaryrefslogtreecommitdiffstats
path: root/lib/kolab_client_task.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kolab_client_task.php')
-rw-r--r--lib/kolab_client_task.php67
1 files changed, 61 insertions, 6 deletions
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index ab5b191..1740384 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -351,10 +351,7 @@ class kolab_client_task
$msg . (isset($args['file']) ? sprintf(' in %s on line %d', $args['file'], $args['line']) : ''),
$_SERVER['REQUEST_METHOD']);
- if (!write_log('errors', $log_line)) {
- // send error to PHPs error handler if write_log() didn't succeed
- trigger_error($msg, E_USER_ERROR);
- }
+ write_log('errors', $log_line);
if (!$output) {
return;
@@ -483,7 +480,7 @@ class kolab_client_task
$capabilities = $this->capabilities();
- //console($capabilities);
+ //console("Capabilities", $capabilities);
foreach ($this->menu as $idx => $label) {
//console("$task: $task, idx: $idx, label: $label");
@@ -524,6 +521,31 @@ class kolab_client_task
}
/**
+ * Returns list of resource types.
+ *
+ * @return array List of resource types
+ */
+ protected function resource_types()
+ {
+
+ if (isset($_SESSION['resource_types'])) {
+ return $_SESSION['resource_types'];
+ }
+
+
+ $result = $this->api->post('resource_types.list');
+ $list = $result->get('list');
+
+
+ if (is_array($list) && !$this->config_get('devel_mode')) {
+ $_SESSION['resource_types'] = $list;
+ }
+
+ return $list;
+ }
+
+
+ /**
* Returns list of user types.
*
* @return array List of user types
@@ -541,6 +563,8 @@ class kolab_client_task
$_SESSION['user_types'] = $list;
}
+ //console("user_types() \$list", $list);
+
return $list;
}
@@ -583,6 +607,8 @@ class kolab_client_task
$result = $this->api->post('system.capabilities');
$list = $result->get('list');
+ //console("Capabilities obtained from the API", $list);
+
if (is_array($list)) {
$_SESSION['capabilities'] = $list;
}
@@ -766,7 +792,12 @@ class kolab_client_task
*/
protected function form_prepare($name, &$data, $extra_fields = array())
{
+ //console("Preparing form for $name with data", $data);
+
$types = (array) $this->{$name . '_types'}();
+
+ //console("form_prepare types", $types);
+
$form_id = $attribs['id'];
$add_mode = empty($data['id']);
@@ -963,6 +994,7 @@ class kolab_client_task
$data[$fname] = (array) $data[$fname];
}
+ //console("The data for field $fname at this point is", $data[$fname]);
// request parameters
$post = array(
'list' => $data[$fname],
@@ -976,6 +1008,7 @@ class kolab_client_task
$result = $result->get('list');
$data[$fname] = $result;
+ //console("Set \$data['$fname'] to", $result);
}
}
@@ -1005,13 +1038,24 @@ class kolab_client_task
*/
protected function form_create($name, $attribs, $sections, $fields, $fields_map, $data, $add_mode)
{
+ //console("Creating form for $name with data", $data);
+
+ //console("Assign fields to sections", $fields);
// Assign sections to fields
foreach ($fields as $idx => $field) {
if (!$field['section']) {
$fields[$idx]['section'] = isset($fields_map[$idx]) ? $fields_map[$idx] : 'other';
+ //console("Assigned field $idx to section " . $fields[$idx]['section']);
+/*
+ } else {
+ $fields[$idx]['section'] = 'other';
+ //console("Assigned field $idx to section " . $fields[$idx]['section']);
+*/
}
}
+ //console("Using fields_map", $fields_map);
+
// Sort
foreach ($fields_map as $idx => $val) {
if (array_key_exists($idx, $fields)) {
@@ -1026,13 +1070,19 @@ class kolab_client_task
$fields_map = array_merge($fields_map, $fields);
}
+ //console("Using attribs", $attribs);
+
$form = new kolab_form($attribs);
$assoc_fields = array();
$req_fields = array();
$writeable = 0;
$auto_fields = $this->output->get_env('auto_fields');
- //console("\$auto_fields", $auto_fields);
+
+ //console("form_create() \$attribs", $attribs);
+ //console("form_create() \$auto_fields", $auto_fields);
+
+ //console("Going to walk through sections", $sections);
// Parse elements and add them to the form object
foreach ($sections as $section_idx => $section) {
@@ -1052,6 +1102,9 @@ class kolab_client_task
$field['section'] = $section_idx;
if (empty($field['value']) && !empty($data[$idx])) {
+
+ //console("Using data value", $data[$idx], "for value of field $idx");
+
$field['value'] = $data[$idx];
// Convert data for the list field with autocompletion
@@ -1116,6 +1169,8 @@ class kolab_client_task
}
}
+ //console("Adding field to form", $field);
+
$form->add_element($field);
}
}