forked from dotproject/dotProject
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.class.php
More file actions
100 lines (93 loc) · 2.42 KB
/
admin.class.php
File metadata and controls
100 lines (93 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php /* ADMIN $Id$ */
if (!defined('DP_BASE_DIR')) {
die('You should not access this file directly.');
}
/**
* User Class
*/
class CUser extends CDpObject {
var $user_id = NULL;
var $user_username = NULL;
var $user_password = NULL;
var $user_parent = NULL;
var $user_type = NULL;
var $user_contact = NULL;
var $user_signature = NULL;
/* var $user_first_name = NULL;
var $user_last_name = NULL;
var $user_company = NULL;
var $user_department = NULL;
var $user_email = NULL;
var $user_phone = NULL;
var $user_home_phone = NULL;
var $user_mobile = NULL;
var $user_address1 = NULL;
var $user_address2 = NULL;
var $user_city = NULL;
var $user_state = NULL;
var $user_zip = NULL;
var $user_country = NULL;
var $user_icq = NULL;
var $user_aol = NULL;
var $user_birthday = NULL;
var $user_pic = NULL;
var $user_owner = NULL; */
public function __construct() {
parent::__construct('users', 'user_id');
}
function check() {
if ($this->user_id === NULL) {
return 'user id is NULL';
}
if ($this->user_password !== NULL) {
$this->user_password = db_escape(trim($this->user_password));
}
// TODO MORE
return NULL; // object is ok
}
function store($updateNulls = FALSE) {
$msg = $this->check();
if ($msg) {
return get_class($this)."::store-check failed";
}
$q = new DBQuery;
if ($this->user_id) {
// save the old password
$perm_func = "updateLogin";
if ($this->user_password) {
$this->user_password = md5($this->user_password);
addHistory($this->_tbl, $this->user_id, 'password changed',
'Password changed from IP ' . $_SERVER['REMOTE_ADDR']);
} else {
$this->user_password = null;
}
$ret = db_updateObject('users', $this, 'user_id', false);
} else {
$perm_func = "addLogin";
$this->user_password = md5($this->user_password);
$ret = db_insertObject('users', $this, 'user_id');
}
if (!$ret) {
return get_class($this)."::store failed <br />" . db_error();
} else {
$acl =& $GLOBALS['AppUI']->acl();
$acl->$perm_func($this->user_id, $this->user_username);
return NULL;
}
}
function delete($oid = NULL, $history_desc = '', $history_proj = 0) {
$id = $this->user_id;
$result = parent::delete($oid);
if (! $result) {
$acl =& $GLOBALS['AppUI']->acl();
$acl->deleteLogin($id);
$q = new DBQuery;
$q->setDelete('user_preferences');
$q->addWhere('pref_user = '.$this->user_id);
$q->exec();
$q->clear();
}
return $result;
}
}
?>