/**
  * Get user's information via OneLogin API
  */
 public function olGetUserAction()
 {
     $this->view->user = null;
     try {
         $userName = $this->_getParam('user');
         $users = new OneLogin_Api_Users();
         //$response = $users->getUser( Zend_Auth::getInstance()->getIdentity()->api_user_username );
         $response = $users->getUser($userName);
         //$response = $users->getUser("john_j_o'*****@*****.**"); // Testing single quotes
         if ($response->isSuccessful()) {
             //echo $xmlResult;
             $xmlResult = simplexml_load_string($response->getBody());
         } else {
             //var_dump($response);exit();
             throw new Exception($response->getMessage() . ' ' . $response->getBody());
         }
         $this->view->user = $xmlResult;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
 /**
  * Return status description based on id
  *
  * @param integer $statusId
  * @return string Status
  */
 public function getOlUserStatus($userName)
 {
     $status = "";
     $userId = 0;
     $userName = trim(strtolower($userName));
     try {
         $users = new OneLogin_Api_Users();
         $response = $users->getUser($userName);
         if ($response->isSuccessful()) {
             //echo $xmlResult;
             $xmlResult = simplexml_load_string($response->getBody());
             $elementsRequired = array('status', 'id');
             foreach ($xmlResult as $child) {
                 if (in_array(strtolower($child->getName()), $elementsRequired)) {
                     $tagName = trim(str_replace('-', ' ', $child->getName()));
                     $className = trim(str_replace('-', '', $child->getName()));
                     // Get status description if needed
                     if (strtolower($className) == 'status') {
                         $status = self::_getUserStatus(trim($child));
                     }
                     if (strtolower($className) == 'id') {
                         $userId = trim($child);
                     }
                 }
                 // End if not in array
             }
             // end foreach
         } else {
             //var_dump($response);exit();
             throw new Exception($response->getMessage() . ' ' . $response->getBody());
         }
     } catch (Exception $e) {
         $msg = $e->getMessage();
         //var_dump($e->getMessage()); exit(); // DEBUG ONLY
         $status = "";
     }
     return array($status, $userId);
 }