[2] | 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 | ); |
---|
| 35 | |
---|
| 36 | function bocustom_fields() |
---|
| 37 | { |
---|
| 38 | $this->config = CreateObject('phpgwapi.config','calendar'); |
---|
| 39 | $this->config->read_repository(); |
---|
| 40 | |
---|
| 41 | $this->fields = &$this->config->config_data['fields']; |
---|
| 42 | |
---|
| 43 | if (!is_array($this->fields)) { |
---|
| 44 | $this->fields = array(); |
---|
| 45 | } |
---|
| 46 | |
---|
| 47 | foreach ($this->fields as $field => $data) // this can be removed after a while |
---|
| 48 | { |
---|
| 49 | if (!isset($this->stock_fields[$field]) && $field[0] != '#') |
---|
| 50 | { |
---|
| 51 | unset($this->fields[$field]); |
---|
| 52 | $this->fields['#'.$field] = $data; |
---|
| 53 | } |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | foreach($this->stock_fields as $field => $data) |
---|
| 57 | { |
---|
| 58 | if (!is_array($data)) |
---|
| 59 | { |
---|
| 60 | $data = array('label' => $data); |
---|
| 61 | } |
---|
| 62 | if (!isset($this->fields[$field])) |
---|
| 63 | { |
---|
| 64 | $this->fields[$field] = array( |
---|
| 65 | 'name' => $field, |
---|
| 66 | 'title' => $data['title'], |
---|
| 67 | 'disabled' => $data['disabled'] |
---|
| 68 | ); |
---|
| 69 | } |
---|
| 70 | $this->fields[$field]['label'] = $data['label']; |
---|
| 71 | $this->fields[$field]['length'] = $data['length']; |
---|
| 72 | $this->fields[$field]['shown'] = $data['shown']; |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | function set($data) |
---|
| 77 | { |
---|
| 78 | if (is_array($data) && strlen($data['name']) > 0) |
---|
| 79 | { |
---|
| 80 | if (!isset($this->stock_fields[$name = $data['name']])) |
---|
| 81 | { |
---|
| 82 | $name = '#'.$name; |
---|
| 83 | } |
---|
| 84 | $this->fields[$name] = $data; |
---|
| 85 | } |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | function save($fields=False) |
---|
| 89 | { |
---|
| 90 | if ($fields) |
---|
| 91 | { |
---|
| 92 | $this->fields = $fields; |
---|
| 93 | } |
---|
| 94 | //echo "<pre>"; print_r($this->config->config_data); echo "</pre>\n"; |
---|
| 95 | $this->config->save_repository(); |
---|
| 96 | } |
---|
| 97 | } |
---|