Пример #1
0
 /**
  * Checks if a new release is available.
  * If so, installation along with
  * database will be updated.
  *
  * @since 6.2.2
  */
 public function updateCheck()
 {
     $error = $this->getServerStatus();
     if (is_etsis_exception($error)) {
         echo $error->getMessage();
     } else {
         $this->update->setCurrentVersion(RELEASE_TAG);
         $this->update->setUpdateUrl($this->url . 'core/1.1/update-check');
         // Optional:
         $this->update->addLogHandler(new \Monolog\Handler\StreamHandler(APP_PATH . 'tmp' . DS . 'logs' . DS . 'core-update.' . date('m-d-Y') . '.txt'));
         $this->update->setCache(new \Desarrolla2\Cache\Adapter\File(APP_PATH . 'tmp/cache'), 3600);
         $cacheFile = APP_PATH . 'tmp/cache/__update-versions.php.cache';
         echo '<p>' . sprintf(_t('Last checked on %s @ %s'), date('M d, Y', file_mod_time($cacheFile)), date('h:i A', file_mod_time($cacheFile)));
         if ($this->update->checkUpdate() !== false) {
             if ($this->update->newVersionAvailable()) {
                 // Install new update
                 echo sprintf(_t('<p>New Release: <font color="red">r%s</font></p>'), $this->update->getLatestVersion());
                 echo '<p>' . _t('Installing Updates: ') . '</p>';
                 echo '<pre>';
                 var_dump(array_map(function ($version) {
                     return (string) $version;
                 }, $this->update->getVersionsToUpdate()));
                 echo '</pre>';
                 $result = $this->update->update();
                 echo '<p>' . _t('Database Check . . .') . '</p>';
                 $this->updateDatabaseCheck();
                 echo '<p>' . _t('Directory Check . . .') . '</p>';
                 $this->removeDirCheck();
                 echo '<p>' . _t('File Check . . .') . '</p>';
                 $this->removeFileCheck();
                 if ($result === true) {
                     echo '<p>' . _t('Update successful!') . '</p>';
                 } else {
                     echo '<p>' . sprintf(_t('Update failed: %s!'), $result) . '</p>';
                     if ($result = \VisualAppeal\AutoUpdate::ERROR_SIMULATE) {
                         echo '<pre>';
                         var_dump($this->update->getSimulationResults());
                         echo '</pre>';
                     }
                 }
             } else {
                 echo sprintf(_t('<p>You currently have the latest release of eduTrac SIS installed: <font color="green">r%s</font></p>'), RELEASE_TAG);
             }
         } else {
             echo '<p>' . _t('Could not check for updates! See log file for details.') . '</p>';
         }
     }
 }
Пример #2
0
 /**
  * Хук инициализации шестерёнки
  *
  * @param object $Gear
  */
 public function hookGearInit($Gear)
 {
     if (cogear()->gears->Role && role() === 1 && $Gear->checkUpdate()) {
         info(t('Шестерёнка <b>%s</b> требует обновления. <a href="%s" class="btn btn-primary btn-mini">Обновить</a>', $Gear->name, l('/admin/gears/update/' . $Gear->gear)));
     }
 }