public function do_update($pkgHandle = false) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { if ($pkgHandle) { $tests = Package::testForInstall($pkgHandle, false); if (is_array($tests)) { $tests = Package::mapError($tests); $this->set('error', $tests); } else { $p = Package::getByHandle($pkgHandle); $currentLocale = Localization::activeLocale(); if ($currentLocale != 'en_US') { // Prevent the database records being stored in wrong language Localization::changeLocale('en_US'); } try { $p->upgradeCoreData(); if ($currentLocale != 'en_US') { Localization::changeLocale($currentLocale); } $p->upgrade(); $this->set('message', t('The package has been updated successfully.')); } catch(Exception $e) { $this->set('error', $e); } } } } $this->view(); }
public function install_package($package) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { $p = Loader::package($package); if (is_object($p)) { if (!$p->showInstallOptionsScreen() || Loader::helper('validation/token')->validate('install_options_selected')) { $tests = Package::testForInstall($package); if (is_array($tests)) { $tests = Package::mapError($tests); $this->set('error', $tests); } else { $currentLocale = Localization::activeLocale(); if ($currentLocale != 'en_US') { // Prevent the database records being stored in wrong language Localization::changeLocale('en_US'); } try { $u = new User(); $pkg = $p->install($this->post()); if ($u->isSuperUser() && $p->allowsFullContentSwap() && $this->post('pkgDoFullContentSwap')) { $p->swapContent($this->post()); } if ($currentLocale != 'en_US') { Localization::changeLocale($currentLocale); } $pkg = Package::getByHandle($p->getPackageHandle()); $this->redirect('/dashboard/extend/install', 'package_installed', $pkg->getPackageID()); } catch (Exception $e) { if ($currentLocale != 'en_US') { Localization::changeLocale($currentLocale); } if ($p->showInstallOptionsScreen()) { $this->set('showInstallOptionsScreen', true); $this->set('pkg', $p); } $this->set('error', $e); } } } else { $this->set('showInstallOptionsScreen', true); $this->set('pkg', $p); } } else { $msg = t('Install failed - invalid package. Check log for details'); $this->error->add($msg); $this->set('error', $this->error); } } else { $this->error->add(t('You do not have permission to install add-ons.')); $this->set('error', $this->error); } }
if (is_array($r)) { $errors = Package::mapError($r); foreach ($errors as $e) { $error->add($e); } } else { $error->add($r); } } } } if (!is_object($mri)) { $error->add(t('Invalid package or no package specified.')); } if (!$error->has() && $install) { $tests = Package::testForInstall($mri->getHandle()); if (is_array($tests)) { $results = Package::mapError($tests); foreach ($results as $te) { $error->add($te); } } else { $p = Loader::package($mri->getHandle()); try { $p->install(); } catch (Exception $e) { $error->add($e->getMessage()); } } } if (!$error->has()) {
public function download() { $file = Marketplace::downloadRemoteFile($this->getRemoteFileURL()); if (empty($file) || $file == Package::E_PACKAGE_DOWNLOAD) { return array(Package::E_PACKAGE_DOWNLOAD); } else { if ($file == Package::E_PACKAGE_SAVE) { return array($file); } else { if ($file == Package::E_PACKAGE_INVALID_APP_VERSION) { return array($file); } } } try { Loader::model('package_archive'); $am = new PackageArchive($this->getHandle()); $am->install($file, true); } catch (Exception $e) { return array($e->getMessage()); } if ($install) { $tests = Package::testForInstall($this->getHandle()); if (is_array($tests)) { return $tests; } else { $p = Loader::package($this->getHandle()); try { $p->install(); } catch (Exception $e) { return array(Package::E_PACKAGE_INSTALL); } } } }
public function install_package($package) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { $tests = Package::testForInstall($package); if (is_array($tests)) { $tests = Package::mapError($tests); $this->set('error', $tests); } else { $p = Loader::package($package); try { $p->install(); $this->set('message', t('The package has been installed.')); } catch(Exception $e) { $this->set('error', $e); } } } else { $this->error->add(t('You do not have permission to install add-ons.')); $this->set('error', $this->error); } }
public function install_package($package) { $tp = new TaskPermission(); if ($tp->canInstallPackages()) { $p = Loader::package($package); if (is_object($p)) { if ( (!$p->showInstallOptionsScreen()) || Loader::helper('validation/token')->validate('install_options_selected') ) { $tests = Package::testForInstall($package); if (is_array($tests)) { $tests = Package::mapError($tests); $this->set('error', $tests); } else { try { $u = new User(); $p->install($this->post()); if ($u->isSuperUser() && $p->allowsFullContentSwap() && $this->post('pkgDoFullContentSwap')) { $p->swapContent($this->post()); } $this->set('message', t('The package has been installed.')); } catch(Exception $e) { if ($p->showInstallOptionsScreen()) { $this->set('showInstallOptionsScreen', true); $this->set('pkg', $p); } $this->set('error', $e); } } } else { $this->set('showInstallOptionsScreen', true); $this->set('pkg', $p); } } } else { $this->error->add(t('You do not have permission to install add-ons.')); $this->set('error', $this->error); } }