Advertisement
Guest User

Untitled

a guest
Feb 11th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.80 KB | None | 0 0
  1. function access_post(){
  2.  
  3. $username = $this->post('username');
  4. $password = $this->post('password');
  5. $silogin = array(
  6. 'username' => $username,
  7. 'password' => $password
  8. );
  9.  
  10. $wsdl = 'http://nic-ng.itb.ac.id/riset/sson.php?wsdl';
  11. $client = new nusoap_client($wsdl,true);
  12. $ITB_LDAPAttributes = $client->call('getAllAtribute', array('SID'=> $silogin['username']));
  13. if (!$ITB_LDAPAttributes) {
  14. $this->response(array('status'=>false,'message'=>'Akun Anda Tidak Ada !'),404);
  15. } else {
  16. // $test = $client->call('getSID',array('username'=> $silogin['username']));
  17. $LDAP_parsedData = $this->parseITBLDAPAttribute($ITB_LDAPAttributes);
  18. $userdata = array(
  19. 'id_ITB' => $silogin['username'],
  20. 'profile' => array(
  21. 'ai3' => $silogin['username'],
  22. 'nama' => $LDAP_parsedData->itbNamaLengkap,
  23. 'email' => explode(',', $LDAP_parsedData->itbAlamatMail),
  24. 'email_nonITB' => isset($LDAP_parsedData->itbEmailNonITB) ? $LDAP_parsedData->itbEmailNonITB: '',
  25. // 'nip' => isset($LDAP_parsedData->itbNIP)? @end(explode(',',$LDAP_parsedData->itbNIP)) : "",
  26. 'nim' => isset($LDAP_parsedData->itbNIM)? @end(explode(',',$LDAP_parsedData->itbNIM)) : "",
  27. 'nip' => isset($LDAP_parsedData->itbNIP)? explode(',',$LDAP_parsedData->itbNIP) : "",
  28. // 'nim' => isset($LDAP_parsedData->itbNIM)? explode(',',$LDAP_parsedData->itbNIM) : "",
  29. 'unit' => $LDAP_parsedData->itbUnity,
  30. 'jenis_civitas' => $LDAP_parsedData->itbStatus
  31. )
  32. );
  33. // var_dump($userdata);exit();
  34. if ($userdata['profile']['jenis_civitas'] == 'Dosen' || $userdata['profile']['jenis_civitas'] == 'Karyawan') {
  35. $x = $userdata['profile']['nip']; //cek nip yg terdaftar di webpac
  36. $nipx = '';
  37. foreach ($x as $key) {
  38. $nip = trim($key);
  39. if ($this->loanmodel->is_exists($nip,'user_account','userAccount')) { //KALO 22 NYA NIP TERDAFTAR DI WEBPAC GMN ?
  40. $nipx = $nip;
  41. }
  42. }
  43. $data = $this->web_model->get_users($nipx,$nipx)->result_array(); //->result_array()
  44. } elseif($userdata['profile']['jenis_civitas'] == 'Tenaga Kontrak') {
  45. $data = $this->web_model->get_kontrak($userdata['profile']['email'][0],$userdata['profile']['email'][0])->result_array(); //validasi pake email itb
  46. } else {
  47. $data = $this->web_model->get_users($userdata['profile']['nim'],$userdata['profile']['nim'])->result_array();
  48. }
  49.  
  50. if (!empty($data)) {
  51. $result = array();
  52. $json = array(
  53. 'id' => $data[0]['userID'],
  54. 'userAccount' => $data[0]['userAccount'],
  55. 'nama' => $userdata['profile']['nama'],
  56. 'alamat' => $data[0]['userAddress'],
  57. 'email' => $userdata['profile']['email'][0],
  58. 'deparment' => $userdata['profile']['unit'],
  59. 'statusdk' => $userdata['profile']['jenis_civitas']
  60. );
  61. array_push($result, $json);
  62. $this->response(array('status' => true, 'message' => 'Welcome', 'data'=>$result),200);
  63. } else {
  64. $this->response(array('status'=> false, 'message' => 'Anda Belum Terdaftar Di Webpac.lib.itb.ac.id'),404);
  65. }
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement