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

Revision 6664, 1.6 KB checked in by niltonneto, 12 years ago (diff)

Ticket #2507 - Adicionada implementação para enviar email com anexo na versão 2.4

RevLine 
[6019]1<?php
2
[6149]3class LoginResource extends ExpressoAdapter {
[6148]4
5        private function getUserProfile(){
[6664]6                if($this->getExpressoVersion() != "2.2") {
7                        $_SESSION['wallet']['user']['uidNumber'] = $GLOBALS['phpgw_info']['user']['account_id'];
8                }
[6148]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'],
[6239]15                                'contactApps'           => $this->getUserApps()
[6148]16                );
17        }
18       
[6239]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       
[6019]37        public function post($request){
38                // to Receive POST Params (use $this->params)
[6061]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);
[6019]47                }
48                else
49                {
[6165]50                        Errors::runException($GLOBALS['phpgw']->session->cd_reason);
[6019]51                }
[6061]52                return $this->getResponse();
[6019]53        }       
54
55}
Note: See TracBrowser for help on using the repository browser.