Esempio n. 1
0
 /**
  * method to run after an install/update/uninstall method
  *
  * @param   string      $type    Installation type (install, update, discover_install)
  * @param   JInstaller  $parent  Parent object
  *
  * @return void
  */
 function postflight($type, $parent)
 {
     $src = $parent->getParent()->getPath('source');
     // Install the babioon Library
     $source = $src . '/library/babioon';
     $installer = new JInstaller();
     $result = $installer->install($source);
 }
Esempio n. 2
0
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string     $type   install, update or discover_update
  * @param   JInstaller $parent Parent object
  */
 function postflight($type, $parent)
 {
     $this->isPaid = is_dir($parent->getParent()->getPath('source') . '/plugins/system/srp');
     parent::postflight($type, $parent);
     // Make sure the two plugins folders exist in Core release and are empty
     if (!$this->isPaid) {
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins');
         }
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins');
         }
     }
 }
Esempio n. 3
0
 /**
  * Copies the CLI scripts into Joomla!'s cli directory
  *
  * @param JInstaller $parent
  */
 private function _copyCliFiles($parent)
 {
     $src = $parent->getParent()->getPath('source');
     if (empty($this->eventgalleryCliScripts)) {
         return;
     }
     foreach ($this->eventgalleryCliScripts as $script) {
         if (JFile::exists(JPATH_ROOT . '/cli/' . $script)) {
             JFile::delete(JPATH_ROOT . '/cli/' . $script);
         }
         if (JFile::exists($src . '/cli/' . $script)) {
             JFile::move($src . '/cli/' . $script, JPATH_ROOT . '/cli/' . $script);
         }
     }
 }
Esempio n. 4
0
 /**
  * Shit happens. Patched function to bypass bug in package uninstaller
  *
  * @param   JInstaller  $parent  Parent object
  *
  * @return  SimpleXMLElement
  */
 protected function getManifest($parent)
 {
     $element = strtolower(str_replace('InstallerScript', '', __CLASS__));
     $elementParts = explode('_', $element);
     if (count($elementParts) == 2) {
         $extType = $elementParts[0];
         $extName = $elementParts[1];
         if ($extType == 'pkg') {
             $rootPath = $parent->getParent()->getPath('extension_root');
             $manifestPath = dirname($rootPath);
             $manifestFile = $manifestPath . '/' . $element . '.xml';
             if (file_exists($manifestFile)) {
                 return JFactory::getXML($manifestFile);
             }
         }
     }
     return $parent->get('manifest');
 }
