Exemplo n.º 1
0
 public function testZurmoUpdatesApiCall()
 {
     $headers = array('Accept: application/json', 'ZURMO_API_REQUEST_TYPE: REST');
     $data = array('zurmoToken' => '1111111111', 'serverIpAddress' => '127.0.0.1', 'serverName' => 'zurmo.com', 'serverSoftware' => 'Apache 2.2.16', 'zurmoVersion' => VERSION, 'serializedData' => '');
     $response = ApiRestHelper::createApiCall('http://updates.zurmo.com/app/index.php/updatesManager/api/create', 'POST', $headers, array('data' => $data));
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $version = $response['data']['latestStableZurmoVersion'];
     $this->assertTrue(is_string($version));
 }
 public static function createXmlApiCall($url, $method, $headers, $data = array())
 {
     $xmlData = Array2XML::createXML('zurmoMessage', $data);
     $data = array('data' => $xmlData->saveXML());
     return ApiRestHelper::createApiCall($url, $method, $headers, $data);
 }
Exemplo n.º 3
0
 /**
  * Check if available zurmo updates has been checked within the last 7 days. If not, then perform
  * update and update the lastAttemptedInfoUpdateTimeStamp and lastZurmoStableVersion global configuration properties.
  * @param boolean $forceCheck - If true, it will ignore the last time the check was made
  */
 public static function checkAndUpdateZurmoInfo($forceCheck = false)
 {
     $lastAttemptedInfoUpdateTimeStamp = self::getLastAttemptedInfoUpdateTimeStamp();
     if ($forceCheck || $lastAttemptedInfoUpdateTimeStamp == null || time() - $lastAttemptedInfoUpdateTimeStamp > 7 * 24 * 60 * 60) {
         $headers = array('Accept: application/json', 'ZURMO_API_REQUEST_TYPE: REST');
         $data = array('zurmoToken' => ZURMO_TOKEN, 'zurmoVersion' => VERSION, 'serializedData' => '');
         if (isset($_SERVER['SERVER_ADDR'])) {
             $data['serverIpAddress'] = $_SERVER['SERVER_ADDR'];
         }
         if (isset($_SERVER['SERVER_NAME'])) {
             $data['serverName'] = $_SERVER['SERVER_NAME'];
         }
         if (isset($_SERVER['SERVER_SOFTWARE'])) {
             $data['serverSoftware'] = $_SERVER['SERVER_SOFTWARE'];
         }
         $sandboxMode = Yii::app()->isApplicationInSandboxMode();
         $data['sandboxMode'] = $sandboxMode;
         $response = ApiRestHelper::createApiCall('http://updates.zurmo.com/app/index.php/updatesManager/api/create', 'POST', $headers, array('data' => $data));
         $response = json_decode($response, true);
         if (ApiResponse::STATUS_SUCCESS == $response['status']) {
             if (isset($response['data']['latestStableZurmoVersion']) && $response['data']['latestStableZurmoVersion'] != '') {
                 self::setLastZurmoStableVersion($response['data']['latestStableZurmoVersion']);
             }
             $zurmoServiceHelper = new ZurmoServiceHelper();
             if (!$zurmoServiceHelper->runCheckAndGetIfSuccessful()) {
                 $message = new NotificationMessage();
                 $message->textContent = $zurmoServiceHelper->getMessage();
                 $rules = new NewZurmoVersionAvailableNotificationRules();
                 NotificationsUtil::submit($message, $rules);
             }
         }
         self::setLastAttemptedInfoUpdateTimeStamp();
     }
 }