mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
make basic data of current user available via egw.user(_field)
This commit is contained in:
parent
54bf7a3d2d
commit
046c0919cc
@ -381,6 +381,27 @@ class accounts
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an account as json, returns only whitelisted fields:
|
||||
* - 'account_id','account_lid','person_id','account_status',
|
||||
* - 'account_firstname','account_lastname','account_email','account_fullname','account_phone'
|
||||
*
|
||||
* @param int|string $id
|
||||
* @return string|boolean json or false if not found
|
||||
*/
|
||||
function json($id)
|
||||
{
|
||||
static $keys = array(
|
||||
'account_id','account_lid','person_id','account_status',
|
||||
'account_firstname','account_lastname','account_email','account_fullname','account_phone',
|
||||
);
|
||||
if (($account = $this->read($id)))
|
||||
{
|
||||
$account = array_intersect_key($account, array_flip($keys));
|
||||
}
|
||||
return json_encode($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves / adds the data of one account
|
||||
*
|
||||
|
@ -476,7 +476,7 @@ class accounts_ldap
|
||||
protected function _read_user($account_id)
|
||||
{
|
||||
$sri = ldap_search($this->ds, $this->user_context, '(&(objectclass=posixAccount)(uidnumber=' . (int)$account_id.'))',
|
||||
array('dn','uidnumber','uid','gidnumber','givenname','sn','cn','mail','userpassword',
|
||||
array('dn','uidnumber','uid','gidnumber','givenname','sn','cn','mail','userpassword','telephonenumber',
|
||||
'shadowexpire','shadowlastchange','homedirectory','loginshell','createtimestamp','modifytimestamp'));
|
||||
|
||||
$data = ldap_get_entries($this->ds, $sri);
|
||||
@ -498,6 +498,7 @@ class accounts_ldap
|
||||
'account_email' => $data['mail'][0],
|
||||
'account_fullname' => $data['cn'][0],
|
||||
'account_pwd' => $data['userpassword'][0],
|
||||
'account_phone' => $data['telephonenumber'][0],
|
||||
// both status and expires are encoded in the single shadowexpire value in LDAP
|
||||
// - if it's unset an account is enabled AND does never expire
|
||||
// - if it's set to 0, the account is disabled
|
||||
|
@ -114,7 +114,8 @@ class accounts_sql
|
||||
$this->contacts_table.'.n_fn AS account_fullname,'.
|
||||
$this->contacts_table.'.contact_id AS person_id,'.
|
||||
$this->contacts_table.'.contact_created AS account_created,'.
|
||||
$this->contacts_table.'.contact_modified AS account_modified,';
|
||||
$this->contacts_table.'.contact_modified AS account_modified,'.
|
||||
$this->contacts_table.'.tel_work AS account_phone,';
|
||||
$join = 'LEFT JOIN '.$this->contacts_table.' ON '.$this->table.'.account_id='.$this->contacts_table.'.account_id';
|
||||
}
|
||||
if (!($data = $this->db->select($this->table,$extra_cols.$this->table.'.*',$this->table.'.account_id='.abs($account_id),
|
||||
|
@ -781,7 +781,8 @@ abstract class egw_framework
|
||||
// add link registry to non-popup windows, if explicit requested (idots_framework::navbar() loads it, if not explicit specified!)
|
||||
if ($GLOBALS['egw_info']['flags']['js_link_registry'])
|
||||
{
|
||||
$java_script .= 'egw.set_preferences('.json_encode($GLOBALS['egw_info']['user']['preferences']['common']).', "common");';
|
||||
$java_script .= 'egw.set_preferences('.json_encode($GLOBALS['egw_info']['user']['preferences']['common']).', "common");'."\n";
|
||||
$java_script .= 'egw.set_user('.$GLOBALS['egw']->accounts->json($GLOBALS['egw_info']['user']['account_id']).');'."\n";
|
||||
}
|
||||
$java_script .= "</script>\n";
|
||||
|
||||
|
@ -312,6 +312,8 @@ else
|
||||
|
||||
/**
|
||||
* Map to serverside available images for users template-set
|
||||
*
|
||||
* @access: private, use egw.image(_name, _app)
|
||||
*/
|
||||
images: {},
|
||||
|
||||
@ -373,6 +375,36 @@ else
|
||||
{
|
||||
return egw_appName;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Data about current user
|
||||
*
|
||||
* @access: private, use egw.user(_field)
|
||||
*/
|
||||
userData: {},
|
||||
|
||||
/**
|
||||
* Set data of current user
|
||||
*
|
||||
* @param object _data
|
||||
*/
|
||||
set_user: function(_data)
|
||||
{
|
||||
this.userData = _data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get data about current user
|
||||
*
|
||||
* @param string _field
|
||||
* - 'account_id','account_lid','person_id','account_status',
|
||||
* - 'account_firstname','account_lastname','account_email','account_fullname','account_phone'
|
||||
* @return string|null
|
||||
*/
|
||||
user: function (_field)
|
||||
{
|
||||
return this.userData[_field];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ class idots_framework extends egw_framework
|
||||
self::validate_file('/phpgwapi/images.php',array('template' => $GLOBALS['egw_info']['user']['preferences']['common']['template_set']));
|
||||
$content .= '<script type="text/javascript">
|
||||
egw.set_preferences('.json_encode($GLOBALS['egw_info']['user']['preferences']['common']).', "common");
|
||||
egw.set_user('.$GLOBALS['egw']->accounts->json($GLOBALS['egw_info']['user']['account_id']).');
|
||||
</script>'."\n";
|
||||
}
|
||||
if($GLOBALS['egw_info']['user']['preferences']['common']['show_general_menu'] != 'sidebox' && !html::$ua_mobile)
|
||||
|
Loading…
Reference in New Issue
Block a user