public static function parseKunenaInstallFile($path) { $xml = simplexml_load_file($path); if (!$xml || $xml->getName() != 'kinstall') { return false; } $data = new stdClass(); $data->name = (string) $xml->name; $data->type = (string) $xml->attributes()->type; $data->creationdate = (string) $xml->creationDate; $data->author = (string) $xml->author; $data->copyright = (string) $xml->copyright; $data->authorEmail = (string) $xml->authorEmail; $data->authorUrl = (string) $xml->authorUrl; $data->version = (string) $xml->version; $data->description = (string) $xml->description; $data->thumbnail = (string) $xml->thumbnail; if ($data->version == '@kunenaversion@') $data->version = KunenaForum::version(); if ($data->creationdate == '@kunenaversiondate@') $data->creationdate = KunenaForum::versionDate(); if (!$data->version) $data->version = JText::_('Unknown'); if (!$data->creationdate) $data->creationdate = JText::_('Unknown'); if (!$data->author) $data->author = JText::_('Unknown'); return $data; }
function prepare() { if (!JRequest::checkToken('get')) { $this->setRedirect('index.php?option=com_kunena'); return; } $start = JRequest::getBool('start', false); // Workaround situation where KunenaForum class doesn't exist (api.php was cached) if (!class_exists('KunenaForum')) { // TODO: add version check $app = JFactory::getApplication(); $try = $app->getUserState('kunena-prepare', 0) + 1; clearstatcache(); if (function_exists('apc_clear_cache')) { apc_clear_cache('system'); } sleep(1); $app->setUserState('kunena-prepare', $try); $start = $start ? '&start=1' : ''; $this->setRedirect('index.php?option=com_kunena&view=install&task=prepare&try=' . $try . $start . '&' . JUtility::getToken() . '=1'); $this->redirect(); } $this->model->install(); if ($start) { // Make sure that the code is identical to the installer (we can improve it later on) $versions = $this->model->getDetectVersions(); $version = reset($versions); if (!empty($version->state) || $version->version == KunenaForum::version() && $version->versiondate == KunenaForum::versionDate()) { unset($version); } } if (isset($version)) { $this->setRedirect($version->link); } else { $this->setRedirect('index.php?option=com_kunena&view=install'); } }
// Kunena uploaded files directory define('KUNENA_RELPATH_UPLOADED', 'media/kunena/attachments'); define('KUNENA_PATH_UPLOADED', KUNENA_ROOT_PATH .'/'. KUNENA_RELPATH_UPLOADED); // Kunena uploaded avatars directory define('KUNENA_RELPATH_AVATAR_UPLOADED', '/media/kunena/avatars'); define('KUNENA_PATH_AVATAR_UPLOADED', KUNENA_ROOT_PATH . KUNENA_RELPATH_AVATAR_UPLOADED); // Kunena legacy uploaded files directory define('KUNENA_RELPATH_UPLOADED_LEGACY', '/images/fbfiles'); define('KUNENA_PATH_UPLOADED_LEGACY', KUNENA_ROOT_PATH . KUNENA_RELPATH_UPLOADED_LEGACY); // Legacy version information define ('KUNENA_VERSION', KunenaForum::version()); define ('KUNENA_VERSION_DATE', KunenaForum::versionDate()); define ('KUNENA_VERSION_NAME', KunenaForum::versionName()); define ('KUNENA_VERSION_BUILD', 0); // Joomla URL define('KUNENA_JLIVEURL', JUri::base(true).'/'); // Joomla template dir define('KUNENA_JTEMPLATEPATH', KUNENA_ROOT_PATH . "/templates/{$app->getTemplate()}"); define('KUNENA_JTEMPLATEURL', KUNENA_JLIVEURL. "templates/{$app->getTemplate()}"); // Kunena live URL define('KUNENA_LIVEURL', KUNENA_JLIVEURL . 'index.php?option=com_kunena'); define('KUNENA_LIVEURLREL', 'index.php?option=com_kunena'); // Kunena files URL
protected function insertVersion($state = 'beginInstall') { // Insert data from the new version $this->insertVersionData(KunenaForum::version(), KunenaForum::versionDate(), KunenaForum::versionName(), $state); }
<div class="span5"> <div class="well well-small"> <div class="center"> <img src="components/com_kunena/media/icons/kunena_logo.png"/> </div> <dl class="dl-horizontal"> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_VERSION') ?>:</dt> <dd><?php echo KunenaForum::version(); ?></dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_CODENAME') ?>:</dt> <dd><?php echo KunenaForum::versionName(); ?></dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_DATE') ?>:</dt> <dd><?php echo KunenaForum::versionDate(); ?></dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_AUTHOR') ?>:</dt> <dd><a href="https://www.kunena.org/team" target="_blank">Kunena Team</a></dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_COPYRIGHT') ?>:</dt> <dd>© 2008 - 2016 Kunena, All rights reserved.</dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_LABEL_LICENSE') ?>:</dt> <dd>GNU General Public License</dd> <hr class="hr-condensed"> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_MOREINFO') ?>:</dt> <dd><a href="https://www.kunena.org/terms-of-use" target="_blank">https://www.kunena.org/terms-of-use</a></dd> </dl>
/** * Retrieve installed Kunena version as string. * * @return string "Kunena X.Y.Z | YYYY-MM-DD [versionname]" */ static function getVersionHTML() { return 'Kunena ' . KunenaForum::version() . ' | ' . KunenaForum::versionDate() . ' [ ' . KunenaForum::versionName() . ' ]'; }
?> </dd> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_CODENAME'); ?> :</dt> <dd><?php echo KunenaForum::versionName(); ?> </dd> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_DATE'); ?> :</dt> <dd><?php echo KunenaForum::versionDate(); ?> </dd> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_AUTHOR'); ?> :</dt> <dd><a href="http://www.kunena.org/team" target="_blank">Kunena Team</a></dd> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_COPYRIGHT'); ?> :</dt> <dd>© 2008 - 2015 Kunena, All rights reserved.</dd> <dt><?php echo JText::_('COM_KUNENA_CPANEL_LABEL_LABEL_LICENSE'); ?>
/** * Migrate custom information. * * This function gets called after all folders and tables have been copied. * * If you want to split this task into smaller chunks, * please store your custom state variables into $this->state and return false. * Returning false will force jUpgrade to call this function again, * which allows you to continue import by reading $this->state before continuing. * * @return boolean Ready (true/false) * @since 1.6.4 * @throws Exception */ protected function migrateExtensionCustom() { require_once JPATH_ADMINISTRATOR . '/components/com_kunena/api.php'; // Need to initialize application jimport('joomla.environment.uri'); $app = JFactory::getApplication('administrator'); // Get component object $component = JTable::getInstance('extension', 'JTable', array('dbo' => $this->db_new)); $component->load(array('type' => 'component', 'element' => $this->name)); // First fix all broken menu items $query = "UPDATE #__menu SET component_id={$this->db_new->quote($component->extension_id)} WHERE type = 'component' AND link LIKE '%option={$this->name}%'"; $this->db_new->setQuery($query); $this->db_new->query(); $menumap = $this->getMapList('menus'); // Get all menu items from the component (JMenu style) $query = $this->db_new->getQuery(true); $query->select('*'); $query->from('#__menu'); $query->where("component_id = {$component->extension_id}"); $query->where('client_id = 0'); $query->order('lft'); $this->db_new->setQuery($query); $menuitems = $this->db_new->loadObjectList('id'); foreach ($menuitems as &$menuitem) { // Get parent information. $parent_tree = array(); if (isset($menuitems[$menuitem->parent_id])) { $parent_tree = $menuitems[$menuitem->parent_id]->tree; } // Create tree. $parent_tree[] = $menuitem->id; $menuitem->tree = $parent_tree; // Create the query array. $url = str_replace('index.php?', '', $menuitem->link); $url = str_replace('&', '&', $url); parse_str($url, $menuitem->query); } // Update menu items foreach ($menuitems as $menuitem) { if (!isset($menuitem->query['view'])) { continue; } $update = false; switch ($menuitem->query['view']) { case 'home': // Update default menu item if (!empty($menuitem->query['defaultmenu'])) { $menuitem->query['defaultmenu'] = isset($menumap[$menuitem->query['defaultmenu']]) ? $menumap[$menuitem->query['defaultmenu']]->new : 0; $update = true; } break; } if ($update) { // Update menuitem link $query_string = array(); foreach ($menuitem->query as $k => $v) { $query_string[] = $k . '=' . $v; } $menuitem->link = 'index.php?' . implode('&', $query_string); // Save menu object $menu = JTable::getInstance('menu', 'JTable', array('dbo' => $this->db_new)); $menu->bind(get_object_vars($menuitem), array('tree', 'query')); $success = $menu->check(); if ($success) { $success = $menu->store(); } if (!$success) { echo "ERROR"; } } } // Replace Joomla! 1.5 manifest file with Joomla! 2.5 version jimport('joomla.filesystem.file'); $manifest25 = JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.j25.xml'; $manifest15 = JPATH_ADMINISTRATOR . '/components/com_kunena/kunena.xml'; if (file_exists($manifest25)) { $content = file_get_contents($manifest25); // Take care of Git install $content = preg_replace('/@kunenaversion@/', preg_replace('/-GIT/i', '', KunenaForum::version()), $content); $content = preg_replace('/@kunenaversiondate@/', KunenaForum::versionDate(), $content); $content = preg_replace('/@kunenaversionname@/', KunenaForum::versionName(), $content); JFile::write($manifest15, $content); JFile::delete($manifest25); } jimport('joomla.plugin.helper'); // Mark Kunena as discovered and install it $component->client_id = 1; $component->state = -1; $component->store(); jimport('joomla.installer.installer'); $installer = JInstaller::getInstance(); $installer->discover_install($component->extension_id); // Start Kunena installer require_once dirname(__FILE__) . '/model.php'; $kunena = new KunenaModelInstall(); // Install all plugins $kunena->stepPlugins(); // Install English language $kunena->installLanguage('en-GB', 'English'); return true; }