[7866] | 1 | <?php |
---|
| 2 | |
---|
| 3 | class 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'); |
---|
[7875] | 22 | $searchUserLiteral= $this->getParam('accountSearchUserLID'); |
---|
| 23 | |
---|
[7866] | 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 | |
---|
[7875] | 31 | $searchUserLiteral = str_replace("*","", $searchUserLiteral); |
---|
| 32 | $searchUserLiteral = str_replace("%","", $searchUserLiteral); |
---|
| 33 | |
---|
[7866] | 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 | |
---|
| 57 | $this->setResult( array( "users" => $return )); |
---|
| 58 | } |
---|
| 59 | else |
---|
| 60 | Errors::runException( "ADMIN_USER_NOT_FOUND" ); |
---|
| 61 | } |
---|
| 62 | else |
---|
| 63 | { |
---|
| 64 | Errors::runException( "ACCESS_NOT_PERMITTED" ); |
---|
| 65 | } |
---|
| 66 | } |
---|
| 67 | else |
---|
| 68 | { |
---|
| 69 | $permission['action'] = 'list_users'; |
---|
| 70 | |
---|
| 71 | if( $this->validatePermission($permission) ) |
---|
| 72 | { |
---|
| 73 | // Return list |
---|
| 74 | $return = array(); |
---|
| 75 | |
---|
[7875] | 76 | if( trim($searchUser) != "" && isset($searchUser) ) |
---|
[7866] | 77 | { |
---|
[7875] | 78 | $list = $this->listUsers( $searchUser ); |
---|
| 79 | |
---|
| 80 | foreach( $list as $key => $users ) |
---|
| 81 | { |
---|
| 82 | $return[$key]['accountId'] = $users['account_id']; |
---|
| 83 | $return[$key]['accountLid'] = $users['account_lid']; |
---|
| 84 | $return[$key]['accountCn'] = $users['account_cn']; |
---|
| 85 | $return[$key]['accountMail'] = $users['account_mail']; |
---|
| 86 | } |
---|
[7866] | 87 | } |
---|
[7875] | 88 | else |
---|
| 89 | { |
---|
| 90 | $list = $this->listUsersLiteral($searchUserLiteral); |
---|
| 91 | |
---|
| 92 | $return = $list; |
---|
| 93 | } |
---|
[7866] | 94 | |
---|
[7875] | 95 | if( count($return) > 0 ) |
---|
[7866] | 96 | { |
---|
| 97 | $this->setResult( array( "users" => $return ) ); |
---|
| 98 | } |
---|
| 99 | else |
---|
| 100 | { |
---|
| 101 | Errors::runException( "ADMIN_USERS_NOT_FOUND" ); |
---|
| 102 | } |
---|
| 103 | } |
---|
| 104 | else |
---|
| 105 | { |
---|
| 106 | Errors::runException( "ACCESS_NOT_PERMITTED" ); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | return $this->getResponse(); |
---|
| 112 | } |
---|
| 113 | } |
---|
| 114 | |
---|
| 115 | ?> |
---|