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 | 'title' => array( |
---|
18 | 'label' => 'Title', |
---|
19 | 'title' => True |
---|
20 | ), |
---|
21 | 'description' => 'Description', |
---|
22 | 'category' => 'Category', |
---|
23 | 'location' => 'Location', |
---|
24 | 'startdate' => 'Start Date/Time', |
---|
25 | 'enddate' => 'End Date/Time', |
---|
26 | 'priority' => 'Priority', |
---|
27 | 'access' => 'Access', |
---|
28 | 'participants'=> 'Participants', |
---|
29 | 'ex_participants'=> 'External Participants', |
---|
30 | 'owner' => 'Created By', |
---|
31 | 'updated' => 'Updated', |
---|
32 | 'alarm' => 'Alarm', |
---|
33 | 'recure_type' => 'Repetition', |
---|
34 | 'observations' => 'Observations', |
---|
35 | 'alter_by' => 'Alter by', |
---|
36 | 'attachment' => 'attachment', |
---|
37 | 'notifications_owner' => 'notifications_owner' |
---|
38 | ); |
---|
39 | |
---|
40 | function bocustom_fields() |
---|
41 | { |
---|
42 | $this->config = CreateObject('phpgwapi.config','calendar'); |
---|
43 | $this->config->read_repository(); |
---|
44 | |
---|
45 | $this->fields = &$this->config->config_data['fields']; |
---|
46 | |
---|
47 | if (!is_array($this->fields)) { |
---|
48 | $this->fields = array(); |
---|
49 | } |
---|
50 | |
---|
51 | foreach ($this->fields as $field => $data) // this can be removed after a while |
---|
52 | { |
---|
53 | if (!isset($this->stock_fields[$field]) && $field[0] != '#') |
---|
54 | { |
---|
55 | unset($this->fields[$field]); |
---|
56 | $this->fields['#'.$field] = $data; |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | foreach($this->stock_fields as $field => $data) |
---|
61 | { |
---|
62 | if (!is_array($data)) |
---|
63 | { |
---|
64 | $data = array('label' => $data); |
---|
65 | } |
---|
66 | if (!isset($this->fields[$field])) |
---|
67 | { |
---|
68 | $this->fields[$field] = array( |
---|
69 | 'name' => $field, |
---|
70 | 'title' => $data['title'], |
---|
71 | 'disabled' => $data['disabled'] |
---|
72 | ); |
---|
73 | } |
---|
74 | $this->fields[$field]['label'] = $data['label']; |
---|
75 | $this->fields[$field]['length'] = $data['length']; |
---|
76 | $this->fields[$field]['shown'] = $data['shown']; |
---|
77 | } |
---|
78 | } |
---|
79 | |
---|
80 | function set($data) |
---|
81 | { |
---|
82 | if (is_array($data) && strlen($data['name']) > 0) |
---|
83 | { |
---|
84 | if (!isset($this->stock_fields[$name = $data['name']])) |
---|
85 | { |
---|
86 | $name = '#'.$name; |
---|
87 | } |
---|
88 | $this->fields[$name] = $data; |
---|
89 | } |
---|
90 | } |
---|
91 | |
---|
92 | function save($fields=False) |
---|
93 | { |
---|
94 | if ($fields) |
---|
95 | { |
---|
96 | $this->fields = $fields; |
---|
97 | } |
---|
98 | //echo "<pre>"; print_r($this->config->config_data); echo "</pre>\n"; |
---|
99 | $this->config->save_repository(); |
---|
100 | } |
---|
101 | } |
---|