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);
		}
	
		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);
				}
			}
		}
	}
示例#2
0
 public function download_update()
 {
     if (MULTI_SITE == 1) {
         return false;
     }
     $vt = Loader::helper('validation/token');
     if (!$vt->validate('download_update')) {
         $this->error->add($vt->getErrorMessage());
     }
     if (!is_dir(DIR_APP_UPDATES)) {
         $this->error->add(t('The directory %s does not exist.', DIR_APP_UPDATES));
     } else {
         if (!is_writable(DIR_APP_UPDATES)) {
             $this->error->add(t('The directory %s must be writable by the web server.', DIR_APP_UPDATES));
         }
     }
     if (!$this->error->has()) {
         $remote = Update::getApplicationUpdateInformation();
         if (is_object($remote)) {
             // try to download
             Loader::library("marketplace");
             $r = Marketplace::downloadRemoteFile($remote->url);
             if (empty($r) || $r == Package::E_PACKAGE_DOWNLOAD) {
                 $response = array(Package::E_PACKAGE_DOWNLOAD);
             } else {
                 if ($r == Package::E_PACKAGE_SAVE) {
                     $response = array($r);
                 }
             }
             if (isset($response)) {
                 $errors = Package::mapError($response);
                 foreach ($errors as $e) {
                     $this->error->add($e);
                 }
             }
             if (!$this->error->has()) {
                 // the file exists in the right spot
                 Loader::library('archive');
                 $ar = new UpdateArchive();
                 try {
                     $ar->install($r);
                 } catch (Exception $e) {
                     $this->error->add($e->getMessage());
                 }
             }
         } else {
             $this->error->add(t('Unable to retrieve software from update server.'));
         }
     }
     $this->view();
 }
示例#3
0
 public function download_update()
 {
     $p = new \Permissions();
     if (!$p->canUpgrade()) {
         return false;
     }
     $vt = Loader::helper('validation/token');
     if (!$vt->validate('download_update')) {
         $this->error->add($vt->getErrorMessage());
     }
     if (!is_dir(DIR_CORE_UPDATES)) {
         $this->error->add(t('The directory %s does not exist.', DIR_CORE_UPDATES));
     } else {
         if (!is_writable(DIR_CORE_UPDATES)) {
             $this->error->add(t('The directory %s must be writable by the web server.', DIR_CORE_UPDATES));
         }
     }
     if (!$this->error->has()) {
         $remote = \Concrete\Core\Updater\Update::getApplicationUpdateInformation();
         if (is_object($remote)) {
             // try to download
             $r = \Marketplace::downloadRemoteFile($remote->getDirectDownloadURL());
             if (empty($r) || $r == \Package::E_PACKAGE_DOWNLOAD) {
                 $response = array(\Package::E_PACKAGE_DOWNLOAD);
             } else {
                 if ($r == \Package::E_PACKAGE_SAVE) {
                     $response = array($r);
                 }
             }
             if (isset($response)) {
                 $errors = \Package::mapError($response);
                 foreach ($errors as $e) {
                     $this->error->add($e);
                 }
             }
             if (!$this->error->has()) {
                 // the file exists in the right spot
                 $ar = new UpdateArchive();
                 try {
                     $ar->install($r);
                 } catch (Exception $e) {
                     $this->error->add($e->getMessage());
                 }
             }
         } else {
             $this->error->add(t('Unable to retrieve software from update server.'));
         }
     }
     $this->view();
 }