]>
src.bluestatic.org Git - bugdar.git/blob - includes/api_user.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Bugdar [#]version[#]
5 || # Copyright ©2002-[#]year[#] Iris Studios, Inc.
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 [#]gpl[#] of the License.
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
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 \*=====================================================================*/
22 $GLOBALS['isso:callback']->load('api', null);
27 * @author Iris Studios, Inc.
28 * @copyright Copyright ©2002 - [#]year[#], Iris Studios, Inc.
33 class UserAPI
extends API
41 'userid' => array(TYPE_UINT
, REQ_AUTO
, 'verify_nozero'),
42 'email' => array(TYPE_STR
, REQ_YES
, ':self'),
43 'displayname' => array(TYPE_STR
, REQ_YES
, ':self'),
44 'usergroupid' => array(TYPE_UINT
, REQ_YES
, ':self'),
45 'password' => array(TYPE_STR
, REQ_YES
, 'verify_noempty'),
46 'salt' => array(TYPE_STR
, REQ_SET
),
47 'authkey' => array(TYPE_STR
, REQ_SET
),
48 'showemail' => array(TYPE_BOOL
, REQ_NO
),
49 'showcolours' => array(TYPE_BOOL
, REQ_NO
),
50 'languageid' => array(TYPE_UINT
, REQ_NO
),
51 'timezone' => array(TYPE_INT
, REQ_NO
)
66 var $prefix = TABLE_PREFIX
;
68 // ###################################################################
76 $this->set('salt', $this->registry
->funct
->rand(array(1, 15)));
79 // ###################################################################
85 function set_authkey()
87 $this->set('authkey', $this->registry
->funct
->rand());
90 // ###################################################################
98 $this->set('password', md5(md5($this->values
['password']) . md5($this->values
['salt'])));
101 // ###################################################################
107 function verify_email()
109 $this->verify_noempty('displayname');
111 if ($this->registry
->funct
->is_valid_email($this->values
['email']))
113 return $this->registry
->lang
->string('The specified email is invalid.');
115 if ($this->registry
->db
->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE email = '" . $this->registry
->db
->escape_string($this->values
['email']) . "'"))
117 return $this->registry
->lang
->string('The specified email is already in use.');
122 // ###################################################################
124 * Verify: displayname
128 function verify_displayname()
130 $this->verify_noempty('displayname');
132 if ($this->registry
->db
->query_first("SELECT * FROM " . TABLE_PREFIX
. "user WHERE displayname = '" . $this->registry
->db
->escape_string($this->values
['displayname']) . "'"))
134 return $this->registry
->lang
->string('That display name is already in use by another user.');
139 // ###################################################################
141 * Verify: usergroupid
145 function verify_usergroupid()
147 if (!isset($this->registry
->datastore
['usergroup'][ $this->values
['usergroupid'] ]))
154 // ###################################################################
160 function pre_update()
162 $this->set_condition();
165 if ($this->values
['password'] == '')
167 $this->set('password', $this->objdata
['password']);
171 $this->registry
->debug("updating password = true");
172 $this->set('password', md5(md5($this->values
['password']) . md5($this->objdata
['salt'])));
177 /*=====================================================================*\
178 || ###################################################################
181 || ###################################################################
182 \*=====================================================================*/