Exemple #1
0
    public function prepare_remote_upgrade($remoteMPID = 0){
		$tp = new TaskPermission();
		if ($tp->canInstallPackages()) { 
			Loader::model('marketplace_remote_item');
			$mri = MarketplaceRemoteItem::getByID($remoteMPID);
	
			if (!is_object($mri)) {
				$this->set('error', array(t('Invalid marketplace item ID.')));
				return;
			}
			
			$local = Package::getbyHandle($mri->getHandle());
			if (!is_object($local) || $local->isPackageInstalled() == false) {
				$this->set('error', array(Package::E_PACKAGE_NOT_FOUND));
				return;
			}		
			
			$r = $mri->downloadUpdate();
	
			if ($r != false) {
				if (!is_array($r)) {
					$this->set('error', array($r));
				} else {
					$errors = Package::mapError($r);
					$this->set('error', $errors);
				}
			} else {
				$this->redirect('/dashboard/extend/update', 'do_update', $mri->getHandle());
			}
		}
    }
Exemple #2
0
<?php   defined('C5_EXECUTE') or die("Access Denied.");

Loader::library('marketplace');
Loader::model('marketplace_remote_item');

$js = Loader::helper('json');
$mi = Marketplace::getInstance();

$obj = new stdClass;
$obj->isConnected = $mi->isConnected();
$obj->connectionError = $mi->getConnectionError();
if ($mi->isConnected() && isset($_REQUEST['mpID'])) {
	// we also perform the "does the user need to buy it?" query here to save some requests
	$mr = MarketplaceRemoteItem::getByID($_REQUEST['mpID']);
	if (is_object($mr)) {
		$obj->purchaseRequired = $mr->purchaseRequired();
		$obj->remoteURL = $mr->getRemoteURL();
		// if purchase is NOT required then we also try and add a license
		// don't worry - this is also verified on the server
		if (!$mr->purchaseRequired()) {
			$mr->enableFreeLicense();
		}
	}
}
print $js->encode($obj);
exit;
if (!$tp->canInstallPackages()) {
    ?>
	<p><?php 
    echo t('You do not have permission to download packages from the marketplace.');
    ?>
</p>
	<?php 
    exit;
}
Loader::library('marketplace');
Loader::model('marketplace_remote_item');
$mpID = $_REQUEST['mpID'];
$install = isset($_REQUEST['install']) ? $_REQUEST['install'] : false;
$error = Loader::helper('validation/error');
if (!empty($mpID)) {
    $mri = MarketplaceRemoteItem::getByID($mpID);
    if (is_object($mri)) {
        $r = $mri->download();
        if ($r != false) {
            if (is_array($r)) {
                $errors = Package::mapError($r);
                foreach ($errors as $e) {
                    $error->add($e);
                }
            } else {
                $error->add($r);
            }
        }
    }
}
if (!is_object($mri)) {
Exemple #4
0
 public function download($remoteMPID = null)
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         Loader::model('marketplace_remote_item');
         $mri = MarketplaceRemoteItem::getByID($remoteMPID);
         if (!is_object($mri)) {
             $this->set('error', array(t('Invalid marketplace item ID.')));
             return;
         }
         $r = $mri->download();
         if ($r != false) {
             if (!is_array($r)) {
                 $this->set('error', array($r));
             } else {
                 $errors = Package::mapError($r);
                 $this->set('error', $errors);
             }
         } else {
             $this->set('message', t('Marketplace item %s downloaded successfully.', $mri->getName()));
         }
     } else {
         $this->error->add(t('You do not have permission to download add-ons.'));
         $this->set('error', $this->error);
     }
 }