Esempio n. 5
0
 /**
  * Let's say that a user tries to install a component and it somehow fails
  * in a non-graceful manner, e.g. a server timeout error, going over the
  * quota etc. In this case the component's administrator directory is
  * created and not removed (because the installer died an untimely death).
  * When the user retries installing the component JInstaller sees that and
  * thinks it's an update. This causes it to neither run the installation SQL
  * file (because it's not supposed to run on extension update) nor the
  * update files (because there is no schema version defined). As a result
  * the files are installed, the database tables are not, the component is
  * broken and I have to explain to non-technical users how to edit their
  * database with phpMyAdmin.
  *
  * This method detects this stupid situation and attempts to execute the
  * installation file instead.
  *
  * @param   string      $extension  Extension name
  * @param   JInstaller  $parent     Installer object
  *
  * @return void
  */
 public static function fixBrokenSQLUpdates($extension, $parent)
 {
     // Get the extension ID
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $query->select('extension_id')->from('#__extensions')->where($db->qn('element') . ' = ' . $db->q($extension));
     $db->setQuery($query);
     $eid = $db->loadResult();
     // Get the schema version
     $query = $db->getQuery(true);
     $query->select('version_id')->from('#__schemas')->where('extension_id = ' . $eid);
     $db->setQuery($query);
     $version = $db->loadResult();
     // If there is a schema version it's not a false update
     if ($version) {
         return;
     }
     // Execute the installation SQL file. Since I don't have access to
     // the manifest, I will improvise (again!)
     $dbDriver = strtolower($db->name);
     if ($dbDriver == 'mysqli') {
         $dbDriver = 'mysql';
     } elseif ($dbDriver == 'sqlsrv') {
         $dbDriver = 'sqlazure';
     }
     // Get the name of the sql file to process
     $sqlfile = $parent->getParent()->getPath('extension_root') . '/' . BABIOON_INSTALL_SUBDIR . $dbDriver . '/install.sql';
     if (file_exists($sqlfile)) {
         $buffer = file_get_contents($sqlfile);
         if ($buffer === false) {
             return;
         }
         $queries = JInstallerHelper::splitSql($buffer);
         if (count($queries) == 0) {
             // No queries to process
             return;
         }
         // Process each query in the $queries array (split out of sql file).
         foreach ($queries as $query) {
             $query = trim($query);
             if ($query != '' && $query[0] != '#') {
                 $db->setQuery($query);
                 if (!$db->execute()) {
                     JError::raiseWarning(1, JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)));
                     return false;
                 }
             }
         }
     }
     // Update #__schemas to the latest version. Again, since I don't have
     // access to the manifest I have to improvise...
     $path = $parent->getParent()->getPath('extension_root') . '/' . BABIOON_INSTALL_SUBDIR . 'updates/' . $dbDriver;
     $files = str_replace('.sql', '', JFolder::files($path, '\\.sql$'));
     if (count($files) > 0) {
         usort($files, 'version_compare');
         $version = array_pop($files);
     } else {
         $version = '0.0.1-2007-08-15';
     }
     $query = $db->getQuery(true);
     $query->insert($db->quoteName('#__schemas'));
     $query->columns(array($db->quoteName('extension_id'), $db->quoteName('version_id')));
     $query->values($eid . ', ' . $db->quote($version));
     $db->setQuery($query);
     $db->execute();
 }
 /**
  * Uninstalls obsolete subextensions (modules, plugins) bundled with the main extension
  *
  * @param   JInstaller $parent The parent object
  *
  * @return  stdClass The subextension uninstallation status
  */
 protected function uninstallObsoleteSubextensions($parent)
 {
     JLoader::import('joomla.installer.installer');
     $db = F0FPlatform::getInstance()->getDbo();
     $status = new stdClass();
     $status->modules = array();
     $status->plugins = array();
     $src = $parent->getParent()->getPath('source');
     // Modules uninstallation
     if (isset($this->uninstallation_queue['modules']) && count($this->uninstallation_queue['modules'])) {
         foreach ($this->uninstallation_queue['modules'] as $folder => $modules) {
             if (count($modules)) {
                 foreach ($modules as $module) {
                     // Find the module ID
                     $sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q('mod_' . $module))->where($db->qn('type') . ' = ' . $db->q('module'));
                     $db->setQuery($sql);
                     $id = $db->loadResult();
                     // Uninstall the module
                     if ($id) {
                         $installer = new JInstaller();
                         $result = $installer->uninstall('module', $id, 1);
                         $status->modules[] = array('name' => 'mod_' . $module, 'client' => $folder, 'result' => $result);
                     }
                 }
             }
         }
     }
     // Plugins uninstallation
     if (isset($this->uninstallation_queue['plugins']) && count($this->uninstallation_queue['plugins'])) {
         foreach ($this->uninstallation_queue['plugins'] as $folder => $plugins) {
             if (count($plugins)) {
                 foreach ($plugins as $plugin) {
                     $sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder));
                     $db->setQuery($sql);
                     $id = $db->loadResult();
                     if ($id) {
                         $installer = new JInstaller();
                         $result = $installer->uninstall('plugin', $id, 1);
                         $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result);
                     }
                 }
             }
         }
     }
     return $status;
 }
 /**
  * Uninstalls subextensions (modules, plugins) bundled with the main extension
  * 
  * @param JInstaller $parent 
  * @return JObject The subextension uninstallation status
  */
 private function _uninstallSubextensions($parent)
 {
     jimport('joomla.installer.installer');
     $db = JFactory::getDBO();
     $status = new JObject();
     $status->modules = array();
     $status->plugins = array();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $src = $parent->getParent()->getPath('source');
     } else {
         $src = $parent->getPath('source');
     }
     // Modules uninstallation
     if (count($this->installation_queue['modules'])) {
         foreach ($this->installation_queue['modules'] as $folder => $modules) {
             if (count($modules)) {
                 foreach ($modules as $module => $modulePreferences) {
                     // Find the module ID
                     $sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('element') . ' = ' . $db->q('mod_' . $module))->where($db->qn('type') . ' = ' . $db->q('module'));
                     $db->setQuery($sql);
                     $id = $db->loadResult();
                     // Uninstall the module
                     if ($id) {
                         $installer = new JInstaller();
                         $result = $installer->uninstall('module', $id, 1);
                         $status->modules[] = array('name' => 'mod_' . $module, 'client' => $folder, 'result' => $result);
                     }
                 }
             }
         }
     }
     // Plugins uninstallation
     if (count($this->installation_queue['plugins'])) {
         foreach ($this->installation_queue['plugins'] as $folder => $plugins) {
             if (count($plugins)) {
                 foreach ($plugins as $plugin => $published) {
                     $sql = $db->getQuery(true)->select($db->qn('extension_id'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('element') . ' = ' . $db->q($plugin))->where($db->qn('folder') . ' = ' . $db->q($folder));
                     $db->setQuery($sql);
                     $id = $db->loadResult();
                     if ($id) {
                         $installer = new JInstaller();
                         $result = $installer->uninstall('plugin', $id, 1);
                         $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result);
                     }
                 }
             }
         }
     }
     return $status;
 }
