public function onAfterInitialise()
 {
     if (JFactory::getApplication()->isAdmin()) {
         $this->loadLanguage();
         $msg = JText::_('PLG_SYSTEM_ATOOLSUPDATECHECK_MSG');
         if ($msg == 'PLG_SYSTEM_ATOOLSUPDATECHECK_MSG') {
             $msg = 'The <b>System - Admin Tools Update Email</b> plugin is now obsolete. You will find your Admin Tools updates under Extensions, Extensions Manager, Update in your Joomla! back-end. You will no longer be receiving emails about Admin Tools updates. Please disable this plugin to stop this message from appearing.';
         }
         JFactory::getApplication()->enqueueMessage($msg, 'warning');
         $db = JFactory::getDbo();
         // Let's get the information of the update plugin
         $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('folder') . ' = ' . $db->quote('system'))->where($db->qn('element') . ' = ' . $db->quote('atoolsupdatecheck'))->where($db->qn('type') . ' = ' . $db->quote('plugin'))->order($db->qn('ordering') . ' ASC');
         $db->setQuery($query);
         $plugin = $db->loadObject();
         if (!is_object($plugin)) {
             return;
         }
         // Otherwise, try to enable it and report false (so the user knows what he did wrong)
         $pluginObject = (object) array('extension_id' => $plugin->extension_id, 'enabled' => 0);
         try {
             $db->updateObject('#__extensions', $pluginObject, 'extension_id');
             F0FUtilsCacheCleaner::clearPluginsCache();
         } catch (Exception $e) {
         }
     }
 }
示例#2
0
 /**
  * Makes sure our system plugin is really the very first system plugin to execute
  */
 public function reorderPlugin()
 {
     // Get our plugin's ID
     $id = $this->getPluginID();
     // The plugin is not enabled, there's no point in continuing
     if (!$id) {
         return;
     }
     // Get a list of ordering values per ID
     $db = $this->getDbo();
     $query = $db->getQuery(true)->select(array($db->qn('extension_id'), $db->qn('ordering')))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('plugin'))->where($db->qn('folder') . ' = ' . $db->q('system'))->order($db->qn('ordering') . ' ASC');
     $db->setQuery($query);
     $orderingPerId = $db->loadAssocList('extension_id', 'ordering');
     $orderings = array_values($orderingPerId);
     $orderings = array_unique($orderings);
     $minOrdering = reset($orderings);
     $myOrdering = $orderingPerId[$id];
     reset($orderings);
     $sharedOrderings = 0;
     foreach ($orderingPerId as $fooid => $order) {
         if ($order > $myOrdering) {
             break;
         }
         if ($order == $myOrdering) {
             $sharedOrderings++;
         }
     }
     // Do I need to reorder the plugin?
     if ($myOrdering > $minOrdering || $sharedOrderings > 1) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('ordering') . ' = ' . $db->q($minOrdering - 1))->where($db->qn('extension_id') . ' = ' . $db->q($id));
         $db->setQuery($query);
         $db->execute();
         // Reset the Joomla! plugins cache
         F0FUtilsCacheCleaner::clearPluginsCache();
     }
 }
