source: branches/2.2.0.1/calendar/inc/class.bocustom_fields.inc.php @ 3976

Revision 3976, 2.9 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1607 - Incluir um campo Observações na Agenda

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