source: trunk/prototype/rest/core/LoginResource.php @ 7732

Revision 7732, 2.0 KB checked in by pereira.jair, 11 years ago (diff)

Ticket #3267 - Re-implementação do Recurso para utilizar a nova Agenda do Expresso.

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