Fix DB_MySQL_PDO::escape_binary().
[bugdar.git] / includes / api_usergroup.php
1 <?php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar
5 || # Copyright (c)2002-2007 Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version 2 of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 $GLOBALS['isso:callback']->load('api', null);
23
24 require_once('./includes/functions_datastore.php');
25
26 /**
27 * API: Usergroup
28 *
29 * @author Blue Static
30 * @copyright Copyright (c)2002 - 2007, Blue Static
31 * @version $Revision$
32 * @package Bugdar
33 *
34 */
35 class UsergroupAPI extends API
36 {
37 /**
38 * Fields
39 * @var array
40 * @access private
41 */
42 var $fields = array(
43 'usergroupid' => array(TYPE_UINT, REQ_AUTO, 'verify_nozero'),
44 'title' => array(TYPE_STR, REQ_YES, 'verify_noempty'),
45 'displaytitle' => array(TYPE_STR, REQ_NO),
46 'permissions' => array(TYPE_UINT, REQ_NO)
47 );
48
49 /**
50 * Database table
51 * @var string
52 * @access private
53 */
54 var $table = 'usergroup';
55
56 /**
57 * Table prefix
58 * @var string
59 * @access private
60 */
61 var $prefix = TABLE_PREFIX;
62
63 // ###################################################################
64 /**
65 * Post-insert
66 *
67 * @access private
68 */
69 function post_insert()
70 {
71 build_usergroups();
72 }
73
74 // ###################################################################
75 /**
76 * Post-update
77 *
78 * @access private
79 */
80 function post_update()
81 {
82 build_usergroups();
83 build_assignedto();
84 }
85
86 // ###################################################################
87 /**
88 * Pre-delete
89 *
90 * @access private
91 */
92 function pre_delete()
93 {
94 if ($this->values['usergroupid'] < 7)
95 {
96 return T('You can\'t delete a default usergroup.');
97 }
98 }
99
100 // ###################################################################
101 /**
102 * Post-delete
103 *
104 * @access private
105 */
106 function post_delete()
107 {
108 $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "permission WHERE usergroupid = " . $this->values['usergroupid']);
109 $this->registry->db->query("DELETE FROM " . TABLE_PREFIX . "bugfieldpermission WHERE usergroupid = " . $this->values['usergroupid']);
110 $this->registry->db->query("UPDATE " . TABLE_PREFIX . "user SET usergroupid = 2 WHERE usergroupid = " . $this->values['usergroupid']);
111 build_usergroups();
112 build_permissions();
113 build_assignedto();
114 }
115 }
116