2 /************************************************************************/
4 /************************************************************************/
5 /* Copyright (c) 2010 */
6 /* Inclusive Design Institute */
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 /************************************************************************/
14 * DAO for "user_groups" table
20 if (!defined('TR_INCLUDE_PATH')) exit;
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
24 class UserGroupPrivilegeDAO extends DAO {
31 * @return true, if successful
32 * false and add error into global var $msg, if unsuccessful
35 public function Create($userGroupID, $privilegeID)
37 $sql = "INSERT INTO ".TABLE_PREFIX."user_group_privilege
41 VALUES (".$userGroupID.",
45 return $this->execute($sql);
49 * Update an existing user group privilege record
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
59 public function UpdateField($userGroupID, $privilegeID, $fieldName, $fieldValue)
63 $sql = "UPDATE ".TABLE_PREFIX."user_group_privilege
64 SET ".$fieldName."='".$addslashes($fieldValue)."'
65 WHERE user_group_id = ".$userGroupID."
66 AND privilege_id = ".$privilegeID;
68 return $this->execute($sql);
76 * @return true, if successful
77 * false and add error into global var $msg, if unsuccessful
80 public function Delete($userGroupID, $privilegeID)
82 $sql = "DELETE FROM ".TABLE_PREFIX."user_group_privilege
83 WHERE user_group_id = ".$userGroupID."
84 AND privilege_id = ".$privilegeID;
86 return $this->execute($sql);
90 * Update an existing user group
93 * @return true, if successful
94 * false and add error into global var $msg, if unsuccessful
97 public function DeleteByUserGroupID($userGroupID)
99 $sql = "DELETE FROM ".TABLE_PREFIX."user_group_privilege
100 WHERE user_group_id = ".$userGroupID;
102 return $this->execute($sql);
106 * Get a row by userGroupID and privilegeID
110 * @return a table row, if successful
111 * false, if the row is not found
112 * @author Cindy Qi Li
114 public function Get($userGroupID, $privilegeID)
116 $sql = "SELECT * FROM ".TABLE_PREFIX."user_group_privilege
117 WHERE user_group_id = ".$userGroupID."
118 AND privilege_id = ".$privilegeID;
120 $rows = $this->execute($sql);
122 if (is_array($rows)) return $rows[0];