/[cvs]/bareface/yakka/storage-providers/YakkaMySqlUserAdapter.php
ViewVC logotype

Contents of /bareface/yakka/storage-providers/YakkaMySqlUserAdapter.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sun Jan 5 00:22:26 2003 UTC (21 years, 11 months ago) by bareface
Branch: MAIN
CVS Tags: HEAD
init;

1 <?php
2
3 require_once("YakkaMySqlDatabase.php");
4 require_once("library/YakkaUser.php");
5
6 class YakkaMySqlUserAdapter extends YakkaMySqlDatabase {
7 var $table;
8 var $roleTable;
9 var $roleAssignmentTable;
10
11 function YakkaMySqlUserAdapter($parameters = null) {
12 $this->YakkaMySqlDatabase();
13
14 if ($parameters)
15 $this->connect($parameters["host"], $parameters["database"], $parameters["user"], $parameters["password"]);
16
17 if (!$prefix = $parameters["table-prefix"]) {
18 $this->table = "users";
19 $this->roleTable = "roles";
20 $this->roleAssignmentTable = "user_role_asgs";
21 } else {
22 $this->table = $prefix."users";
23 $this->roleTable = $prefix."roles";
24 $this->roleAssignmentTable = $prefix."user_role_asgs";
25 }
26 }
27
28 function loadUser($id) {
29 $id = $this->escapeString($id);
30 $sql =
31 <<<MYSQL
32 SELECT
33 user_tag,
34 user_name
35 FROM
36 $this->table
37 WHERE
38 user_tag = '$id'
39 LIMIT 1
40 MYSQL;
41 if ($result = $this->queryRecord($sql))
42 return array(
43 "id" => $result["user_tag"],
44 "name" => $result["user_name"]
45 );
46
47 return null;
48 }
49
50 function authenticateUser($username, $password) {
51 $username = $this->escapeString($username);
52 $password = $this->escapeString(md5($password));
53 $sql =
54 <<<MYSQL
55 SELECT
56 user_tag,
57 user_name
58 FROM
59 $this->table
60 WHERE
61 user_username = '$username'
62 AND
63 user_password = '$password'
64 LIMIT 1
65 MYSQL;
66 if ($result = $this->queryRecord($sql))
67 return array(
68 "id" => $result["user_tag"],
69 "name" => $result["user_name"]
70 );
71
72 return null;
73 }
74
75 function loadUserRoles($id) {
76 $id = $this->escapeString($id);
77 $sql =
78 <<<MYSQL
79 SELECT
80 role_tag as id
81 FROM
82 $this->roleTable,
83 $this->roleAssignmentTable,
84 $this->table
85 WHERE
86 user_tag = '$id'
87 AND
88 user_id = uras_user_id
89 AND
90 uras_role_id = role_id
91 MYSQL;
92 if ($result = $this->queryRecordset($sql))
93 return $result;
94
95 return null;
96 }
97
98 function loadRole($id) {
99 $id = $this->escapeString($id);
100 $sql =
101 <<<MYSQL
102 SELECT
103 role_tag,
104 role_name,
105 role_comment
106 FROM
107 $this->roleTable
108 WHERE
109 role_tag = '$id'
110 LIMIT 1
111 MYSQL;
112
113 if ($result = $this->queryRecord($sql))
114 return array(
115 "id" => $result["role_tag"],
116 "name" => $result["role_name"],
117 "comment" => $result["role_comment"]
118 );
119
120 return null;
121 }
122 }
123
124 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed