Пример #1
0
 /**
  * Function called before extension installation/update/removal procedure commences
  *
  * @param   string             $type    The type of change (install, update or discover_install, not uninstall)
  * @param   JInstallerAdapter  $parent  The class calling this method
  *
  * @return  boolean  True on success
  *
  * @since   3.6
  */
 public function preflight($type, $parent)
 {
     // Check for the minimum PHP version before continuing
     if (!empty($this->minimumPhp) && !version_compare(PHP_VERSION, $this->minimumPhp, '>')) {
         JLog::add(JText::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), JLog::WARNING, 'jerror');
     }
     // Check for the minimum Joomla version before continuing
     if (!empty($this->minimumJoomla) && !version_compare(JVERSION, $this->minimumJoomla, '>')) {
         JLog::add(JText::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), JLog::WARNING, 'jerror');
     }
     // Extension manifest file version
     $this->release = $parent->get("manifest")->version;
     $extensionType = substr($this->extension, 0, 3);
     // Modules parameters are located in the module table - else in the extension table
     if ($extensionType === 'mod') {
         $this->paramTable = '#__modules';
     } else {
         $this->paramTable = '#__extensions';
     }
     // Abort if the extension being installed is not newer than the currently installed version
     if (strtolower($type) == 'update' && !$this->allowDowngrades) {
         $manifest = $this->getItemArray('manifest_cache', '#__extensions', 'element', JFactory::getDbo()->quote($this->extension));
         $oldRelease = $manifest['version'];
         if (version_compare($this->release, $oldRelease, '<')) {
             JFactory::getApplication()->enqueueMessage(JText::sprintf('JLIB_INSTALLER_INCORRECT_SEQUENCE', $oldRelease, $this->release), 'error');
             return false;
         }
     }
     return true;
 }
Пример #2
0
 /**
  * Shit happens. Patched function to bypass bug in package uninstaller
  *
  * @param   JInstallerAdapter  $parent  Parent object
  *
  * @return  void
  */
 protected function loadManifest($parent)
 {
     $element = strtolower(str_replace('InstallerScript', '', get_called_class()));
     $elementParts = explode('_', $element);
     // Type not properly detected or not a package
     if (count($elementParts) != 2 || strtolower($elementParts[0]) != 'pkg') {
         $this->manifest = $parent->get('manifest');
         return;
     }
     $rootPath = $parent->getParent()->getPath('extension_root');
     $manifestPath = dirname($rootPath);
     $manifestFile = $manifestPath . '/' . $element . '.xml';
     // Package manifest found
     if (file_exists($manifestFile)) {
         $this->manifest = JFactory::getXML($manifestFile);
         return;
     }
     $this->manifest = $parent->get('manifest');
 }