1 | <?php |
---|
2 | /**************************************************************************\ |
---|
3 | * eGroupWare - Calendar - Custom fields and sorting * |
---|
4 | * http://www.egroupware.org * |
---|
5 | * Written by Ralf Becker <RalfBecker@outdoor-training.de> * |
---|
6 | * -------------------------------------------- * |
---|
7 | * This program is free software; you can redistribute it and/or modify it * |
---|
8 | * under the terms of the GNU General Public License as published by the * |
---|
9 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
10 | * option) any later version. * |
---|
11 | \**************************************************************************/ |
---|
12 | |
---|
13 | |
---|
14 | class bocustom_fields |
---|
15 | { |
---|
16 | var $stock_fields = array( |
---|
17 | |
---|
18 | 'title' => 'title', |
---|
19 | 'category' => 'Category', |
---|
20 | 'project' => 'project', |
---|
21 | |
---|
22 | 'tarea' => 'tarea', |
---|
23 | 'accesso' => 'accesso', |
---|
24 | 'description' => 'Description', |
---|
25 | 'startdate' => 'Start Date/Time', |
---|
26 | 'enddate' => 'End Date/Time'//, |
---|
27 | |
---|
28 | //'enddate2' => 'End Date2/End Time2' |
---|
29 | ); |
---|
30 | |
---|
31 | function bocustom_fields() |
---|
32 | { |
---|
33 | $this->config = CreateObject('phpgwapi.config','calendar'); |
---|
34 | $this->config->read_repository(); |
---|
35 | |
---|
36 | $this->fields = &$this->config->config_data['fields']; |
---|
37 | |
---|
38 | if (!is_array($this->fields)) { |
---|
39 | $this->fields = array(); |
---|
40 | } |
---|
41 | |
---|
42 | foreach ($this->fields as $field => $data) // this can be removed after a while |
---|
43 | { |
---|
44 | if (!isset($this->stock_fields[$field]) && $field[0] != '#') |
---|
45 | { |
---|
46 | unset($this->fields[$field]); |
---|
47 | $this->fields['#'.$field] = $data; |
---|
48 | } |
---|
49 | } |
---|
50 | |
---|
51 | foreach($this->stock_fields as $field => $data) |
---|
52 | { |
---|
53 | if (!is_array($data)) |
---|
54 | { |
---|
55 | $data = array('label' => $data); |
---|
56 | } |
---|
57 | if (!isset($this->fields[$field])) |
---|
58 | { |
---|
59 | $this->fields[$field] = array( |
---|
60 | 'name' => $field, |
---|
61 | 'title' => $data['title'], |
---|
62 | 'disabled' => $data['disabled'] |
---|
63 | ); |
---|
64 | } |
---|
65 | $this->fields[$field]['label'] = $data['label']; |
---|
66 | $this->fields[$field]['length'] = $data['length']; |
---|
67 | $this->fields[$field]['shown'] = $data['shown']; |
---|
68 | } |
---|
69 | } |
---|
70 | |
---|
71 | function set($data) |
---|
72 | { |
---|
73 | if (is_array($data) && strlen($data['name']) > 0) |
---|
74 | { |
---|
75 | if (!isset($this->stock_fields[$name = $data['name']])) |
---|
76 | { |
---|
77 | $name = '#'.$name; |
---|
78 | } |
---|
79 | $this->fields[$name] = $data; |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|
83 | function save($fields=False) |
---|
84 | { |
---|
85 | if ($fields) |
---|
86 | { |
---|
87 | $this->fields = $fields; |
---|
88 | } |
---|
89 | //echo "<pre>"; print_r($this->config->config_data); echo "</pre>\n"; |
---|
90 | $this->config->save_repository(); |
---|
91 | } |
---|
92 | } |
---|