Example #1
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.'));
     }
 }