public function checkAction()
 {
     $data = array();
     $sessVersions = array();
     $updateFile = new UpdateFile();
     $output = $this->_fetch('check', array('versions' => $updateFile->getAllVersions()));
     if ($output === false) {
         $data['code'] = 400;
         $data['msg'] = __('There was an error connecting to HealthCloud');
         trigger_error($output, E_USER_NOTICE);
     } else {
         $xml = simplexml_load_string($output);
         if (isset($xml->error)) {
             $data['code'] = 201;
             $data['msg'] = (string) $xml->error->errorMsg;
         } else {
             $data['code'] = 200;
             $ctr = 0;
             foreach ($xml as $update) {
                 $tmp = array();
                 foreach ($update as $key => $value) {
                     $tmp[$key] = (string) $value;
                 }
                 $sessVersions[$tmp['id']] = $tmp;
                 $ctr++;
             }
             $data['msg'] = $sessVersions;
             $data['len'] = $ctr;
         }
     }
     $this->_session->versions = $sessVersions;
     $json = Zend_Controller_Action_HelperBroker::getStaticHelper('json');
     $json->suppressExit = true;
     $json->direct($data);
 }
 protected function _fetch($action, $version = null)
 {
     $ch = curl_init();
     $updateServerUrl = Zend_Registry::get('config')->healthcloud->updateServerUrl;
     $updateServerUrl .= '/' . $action;
     $updateFile = new UpdateFile();
     $data = array();
     $data['apiKey'] = Zend_Registry::get('config')->healthcloud->apiKey;
     if ($version === null) {
         $data['version'] = $updateFile->getAllVersions();
     } else {
         $data['version'] = $version;
     }
     $data = http_build_query($data);
     curl_setopt($ch, CURLOPT_URL, $updateServerUrl);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERPWD, 'admin:ch3!');
     $ret = curl_exec($ch);
     $curlErrno = curl_errno($ch);
     $curlError = curl_errno($ch);
     curl_close($ch);
     if ($curlErrno) {
         $ret = false;
     }
     return $ret;
 }