Beispiel #1
0
 public function applyUpdate($dir)
 {
     $update = new UpdateHelper($this->application);
     $copy = $update->copyDirectory($dir, $this->directory);
     if ($copy !== true) {
         return array(self::ERR_COPY, $copy);
     }
     // import SQL
     foreach (glob($dir . '/update/*/*.sql') as $file) {
         try {
             $this->loadSQL($file);
         } catch (Exception $e) {
             return array(self::ERR_DB, $e->getMessage());
         }
     }
     // custom scripts
     $this->application->getConfigContainer()->clearCache();
     return true;
 }
Beispiel #2
0
 public function fetch()
 {
     require_once ClassLoader::getRealPath('library.pclzip') . '/pclzip.lib.php';
     $id = unserialize(base64_decode($this->request->get('module')));
     $repos = json_decode(base64_decode($this->request->get('repos')), true);
     $repo = $repos[$id[0]];
     $this->request->set('repo', $repo['repo']);
     $this->request->set('handshake', $repo['handshake']);
     $this->request->set('id', $id[1]);
     $tmpFile = ClassLoader::getRealPath('cache.') . 'install' . rand(1, 5000000) . '.zip';
     file_put_contents($tmpFile, $this->getRepoResponse('package/downloadInstall', array(), true));
     if (!filesize($tmpFile)) {
         return new JSONResponse(array('error' => $this->translate('_err_download_package')));
     }
     $tmpDir = substr($tmpFile, 0, -4);
     mkdir($tmpDir);
     $archive = new PclZip($tmpFile);
     $archive->extract($tmpDir);
     unlink($tmpFile);
     $update = new UpdateHelper($this->application);
     $moduleDir = ClassLoader::getRealPath('module.' . $id[1]);
     $copy = $update->copyDirectory($tmpDir, $moduleDir);
     if ($copy !== true) {
         return new JSONResponse(array('error' => $this->maketext('_err_update_copy_msg', array($copy))));
     }
     $this->application->getConfigContainer()->addModule('module.' . $id[1]);
     $module = $this->application->getConfigContainer()->getModule('module.' . $id[1]);
     $module->install($this->application);
     $module->setStatus(true);
     $this->request->set('id', 'module.' . $id[1]);
     return $this->node();
 }