Ejemplo n.º 1
0
 public function start()
 {
     $p = new \Permissions();
     if (!$p->canUpgrade()) {
         return false;
     }
     $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 {
             $token = Loader::helper("validation/token");
             \Redirect::to('/ccm/system/upgrade/submit?ccm_token=' . $token->generate('Concrete\Controller\Upgrade'))->send();
             exit;
         }
         */
         $this->set('update', $upd);
     }
     $this->view();
 }
Ejemplo n.º 2
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.
  *
  * @return ApplicationUpdate[]
  */
 public function getLocalAvailableUpdates()
 {
     $fh = Core::make('helper/file');
     $updates = [];
     $contents = @$fh->getDirectoryContents(DIR_CORE_UPDATES);
     foreach ($contents as $con) {
         if (is_dir(DIR_CORE_UPDATES . '/' . $con)) {
             $obj = ApplicationUpdate::get($con);
             if (is_object($obj)) {
                 if (version_compare($obj->getUpdateVersion(), APP_VERSION, '>')) {
                     $updates[] = $obj;
                 }
             }
         }
     }
     usort($updates, function ($a, $b) {
         return version_compare($a->getUpdateVersion(), $b->getUpdateVersion());
     });
     return $updates;
 }