Esempio n. 1
0
 public function process()
 {
     $collection = array();
     $packageArray = $this->package->toArray();
     $installed = $this->package->get('installed');
     $packageArray['installed'] = $installed == null ? $this->modx->lexicon('no') : $installed;
     $collection[] = $packageArray;
     return $this->success('', $collection);
 }
 public function getPackages()
 {
     /* get current version for supportability */
     $this->modx->getVersionData();
     $productVersion = $this->modx->version['code_name'] . '-' . $this->modx->version['full_version'];
     /** @var modRestResponse $response */
     $response = $this->provider->request('package/update', 'GET', array('signature' => $this->package->get('signature'), 'supports' => $productVersion));
     if ($response->isError()) {
         return $this->modx->lexicon('provider_err_connect', array('error' => $response->getError()));
     }
     return $response->toXml();
 }
Esempio n. 3
0
 public function process()
 {
     $this->modx->log(xPDO::LOG_LEVEL_INFO, $this->modx->lexicon('package_install_info_found'));
     $installed = $this->package->install($this->getProperties());
     $this->clearCache();
     if (!$installed) {
         $msg = $this->modx->lexicon('package_err_install', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_ERROR, $msg);
         $this->modx->log(modX::LOG_LEVEL_INFO, 'COMPLETED');
         return $this->failure($msg);
     } else {
         $msg = $this->modx->lexicon('package_install_info_success', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_WARN, $msg);
         $this->modx->log(modX::LOG_LEVEL_INFO, 'COMPLETED');
         return $this->success($msg);
     }
 }
 public function process()
 {
     $this->modx->log(modX::LOG_LEVEL_INFO, $this->modx->lexicon('package_update_info_provider_scan', array('provider' => $this->provider->get('name'))));
     $packages = $this->provider->latest($this->getProperty('signature'));
     if (is_string($packages)) {
         return $this->failure($packages);
     }
     /* if no newer packages were found */
     if (count($packages) < 1) {
         $msg = $this->modx->lexicon('package_err_uptodate', array('signature' => $this->package->get('signature')));
         $this->modx->log(modX::LOG_LEVEL_INFO, $msg);
         return $this->failure($msg);
     }
     $list = array();
     /** @var SimpleXMLElement $package */
     foreach ($packages as $package) {
         $packageArray = array('id' => (string) $package['id'], 'package' => (string) $package['package'], 'version' => (string) $package['version'], 'release' => (string) $package['release'], 'signature' => (string) $package['signature'], 'location' => (string) $package['location'], 'info' => (string) $package['location'] . '::' . (string) $package['signature']);
         $list[] = $packageArray;
     }
     return $this->success('', $list);
 }
Esempio n. 5
0
 /**
  * Format the dates for readability
  * 
  * @param array $packageArray
  * @return array
  */
 public function formatDates(array $packageArray)
 {
     if ($this->object->get('updated') != '0000-00-00 00:00:00' && $this->object->get('updated') != null) {
         $packageArray['updated'] = strftime($this->dateFormat, strtotime($this->object->get('updated')));
     } else {
         $packageArray['updated'] = '';
     }
     $packageArray['created'] = strftime($this->dateFormat, strtotime($this->object->get('created')));
     if ($this->object->get('installed') == null || $this->object->get('installed') == '0000-00-00 00:00:00') {
         $packageArray['installed'] = null;
     } else {
         $packageArray['installed'] = strftime($this->dateFormat, strtotime($this->object->get('installed')));
     }
     return $packageArray;
 }
Esempio n. 6
0
 /**
  * @param modTransportPackage $package
  * @param array $packageArray
  * @return array
  */
 public function checkForUpdates(modTransportPackage $package, array $packageArray)
 {
     $updates = array('count' => 0);
     if ($package->get('provider') > 0 && $this->modx->getOption('auto_check_pkg_updates', null, false)) {
         $updateCacheKey = 'mgr/providers/updates/' . $package->get('provider') . '/' . $package->get('signature');
         $updateCacheOptions = array(xPDO::OPT_CACHE_KEY => $this->modx->cacheManager->getOption('cache_packages_key', null, 'packages'), xPDO::OPT_CACHE_HANDLER => $this->modx->cacheManager->getOption('cache_packages_handler', null, $this->modx->cacheManager->getOption(xPDO::OPT_CACHE_HANDLER)));
         $updates = $this->modx->cacheManager->get($updateCacheKey, $updateCacheOptions);
         if (empty($updates)) {
             /* cache providers to speed up load time */
             /** @var modTransportProvider $provider */
             if (!empty($this->providerCache[$package->get('provider')])) {
                 $provider =& $this->providerCache[$package->get('provider')];
             } else {
                 $provider = $package->getOne('Provider');
                 if ($provider) {
                     $this->providerCache[$provider->get('id')] = $provider;
                 }
             }
             if ($provider) {
                 $loaded = $provider->getClient();
                 if ($loaded) {
                     /** @var modRestResponse $response */
                     $response = $provider->request('package/update', 'GET', array('signature' => $package->get('signature'), 'supports' => $this->productVersion));
                     if ($response && !$response->isError()) {
                         $updates = $response->toXml();
                     }
                 }
                 $updates = array('count' => count($updates));
                 $this->modx->cacheManager->set($updateCacheKey, $updates, $this->updatesCacheExpire, $updateCacheOptions);
             }
         }
     }
     $packageArray['updateable'] = (int) $updates['count'] >= 1 ? true : false;
     return $packageArray;
 }
Esempio n. 7
0
 public function prepareMenu(modTransportPackage $package, array $packageArray)
 {
     $notInstalled = $package->get('installed') == null || $package->get('installed') == '0000-00-00 00:00:00';
     $packageArray['iconaction'] = $notInstalled ? 'icon-install' : 'icon-uninstall';
     $packageArray['textaction'] = $notInstalled ? $this->modx->lexicon('install') : $this->modx->lexicon('uninstall');
     if ($this->currentIndex > 0 || !$package->get('installed')) {
         $packageArray['menu'] = array();
         $packageArray['menu'][] = array('text' => $this->modx->lexicon('package_version_remove'), 'handler' => 'this.removePriorVersion');
     }
     return $packageArray;
 }
Esempio n. 8
0
 public function logManagerAction()
 {
     $this->modx->logManagerAction('package_remove', 'transport.modTransportPackage', $this->package->get('id'));
 }