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 "myown_patches_files" table
20 if (!defined('TR_INCLUDE_PATH')) exit;
22 require_once(TR_INCLUDE_PATH. 'classes/DAO/DAO.class.php');
24 class MyownPatchesFilesDAO extends DAO {
29 * @param $myown_patch_id, $action, $name, $location,
30 * $code_from, $code_to, $uploaded_file
31 * @return myown_patches_files_id, if successful
32 * false and add error into global var $msg, if unsuccessful
35 public function Create($myown_patch_id, $action, $name, $location,
36 $code_from, $code_to, $uploaded_file)
40 $sql = "INSERT INTO ".TABLE_PREFIX."myown_patches_files
48 VALUES ('".$myown_patch_id."',
54 '".$addslashes($uploaded_file)."')";
56 if (!$this->execute($sql))
58 $msg->addError('DB_NOT_UPDATED');
63 return mysql_insert_id();
70 * @param user_group_id: user group ID (1 [admin] or 2 [user])
74 * first_name: first name
75 * last_name: last name
76 * @return user id, if successful
77 * false and add error into global var $msg, if unsuccessful
80 public function Update($userID, $user_group_id, $login, $email, $first_name, $last_name, $status)
82 global $addslashes, $msg;
85 $login = $addslashes(strtolower(trim($login)));
86 $email = $addslashes(trim($email));
87 $first_name = $addslashes(str_replace('<', '', trim($first_name)));
88 $last_name = $addslashes(str_replace('<', '', trim($last_name)));
90 if ($this->isFieldsValid('update', $user_group_id,$login, $email,$first_name, $last_name))
92 /* insert into the db */
93 $sql = "UPDATE ".TABLE_PREFIX."users
94 SET login = '".$login."',
95 user_group_id = '".$user_group_id."',
96 first_name = '".$first_name."',
97 last_name = '".$last_name."',
99 status = '".$status."'
100 WHERE user_id = ".$userID;
102 return $this->execute($sql);
107 * Delete rows by given patch id
110 * @return true, if successful
111 * false and add error into global var $msg, if unsuccessful
112 * @author Cindy Qi Li
114 public function DeleteByPatchID($patchID)
116 $sql = "DELETE FROM ".TABLE_PREFIX."myown_patches_files
117 WHERE myown_patch_id = ".$patchID;
119 return $this->execute($sql);
123 * Return the patch files info with the given patch id
127 * @author Cindy Qi Li
129 public function getByPatchID($patchID)
131 $sql = "SELECT * from ".TABLE_PREFIX."myown_patches_files
132 WHERE myown_patch_id=". $patchID."
133 ORDER BY myown_patches_files_id";
135 return $this->execute($sql);