source: sandbox/webservice/api/rest/admin/GetUsersResource.php @ 7882

Revision 7882, 3.0 KB checked in by alexandrecorreia, 11 years ago (diff)

Ticket #2507 - Implementado a alteração da quota do usuário

Line 
1<?php
2
3class GetUsersResource extends AdminAdapter
4{
5
6        public function post($request)
7        {
8                // to Receive POST Params (use $this->params)
9                parent::post($request);
10
11                if( $this->isLoggedIn() )
12                {
13                        // Permission
14                        $permission = array();
15                        $permission['apps'] = $this->getUserApps();
16
17                        //Load Conf Admin
18                        $this->loadConfAdmin();
19
20                        $uidUser        = $this->getParam('accountUidNumber');
21                        $searchUser = $this->getParam('accountSearchUser');
22                        $searchUserLiteral= $this->getParam('accountSearchUserLID');
23                                                                                                 
24                        //Validate Fields
25                        $uidUser = str_replace("*","",$uidUser);
26                        $uidUser = str_replace("%","",$uidUser);
27
28                        $searchUser = str_replace("*","", $searchUser);
29                        $searchUser = str_replace("%","", $searchUser);
30
31                        $searchUserLiteral = str_replace("*","", $searchUserLiteral);
32                        $searchUserLiteral = str_replace("%","", $searchUserLiteral);
33
34                        if( trim($uidUser) != "" && isset($uidUser) )
35                        {
36                                $permission['action'] = 'edit_users';
37
38                                if( $this->validatePermission($permission) )
39                                {
40                                        // Get User
41                                        $fields = $this->editUser($uidUser);
42
43                                        if( $fields != false )
44                                        {       
45                                                // Return fields
46                                                $return = array();
47                                                $return['accountUidnumber']             = $fields['uidnumber'];
48                                                $return['accountLogin']                 = $fields['uid'];
49                                                $return['accountEmail']                 = $fields['mail'];
50                                                $return['accountName']                  = $fields['givenname']." ".$fields['sn'];
51                                                $return['accountPhone']                 = $fields['telephonenumber'];   
52                                                $return['accountCpf']                   = $fields['corporative_information_cpf'];
53                                                $return['accountRg']                    = $fields['corporative_information_rg'];
54                                                $return['accountRgUf']                  = $fields['corporative_information_rguf'];
55                                                $return['accountDescription']   = $fields['corporative_information_description'];
56                                                $return['accountMailQuota']             = $fields['mailquota'];
57                                               
58                                                $this->setResult( array( "users" => $return ));
59                                        }
60                                        else
61                                                Errors::runException( "ADMIN_USER_NOT_FOUND" );                                 
62                                }
63                                else
64                                {
65                                        Errors::runException( "ACCESS_NOT_PERMITTED" );
66                                }                       
67                        }
68                        else
69                        {
70                                $permission['action'] = 'list_users';
71
72                                if( $this->validatePermission($permission) )
73                                {
74                                        // Return list
75                                        $return = array();
76
77                                        if( trim($searchUser) != "" && isset($searchUser) )
78                                        {
79                                                $list = $this->listUsers( $searchUser );
80
81                                                foreach( $list as $key => $users )
82                                                {
83                                                        $return[$key]['accountId']              = $users['account_id'];
84                                                        $return[$key]['accountLid']             = $users['account_lid'];
85                                                        $return[$key]['accountCn']              = $users['account_cn'];
86                                                        $return[$key]['accountMail']    = $users['account_mail'];
87                                                }
88                                        }
89                                        else
90                                        {
91                                                $list = $this->listUsersLiteral($searchUserLiteral);
92                                               
93                                                $return = $list;
94                                        }
95
96                                        if( count($return) > 0 )
97                                        {
98                                                $this->setResult( array( "users" => $return ) );
99                                        }
100                                        else
101                                        {
102                                                Errors::runException( "ADMIN_USERS_NOT_FOUND" );               
103                                        }
104                                }
105                                else
106                                {
107                                        Errors::runException( "ACCESS_NOT_PERMITTED" );
108                                }                       
109                        }
110                }       
111
112                return $this->getResponse();
113        }               
114}
115
116?>
Note: See TracBrowser for help on using the repository browser.