Exemplo n.º 1
0
 /**
  * Sets up the fixture.
  */
 public static function setUpBeforeClass()
 {
     $queries[] = "TRUNCATE TABLE #__kunena_categories";
     $queries[] = "TRUNCATE TABLE #__kunena_topics";
     $queries[] = "TRUNCATE TABLE #__kunena_messages";
     $queries[] = "TRUNCATE TABLE #__kunena_messages_text";
     $queries[] = "TRUNCATE TABLE #__kunena_users";
     $queries[] = "TRUNCATE TABLE #__kunena_users_banned";
     $queries[] = "TRUNCATE TABLE #__kunena_user_categories";
     $queries[] = "TRUNCATE TABLE #__kunena_user_read";
     $queries[] = "TRUNCATE TABLE #__kunena_user_topics";
     $queries[] = "TRUNCATE TABLE #__kunena_thankyou";
     $queries[] = "TRUNCATE TABLE #__kunena_keywords";
     $queries[] = "TRUNCATE TABLE #__kunena_keywords_map";
     $queries[] = "TRUNCATE TABLE #__kunena_polls_users";
     $queries[] = "TRUNCATE TABLE #__kunena_polls_options";
     $queries[] = "TRUNCATE TABLE #__kunena_polls";
     $queries[] = "TRUNCATE TABLE #__kunena_sessions";
     $db = JFactory::getDBO();
     foreach ($queries as $query) {
         $db->setQuery($query);
         $db->query();
         KunenaError::checkDatabaseError();
     }
     KunenaFactory::loadLanguage();
     KunenaFactory::getUser(42)->save();
 }
Exemplo n.º 2
0
 public function __construct($params)
 {
     static $cssadded = false;
     require_once KUNENA_PATH_LIB . DS . 'kunena.link.class.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.image.class.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php';
     require_once KUNENA_PATH_FUNCS . DS . 'latestx.php';
     require_once JPATH_ADMINISTRATOR . '/components/com_kunena/libraries/html/parser.php';
     $this->kunena_config = KunenaFactory::getConfig();
     $this->myprofile = KunenaFactory::getUser();
     // load Kunena main language file so we can leverage langaueg strings from it
     KunenaFactory::loadLanguage();
     // Initialize session
     $session = KunenaFactory::getSession();
     $session->updateAllowedForums();
     $this->document = JFactory::getDocument();
     $kloadcss = $params->get('kunena_load_css');
     if ($cssadded == false && $kloadcss) {
         $this->document->addStyleSheet(JURI::root() . 'modules/mod_kunenalatest/tmpl/css/kunenalatest.css');
         $cssadded = true;
     }
     $this->latestdo = null;
     if ($params->get('choosemodel') != 'latest') {
         $this->latestdo = $params->get('choosemodel');
     }
     $this->params = $params;
     $this->ktemplate = KunenaFactory::getTemplate();
     $this->klistpost = modKunenaLatestHelper::getKunenaLatestList($params);
     $this->topic_ordering = modKunenaLatestHelper::getTopicsOrdering($this->myprofile, $this->kunena_config);
     require JModuleHelper::getLayoutPath('mod_kunenalatest');
 }
