source: sandbox/webservice/api/rest/admin/EditUserResource.php @ 7810

Revision 7810, 1.6 KB checked in by alexandrecorreia, 11 years ago (diff)

Ticket #2507 - Criado os resources para o módulo Expresso-Admin

  • Property svn:executable set to *
Line 
1<?php
2
3class EditUserResource extends AdminAdapter
4{
5        public function post($request)
6        {
7                // to Receive POST Params (use $this->params)
8                parent::post($request);
9
10                if( $this->isLoggedIn() )
11                {
12                        // Permission
13                        $permission = array();
14                        $permission['action'] = 'edit_users';
15                        $permission['apps'] = $this->getUserApps();
16
17                        //Load Conf Admin
18                        $this->loadConfAdmin();
19
20                        if( $this->validatePermission($permission) )   
21                        {       
22                                $uidUser = $this->getParam('account_uidnumber_edit');
23
24                                // Validate fields
25                                if( trim($uidUser) == "" && isset($uidUser) )
26                                        Errors::runException( "ADMIN_UIDNUMBER_EMPTY" );
27
28                                // Get User
29                                $fields = $this->editUser($uidUser);
30
31                                if( $fields != false )
32                                {       
33                                        // Return fields
34                                        $return = array();
35                                        $return['account_uidnumber']    = $fields['uidnumber'];
36                                        $return['account_login']                = $fields['uid'];
37                                        $return['account_email']                = $fields['mail'];
38                                        $return['account_name']                 = $fields['givenname']." ".$fields['sn'];
39                                        $return['account_phone']                = $fields['telephonenumber'];   
40                                        $return['account_cpf']                  = $fields['corporative_information_cpf'];
41                                        $return['account_rg']                   = $fields['corporative_information_rg'];
42                                        $return['account_rg_uf']                = $fields['corporative_information_rguf'];
43                                        $return['account_description']  = $fields['corporative_information_description'];
44                                       
45                                        $this->setResult( array( "result" => $return ));
46                                }
47                                else
48                                        Errors::runException( "ADMIN_USER_NOT_FOUND" );
49                        }
50                        else
51                        {
52                                Errors::runException( "ACCESS_NOT_PERMITTED" );
53                        }                       
54                }
55               
56                return $this->getResponse();
57        }
58}
59
60?>
Note: See TracBrowser for help on using the repository browser.