Esempio n. 8
0
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string     $type   install, update or discover_update
  * @param   JInstaller $parent Parent object
  */
 function postflight($type, $parent)
 {
     $this->isPaid = is_dir($parent->getParent()->getPath('source') . '/backend/alice');
     // Let's install common tables
     $model = F0FModel::getTmpInstance('Stats', 'AkeebaModel');
     if (method_exists($model, 'checkAndFixCommonTables')) {
         $model->checkAndFixCommonTables();
     }
     parent::postflight($type, $parent);
     $this->uninstallObsoletePostinstallMessages();
     // Make sure the two plugins folders exist in Core release and are empty
     if (!$this->isPaid) {
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins');
         }
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins');
         }
     }
     // If this is a new installation tell it to NOT mark the backup profiles as configured.
     if (defined('AKEEBA_THIS_IS_INSTALLATION_FROM_SCRATCH')) {
         $db = F0FPlatform::getInstance()->getDbo();
         $query = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
         $jsonData = $db->setQuery($query)->loadResult();
         $reg = new JRegistry($jsonData);
         $reg->set('confwiz_upgrade', 1);
         $jsonData = $reg->toString('JSON');
         $query = $db->getQuery()->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($jsonData))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'));
         $db->setQuery($query)->execute();
     }
     // This is an update of an existing installation
     if (!defined('AKEEBA_THIS_IS_INSTALLATION_FROM_SCRATCH')) {
         // Migrate profiles if necessary
         $this->migrateProfiles();
     }
 }