Exemplo n.º 3
0
	public function display() {
		static $cssadded = false;

		require_once (KUNENA_PATH_LIB . DS . 'kunena.link.class.php');
		require_once (KUNENA_PATH_LIB . DS . 'kunena.image.class.php');
		require_once (KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php');
		require_once (KUNENA_PATH_FUNCS . DS . 'latestx.php');
		require_once (JPATH_ADMINISTRATOR . '/components/com_kunena/libraries/html/parser.php');
		$this->kunena_config = KunenaFactory::getConfig ();
		$this->myprofile = KunenaFactory::getUser ();

		// load Kunena main language file so we can leverage langaueg strings from it
		KunenaFactory::loadLanguage();

		// Initialize session
		$session = KunenaFactory::getSession ();
		$session->updateAllowedForums();

		$this->latestdo = null;

		if ($this->params->get ( 'choosemodel' ) != 'latest') {
			$this->latestdo = $this->params->get ( 'choosemodel' );
		}

		$this->ktemplate = KunenaFactory::getTemplate();
		$this->klistpost = modKunenaLatestHelper::getKunenaLatestList ( $this->params );
		$this->topic_ordering = modKunenaLatestHelper::getTopicsOrdering($this->myprofile, $this->kunena_config);

		require (JModuleHelper::getLayoutPath ( 'mod_kunenalatest' ));
	}
Exemplo n.º 4
0
	/**
	 * @param object $subject
	 * @param array  $config
	 */
	public function __construct(&$subject, $config)
	{
		// Do not load if Kunena version is not supported or Kunena is offline
		if (!(class_exists('KunenaForum') && KunenaForum::isCompatible('4.0') && KunenaForum::installed()))
		{
			return;
		}

		KunenaFactory::loadLanguage('plg_kunena_uddeim.sys', 'admin');
		$path = JPATH_SITE . "/components/com_uddeim/uddeim.api.php";

		if (!is_file($path))
		{
			return;
		}

		include_once($path);

		$uddeim = new uddeIMAPI();
		if ($uddeim->version() < 1)
		{
			return;
		}

		parent::__construct($subject, $config);

		$this->loadLanguage('plg_kunena_uddeim.sys', JPATH_ADMINISTRATOR) || $this->loadLanguage('plg_kunena_uddeim.sys', KPATH_ADMIN);
	}
Exemplo n.º 5
0
 function fetchElement($name, $value, &$node, $control_name)
 {
     if (!class_exists('KunenaForum') || !KunenaForum::installed()) {
         echo '<a href="index.php?option=com_kunena">PLEASE COMPLETE KUNENA INSTALLATION</a>';
         return;
     }
     KunenaFactory::loadLanguage('com_kunena');
     $none = $node->attributes('none');
     $options = array();
     foreach ($node->children() as $option) {
         $options[] = JHTML::_('select.option', $option->attributes('value'), JText::_($option->data()));
     }
     $ctrl = $control_name . '[' . $name . ']';
     $size = $node->attributes('size');
     $class = $node->attributes('class');
     $attribs = ' ';
     if ($size) {
         $attribs .= 'size="' . $size . '"';
     }
     if ($class) {
         $attribs .= 'class="' . $class . '"';
     } else {
         $attribs .= 'class="inputbox"';
     }
     if ($node->attributes('multiple')) {
         $attribs .= ' multiple="multiple"';
         $ctrl .= '[]';
     }
     return JHTML::_('kunenaforum.categorylist', $ctrl, 0, $options, $node->attributes(), $attribs, 'value', 'text', $value);
 }
Exemplo n.º 6
0
 /**
  * @return string
  */
 protected function getInput()
 {
     if (!class_exists('KunenaForum') || !KunenaForum::installed()) {
         echo '<a href="index.php?option=com_kunena">PLEASE COMPLETE KUNENA INSTALLATION</a>';
         return '';
     }
     KunenaFactory::loadLanguage('com_kunena');
     $size = $this->element['size'];
     $class = $this->element['class'];
     $attribs = ' ';
     if ($size) {
         $attribs .= 'size="' . $size . '"';
     }
     if ($class) {
         $attribs .= 'class="' . $class . '"';
     } else {
         $attribs .= 'class="inputbox"';
     }
     if (!empty($this->element['multiple'])) {
         $attribs .= ' multiple="multiple"';
     }
     // Get the field options.
     $options = $this->getOptions();
     return JHtml::_('kunenaforum.categorylist', $this->name, 0, $options, $this->element, $attribs, 'value', 'text', $this->value);
 }
Exemplo n.º 7
0
 /**
  * Logic to load language strings for the template.
  *
  * By default language files are also loaded from the parent templates.
  *
  * @return void
  */
 public function loadLanguage()
 {
     $lang = JFactory::getLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates', 'site');
     foreach (array_reverse($this->default) as $template) {
         $file = "kunena_tmpl_{$template}";
         $lang->load($file, JPATH_SITE) || $lang->load($file, KPATH_SITE) || $lang->load($file, KPATH_SITE . "/template/{$template}");
     }
 }
Exemplo n.º 8
0
 public function loadLanguage()
 {
     // Loading language strings for the template
     $lang = JFactory::getLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates', 'site');
     foreach (array_reverse($this->default) as $template) {
         $file = 'kunena_tmpl_' . $template;
         $lang->load($file, JPATH_SITE) || $lang->load($file, KPATH_SITE) || $lang->load($file, KPATH_SITE . '/template/' . $template);
     }
 }
Exemplo n.º 9
0
 /**
  * Determines if Kunena is installed on the site.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function exists()
 {
     $file = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
     if (!JFile::exists($file)) {
         return false;
     }
     // Load Kunena's api file
     require_once $file;
     // Load Kunena's language
     KunenaFactory::loadLanguage('com_kunena.libraries', 'admin');
     return true;
 }
Exemplo n.º 10
0
 /**
  * Prepare AJAX display.
  *
  * @return void
  */
 protected function before()
 {
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     KunenaFactory::loadLanguage('com_kunena.templates');
     KunenaFactory::loadLanguage('com_kunena.models');
     KunenaFactory::loadLanguage('com_kunena.views');
     $this->me = KunenaUserHelper::getMyself();
     $this->config = KunenaConfig::getInstance();
     $this->document = JFactory::getDocument();
     $this->template = KunenaFactory::getTemplate();
     $this->template->initialize();
 }
Exemplo n.º 11
0
    public function initialize()
    {
        KunenaFactory::loadLanguage('com_kunena.tpl_blue_eagle');
        // Enable legacy mode
        KunenaTemplateLegacy::load();
        require_once JPATH_SITE . '/' . $this->getFile('initialize.php');
        $this->addStyleSheet('css/kunena.20.css');
        // Toggler language strings
        JFactory::getDocument()->addScriptDeclaration('// <![CDATA[
var kunena_toggler_close = "' . JText::_('COM_KUNENA_TOGGLER_COLLAPSE', true) . '";
var kunena_toggler_open = "' . JText::_('COM_KUNENA_TOGGLER_EXPAND', true) . '";
// ]]>');
    }
Exemplo n.º 12
0
 public function __construct($params)
 {
     require_once KPATH_SITE . '/lib/kunena.link.class.php';
     $this->params = $params;
     $this->type = $this->params->get('type', 'general');
     $this->items = (int) $this->params->get('items', 5);
     // load Kunena main language file so we can leverage langaueg strings from it
     KunenaFactory::loadLanguage();
     // Initialize session
     $session = KunenaFactory::getSession();
     $session->updateAllowedForums();
     $this->api = Kunena::getStatsAPI();
 }
Exemplo n.º 13
0
 /**
  * Display Kunena backend icon in Joomla 2.5+
  *
  * @param string $context
  */
 public function onGetIcons($context)
 {
     if (!$context == 'mod_quickicon' || !JFactory::getUser()->authorise('core.manage', 'com_kunena')) {
         return;
     }
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     if (KunenaForum::installed() && KunenaFactory::getConfig()->version_check && JFactory::getUser()->authorise('core.manage', 'com_installer')) {
         $db = JFactory::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_kunena'));
         $db->setQuery($query);
         $cparams = new JRegistry((string) $db->loadResult());
         //$cparams = JComponentHelper::getParams('com_kunena');
         $liveupdate = new JRegistry($cparams->get('liveupdate', null));
         $lastCheck = $liveupdate->get('lastcheck', 0);
         $updateInfo = json_decode(trim((string) $liveupdate->get('updatedata', ''), '"'));
         $valid = abs(time() - $lastCheck) <= 24 * 3600;
         // 24 hours
         if (!$valid) {
             // If information is not valid, update it asynchronously.
             $ajax_url = JURI::base() . 'index.php?option=com_kunena&view=liveupdate&task=ajax';
             $script = "window.addEvent('domready', function() {\n\tvar com_kunena_updatecheck_ajax_structure = {\n\t\tonSuccess: function(msg, responseXML) {\n\t\t\tvar updateInfo = JSON.decode(msg, true);\n\t\t\tif (updateInfo.html) {\n\t\t\t\tdocument.id('com_kunena_icon').getElement('img').setProperty('src',updateInfo.img);\n\t\t\t\tdocument.id('com_kunena_icon').getElement('span').set('html', updateInfo.html);\n\t\t\t\tdocument.id('com_kunena_icon').getElement('a').set('href', updateInfo.link);\n\t\t\t}\n\t\t},\n\t\turl: '{$ajax_url}'\n\t};\n\tajax_object = new Request(com_kunena_updatecheck_ajax_structure);\n\tajax_object.send();\n});";
             $document = JFactory::getDocument();
             $document->addScriptDeclaration($script);
         }
     }
     $link = 'index.php?option=com_kunena';
     if (!KunenaForum::installed()) {
         // Not fully installed
         $img = 'kunena/icons/icon-48-kupdate-alert-white.png';
         $text = JText::_('PLG_QUICKICON_KUNENA_COMPLETE_INSTALLATION');
     } elseif (empty($updateInfo->supported)) {
         // Unsupported
         $img = 'kunena/icons/kunena-logo-48-white.png';
         $text = JText::_('COM_KUNENA');
     } elseif ($updateInfo->stuck) {
         // Stuck
         $img = 'kunena/icons/icon-48-kupdate-alert-white.png';
         $text = JText::_('COM_KUNENA') . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_CRASH');
     } elseif (version_compare(KunenaForum::version(), $updateInfo->version, '<')) {
         // Has updates
         $img = 'kunena/icons/icon-48-kupdate-update-white.png';
         $text = 'Kunena ' . $updateInfo->version . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_AVAILABLE');
         $link .= '&view=liveupdate';
     } else {
         // Already in the latest release
         $img = 'kunena/icons/icon-48-kupdate-good-white.png';
         $text = JText::_('COM_KUNENA');
     }
     return array(array('link' => JRoute::_($link), 'image' => $img, 'text' => $text, 'access' => array('core.manage', 'com_kunena'), 'id' => 'com_kunena_icon'));
 }
Exemplo n.º 14
0
 function display()
 {
     KunenaForum::setup();
     KunenaFactory::loadLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates');
     $this->params->def('greeting', 1);
     $this->document = JFactory::getDocument();
     $this->me = KunenaFactory::getUser();
     $token = JUtility::getToken();
     // Load CSS only once
     if (self::$cssadded == false) {
         $this->document->addStyleSheet(JURI::root(true) . '/modules/mod_kunenalogin/tmpl/css/kunenalogin.css');
         self::$cssadded = true;
     }
     $cache = JFactory::getCache('com_kunena', 'output');
     if ($cache->start("{$this->me->userid}.{$token}", 'mod_kunenalogin')) {
         return;
     }
     $login = KunenaLogin::getInstance();
     if (!$this->me->exists()) {
         $this->type = 'login';
         $this->login = null;
         if ($login) {
             $this->lostPasswordUrl = $login->getResetURL();
             $this->lostUsernameUrl = $login->getRemindURL();
             $this->registerUrl = $login->getRegistrationURL();
             $this->remember = JPluginHelper::isEnabled('system', 'remember');
         }
     } else {
         $this->type = 'logout';
         $this->logout = null;
         $this->lastvisitDate = new KunenaDate($this->me->lastvisitDate);
         if ($login) {
             $this->logout = $login->getLogoutURL();
             $this->recentPosts = JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=topics', JText::_('MOD_KUNENALOGIN_RECENT'));
             $this->myPosts = JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=topics&layout=user&mode=default', JText::_('MOD_KUNENALOGIN_MYPOSTS'));
         }
         // Private messages
         $private = KunenaFactory::getPrivateMessaging();
         $this->privateMessages = '';
         if ($this->params->get('showmessage') && $private) {
             $count = $private->getUnreadCount($this->me->userid);
             $this->privateMessages = $private->getInboxLink($count ? JText::sprintf('COM_KUNENA_PMS_INBOX_NEW', $count) : JText::_('COM_KUNENA_PMS_INBOX'));
         }
     }
     $this->return = $this->getReturnURL();
     require JModuleHelper::getLayoutPath('mod_kunenalogin');
     $cache->end();
 }
Exemplo n.º 15
0
 /**
  * Determines if Kunena is installed on the site.
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function exists()
 {
     $file = JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
     if (!JFile::exists($file)) {
         return false;
     }
     // Load Kunena's api file
     require_once $file;
     // Load Kunena's js file
     $doc = JFactory::getDocument();
     $doc->addScript(rtrim(JURI::root(), '/') . '/media/kunena/js/default.js');
     // Load Kunena's language
     KunenaFactory::loadLanguage('com_kunena.libraries', 'admin');
     return true;
 }
Exemplo n.º 16
0
 function __construct($params)
 {
     // Include the syndicate functions only once
     require_once KUNENA_PATH . DS . 'class.kunena.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.link.class.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.image.class.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.login.php';
     require_once KUNENA_PATH_LIB . DS . 'kunena.timeformat.class.php';
     $this->params = $params;
     // load Kunena main language file so we can leverage language strings from it
     KunenaFactory::loadLanguage();
     // Initialize session
     $session = KunenaFactory::getSession();
     $session->updateAllowedForums();
 }
Exemplo n.º 17
0
 public function display($userId = null, $docType = null)
 {
     if (!KunenaHelper::exists()) {
         return;
     }
     // Load language file from Kunena
     KunenaFactory::loadLanguage('com_kunena.libraries', 'admin');
     // Load Kunena's language file
     JFactory::getLanguage()->load('com_kunena.libraries', JPATH_ADMINISTRATOR);
     // Get the current user
     $user = FD::user($userId);
     // Get the user params
     $params = $this->getUserParams($user->id);
     // Get the app params
     $appParams = $this->app->getParams();
     // Get the total items to display
     $total = (int) $params->get('total', $appParams->get('total', 5));
     // Get the posts created by the user.
     $model = $this->getModel('Posts');
     $posts = $model->getPosts($user->id, $total);
     // Get the replies
     $replies = $model->getReplies($user->id);
     // Get stats
     $stats = $model->getStats($user->id);
     // Get total replies
     $totalReplies = $model->getTotalReplies($user->id);
     // Get Kunena's template
     $kTemplate = KunenaFactory::getTemplate();
     $kUser = KunenaUserHelper::get($userId);
     $this->set('totalReplies', $totalReplies);
     $this->set('stats', $stats);
     $this->set('thanks', $kUser->thankyou);
     $this->set('totalPosts', $kUser->posts);
     $this->set('kTemplate', $kTemplate);
     $this->set('user', $user);
     $this->set('params', $params);
     $this->set('posts', $posts);
     $this->set('replies', $replies);
     echo parent::display('profile/default');
 }
Exemplo n.º 18
0
 protected function _display()
 {
     // Load language files.
     KunenaFactory::loadLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates');
     $this->params->def('greeting', 1);
     $this->document = JFactory::getDocument();
     $this->me = KunenaFactory::getUser();
     $token = JSession::getFormToken();
     $login = KunenaLogin::getInstance();
     if (!$this->me->exists()) {
         $this->type = 'login';
         $this->login = null;
         if ($login) {
             $this->lostPasswordUrl = $login->getResetURL();
             $this->lostUsernameUrl = $login->getRemindURL();
             $this->registerUrl = $login->getRegistrationURL();
             $this->remember = JPluginHelper::isEnabled('system', 'remember');
         }
     } else {
         $this->type = 'logout';
         $this->logout = null;
         $this->lastvisitDate = KunenaDate::getInstance($this->me->lastvisitDate);
         if ($login) {
             $this->logout = $login->getLogoutURL();
             $this->recentPosts = JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=topics', JText::_('MOD_KUNENALOGIN_RECENT'));
             $this->myPosts = JHtml::_('kunenaforum.link', 'index.php?option=com_kunena&view=topics&layout=user&mode=default', JText::_('MOD_KUNENALOGIN_MYPOSTS'));
         }
         // Private messages
         $private = KunenaFactory::getPrivateMessaging();
         $this->privateMessages = '';
         if ($this->params->get('showmessage') && $private) {
             $count = $private->getUnreadCount($this->me->userid);
             $this->privateMessages = $private->getInboxLink($count ? JText::sprintf('COM_KUNENA_PMS_INBOX_NEW', $count) : JText::_('COM_KUNENA_PMS_INBOX'));
         }
     }
     $this->return = $this->getReturnURL();
     require JModuleHelper::getLayoutPath('mod_kunenalogin');
 }
Exemplo n.º 19
0
	protected function setVariable($cid, $variable, $value)
	{
		KunenaFactory::loadLanguage('com_kunena', 'admin');

		if (!JSession::checkToken('post'))
		{
			$this->app->enqueueMessage(JText::_('COM_KUNENA_ERROR_TOKEN'), 'error');

			return;
		}

		if (empty ($cid))
		{
			$this->app->enqueueMessage(JText::_('COM_KUNENA_A_NO_CATEGORIES_SELECTED'), 'notice');

			return;
		}

		$count = 0;
		$name  = null;

		$categories = KunenaForumCategoryHelper::getCategories($cid);
		foreach ($categories as $category)
		{
			if ($category->get($variable) == $value)
			{
				continue;
			}

			if (!$category->authorise('admin'))
			{
				$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_NO_ADMIN', $this->escape($category->name)), 'notice');
			}
			elseif (!$category->isCheckedOut($this->me->userid))
			{
				$category->set($variable, $value);

				if ($category->save())
				{
					$count++;
					$name = $category->name;
				}
				else
				{
					$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_SAVE_FAILED', $category->id, $this->escape($category->getError())), 'notice');
				}
			}
			else
			{
				$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_X_CHECKED_OUT', $this->escape($category->name)), 'notice');
			}
		}

		if ($count == 1 && $name)
		{
			$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORY_SAVED', $this->escape($name)));
		}
		if ($count > 1)
		{
			$this->app->enqueueMessage(JText::sprintf('COM_KUNENA_A_CATEGORIES_SAVED', $count));
		}
	}
Exemplo n.º 20
0
// We need also these:
jimport('joomla.plugin.helper');

$_SERVER['HTTP_HOST'] = 'http://localhost';
$_SERVER['REQUEST_URI'] = '/index.php';
//$_SERVER['REMOTE_ADDR'] = '127.0.0.1';

$app = JFactory::getApplication('site');

if (!defined('KPATH_TESTS'))
{
	define('KPATH_TESTS', dirname(__FILE__));
}

// Exclude all of the tests from code coverage reports
if (class_exists('PHP_CodeCoverage_Filter')) {
	PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist(JPATH_BASE . '/tests');
} else {
	PHPUnit_Util_Filter::addDirectoryToFilter(JPATH_BASE . '/tests');
}

// Set error handling.
JError::setErrorHandling(E_NOTICE, 'ignore');
JError::setErrorHandling(E_WARNING, 'ignore');
JError::setErrorHandling(E_ERROR, 'ignore');

// Load Kunena API
require_once JPATH_ADMINISTRATOR . '/components/com_kunena/api.php';
KunenaFactory::loadLanguage();
Exemplo n.º 21
0
 protected function _display()
 {
     // Load language files.
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     KunenaFactory::loadLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates');
     // Convert module parameters into topics view parameters
     $categories = $this->params->get('category_id', 0);
     $categories = is_array($categories) ? implode(',', $categories) : $categories;
     $this->params->set('limitstart', 0);
     $this->params->set('limit', $this->params->get('nbpost', 5));
     $this->params->set('topics_categories', $categories);
     $this->params->set('topics_catselection', $this->params->get('sh_category_id_in', 1));
     $this->params->set('topics_time', $this->params->get('show_list_time', 168));
     $userid = 0;
     switch ($this->params->get('choosemodel')) {
         case 'latestposts':
             $layout = 'posts';
             $mode = 'recent';
             break;
         case 'noreplies':
             $layout = 'default';
             $mode = 'noreplies';
             break;
         case 'catsubscriptions':
             // TODO
             break;
         case 'subscriptions':
             $userid = -1;
             $layout = 'user';
             $mode = 'subscriptions';
             break;
         case 'favorites':
             $userid = -1;
             $layout = 'user';
             $mode = 'favorites';
             break;
         case 'owntopics':
             $layout = 'user';
             $mode = 'posted';
             break;
         case 'deleted':
             $layout = 'posts';
             $mode = 'deleted';
             break;
         case 'saidthankyouposts':
             $userid = -1;
             $layout = 'posts';
             $mode = 'mythanks';
             break;
         case 'gotthankyouposts':
             $userid = -1;
             $layout = 'posts';
             $mode = 'thankyou';
             break;
         case 'userposts':
             $userid = -1;
             $layout = 'posts';
             $mode = 'recent';
             break;
         case 'latesttopics':
         default:
             $layout = 'default';
             $mode = 'recent';
     }
     $this->params->set('layout', $layout);
     $this->params->set('mode', $mode);
     $this->params->set('userid', $userid);
     $this->params->set('moreuri', "index.php?option=com_kunena&view=topics&layout={$layout}&mode={$mode}" . ($userid ? "&userid={$userid}" : ''));
     // Set template path to module
     $this->params->set('templatepath', dirname(JModuleHelper::getLayoutPath('mod_kunenalatest')));
     // Display topics view
     KunenaForum::display('topics', $layout, null, $this->params);
 }
Exemplo n.º 22
0
	function displayBreadcrumb($tpl = null)
	{
		if ($this->offline)
		{
			return;
		}

		$catid  = JRequest::getInt('catid', 0);
		$id     = JRequest::getInt('id', 0);
		$view   = JRequest::getWord('view', 'default');
		$layout = JRequest::getWord('layout', 'default');

		$this->breadcrumb = $pathway = $this->app->getPathway();
		$active           = $this->app->getMenu()->getActive();

		if (empty($this->pathway))
		{
			KunenaFactory::loadLanguage('com_kunena.sys', 'admin');

			if ($catid)
			{
				$parents         = KunenaForumCategoryHelper::getParents($catid);
				$parents[$catid] = KunenaForumCategoryHelper::get($catid);

				// Remove categories from pathway if menu item contains/excludes them
				if (!empty($active->query['catid']) && isset($parents[$active->query['catid']]))
				{
					$curcatid = $active->query['catid'];
					while (($item = array_shift($parents)) !== null)
					{
						if ($item->id == $curcatid)
						{
							break;
						}
					}
				}

				foreach ($parents as $parent)
				{
					$pathway->addItem($this->escape($parent->name), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$parent->id}"));
				}
			}

			if ($view == 'announcement')
			{
				$pathway->addItem(JText::_('COM_KUNENA_ANN_ANNOUNCEMENTS'), KunenaRoute::normalize("index.php?option=com_kunena&view=announcement&layout=list"));
			}
			elseif ($id)
			{
				$topic = KunenaForumTopicHelper::get($id);
				$pathway->addItem($this->escape($topic->subject), KunenaRoute::normalize("index.php?option=com_kunena&view=category&catid={$catid}&id={$topic->id}"));
			}

			if ($view == 'topic')
			{
				$active_layout = (!empty($active->query['view']) && $active->query['view'] == 'topic' && !empty($active->query['layout'])) ? $active->query['layout'] : '';
				switch ($layout)
				{
					case 'create':
						if ($active_layout != 'create')
						{
							$pathway->addItem($this->escape(JText::_('COM_KUNENA_NEW'), KunenaRoute::normalize()));
						}
						break;
					case 'reply':
						if ($active_layout != 'reply')
						{
							$pathway->addItem($this->escape(JText::_('COM_KUNENA_BUTTON_MESSAGE_REPLY'), KunenaRoute::normalize()));
						}
						break;
					case 'edit':
						if ($active_layout != 'edit')
						{
							$pathway->addItem($this->escape(JText::_('COM_KUNENA_EDIT'), KunenaRoute::normalize()));
						}
						break;
				}
			}
		}
		$this->pathway = array();

		foreach ($pathway->getPathway() as $pitem)
		{
			$item       = new StdClass();
			$item->name = $this->escape($pitem->name);
			$item->link = KunenaRoute::_($pitem->link);

			if ($item->link)
			{
				$this->pathway[] = $item;
			}
		}

		$result = $this->loadTemplateFile($tpl, array('pathway' => $this->pathway));

		if (JError::isError($result))
		{
			return $result;
		}

		echo $result;
	}
Exemplo n.º 23
0
	function plgContentKunenaDiscuss(&$subject, $params) {

		$this->_app = JFactory::getApplication ( 'site' );

		// If plugin is not enabled in current scope, do not register it
		if (! $this->enabled ())
			return null;

		$jversion = new JVersion();
		if ($jversion->RELEASE != '1.5') {
			$this->basepath = 'plugins/content/kunenadiscuss';
		} else {
			$this->basepath = 'plugins/content';
		}

		// Load language files
		$this->loadLanguage ( 'plg_content_kunenadiscuss', JPATH_ADMINISTRATOR );

		// Kunena detection and version check
		$minKunenaVersion = '1.6.3';
		if (!class_exists('Kunena') || Kunena::versionBuild() < 4344) {
			$this->_app->enqueueMessage( JText::sprintf ( 'PLG_KUNENADISCUSS_DEPENDENCY_FAIL', $minKunenaVersion ) );
			return null;
		}
		// Kunena online check
		if (!Kunena::enabled()) {
			return null;
		}
		// Initialize session
		$session = KunenaFactory::getSession ();
		$session->updateAllowedForums();

		// Initialize plugin
		parent::__construct ( $subject, $params );

		// Initialize variables
		$this->_db = JFactory::getDbo ();
		$this->_my = JFactory::getUser ();

		require_once (KUNENA_PATH . DS . 'class.kunena.php');

		$this->config = KunenaFactory::getConfig ();

		// load Kunena main language file so we can leverage language strings from it
		KunenaFactory::loadLanguage();

		// Create plugin table if doesn't exist
		$query = "SHOW TABLES LIKE '{$this->_db->getPrefix()}kunenadiscuss'";
		$this->_db->setQuery ( $query );
		if (!$this->_db->loadResult ()) {
			CKunenaTools::checkDatabaseError ();
			$query = "CREATE TABLE IF NOT EXISTS `#__kunenadiscuss`
					(`content_id` int(11) NOT NULL default '0',
					 `thread_id` int(11) NOT NULL default '0',
					 PRIMARY KEY  (`content_id`)
					 )";
			$this->_db->setQuery ( $query );
			$this->_db->query ();
			CKunenaTools::checkDatabaseError ();
			$this->debug ( "Created #__kunenadiscuss cross reference table." );

			// Migrate data from old FireBoard discussbot if it exists
			$query = "SHOW TABLES LIKE '{$this->_db->getPrefix()}fb_discussbot'";
			$this->_db->setQuery ( $query );
			if ($this->_db->loadResult ()) {
				$query = "REPLACE INTO `#__kunenadiscuss`
					SELECT `content_id` , `thread_id`
					FROM `#__fb_discussbot`";
				$this->_db->setQuery ( $query );
				$this->_db->query ();
				CKunenaTools::checkDatabaseError ();
				$this->debug ( "Migrated old data." );
			}
		}

		$this->debug ( "Constructor called in " . $this->_app->scope );
	}
Exemplo n.º 24
0
 function displayEdit()
 {
     $this->category = $this->get('AdminCategory');
     if ($this->category === false) {
         $this->setError(JText::_('COM_KUNENA_NO_ACCESS'));
         $this->displayNoAccess($this->getErrors());
         return;
     }
     KunenaFactory::loadLanguage('com_kunena', 'admin');
     $this->options = $this->get('AdminOptions');
     $this->moderators = $this->get('AdminModerators');
     $header = $this->category->exists() ? JText::sprintf('COM_KUNENA_CATEGORY_EDIT', $this->escape($this->category->name)) : JText::_('COM_KUNENA_CATEGORY_NEW');
     $this->header = $header;
     $this->setTitle($header);
     $this->display();
 }
Exemplo n.º 25
0
 /**
  * Method to display a view.
  *
  * @param   boolean    $cachable   If true, the view output will be cached
  * @param   array|bool $urlparams  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  *
  * @return  JControllerLegacy  A JControllerLegacy object to support chaining.
  */
 public function display($cachable = false, $urlparams = false)
 {
     KUNENA_PROFILER ? $this->profiler->mark('beforeDisplay') : null;
     KUNENA_PROFILER ? KunenaProfiler::instance()->start('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     // Get the document object.
     $document = JFactory::getDocument();
     // Set the default view name and format from the Request.
     $vName = JRequest::getWord('view', $this->app->isAdmin() ? 'cpanel' : 'home');
     $lName = JRequest::getWord('layout', 'default');
     $vFormat = $document->getType();
     if ($this->app->isAdmin()) {
         // Load admin language files
         KunenaFactory::loadLanguage('com_kunena.install', 'admin');
         KunenaFactory::loadLanguage('com_kunena.views', 'admin');
         // Load last to get deprecated language files to work
         KunenaFactory::loadLanguage('com_kunena', 'admin');
         // Version warning
         require_once KPATH_ADMIN . '/install/version.php';
         $version = new KunenaVersion();
         $version_warning = $version->getVersionWarning();
         if (!empty($version_warning)) {
             $this->app->enqueueMessage($version_warning, 'notice');
         }
     } else {
         // Load site language files
         KunenaFactory::loadLanguage('com_kunena.views');
         KunenaFactory::loadLanguage('com_kunena.templates');
         // Load last to get deprecated language files to work
         KunenaFactory::loadLanguage('com_kunena');
         $menu = $this->app->getMenu();
         $active = $menu->getActive();
         // Check if menu item was correctly routed
         $routed = $menu->getItem(KunenaRoute::getItemID());
         if ($vFormat == 'html' && !empty($routed->id) && (empty($active->id) || $active->id != $routed->id)) {
             // Routing has been changed, redirect
             // FIXME: check possible redirect loops!
             $route = KunenaRoute::_(null, false);
             $activeId = !empty($active->id) ? $active->id : 0;
             JLog::add("Redirect from " . JUri::getInstance()->toString(array('path', 'query')) . " ({$activeId}) to {$route} ({$routed->id})", JLog::DEBUG, 'kunena');
             $this->app->redirect($route);
         }
         // Joomla 2.5+ multi-language support
         /* // FIXME:
         			if (isset($active->language) && $active->language != '*') {
         				$language = JFactory::getDocument()->getLanguage();
         				if (strtolower($active->language) != strtolower($language)) {
         					$route = KunenaRoute::_(null, false);
         					JLog::add("Language redirect from ".JUri::getInstance()->toString(array('path', 'query'))." to {$route}", JLog::DEBUG, 'kunena');
         					$this->redirect ($route);
         				}
         			}
         			*/
     }
     $view = $this->getView($vName, $vFormat);
     if ($view) {
         if ($this->app->isSite() && $vFormat == 'html') {
             $common = $this->getView('common', $vFormat);
             $model = $this->getModel('common');
             $common->setModel($model, true);
             $view->ktemplate = $common->ktemplate = KunenaFactory::getTemplate();
             $view->common = $common;
         }
         // Set the view layout.
         $view->setLayout($lName);
         // Get the appropriate model for the view.
         $model = $this->getModel($vName);
         // Push the model into the view (as default).
         $view->setModel($model, true);
         // Push document object into the view.
         $view->document = $document;
         // Render the view.
         if ($vFormat == 'html') {
             JPluginHelper::importPlugin('kunena');
             $dispatcher = JDispatcher::getInstance();
             $dispatcher->trigger('onKunenaDisplay', array('start', $view));
             $view->displayAll();
             $dispatcher->trigger('onKunenaDisplay', array('end', $view));
         } else {
             $view->displayLayout();
         }
     }
     KUNENA_PROFILER ? KunenaProfiler::instance()->stop('function ' . __CLASS__ . '::' . __FUNCTION__ . '()') : null;
     return $this;
 }
Exemplo n.º 26
0
	public function display($viewName, $layout='default', $template=null, $params = array()) {
		$viewName = preg_replace( '/[^A-Z0-9_]/i', '', $viewName );
		$view = "KunenaView{$viewName}";
		$model = "KunenaModel{$viewName}";

		// load Kunena main language file so we can leverage language strings from it
		KunenaFactory::loadLanguage();

		require_once KPATH_SITE . '/views/common/view.html.php';
		require_once KPATH_SITE . '/models/common.php';

		if ( !class_exists( $view ) ) {
			$vpath = KPATH_SITE . '/views/'.$viewName.'/view.html.php';
			if (!is_file($vpath)) return;
			require_once $vpath;
		}
		if ( $viewName != 'common' && !class_exists( $model ) ) {
			$mpath = KPATH_SITE . '/models/'.$viewName.'.php';
			if (!is_file($mpath)) return;
			require_once $mpath;
		}

		$view = new $view ( array ('base_path' => KPATH_SITE ) );
		if (!($params instanceof JParameter)) {
			$parameters = new JParameter('');
			$parameters->bind($params);
		} else {
			$parameters = $params;
		}
		$parameters->set('layout', $layout);
		// Push the model into the view (as default).
		$model = new $model ();
		$model->initialize($parameters);
		$view->setModel ( $model, true );

		// Add template path
		$ktemplate = KunenaFactory::getTemplate();
		$templatepath = KPATH_SITE."/{$ktemplate->getPath()}/html/";
		$view->addTemplatePath($templatepath.$viewName);
		if ($parameters->get('templatepath')) $view->addTemplatePath($parameters->get('templatepath'));

		if ($viewName != 'common') {
			$view->common = new KunenaViewCommon ( array ('base_path' => KPATH_SITE ) );
			$view->common->addTemplatePath($templatepath.'common');
		}
		// Push document object into the view.
		$view->assignRef ( 'document', JFactory::getDocument() );

		// Render the view.
		$view->displayLayout ($layout, $template);
	}
Exemplo n.º 27
0
 /**
  * Before display content method.
  *
  * Method is called by the view and the results are imploded and displayed in a placeholder.
  *
  * @param   string  $context    The context for the content passed to the plugin.
  * @param   object  $article    The content object.  Note $article->text is also available
  * @param   object  $params     The content params
  * @param   integer $limitstart The 'page' number
  *
  * @return  string
  */
 public function onContentBeforeDisplay($context, &$article, &$params, $limitstart = 0)
 {
     static $loaded = false;
     // Initialize plug-in during the first run.
     if (!$loaded) {
         $loaded = true;
         // Load language files and setup Kunena libraries.
         $this->loadLanguage();
         KunenaForum::setup();
         KunenaFactory::loadLanguage();
         // Create Kunena Discuss table if it doesn't exist.
         $this->createTable();
     }
     // Make sure that event gets only called once.
     if (self::$inevent) {
         return '';
     }
     self::$inevent = true;
     $this->prepare($context, $article, $params);
     self::$inevent = false;
     return '';
 }
Exemplo n.º 28
0
 /**
  * Displays Kunena Forum view/layout inside your extension.
  *
  * <code>
  *
  * </code>
  *
  * @param   string $viewName Name of the view.
  * @param   string $layout Name of the layout.
  * @param   null|string $template Name of the template file.
  * @param   array|JRegistry $params Extra parameters to control the model.
  */
 public static function display($viewName, $layout = 'default', $template = null, $params = array())
 {
     // Filter input
     $viewName = preg_replace('/[^A-Z0-9_]/i', '', $viewName);
     $layout = preg_replace('/[^A-Z0-9_]/i', '', $layout);
     $template = preg_replace('/[^A-Z0-9_]/i', '', $template);
     $template = $template ? $template : null;
     $view = "KunenaView{$viewName}";
     $model = "KunenaModel{$viewName}";
     // Load potentially needed language files
     KunenaFactory::loadLanguage();
     KunenaFactory::loadLanguage('com_kunena.model');
     KunenaFactory::loadLanguage('com_kunena.view');
     require_once KPATH_SITE . '/views/common/view.html.php';
     require_once KPATH_SITE . '/models/common.php';
     if (!class_exists($view)) {
         $vpath = KPATH_SITE . '/views/' . $viewName . '/view.html.php';
         if (!is_file($vpath)) {
             return;
         }
         require_once $vpath;
     }
     if ($viewName != 'common' && !class_exists($model)) {
         $mpath = KPATH_SITE . '/models/' . $viewName . '.php';
         if (!is_file($mpath)) {
             return;
         }
         require_once $mpath;
     }
     $view = new $view(array('base_path' => KPATH_SITE));
     // @var KunenaView $view
     if ($params instanceof JRegistry) {
         // Do nothing
     } else {
         $params = new JRegistry($params);
     }
     $params->set('layout', $layout);
     // Push the model into the view (as default).
     $model = new $model();
     // @var KunenaModel $model
     $model->initialize($params);
     $view->setModel($model, true);
     // Add template path
     if ($params->get('templatepath')) {
         $view->addTemplatePath($params->get('templatepath'));
     }
     if ($viewName != 'common') {
         $view->common = new KunenaViewCommon(array('base_path' => KPATH_SITE));
         $view->common->embedded = true;
     }
     // Flag view as being embedded
     $view->embedded = true;
     // Flag view as being teaser
     $view->teaser = $params->get('teaser', 0);
     // Render the view.
     $view->displayLayout($layout, $template);
 }
Exemplo n.º 29
0
 public function loadLanguage()
 {
     // Loading language strings for the template
     $lang = JFactory::getLanguage();
     KunenaFactory::loadLanguage('com_kunena.templates', 'site');
     foreach (array_reverse($this->default) as $template) {
         // Try to load language file for legacy templates
         if ($lang->load('com_kunena.tpl_' . $template, JPATH_SITE) || $lang->load('com_kunena.tpl_' . $template, KPATH_SITE) || $lang->load('com_kunena.tpl_' . $template, KPATH_SITE . '/template/' . $template)) {
             $lang->load('com_kunena.tpl_' . $template, JPATH_SITE) || $lang->load('com_kunena.tpl_' . $template, KPATH_SITE) || $lang->load('com_kunena.tpl_' . $template, KPATH_SITE . '/template/' . $template);
         } else {
             $lang->load('kunena_tmpl_' . $template, JPATH_SITE) || $lang->load('kunena_tmpl_' . $template, KPATH_SITE) || $lang->load('kunena_tmpl_' . $template, KPATH_SITE . '/template/' . $template);
         }
     }
 }
Exemplo n.º 30
0
 /**
  * Display Kunena backend icon in Joomla 2.5+
  *
  * @param string $context
  *
  * @return array|null
  */
 public function onGetIcons($context)
 {
     if ($context != $this->params->get('context', 'mod_quickicon') || !JFactory::getUser()->authorise('core.manage', 'com_kunena')) {
         return null;
     }
     KunenaFactory::loadLanguage('com_kunena.sys', 'admin');
     $updateInfo = null;
     if (KunenaForum::installed() && JFactory::getUser()->authorise('core.manage', 'com_installer')) {
         $updateSite = 'http://update.kunena.org/%';
         $db = JFactory::getDbo();
         $query = $db->getQuery(true)->select('*')->from($db->qn('#__updates'))->where($db->qn('extension_id') . ' > 0')->where($db->qn('detailsurl') . ' LIKE ' . $db->q($updateSite));
         $db->setQuery($query);
         $list = (array) $db->loadObjectList();
         if ($list) {
             $updateInfo = new stdClass();
             $updateInfo->addons = 0;
             $updateInfo->version = 0;
             foreach ($list as $item) {
                 if ($item->element == 'pkg_kunena') {
                     $updateInfo->version = $item->version;
                 } else {
                     $updateInfo->addons++;
                 }
             }
         } else {
             $query = $db->getQuery(true)->select('update_site_id')->from($db->qn('#__update_sites'))->where($db->qn('enabled') . ' = 0')->where($db->qn('location') . ' LIKE ' . $db->q($updateSite));
             $db->setQuery($query);
             $updateInfo = !$db->loadResult();
         }
     }
     $link = 'index.php?option=com_kunena';
     $useIcons = version_compare(JVERSION, '3.0', '>');
     if (!KunenaForum::installed()) {
         // Not fully installed
         $img = $useIcons ? 'warning' : 'kunena/icons/icon-48-kupdate-alert-white.png';
         $icon = 'kunena/icons/icon-48-kupdate-alert-white.png';
         $text = JText::_('PLG_QUICKICON_KUNENA_COMPLETE_INSTALLATION');
     } elseif ($updateInfo === null) {
         // Unsupported
         $img = $useIcons ? 'remove' : 'kunena/icons/kunena-logo-48-white.png';
         $icon = 'kunena/icons/kunena-logo-48-white.png';
         $text = JText::_('COM_KUNENA');
     } elseif ($updateInfo === false) {
         // Disabled
         $img = $useIcons ? 'minus' : 'kunena/icons/icon-48-kupdate-alert-white.png';
         $icon = 'kunena/icons/icon-48-kupdate-alert-white.png';
         $text = JText::_('COM_KUNENA') . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_DISABLED');
     } elseif (!empty($updateInfo->version) && version_compare(KunenaForum::version(), $updateInfo->version, '<')) {
         // Has updates
         $img = $useIcons ? 'download' : 'kunena/icons/icon-48-kupdate-update-white.png';
         $icon = 'kunena/icons/icon-48-kupdate-update-white.png';
         $text = 'Kunena ' . $updateInfo->version . '<br />' . JText::_('PLG_QUICKICON_KUNENA_UPDATE_NOW');
         $link = 'index.php?option=com_installer&view=update&filter_search=kunena';
     } elseif (!empty($updateInfo->addons)) {
         // Has updated add-ons
         $img = $useIcons ? 'download' : 'kunena/icons/icon-48-kupdate-update-white.png';
         $icon = 'kunena/icons/icon-48-kupdate-update-white.png';
         $text = JText::_('COM_KUNENA') . '<br />' . JText::sprintf('PLG_QUICKICON_KUNENA_UPDATE_ADDONS', $updateInfo->addons);
         $link = 'index.php?option=com_installer&view=update&filter_search=kunena';
     } else {
         // Already in the latest release
         $img = $useIcons ? 'comments' : 'kunena/icons/icon-48-kupdate-good-white.png';
         $icon = 'kunena/icons/icon-48-kupdate-good-white.png';
         $text = JText::_('COM_KUNENA');
     }
     // Use one line in J!3.0.
     if (version_compare(JVERSION, '3.0', '>')) {
         $text = preg_replace('|<br />|', ' - ', $text);
     }
     return array(array('link' => JRoute::_($link), 'image' => $img, 'text' => $text, 'icon' => $icon, 'access' => array('core.manage', 'com_kunena'), 'id' => 'com_kunena_icon'));
 }