1 | <?php |
---|
2 | |
---|
3 | class LoginResource extends ExpressoAdapter { |
---|
4 | |
---|
5 | private function getUserProfile(){ |
---|
6 | if($this->getExpressoVersion() != "2.2") { |
---|
7 | $_SESSION['wallet']['user']['uidNumber'] = $GLOBALS['phpgw_info']['user']['account_id']; |
---|
8 | } |
---|
9 | |
---|
10 | return array( |
---|
11 | 'contactID' => $GLOBALS['phpgw_info']['user']['account_dn'], |
---|
12 | 'contactMails' => array($GLOBALS['phpgw_info']['user']['email']), |
---|
13 | 'contactPhones' => array($GLOBALS['phpgw_info']['user']['telephonenumber']), |
---|
14 | 'contactFullName' => $GLOBALS['phpgw_info']['user']['fullname'], |
---|
15 | 'contactApps' => $this->getUserApps() |
---|
16 | ); |
---|
17 | } |
---|
18 | |
---|
19 | private function getUserApps(){ |
---|
20 | // Load Granted Apps for Web Service |
---|
21 | $config = parse_ini_file( __DIR__ . '/../../config/user.ini',true); |
---|
22 | $apps = $config['Applications.mapping']; |
---|
23 | |
---|
24 | // Load Granted Apps for User |
---|
25 | $contactApps = array(); |
---|
26 | $acl = CreateObject('phpgwapi.acl'); |
---|
27 | $user_id = $GLOBALS['phpgw_info']['user']['account_id']['acl']; |
---|
28 | foreach($acl->get_user_applications($user_id) as $app => $value){ |
---|
29 | $enabledApp = array_search($app, $apps); |
---|
30 | if($enabledApp !== FALSE) |
---|
31 | $contactApps[] = $enabledApp; |
---|
32 | } |
---|
33 | |
---|
34 | return $contactApps; |
---|
35 | } |
---|
36 | |
---|
37 | public function post($request){ |
---|
38 | // to Receive POST Params (use $this->params) |
---|
39 | parent::post($request); |
---|
40 | if($sessionid = $GLOBALS['phpgw']->session->create($this->getParam('user'), $this->getParam('password'))) |
---|
41 | { |
---|
42 | $result = array( |
---|
43 | 'auth' => $sessionid.":".$GLOBALS['phpgw']->session->kp3, |
---|
44 | 'profile' => array($this->getUserProfile()) |
---|
45 | ); |
---|
46 | $this->setResult($result); |
---|
47 | } |
---|
48 | else |
---|
49 | { |
---|
50 | Errors::runException($GLOBALS['phpgw']->session->cd_reason); |
---|
51 | } |
---|
52 | return $this->getResponse(); |
---|
53 | } |
---|
54 | |
---|
55 | } |
---|