示例#3
0
function com_akeeba_postinstall_common_savesettings($upgradedAngie = 0)
{
    include_once JPATH_SITE . '/libraries/f0f/include.php';
    if (!defined('F0F_INCLUDED') || !class_exists('F0FForm', true)) {
        JError::raiseError('500', 'Your Akeeba Backup installation is broken; please re-install. Alternatively, extract the installation archive and copy the fof directory inside your site\'s libraries directory.');
        return;
    }
    $db = JFactory::getDbo();
    // Update last version check and minstability. DO NOT USE JCOMPONENTHELPER!
    $sql = $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'));
    $db->setQuery($sql);
    $rawparams = $db->loadResult();
    $params = new JRegistry();
    $params->loadString($rawparams);
    if (!defined('AKEEBA_VERSION')) {
        require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/version.php';
    }
    $version = AKEEBA_VERSION;
    if ($upgradedAngie) {
        $params->set('angieupgrade', $upgradedAngie);
    } else {
        $params->set('lastversion', $version);
    }
    $data = $params->toString('JSON');
    $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'))->where($db->qn('type') . ' = ' . $db->q('component'));
    $db->setQuery($sql);
    $db->execute();
    // Even better, create the "akeeba.lastversion.php" file with this information
    $fileData = "<" . "?php\ndefined('_JEXEC') or die();\ndefine('AKEEBA_LASTVERSIONCHECK','" . $version . "');";
    JLoader::import('joomla.filesystem.file');
    $fileName = JPATH_ADMINISTRATOR . '/components/com_akeeba/akeeba.lastversion.php';
    JFile::write($fileName, $fileData);
    // Reset the plugins and modules cache
    F0FUtilsCacheCleaner::clearPluginsCache();
}
 /**
  * Uninstalls subextensions (modules, plugins) bundled with the main extension
  *
  * @param   JInstaller $parent The parent object
  *
  * @return  stdClass  The subextension uninstallation status
  */
 protected function uninstallSubextensions($parent)
 {
     $db = F0FPlatform::getInstance()->getDbo();
     $status = new stdClass();
     $status->modules = array();
     $status->plugins = array();
     $src = $parent->getParent()->getPath('source');
     // Modules uninstallation
     if (isset($this->installation_queue['modules']) && 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);
                     try {
                         $id = $db->loadResult();
                     } catch (Exception $exc) {
                         $id = 0;
                     }
                     // 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->installation_queue['plugins']) && 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);
                     try {
                         $id = $db->loadResult();
                     } catch (Exception $exc) {
                         $id = 0;
                     }
                     if ($id) {
                         $installer = new JInstaller();
                         $result = $installer->uninstall('plugin', $id, 1);
                         $status->plugins[] = array('name' => 'plg_' . $plugin, 'group' => $folder, 'result' => $result);
                     }
                 }
             }
         }
     }
     // Clear com_modules and com_plugins cache (needed when we alter module/plugin state)
     F0FUtilsCacheCleaner::clearPluginsAndModulesCache();
     return $status;
 }
示例#5
0
    /**
     * This method is called when the Quick Icons module is constructing its set
     * of icons. You can return an array which defines a single icon and it will
     * be rendered right after the stock Quick Icons.
     *
     * @param  $context  The calling context
     *
     * @return array A list of icon definition associative arrays, consisting of the
     *                 keys link, image, text and access.
     *
     * @since       2.5
     */
    public function onGetIcons($context)
    {
        $user = JFactory::getUser();
        if (!$user->authorise('akeeba.backup', 'com_akeeba')) {
            return;
        }
        if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_installer')) {
            return;
        }
        Platform::addPlatform('joomla25', JPATH_ADMINISTRATOR . '/components/com_akeeba/platform/joomla25');
        $url = JUri::base();
        $url = rtrim($url, '/');
        $profileId = (int) $this->params->get('profileid', 1);
        $token = JFactory::getSession()->getToken();
        if ($profileId <= 0) {
            $profileId = 1;
        }
        $ret = array('link' => 'index.php?option=com_akeeba&view=backup&autostart=1&returnurl=' . urlencode($url) . '&profileid=' . $profileId . "&{$token}=1", 'image' => 'akeeba-black', 'text' => JText::_('PLG_QUICKICON_AKEEBABACKUP_OK'), 'id' => 'plg_quickicon_akeebabackup', 'group' => 'MOD_QUICKICON_MAINTENANCE');
        if (version_compare(JVERSION, '3.0', 'lt')) {
            $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-48.png';
        }
        if ($this->params->get('enablewarning', 0) == 0) {
            // Process warnings
            $warning = false;
            $aeconfig = Factory::getConfiguration();
            Platform::getInstance()->load_configuration();
            // Get latest non-SRP backup ID
            $filters = array(array('field' => 'tag', 'operand' => '<>', 'value' => 'restorepoint'));
            $ordering = array('by' => 'backupstart', 'order' => 'DESC');
            require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/models/statistics.php';
            $model = new AkeebaModelStatistics();
            $list = $model->getStatisticsListWithMeta(false, $filters, $ordering);
            if (!empty($list)) {
                $record = (object) array_shift($list);
            } else {
                $record = null;
            }
            // Process "failed backup" warnings, if specified
            if ($this->params->get('warnfailed', 0) == 0) {
                if (!is_null($record)) {
                    $warning = $record->status == 'fail' || $record->status == 'run';
                }
            }
            // Process "stale backup" warnings, if specified
            if (is_null($record)) {
                $warning = true;
            } else {
                $maxperiod = $this->params->get('maxbackupperiod', 24);
                JLoader::import('joomla.utilities.date');
                $lastBackupRaw = $record->backupstart;
                $lastBackupObject = new JDate($lastBackupRaw);
                $lastBackup = $lastBackupObject->toUnix(false);
                $maxBackup = time() - $maxperiod * 3600;
                if (!$warning) {
                    $warning = $lastBackup < $maxBackup;
                }
            }
            if ($warning) {
                $ret['image'] = 'akeeba-red';
                $ret['text'] = JText::_('PLG_QUICKICON_AKEEBABACKUP_BACKUPREQUIRED');
                if (version_compare(JVERSION, '3.0', 'lt')) {
                    $ret['image'] = $url . '/../media/com_akeeba/icons/akeeba-warning-48.png';
                } else {
                    $ret['text'] = '<span class="badge badge-important">' . $ret['text'] . '</span>';
                }
            }
        }
        if (version_compare(JVERSION, '3.0', 'gt')) {
            $inlineCSS = <<<CSS
.icon-akeeba-black {
\tbackground-image: url("../media/com_akeeba/icons/akeebabackup-16-black.png");
\twidth: 16px;
\theight: 16px;
}

.icon-akeeba-red {
\tbackground-image: url("../media/com_akeeba/icons/akeebabackup-16-red.png");
\twidth: 16px;
\theight: 16px;
}

.quick-icons .nav-list [class^="icon-akeeba-"], .quick-icons .nav-list [class*=" icon-akeeba-"] {
\tmargin-right: 7px;
}

.quick-icons .nav-list [class^="icon-akeeba-red"], .quick-icons .nav-list [class*=" icon-akeeba-red"] {
\tmargin-bottom: -4px;
}
CSS;
            JFactory::getApplication()->getDocument()->addStyleDeclaration($inlineCSS);
        }
        // Re-enable self
        $db = JFactory::getDbo();
        $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('akeebabackup'))->where($db->qn('folder') . ' = ' . $db->q('quickicon'));
        $db->setQuery($query);
        $db->execute();
        F0FUtilsCacheCleaner::clearPluginsCache();
        return array($ret);
    }