Esempio n. 9
0
 /**
  * Runs after install, update or discover_update. In other words, it executes after Joomla! has finished installing
  * or updating your component. This is the last chance you've got to perform any additional installations, clean-up,
  * database updates and similar housekeeping functions.
  *
  * @param   string     $type   install, update or discover_update
  * @param   JInstaller $parent Parent object
  */
 function postflight($type, $parent)
 {
     $this->isPaid = is_dir($parent->getParent()->getPath('source') . '/plugins/system/srp');
     if (!$this->isPaid) {
         unset($this->postInstallationMessages['srp']);
         unset($this->postInstallationMessages['backuponupdate']);
     }
     // Let's install common tables
     $model = F0FModel::getTmpInstance('Stats', 'AkeebaModel');
     if (method_exists($model, 'checkAndFixCommonTables')) {
         $model->checkAndFixCommonTables();
     }
     parent::postflight($type, $parent);
     if (version_compare(JVERSION, '3.2.0', 'ge')) {
         $this->uninstallObsoletePostinstallMessages();
     }
     // Make sure the two plugins folders exist in Core release and are empty
     if (!$this->isPaid) {
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/plugins');
         }
         if (!JFolder::exists(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins')) {
             JFolder::create(JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba/plugins');
         }
     }
 }
 /**
  * Runs after install, update or discover_update
  *
  * @param string     $type install, update or discover_update
  * @param JInstaller $parent
  */
 function postflight($type, $parent)
 {
     /** @var AdmintoolsModelStats $model */
     $this->isPaid = is_dir($parent->getParent()->getPath('source') . '/plugins/system/admintools/admintools/pro.php');
     if (!$this->isPaid) {
         unset($this->postInstallationMessages['autojupdate']);
     }
     // Let's install common tables
     $model = F0FModel::getTmpInstance('Stats', 'AdmintoolsModel');
     if (method_exists($model, 'checkAndFixCommonTables')) {
         $model->checkAndFixCommonTables();
     }
     parent::postflight($type, $parent);
 }
Esempio n. 11
0
 /**
  * Runs after install, update or discover_update
  *
  * @param string     $type install, update or discover_update
  * @param JInstaller $parent
  */
 function postflight($type, $parent)
 {
     /** @var AdmintoolsModelStats $model */
     $this->isPaid = is_dir($parent->getParent()->getPath('source') . '/plugins/system/admintools/admintools/pro.php');
     if (!$this->isPaid) {
         unset($this->postInstallationMessages['autojupdate']);
     }
     // Let's install common tables
     $model = F0FModel::getTmpInstance('Stats', 'AdmintoolsModel');
     if (method_exists($model, 'checkAndFixCommonTables')) {
         $model->checkAndFixCommonTables();
     }
     // Set the configuration wizad flag on update (so as not to bother existing users)
     if ($type == 'update') {
         if (!class_exists('AdmintoolsModelStorage')) {
             include_once JPATH_ADMINISTRATOR . '/components/com_admintools/models/storage.php';
         }
         if (class_exists('AdmintoolsModelStorage')) {
             $params = JModelLegacy::getInstance('Storage', 'AdmintoolsModel');
             $params->load();
             $params->setValue('quickstart', 1, true);
         }
     }
     parent::postflight($type, $parent);
 }
Esempio n. 12
0
 /**
  * Installs subextensions (modules, plugins) bundled with the main extension
  *
  * @param JInstaller $parent
  * @return JObject The subextension installation status
  */
 private function _installSubextensions($parent)
 {
     $src = $parent->getParent()->getPath('source');
     $db = JFactory::getDbo();
     $status = new JObject();
     $status->modules = array();
     $status->plugins = array();
     // Modules installation
     if (count($this->installation_queue['modules'])) {
         foreach ($this->installation_queue['modules'] as $folder => $modules) {
             if (count($modules)) {
                 foreach ($modules as $module => $modulePreferences) {
                     // Install the module
                     if (empty($folder)) {
                         $folder = 'site';
                     }
                     $path = "{$src}/modules/{$folder}/{$module}";
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/{$folder}/mod_{$module}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/{$module}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/modules/mod_{$module}";
                     }
                     if (!is_dir($path)) {
                         $fortest = '';
                         //continue;
                     }
                     // Was the module already installed?
                     $sql = $db->getQuery(true)->select('COUNT(*)')->from('#__modules')->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                     $db->setQuery($sql);
                     $count = $db->loadResult();
                     $installer = new JInstaller();
                     $result = $installer->install($path);
                     $status->modules[] = array('name' => $module, 'client' => $folder, 'result' => $result, 'status' => $modulePreferences[1]);
                     // Modify where it's published and its published state
                     if (!$count) {
                         // A. Position and state
                         list($modulePosition, $modulePublished) = $modulePreferences;
                         if ($modulePosition == 'cpanel') {
                             $modulePosition = 'icon';
                         }
                         $sql = $db->getQuery(true)->update($db->qn('#__modules'))->set($db->qn('position') . ' = ' . $db->q($modulePosition))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         if ($modulePublished) {
                             $sql->set($db->qn('published') . ' = ' . $db->q('1'));
                         }
                         $db->setQuery($sql);
                         $db->query();
                         // B. Change the ordering of back-end modules to 1 + max ordering
                         if ($folder == 'admin') {
                             $query = $db->getQuery(true);
                             $query->select('MAX(' . $db->qn('ordering') . ')')->from($db->qn('#__modules'))->where($db->qn('position') . '=' . $db->q($modulePosition));
                             $db->setQuery($query);
                             $position = $db->loadResult();
                             $position++;
                             $query = $db->getQuery(true);
                             $query->update($db->qn('#__modules'))->set($db->qn('ordering') . ' = ' . $db->q($position))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                             $db->setQuery($query);
                             $db->query();
                         }
                         // C. Link to all pages
                         $query = $db->getQuery(true);
                         $query->select('id')->from($db->qn('#__modules'))->where($db->qn('module') . ' = ' . $db->q('mod_' . $module));
                         $db->setQuery($query);
                         $moduleid = $db->loadResult();
                         $query = $db->getQuery(true);
                         $query->select('*')->from($db->qn('#__modules_menu'))->where($db->qn('moduleid') . ' = ' . $db->q($moduleid));
                         $db->setQuery($query);
                         $assignments = $db->loadObjectList();
                         $isAssigned = !empty($assignments);
                         if (!$isAssigned) {
                             $o = (object) array('moduleid' => $moduleid, 'menuid' => 0);
                             $db->insertObject('#__modules_menu', $o);
                         }
                     }
                 }
             }
         }
     }
     // Plugins installation
     if (count($this->installation_queue['plugins'])) {
         foreach ($this->installation_queue['plugins'] as $folder => $plugins) {
             if (count($plugins)) {
                 foreach ($plugins as $plugin => $published) {
                     $path = "{$src}/plugins/{$folder}/{$plugin}";
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/{$folder}/plg_{$plugin}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/{$plugin}";
                     }
                     if (!is_dir($path)) {
                         $path = "{$src}/plugins/plg_{$plugin}";
                     }
                     if (!is_dir($path)) {
                         continue;
                     }
                     // Was the plugin already installed?
                     $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($plugin)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($plugin)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                     $db->setQuery($query);
                     $count = $db->loadResult();
                     $installer = new JInstaller();
                     $result = $installer->install($path);
                     $status->plugins[] = array('name' => $plugin, 'group' => $folder, 'result' => $result, 'status' => $published);
                     if ($published && !$count) {
                         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($plugin)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($plugin)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                         $db->setQuery($query);
                         $db->query();
                     }
                 }
             }
         }
     }
     // library installation
     if (count($this->installation_queue['libraries'])) {
         foreach ($this->installation_queue['libraries'] as $folder => $status1) {
             $path = "{$src}/libraries/{$folder}";
             $query = $db->getQuery(true)->select('COUNT(*)')->from($db->qn('#__extensions'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($folder)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($folder)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
             $db->setQuery($query);
             $count = $db->loadResult();
             $installer = new JInstaller();
             $result = $installer->install($path);
             $status->libraries[] = array('name' => $folder, 'group' => $folder, 'result' => $result, 'status' => $status1);
             if ($published && !$count) {
                 $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where('( ' . ($db->qn('name') . ' = ' . $db->q($folder)) . ' OR ' . ($db->qn('element') . ' = ' . $db->q($folder)) . ' )')->where($db->qn('folder') . ' = ' . $db->q($folder));
                 $db->setQuery($query);
                 $db->query();
             }
         }
     }
     return $status;
 }
 /**
  * _fix_createAdminMenus
  *
  * @param   JInstaller  $parent  Parent object
  *
  * @return void
  */
 private function _fix_createAdminMenus($parent)
 {
     $db = $parent->getParent()->getDbo();
     $query = $db->getQuery(true);
     $option = $parent->get('element');
     $query->clear()->select('id')->from('#__menu')->where('menutype = ' . $db->quote('main'))->where('client_id = 1')->where('(link = ' . $db->quote('index.php?option=' . $option) . ' OR ' . 'link like ' . $db->quote('index.php?option=' . $option . '&%') . ')')->where('type = ' . $db->quote('component'))->where('home = 0');
     $db->setQuery($query);
     $menu_ids = $db->loadColumn();
     if (!empty($menu_ids)) {
         $ids = implode(',', $menu_ids);
         // Remove the old menu item
         $query->clear()->delete('#__menu')->where('id in (' . $ids . ')');
         $db->setQuery($query);
         $db->query();
     }
 }