source: companies/celepar/contactcenter/inc/class.bo_group_manager.inc.php @ 763

Revision 763, 4.5 KB checked in by niltonneto, 15 years ago (diff)

Importação inicial do Expresso da Celepar

Line 
1<?php
2  /***************************************************************************\
3  * eGroupWare - Contacts Center                                              *
4  * http://www.egroupware.org                                                 *
5  * Written by:                                                               *
6  *  - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net>         *
7  *  sponsored by Thyamad - http://www.thyamad.com
8  * ------------------------------------------------------------------------- *
9  *  This program is free software; you can redistribute it and/or modify it  *
10  *  under the terms of the GNU General Public License as published by the    *
11  *  Free Software Foundation; either version 2 of the License, or (at your   *
12  *  option) any later version.                                               *
13  \***************************************************************************/
14
15        include_once('class.abo_catalog.inc.php');
16        class bo_group_manager extends abo_catalog
17        {
18                       
19                var $fields = array(
20                        'id_group'      => true,
21                        'title'                         => true,                       
22                        'short_name'    => true,
23                        'owner' => true
24                );
25       
26                /*!
27               
28                 @function bo_group_manager
29                 @abstract Constructor
30                 @author Raphael Derosso Pereira
31                 
32                */
33                function bo_group_manager()
34                {
35                        $this->init();         
36                       
37                }
38
39                /*!
40                        @function find
41                        @abstract Find function for this catalog
42                        @author Raphael Derosso Pereira
43
44                */
45                function find($what, $rules=false, $other=false)
46                {
47                       
48                        if (is_array($what) and count($what))
49                        {
50                                $found = false;
51                               
52                                foreach ($what as $value)
53                                {
54                                        if (strpos($value, 'group') === 0)
55                                        {
56                                                $found = true;
57                                        }
58                                }
59                               
60                                if (!$found)
61                                {
62                                        return $this->sql_find($what, $rules, $other);
63                                }
64                                                               
65                        }
66
67                        return $this->sql_find($what, $rules, $other);
68                }
69                       
70                /*!
71                 
72                 @function get_multiple_entries
73                 @abstract Returns multiple Contacts data into one array
74                 @author Raphael Derosso Pereira
75
76                 @param array $id_contacts The Contacts IDs
77                 @param array $fields The Contacts fields to be retrieved
78                 @param array $other_data Other informations. The format is:
79                        $other_data = array(
80                                'offset'    => <offset>,
81                                'limit'     => <max_num_returns>,
82                                'sort'      => <sort>,
83                                'order_by'  => <order by>
84                        );
85               
86                */
87                function get_multiple_entries ( $id_groups, $fields, $other_data = false )
88                {
89                               
90                        $groups = array();
91                       
92                        foreach ($id_groups as $id)
93                        {
94                                $group = $this->get_single_entry($id,$fields);                         
95                                                               
96                                if ($group)
97                                {
98                                        $groups[] = $group;
99                                }
100                        }                       
101                       
102                        return $groups;
103       
104                }
105
106                /*!
107               
108                        @function get_all_entries_ids
109                        @abstract Returns the IDs of all the entries in this catalog
110                        @author Raphael Derosso Pereira
111
112                */
113                function get_all_entries_ids ()
114                {
115                       
116                        $search_fields = array('group.id_group', 'group.title');
117                        $search_other  = array('order' => 'group.title');
118                       
119                        $search_rules = array();
120                        array_push($search_rules, array(
121                                        'field' => 'group.owner',
122                                        'type'  => '=',
123                                        'value' => $GLOBALS['phpgw_info']['user']['account_id']
124                                ));                     
125
126                        $result_i = $this->find($search_fields, $search_rules, $search_other);
127                       
128
129                        if (is_array($result_i) and count($result_i))
130                        {
131                                $result = array();
132                                foreach($result_i as $result_part)
133                                {
134                                        $result[] = $result_part['id_group'];
135                                }
136                                                                                               
137                                return $result;
138                        }
139                       
140                        return null;
141                }
142               
143                function get_single_entry ( $id, $fields )
144                {       
145                       
146                        if (!is_array($fields))
147                        {
148                                if (is_object($GLOBALS['phpgw']->log))
149                                {
150                                        $GLOBALS['phpgw']->log->message(array(
151                                                'text' => 'F-BadcontactcenterParam, wrong get_single_entry parameters type.',
152                                                'line' => __LINE__,
153                                                'file' => __FILE__));
154                                       
155                                        $GLOBALS['phpgw']->log->commit();
156                                }
157                                else
158                                {
159                                        exit('Argument Error on: <br>File:'.__FILE__.'<br>Line:'.__LINE__.'<br>');
160                                }
161                        }
162
163                        $soGroup = CreateObject('contactcenter.so_group');                     
164                        $group = $soGroup -> select($id);
165
166                         return $group[0];                                             
167                }
168               
169                function add_group ( $data )
170                {
171                        $permissions = $this->security->get_permissions();
172                       
173                        if (!$permissions['create'])
174                        {
175                                return false;
176                        }
177                       
178                        $soGroup = CreateObject('contactcenter.so_group');
179       
180                        if(! $data['id_group'])
181                                $id = $soGroup -> insert($data);
182                        else                           
183                                $id = $soGroup -> update($data);
184                               
185                        return $id;
186                }
187               
188                function get_contacts_by_group ( $id )
189                {
190                        $soGroup = CreateObject('contactcenter.so_group');                     
191                        return $soGroup -> selectContactsByGroup($id);
192                }
193       
194}
195?>
Note: See TracBrowser for help on using the repository browser.