Пример #1
0
 public function do_update($pkgHandle = false)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         if ($pkgHandle) {
             $pkg = \Concrete\Core\Support\Facade\Package::getClass($pkgHandle);
             $r = $pkg->testForInstall(false);
             if (is_object($r)) {
                 $this->error->add($r);
             } else {
                 $p = Package::getByHandle($pkgHandle);
                 $loc = Localization::getInstance();
                 $loc->pushActiveContext('system');
                 try {
                     $p->upgradeCoreData();
                     $p->upgrade();
                     $loc->popActiveContext();
                     $this->set('message', t('The package has been updated successfully.'));
                 } catch (Exception $e) {
                     $loc->popActiveContext();
                     $this->error->add($e);
                 }
             }
         }
     }
     $this->view();
 }
Пример #2
0
 public function view()
 {
     $error = \Core::make('helper/validation/error');
     $r = $this->item->download();
     if ($r != false) {
         $error->add($r);
     }
     if (!$error->has()) {
         $pkg = PackageService::getByHandle($this->item->getHandle());
         if (is_object($pkg)) {
             $tests = $pkg->testForInstall();
             if (is_object($tests)) {
                 $error->add($tests);
             } else {
                 $p = PackageService::getClass($this->item->getHandle());
                 try {
                     $p->install();
                 } catch (\Exception $e) {
                     $error->add($e->getMessage());
                 }
             }
         }
     }
     $this->set('error', $error);
     $this->set('mri', $this->item);
 }
Пример #3
0
 public function install_package($package)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         $p = Package::getClass($package);
         if ($p instanceof BrokenPackage) {
             $this->error->add($p->getInstallErrorMessage());
         } elseif (is_object($p)) {
             $loader = new ClassLoader();
             $loader->registerPackageCustomAutoloaders($p);
             if (!$p->showInstallOptionsScreen() || Loader::helper('validation/token')->validate('install_options_selected')) {
                 $tests = $p->testForInstall();
                 if (is_object($tests)) {
                     $this->error->add($tests);
                 } else {
                     $r = Package::install($p, $this->post());
                     if ($r instanceof ErrorList) {
                         $this->error->add($r);
                         if ($p->showInstallOptionsScreen()) {
                             $this->set('showInstallOptionsScreen', true);
                             $this->set('pkg', $p);
                         }
                     } else {
                         $this->redirect('/dashboard/extend/install', 'package_installed', $r->getPackageID());
                     }
                 }
             } else {
                 $this->set('showInstallOptionsScreen', true);
                 $this->set('pkg', $p);
             }
         } else {
             $this->error->add(t('Package controller file not found.'));
         }
     } else {
         $this->error->add(t('You do not have permission to install add-ons.'));
     }
 }
Пример #4
0
 /**
  * @deprecated
  */
 public static function getClass($pkgHandle)
 {
     // this should go through the facade instead
     return \Concrete\Core\Support\Facade\Package::getClass($pkgHandle);
 }