source: contrib/resources/inc/class.bocustom_fields.inc.php @ 3524

Revision 3524, 2.5 KB checked in by afernandes, 13 years ago (diff)

Ticket #1416 - Disponibilizado módulo de recursos para a comunidade

  • 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                       
18                        'name'    => 'name',
19                        'category'    => 'Category',
20                        'location'    => 'location',                   
21                        'cantidad'    => 'cantidad',
22                        'administrador'      => 'administrador',
23                        'email' =>'email',
24                        'description' => 'Description'//,
25
26//'enddate2'     => 'End Date2/End Time2'
27                );
28
29                function bocustom_fields()
30                {
31                        $this->config = CreateObject('phpgwapi.config','calendar');
32                        $this->config->read_repository();
33
34                        $this->fields = &$this->config->config_data['fields'];
35
36                        if (!is_array($this->fields)) {
37                                $this->fields = array();
38                        }
39
40                        foreach ($this->fields as $field => $data)      // this can be removed after a while
41                        {
42                                if (!isset($this->stock_fields[$field]) && $field[0] != '#')
43                                {
44                                        unset($this->fields[$field]);
45                                        $this->fields['#'.$field] = $data;
46                                }
47                        }
48
49                        foreach($this->stock_fields as $field => $data)
50                        {
51                                if (!is_array($data))
52                                {
53                                        $data = array('label' => $data);
54                                }
55                                if (!isset($this->fields[$field]))
56                                {
57                                        $this->fields[$field] = array(
58                                                'name'     => $field,
59                                                'title'    => $data['title'],
60                                                'disabled' => $data['disabled']
61                                        );
62                                }
63                                $this->fields[$field]['label']  = $data['label'];
64                                $this->fields[$field]['length'] = $data['length'];
65                                $this->fields[$field]['shown']  = $data['shown'];
66                        }
67                }
68
69                function set($data)
70                {
71                        if (is_array($data) && strlen($data['name']) > 0)
72                        {
73                                if (!isset($this->stock_fields[$name = $data['name']]))
74                                {
75                                        $name = '#'.$name;
76                                }
77                                $this->fields[$name] = $data;
78                        }
79                }
80
81                function save($fields=False)
82                {
83                        if ($fields)
84                        {
85                                $this->fields = $fields;
86                        }
87                        //echo "<pre>"; print_r($this->config->config_data); echo "</pre>\n";
88                        $this->config->save_repository();
89                }
90        }
Note: See TracBrowser for help on using the repository browser.