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