source: branches/1.2/contactcenter/inc/class.so_connection.inc.php @ 2

Revision 2, 4.7 KB checked in by niltonneto, 17 years ago (diff)

Removida todas as tags usadas pelo CVS ($Id, $Source).
Primeira versão no CVS externo.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  *                                                                           *
6  * Storage Object Classes                                                    *
7  * Written by:                                                               *
8  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
9  *  sponsored by Thyamad - http://www.thyamad.com                            *
10  * ------------------------------------------------------------------------- *
11  *  This program is free software; you can redistribute it and/or modify it  *
12  *  under the terms of the GNU General Public License as published by the    *
13  *  Free Software Foundation; either version 2 of the License, or (at your   *
14  *  option) any later version.                                               *
15  \***************************************************************************/
16
17
18        include_once("class.so_main.inc.php");
19       
20        class so_connection extends so_main
21        {
22       
23                function so_connection ( $id = false )
24                {
25                        $this->init();
26                       
27                        $this->main_fields = array(
28                                'id_connection' => array(
29                                        'name'  => 'id_connection',
30                                        'type'  => 'primary',
31                                        'state' => 'empty',
32                                        'value' => &$this->id
33                                ),
34                                'connection_name' => array(
35                                        'name'  => 'connection_name',
36                                        'type'  => false,
37                                        'state' => 'empty',
38                                        'value' => false
39                                ),
40                                'connection_value' => array(
41                                        'name'  => 'connection_value',
42                                        'type'  => false,
43                                        'state' => 'empty',
44                                        'value' => false
45                                ),
46                                'connection_is_default' => array(
47                                        'name'  => 'connection_is_default',
48                                        'type'  => false,
49                                        'state' => 'empty',
50                                        'value' => false
51                                )
52                        );
53
54                        $this->db_tables = array(
55                                'phpgw_cc_connections' => array(
56                                        'type'   => 'main',
57                                        'keys'   => array(
58                                                'primary' => array(&$this->main_fields['id_connection']),
59                                                'foreign' => false
60                                        ),
61                                        'fields' => & $this->main_fields
62                                )
63                        );
64                       
65                        if ($id)
66                        {
67                                if (!$this->checkout($id))
68                                {
69                                        $this->reset_values();
70                                        $this->state = 'new';
71                                }
72                        }
73                        else
74                        {
75                                $this->state = 'new';
76                        }
77                }
78
79
80
81                /**********************************************************************\
82                 *                    Methods to Get Information                      *
83                \**********************************************************************/
84
85                /*!
86               
87                        @function get_name
88                        @abstract Returns the Connection Name
89                        @author Raphael Derosso Pereira
90                       
91                */     
92                function get_name (  )
93                {
94                        return $this->main_fields['connection_name']['value'];
95                }
96       
97                /*!
98               
99                        @function get_value
100                        @abstract Return the Connection Value
101                        @author Raphael Derosso Pereira
102               
103                */     
104                function get_value (  )
105                {
106                        return $this->main_fields['connection_value']['value'];
107                }
108       
109                /*!
110               
111                        @function is_default
112                        @abstract Return true if this is the default
113                                connection, else return false
114                        @author Raphael Derosso Pereira
115               
116                */     
117                function is_default (  )
118                {
119                        switch (strtolower($this->main_fields['connection_is_default']['value']))
120                        {
121                                case 't':
122                                case 'true':
123                                case '1':
124                                        return true;
125
126                                case 'f':
127                                case 'false':
128                                case '0':
129                                        return false;
130                        }
131                }
132       
133
134
135                /**********************************************************************\
136                 *                    Methods to Set Information                      *
137                \**********************************************************************/
138
139                /*!
140               
141                        @function set_name
142                        @abstract Sets the Connection Name
143                        @author Raphael Derosso Pereira
144                       
145                        @param string $name The Connection Name
146               
147                */     
148                function set_name ( $name )
149                {
150                        $this->main_fields['connection_name']['value'] = $name;
151                        $this->manage_fields($this->main_fields['connection_name'], 'changed');
152                }
153       
154                /*!
155               
156                        @function set_value
157                        @abstract Sets the Connection Value
158                        @author Raphael Derosso Pereira
159               
160                        @param string $value The Connection Value
161               
162                */     
163                function set_value ( $value )
164                {
165                        $this->main_fields['connection_value']['value'] = $value;
166                        $this->manage_fields($this->main_fields['connection_value'], 'changed');
167                }
168       
169                /*!
170               
171                        @function set_default
172                        @abstract Sets the Connection Default trueness
173                        @author Raphael Derosso Pereira
174               
175                        @param boolean $default The Connection Default trueness
176               
177                */     
178                function set_default ( $default )
179                {
180                        if ($default)
181                        {
182                                $this->main_fields['connection_name']['value'] = 1;
183                        }
184                        else
185                        {
186                                $this->main_fields['connection_name']['value'] = 0;
187                        }
188                        $this->manage_fields($this->main_fields['connection_name'], 'changed');
189                }
190       
191        }
192?>
Note: See TracBrowser for help on using the repository browser.