示例#6
0
 public function save()
 {
     $enableSRP = $this->input->get('srp', 0, 'bool');
     $enableAutoupdate = $this->input->get('autoupdate', 0, 'bool');
     $enableBackuponupdate = $this->input->get('backuponupdate', 0, 'bool');
     $runConfwiz = $this->input->get('confwiz', 0, 'bool');
     $acceptlicense = $this->input->get('acceptlicense', 0, 'bool');
     $acceptsupport = $this->input->get('acceptsupport', 0, 'bool');
     $acceptbackuptest = $this->input->get('acceptbackuptest', 0, 'bool');
     // SRP is only supported on MySQL databases
     if (!$this->isMySQL()) {
         $enableSRP = false;
     }
     $db = JFactory::getDBO();
     if ($enableSRP) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('srp'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     if ($enableBackuponupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('backuponupdate'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('backuponupdate'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('akeebaupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
     $db->setQuery($query);
     $db->execute();
     // Update last version check and minstability. DO NOT USE JCOMPONENTHELPER!
     $sql = $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'));
     $db->setQuery($sql);
     $rawparams = $db->loadResult();
     if (version_compare(JVERSION, '1.6.0', 'ge')) {
         $params = new JRegistry();
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $params->loadString($rawparams);
         } else {
             $params->loadJSON($rawparams);
         }
     } else {
         $params = new JRegistry($rawparams);
     }
     if ($acceptlicense && $acceptsupport) {
         $version = AKEEBA_VERSION;
     } else {
         $version = '0.0.0';
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->set('lastversion', $version);
         $params->set('acceptlicense', $acceptlicense);
         $params->set('acceptsupport', $acceptsupport);
         $params->set('acceptbackuptest', $acceptbackuptest);
     } else {
         $params->setValue('lastversion', $version);
         $params->setValue('acceptlicense', $acceptlicense);
         $params->setValue('acceptsupport', $acceptsupport);
         $params->setValue('acceptbackuptest', $acceptbackuptest);
     }
     $data = $params->toString('JSON');
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_akeeba'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
     // Even better, create the "akeeba.lastversion.php" file with this information
     $fileData = "<" . "?php\ndefined('_JEXEC') or die();\ndefine('AKEEBA_LASTVERSIONCHECK','" . $version . "');";
     JLoader::import('joomla.filesystem.file');
     $fileName = JPATH_COMPONENT_ADMINISTRATOR . '/akeeba.lastversion.php';
     JFile::write($fileName, $fileData);
     // Reset the plugins and modules cache
     F0FUtilsCacheCleaner::clearPluginsCache();
     // Run the configuration wizard if requested
     $message = '';
     if ($runConfwiz) {
         $url = 'index.php?option=com_akeeba&view=confwiz';
     } else {
         $url = 'index.php?option=com_akeeba&view=cpanel';
     }
     if (!$acceptlicense) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTLICENSE'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptsupport) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTSUPPORT'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     if (!$acceptbackuptest) {
         JFactory::getApplication()->enqueueMessage(JText::_('AKEEBA_POSTSETUP_ERR_ACCEPTBACKUPTEST'), 'error');
         $url = 'index.php?option=com_akeeba&view=postsetup';
     }
     JFactory::getApplication()->redirect($url);
 }
示例#7
0
 /**
  * Checks if the download ID provisioning plugin for the updates of this extension is published. If not, it will try
  * to publish it automatically. It reports the status of the plugin as a boolean.
  *
  * @return  bool
  */
 public function isUpdatePluginEnabled()
 {
     // We can't be bothered about the plugin in Joomla! 2.5.0 through 2.5.19
     if (version_compare(JVERSION, '2.5.19', 'lt')) {
         return true;
     }
     // We can't be bothered about the plugin in Joomla! 3.x
     if (version_compare(JVERSION, '3.0.0', 'gt')) {
         return true;
     }
     $db = $this->getDBO();
     // Let's get the information of the update plugin
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('folder') . ' = ' . $db->quote('installer'))->where($db->qn('element') . ' = ' . $db->quote('akeebabackup'))->where($db->qn('type') . ' = ' . $db->quote('plugin'))->order($db->qn('ordering') . ' ASC');
     $db->setQuery($query);
     $plugin = $db->loadObject();
     // If the plugin is missing report it as unpublished (of course!)
     if (!is_object($plugin)) {
         return false;
     }
     // If it's enabled there's nothing else to do
     if ($plugin->enabled) {
         return true;
     }
     // Otherwise, try to enable it and report false (so the user knows what he did wrong)
     $pluginObject = (object) array('extension_id' => $plugin->extension_id, 'enabled' => 1);
     try {
         $result = $db->updateObject('#__extensions', $pluginObject, 'extension_id');
         // Do not remove this line. We need to tell the user he's doing something wrong.
         $result = false;
     } catch (Exception $e) {
         $result = false;
     }
     // Reset the plugins cache
     F0FUtilsCacheCleaner::clearPluginsCache();
     return $result;
 }
示例#8
0
 public function autoDisable()
 {
     $this->loadLanguage();
     $pluginName = JText::_('PLG_SYSTEM_BACKUPONUPDATE_TITLE');
     if ($pluginName == 'PLG_SYSTEM_BACKUPONUPDATE_TITLE') {
         $pluginName = 'System - Backup on update';
     }
     $msg = JText::sprintf('PLG_SYSTEM_BACKUPONUPDATE_MSG_AUTODISABLE', $pluginName);
     if ($msg == 'PLG_SYSTEM_AKEEBAUPDATECHECK_MSG') {
         $msg = sprintf('The plugin %s will only work on Joomla! 2.5. Since it is incompatible with your version of Joomla! it will now disable itself.', $pluginName);
     }
     JFactory::getApplication()->enqueueMessage($msg, 'warning');
     $db = JFactory::getDbo();
     // Let's get the information of the update plugin
     $query = $db->getQuery(true)->select('*')->from($db->nameQuote('#__extensions'))->where($db->nameQuote('folder') . ' = ' . $db->quote('system'))->where($db->nameQuote('element') . ' = ' . $db->quote('backuponupdate'))->where($db->nameQuote('type') . ' = ' . $db->quote('plugin'))->order($db->nameQuote('ordering') . ' ASC');
     $db->setQuery($query);
     $plugin = $db->loadObject();
     if (!is_object($plugin)) {
         return;
     }
     // Otherwise, try to enable it and report false (so the user knows what he did wrong)
     $pluginObject = (object) array('extension_id' => $plugin->extension_id, 'enabled' => 0);
     try {
         $db->updateObject('#__extensions', $pluginObject, 'extension_id');
     } catch (Exception $e) {
     }
     if (!class_exists('F0FUtilsCacheCleaner')) {
         include_once JPATH_SITE . '/libraries/f0f/include.php';
     }
     if (class_exists('F0FUtilsCacheCleaner')) {
         F0FUtilsCacheCleaner::clearPluginsCache();
     }
 }
示例#9
0
 public function cleanup()
 {
     // Anti-CSRF token check
     if ($this->csrfProtection) {
         $this->_csrfProtection();
     }
     /** @var AkeebaModelUpdates $model */
     $model = $this->getThisModel();
     // Get information from the session
     $session = JFactory::getSession();
     $updatePackagePath = $session->get('downloadedPackage', null, 'com_akeeba.update');
     $installationDirectory = $session->get('installationDirectory', null, 'com_akeeba.update');
     jimport('jooomla.filesystem.file');
     jimport('jooomla.filesystem.folder');
     jimport('joomla.installer.helper');
     // Registers FTP credentials from the session
     $needsFTP = $model->needsFTPCredentials();
     // First try using Joomla!'s cleanupInstall
     if (class_exists('JInstallerHelper') && method_exists('JInstallerHelper', 'cleanupInstall')) {
         JInstallerHelper::cleanupInstall($updatePackagePath, $installationDirectory);
     }
     // Make sure we have cleaned up the downloaded package
     if (is_file($updatePackagePath)) {
         if (!@unlink($updatePackagePath)) {
             JFile::delete($updatePackagePath);
         }
     }
     // Make sure we have cleaned up the extracted package's folder
     if (is_dir($installationDirectory)) {
         JFolder::delete($installationDirectory);
     }
     // Clear Joomla! caches
     if (class_exists('JCache') && method_exists('JCache', 'clean')) {
         F0FUtilsCacheCleaner::clearCacheGroups(array('mod_menu'));
         F0FUtilsCacheCleaner::clearPluginsCache();
         F0FUtilsCacheCleaner::clearModulesCache();
     } else {
         $cacheGroups = array('mod_menu', 'com_plugins', 'com_modules');
         foreach ($cacheGroups as $group) {
             $cache = JFactory::getCache($group);
             $cache->clean();
         }
     }
     // Force refresh the update information
     $model->getUpdates(true);
     // Reset Joomla!'s update cache as well
     $model->refreshUpdateSite();
 }
示例#10
0
 /**
  * Moves this plugin's settings from the plugin into each subscription
  * level's configuration parameters.
  */
 protected function upgradeSettings($config = array())
 {
     $model = F0FModel::getTmpInstance('Levels', 'AkeebasubsModel');
     $levels = $model->getList(true);
     $addgroupsKey = strtolower($this->name) . '_addgroups';
     $removegroupsKey = strtolower($this->name) . '_removegroups';
     if (!empty($levels)) {
         foreach ($levels as $level) {
             $save = false;
             if (is_string($level->params)) {
                 $level->params = @json_decode($level->params);
                 if (empty($level->params)) {
                     $level->params = new stdClass();
                 }
             } elseif (empty($level->params)) {
                 $level->params = new stdClass();
             }
             if (array_key_exists($level->akeebasubs_level_id, $this->addGroups)) {
                 $data = $this->addGroups[$level->akeebasubs_level_id];
                 if (!empty($data)) {
                     foreach ($data as $k => $v) {
                         $key = strtolower($this->name) . '_' . $k;
                         if (empty($level->params->{$key})) {
                             $level->params->{$key} = $v;
                             $save = true;
                         }
                     }
                 }
             }
             if ($save) {
                 $level->params = json_encode($level->params);
                 $result = $model->setId($level->akeebasubs_level_id)->save($level);
             }
         }
     }
     // Remove the plugin parameters
     if (isset($config['params'])) {
         $configParams = @json_decode($config['params']);
         unset($configParams->addgroups);
         unset($configParams->removegroups);
         $param_string = @json_encode($configParams);
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->where($db->qn('type') . '=' . $db->q('plugin'))->where($db->qn('element') . '=' . $db->q(strtolower($this->name)))->where($db->qn('folder') . '=' . $db->q('akeebasubs'))->set($db->qn('params') . ' = ' . $db->q($param_string));
         $db->setQuery($query);
         $db->execute();
         F0FUtilsCacheCleaner::clearPluginsCache();
     }
 }
示例#11
0
 public function save()
 {
     // CSRF prevention
     $this->_csrfProtection();
     $enableAutoupdate = $this->input->getBool('autoupdate', 0);
     $enableAutojupdate = $this->input->getBool('autojupdate', 0);
     $acceptlicense = $this->input->getBool('acceptlicense', 0);
     $acceptsupport = $this->input->getBool('acceptsupport', 0);
     $db = JFactory::getDBO();
     if ($enableAutoupdate || $enableAutojupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('oneclickaction'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('atoolsupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
     $db->setQuery($query);
     $db->execute();
     if ($enableAutojupdate) {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('1'))->where($db->qn('element') . ' = ' . $db->q('atoolsjupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     } else {
         $query = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('enabled') . ' = ' . $db->q('0'))->where($db->qn('element') . ' = ' . $db->q('atoolsjupdatecheck'))->where($db->qn('folder') . ' = ' . $db->q('system'));
         $db->setQuery($query);
         $db->execute();
     }
     // Load the component parameters. DO NOT USE JCOMPONENTHELPER!
     $query = $db->getQuery(true)->select(array($db->qn('params')))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_admintools'));
     $db->setQuery($query);
     $rawparams = $db->loadResult();
     $params = new JRegistry();
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->loadString($rawparams, 'JSON');
     } else {
         $params->loadJSON($rawparams);
     }
     // Apply htmaker folders fix.
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $has240Fix = $params->get('htmaker_folders_fix_at240', '0');
     } else {
         $has240Fix = $params->getValue('htmaker_folders_fix_at240', '0');
     }
     if (!$has240Fix) {
         $htmaker = $this->getModel('htmaker');
         $config = $htmaker->loadConfiguration();
         $isConfigChanged = false;
         $jUpdateRestore = 'administrator/components/com_joomlaupdate/restore.php';
         if (!in_array($jUpdateRestore, $config->exceptionfiles)) {
             array_push($config->exceptionfiles, $jUpdateRestore);
             $isConfigChanged = true;
         }
         $fontDir = 'media/jui/fonts';
         if (!in_array($fontDir, $config->fepexdirs)) {
             array_push($config->fepexdirs, $fontDir);
             $isConfigChanged = true;
         }
         if ($isConfigChanged) {
             $htmaker->saveConfiguration($config, true);
         }
         if (version_compare(JVERSION, '3.0', 'ge')) {
             $params->set('htmaker_folders_fix_at240', '1');
         } else {
             $params->setValue('htmaker_folders_fix_at240', '1');
         }
     }
     // Update last version check.
     if ($acceptlicense && $acceptsupport) {
         $version = ADMINTOOLS_VERSION;
     } else {
         $version = '0.0.0';
     }
     if (version_compare(JVERSION, '3.0', 'ge')) {
         $params->set('lastversion', $version);
         $params->set('acceptlicense', $acceptlicense);
         $params->set('acceptsupport', $acceptsupport);
     } else {
         $params->setValue('lastversion', $version);
         $params->setValue('acceptlicense', $acceptlicense);
         $params->setValue('acceptsupport', $acceptsupport);
     }
     // Joomla! 1.6
     $data = $params->toString('JSON');
     $sql = $db->getQuery(true)->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($data))->where($db->qn('element') . ' = ' . $db->q('com_admintools'))->where($db->qn('type') . ' = ' . $db->q('component'));
     $db->setQuery($sql);
     $db->execute();
     // Even better, create the "admintools.lastversion.php" file with this information
     $fileData = "<" . "?php\ndefined('_JEXEC') or die;\ndefine('ADMINTOOLS_LASTVERSIONCHECK','" . $version . "');";
     JLoader::import('joomla.filesystem.file');
     $fileName = JPATH_COMPONENT_ADMINISTRATOR . '/admintools.lastversion.php';
     JFile::write($fileName, $fileData);
     $url = 'index.php?option=com_admintools&view=cpanel';
     // Reset the Joomla! plugins cache
     F0FUtilsCacheCleaner::clearPluginsCache();
     if (!$acceptlicense) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ADMINTOOLS_POSTSETUP_ERR_ACCEPTLICENSE'), 'error');
         $url = 'index.php?option=com_admintools&view=postsetup';
     }
     if (!$acceptsupport) {
         JFactory::getApplication()->enqueueMessage(JText::_('COM_ADMINTOOLS_POSTSETUP_ERR_ACCEPTSUPPORT'), 'error');
         $url = 'index.php?option=com_admintools&view=postsetup';
     }
     JFactory::getApplication()->redirect($url);
 }