Exemplo n.º 1
0
 /** 
  * Looks in the designated updates location for all directories, ascertains what
  * version they represent, and finds all versions greater than the currently installed version of
  * concrete5
  */
 public function getLocalAvailableUpdates()
 {
     $fh = Loader::helper('file');
     $updates = array();
     $contents = @$fh->getDirectoryContents(DIR_APP_UPDATES);
     foreach ($contents as $con) {
         if (is_dir(DIR_APP_UPDATES . '/' . $con)) {
             $obj = ApplicationUpdate::get($con);
             if (is_object($obj)) {
                 if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
                     $updates[] = $obj;
                 }
             }
         }
     }
     return $updates;
 }
 public function do_update()
 {
     $updateVersion = $this->post('updateVersion');
     if (!$updateVersion) {
         $this->error->add(t('Invalid version'));
     } else {
         $upd = ApplicationUpdate::getByVersionNumber($updateVersion);
     }
     if (!is_object($upd)) {
         $this->error->add(t('Invalid version'));
     } else {
         if (version_compare($upd->getUpdateVersion(), APP_VERSION, '<=')) {
             $this->error->add(t('You may only apply updates with a greater version number than the version you are currently running.'));
         }
     }
     if (!$this->error->has()) {
         $resp = $upd->apply();
         if ($resp !== true) {
             switch ($resp) {
                 case ApplicationUpdate::E_UPDATE_WRITE_CONFIG:
                     $this->error->add(t('Unable to write to config/site.php. You must make config/site.php writable in order to upgrade in this manner.'));
                     break;
             }
         } else {
             header('Location: ' . BASE_URL . REL_DIR_FILES_TOOLS_REQUIRED . '/upgrade?source=dashboard_update');
             exit;
         }
     }
     $this->view();
 }