source: sandbox/webservice/api/rest/core/LoginResource.php @ 6149

Revision 6149, 1.2 KB checked in by niltonneto, 12 years ago (diff)

Ticket #2507 - Restruturado diretório para alinhamento com projeto REST.

Line 
1<?php
2
3class LoginResource extends ExpressoAdapter {
4
5        private function getUserProfile(){
6                $user_id = $GLOBALS['phpgw_info']['user']['account_id']['acl'];
7                $acl = CreateObject('phpgwapi.acl');
8                $apps = $acl->get_user_applications($user_id);
9                $contactApps = array();
10                foreach($apps as $app => $isEnabled){
11                        if($isEnabled)
12                                $contactApps[] = $app;
13                }
14       
15                return array(
16                                'contactID'                     => $GLOBALS['phpgw_info']['user']['account_dn'],
17                                'contactMails'          => array($GLOBALS['phpgw_info']['user']['email']),
18                                'contactPhones'         => array($GLOBALS['phpgw_info']['user']['telephonenumber']),
19                                'contactFullName'       => $GLOBALS['phpgw_info']['user']['fullname'],
20                                'contactApps'           => $contactApps
21                );
22        }
23       
24        public function post($request){
25                // to Receive POST Params (use $this->params)
26                parent::post($request);
27                if($sessionid = $GLOBALS['phpgw']->session->create($this->getParam('user'), $this->getParam('password')))
28                {
29                        $result = array(
30                                'auth'                  => $sessionid.":".$GLOBALS['phpgw']->session->kp3,
31                                'profile'               => array($this->getUserProfile())
32                        );
33                        $this->setResult($result);
34                }
35                else
36                {
37                        throw new ResponseException("",$GLOBALS['phpgw']->session->cd_reason);
38                }
39                return $this->getResponse();
40        }       
41
42}
Note: See TracBrowser for help on using the repository browser.