git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@832 97e9348a-65ac-dc4b-aefc-98561f571b83
40 lines
956 B
PHP
40 lines
956 B
PHP
<?php
|
|
class User extends AppModel {
|
|
|
|
var $hasMany =
|
|
array('UserOption',
|
|
'Membership',
|
|
);
|
|
|
|
static $current_user_id;
|
|
|
|
function currentUser() {
|
|
if (!empty($_SERVER['REMOTE_USER']))
|
|
return $_SERVER['REMOTE_USER'];
|
|
|
|
return null;
|
|
}
|
|
|
|
function currentUserId() {
|
|
if (!empty(self::$current_user_id))
|
|
return self::$current_user_id;
|
|
|
|
$user = $this->find
|
|
('first',
|
|
array('recursive' => -1,
|
|
'conditions' => array('login' => $this->currentUser())));
|
|
|
|
if (!empty($user['User']['id']))
|
|
self::$current_user_id = $user['User']['id'];
|
|
else
|
|
// We must force a stop here, since this is typically
|
|
// called very early on, and so will cause a recursive
|
|
// crash as we try to render the internal error and
|
|
// again stumble on this problem.
|
|
$this->INTERNAL_ERROR('UNKNOWN USER', 0, true);
|
|
|
|
return self::$current_user_id;
|
|
}
|
|
|
|
}
|