AC_4897, AC_4898, AC_4899: Multifile uploader fixes.
[acontent.git] / include / classes / DAO / UserGroupPrivilegeDAO.class.php
1 <?php
2 /************************************************************************/
3 /* AContent                                                             */
4 /************************************************************************/
5 /* Copyright (c) 2010                                                   */
6 /* Inclusive Design Institute                                           */
7 /*                                                                      */
8 /* This program is free software. You can redistribute it and/or        */
9 /* modify it under the terms of the GNU General Public License          */
10 /* as published by the Free Software Foundation.                        */
11 /************************************************************************/
12
13 /**
14  * DAO for "user_groups" table
15  * @access      public
16  * @author      Cindy Qi Li
17  * @package     DAO
18  */
19
20 if (!defined('TR_INCLUDE_PATH')) exit;
21
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
23
24 class UserGroupPrivilegeDAO extends DAO {
25
26         /**
27          * Create
28          * @access  public
29          * @param   userGroupID
30          *          privilegeID
31          * @return  true, if successful
32          *          false and add error into global var $msg, if unsuccessful
33          * @author  Cindy Qi Li
34          */
35         public function Create($userGroupID, $privilegeID)
36         {
37                 $sql = "INSERT INTO ".TABLE_PREFIX."user_group_privilege
38                               (user_group_id,
39                                privilege_id
40                                )
41                        VALUES (".$userGroupID.",
42                                ".$privilegeID."
43                               )";
44         
45                 return $this->execute($sql);
46         }
47
48         /**
49          * Update an existing user group privilege record
50          * @access  public
51          * @param   userGroupID: user group ID
52          *          privilegeID: privilege ID
53          *          fieldName: the name of the table field to update
54          *          fieldValue: the value to update
55          * @return  true if successful
56          *          error message array if failed; false if update db failed
57          * @author  Cindy Qi Li
58          */
59         public function UpdateField($userGroupID, $privilegeID, $fieldName, $fieldValue)
60         {
61                 global $addslashes;
62
63                 $sql = "UPDATE ".TABLE_PREFIX."user_group_privilege
64                            SET ".$fieldName."='".$addslashes($fieldValue)."'
65                          WHERE user_group_id = ".$userGroupID."
66                            AND privilege_id = ".$privilegeID;
67                 
68                 return $this->execute($sql);
69         }
70         
71         /**
72          * Delete a row
73          * @access  public
74          * @param   userGroupID
75          *          privilegeID
76          * @return  true, if successful
77          *          false and add error into global var $msg, if unsuccessful
78          * @author  Cindy Qi Li
79          */
80         public function Delete($userGroupID, $privilegeID)
81         {
82                 $sql = "DELETE FROM ".TABLE_PREFIX."user_group_privilege
83                          WHERE user_group_id = ".$userGroupID."
84                            AND privilege_id = ".$privilegeID;
85         
86                 return $this->execute($sql);
87         }
88
89         /**
90          * Update an existing user group
91          * @access  public
92          * @param   userGroupID
93          * @return  true, if successful
94          *          false and add error into global var $msg, if unsuccessful
95          * @author  Cindy Qi Li
96          */
97         public function DeleteByUserGroupID($userGroupID)
98         {
99                 $sql = "DELETE FROM ".TABLE_PREFIX."user_group_privilege
100                          WHERE user_group_id = ".$userGroupID;
101
102                 return $this->execute($sql);
103         }
104
105         /**
106          * Get a row by userGroupID and privilegeID
107          * @access  public
108          * @param   userGroupID
109          *          privilegeID
110          * @return  a table row, if successful
111          *          false, if the row is not found
112          * @author  Cindy Qi Li
113          */
114         public function Get($userGroupID, $privilegeID)
115         {
116                 $sql = "SELECT * FROM ".TABLE_PREFIX."user_group_privilege
117                          WHERE user_group_id = ".$userGroupID."
118                            AND privilege_id = ".$privilegeID;
119         
120                 $rows = $this->execute($sql);
121                 
122                 if (is_array($rows)) return $rows[0];
123                 else return false;
124         }
125
126 }
127 ?>