You've already forked joomla_test
							
							first commit
This commit is contained in:
		
							
								
								
									
										216
									
								
								components/com_k2/controllers/comments.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										216
									
								
								components/com_k2/controllers/comments.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,216 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @version		$Id: comments.php 1978 2013-05-15 19:34:16Z joomlaworks $
 | 
			
		||||
 * @package		K2
 | 
			
		||||
 * @author		JoomlaWorks http://www.joomlaworks.net
 | 
			
		||||
 * @copyright	Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 | 
			
		||||
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 | 
			
		||||
 */
 | 
			
		||||
// no direct access
 | 
			
		||||
defined('_JEXEC') or die ;
 | 
			
		||||
 | 
			
		||||
jimport('joomla.application.component.controller');
 | 
			
		||||
 | 
			
		||||
class K2ControllerComments extends K2Controller
 | 
			
		||||
{
 | 
			
		||||
    public function display($cachable = false, $urlparams = array())
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            $uri = JFactory::getURI();
 | 
			
		||||
            if (K2_JVERSION != '15')
 | 
			
		||||
            {
 | 
			
		||||
                $url = 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                $url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
 | 
			
		||||
            }
 | 
			
		||||
            $application = JFactory::getApplication();
 | 
			
		||||
            $application->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
 | 
			
		||||
        }
 | 
			
		||||
        JRequest::setVar('tmpl', 'component');
 | 
			
		||||
 | 
			
		||||
        $params = JComponentHelper::getParams('com_k2');
 | 
			
		||||
 | 
			
		||||
        $document = JFactory::getDocument();
 | 
			
		||||
 | 
			
		||||
        if (version_compare(JVERSION, '1.6.0', 'ge'))
 | 
			
		||||
        {
 | 
			
		||||
            JHtml::_('behavior.framework');
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            JHTML::_('behavior.mootools');
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // Language
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
 | 
			
		||||
        // CSS
 | 
			
		||||
        $document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.css?v=2.6.7');
 | 
			
		||||
 | 
			
		||||
        // JS
 | 
			
		||||
        K2HelperHTML::loadjQuery(true);
 | 
			
		||||
        $document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.7&sitepath='.JURI::root(true).'/');
 | 
			
		||||
 | 
			
		||||
        $this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
 | 
			
		||||
        $this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $view = $this->getView('comments', 'html');
 | 
			
		||||
        $view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'comments'.DS.'tmpl');
 | 
			
		||||
        $view->addHelperPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'helpers');
 | 
			
		||||
        $view->display();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function publish()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->publish();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function unpublish()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->unpublish();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function remove()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->remove();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function deleteUnpublished()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->deleteUnpublished();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function saveComment()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $language = JFactory::getLanguage();
 | 
			
		||||
        $language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->save();
 | 
			
		||||
        $mainframe->close();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function report()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::setVar('tmpl', 'component');
 | 
			
		||||
        $view = $this->getView('comments', 'html');
 | 
			
		||||
        $view->setLayout('report');
 | 
			
		||||
        $view->report();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function sendReport()
 | 
			
		||||
    {
 | 
			
		||||
        JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
        $params = K2HelperUtilities::getParams('com_k2');
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if (!$params->get('comments') || !$params->get('commentsReporting') || ($params->get('commentsReporting') == '2' && $user->guest))
 | 
			
		||||
        {
 | 
			
		||||
            JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('Comments', 'K2Model');
 | 
			
		||||
        $model->setState('id', JRequest::getInt('id'));
 | 
			
		||||
        $model->setState('name', JRequest::getString('name'));
 | 
			
		||||
        $model->setState('reportReason', JRequest::getString('reportReason'));
 | 
			
		||||
        if (!$model->report())
 | 
			
		||||
        {
 | 
			
		||||
            echo $model->getError();
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            echo JText::_('K2_REPORT_SUBMITTED');
 | 
			
		||||
        }
 | 
			
		||||
        $mainframe = JFactory::getApplication();
 | 
			
		||||
        $mainframe->close();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    function reportSpammer()
 | 
			
		||||
    {
 | 
			
		||||
        $mainframe = JFactory::getApplication();
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        $format = JRequest::getVar('format');
 | 
			
		||||
        $errors = array();
 | 
			
		||||
        if (K2_JVERSION != '15')
 | 
			
		||||
        {
 | 
			
		||||
            if (!$user->authorise('core.admin', 'com_k2'))
 | 
			
		||||
            {
 | 
			
		||||
                $format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            if ($user->gid < 25)
 | 
			
		||||
            {
 | 
			
		||||
                $format == 'raw' ? die(JText::_('K2_ALERTNOTAUTH')) : JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        K2Model::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'models');
 | 
			
		||||
        $model = K2Model::getInstance('User', 'K2Model');
 | 
			
		||||
        $model->setState('id', JRequest::getInt('id'));
 | 
			
		||||
        $model->reportSpammer();
 | 
			
		||||
        if ($format == 'raw')
 | 
			
		||||
        {
 | 
			
		||||
            $response = '';
 | 
			
		||||
            $messages = $mainframe->getMessageQueue();
 | 
			
		||||
            foreach ($messages as $message)
 | 
			
		||||
            {
 | 
			
		||||
                $response .= $message['message']."\n";
 | 
			
		||||
            }
 | 
			
		||||
            die($response);
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        $this->setRedirect('index.php?option=com_k2&view=comments&tmpl=component');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										49
									
								
								components/com_k2/controllers/controller.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								components/com_k2/controllers/controller.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,49 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @version     $Id: controller.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
 | 
			
		||||
 * @package     K2
 | 
			
		||||
 * @author      JoomlaWorks http://www.joomlaworks.net
 | 
			
		||||
 * @copyright   Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 | 
			
		||||
 * @license     GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
defined('_JEXEC') or die ;
 | 
			
		||||
 | 
			
		||||
jimport('joomla.application.component.controller');
 | 
			
		||||
 | 
			
		||||
if (version_compare(JVERSION, '3.0', 'ge'))
 | 
			
		||||
{
 | 
			
		||||
    class K2Controller extends JControllerLegacy
 | 
			
		||||
    {
 | 
			
		||||
        public function display($cachable = false, $urlparams = array())
 | 
			
		||||
        {
 | 
			
		||||
            parent::display($cachable, $urlparams);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
else if (version_compare(JVERSION, '2.5', 'ge'))
 | 
			
		||||
{
 | 
			
		||||
    class K2Controller extends JController
 | 
			
		||||
    {
 | 
			
		||||
        public function display($cachable = false, $urlparams = false)
 | 
			
		||||
        {
 | 
			
		||||
            parent::display($cachable, $urlparams);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
else
 | 
			
		||||
{
 | 
			
		||||
    class K2Controller extends JController
 | 
			
		||||
    {
 | 
			
		||||
        public function display($cachable = false)
 | 
			
		||||
        {
 | 
			
		||||
            parent::display($cachable);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										404
									
								
								components/com_k2/controllers/item.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										404
									
								
								components/com_k2/controllers/item.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,404 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @version		$Id: item.php 1985 2013-06-25 16:58:55Z lefteris.kavadas $
 | 
			
		||||
 * @package		K2
 | 
			
		||||
 * @author		JoomlaWorks http://www.joomlaworks.net
 | 
			
		||||
 * @copyright	Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 | 
			
		||||
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// no direct access
 | 
			
		||||
defined('_JEXEC') or die ;
 | 
			
		||||
 | 
			
		||||
jimport('joomla.application.component.controller');
 | 
			
		||||
 | 
			
		||||
class K2ControllerItem extends K2Controller
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public function display($cachable = false, $urlparams = array())
 | 
			
		||||
	{
 | 
			
		||||
		$model = $this->getModel('itemlist');
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
		$viewType = $document->getType();
 | 
			
		||||
		$view = $this->getView('item', $viewType);
 | 
			
		||||
		$view->setModel($model);
 | 
			
		||||
		JRequest::setVar('view', 'item');
 | 
			
		||||
		$user = JFactory::getUser();
 | 
			
		||||
		if ($user->guest)
 | 
			
		||||
		{
 | 
			
		||||
			$cache = true;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$cache = true;
 | 
			
		||||
			JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
 | 
			
		||||
			$row = JTable::getInstance('K2Item', 'Table');
 | 
			
		||||
			$row->load(JRequest::getInt('id'));
 | 
			
		||||
			if (K2HelperPermissions::canEditItem($row->created_by, $row->catid))
 | 
			
		||||
			{
 | 
			
		||||
				$cache = false;
 | 
			
		||||
			}
 | 
			
		||||
			$params = K2HelperUtilities::getParams('com_k2');
 | 
			
		||||
			if ($row->created_by == $user->id && $params->get('inlineCommentsModeration'))
 | 
			
		||||
			{
 | 
			
		||||
				$cache = false;
 | 
			
		||||
			}
 | 
			
		||||
			if ($row->access > 0)
 | 
			
		||||
			{
 | 
			
		||||
				$cache = false;
 | 
			
		||||
			}
 | 
			
		||||
			$category = JTable::getInstance('K2Category', 'Table');
 | 
			
		||||
			$category->load($row->catid);
 | 
			
		||||
			if ($category->access > 0)
 | 
			
		||||
			{
 | 
			
		||||
				$cache = false;
 | 
			
		||||
			}
 | 
			
		||||
			if ($params->get('comments') && $document->getType() == 'html')
 | 
			
		||||
			{
 | 
			
		||||
				$itemListModel = K2Model::getInstance('Itemlist', 'K2Model');
 | 
			
		||||
				$profile = $itemListModel->getUserProfile($user->id);
 | 
			
		||||
				$script = "
 | 
			
		||||
\$K2(document).ready(function() {
 | 
			
		||||
\$K2('#userName').val('".$view->escape($user->name)."').attr('disabled', 'disabled');
 | 
			
		||||
\$K2('#commentEmail').val('".$user->email."').attr('disabled', 'disabled');";
 | 
			
		||||
				if (is_object($profile) && $profile->url)
 | 
			
		||||
				{
 | 
			
		||||
					$script .= " \$K2('#commentURL').val('".htmlspecialchars($profile->url, ENT_QUOTES, 'UTF-8')."').attr('disabled', 'disabled');";
 | 
			
		||||
				}
 | 
			
		||||
				$script .= " });";
 | 
			
		||||
				$document->addScriptDeclaration($script);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if (K2_JVERSION != '15')
 | 
			
		||||
		{
 | 
			
		||||
			$urlparams['id'] = 'INT';
 | 
			
		||||
			$urlparams['print'] = 'INT';
 | 
			
		||||
			$urlparams['lang'] = 'CMD';
 | 
			
		||||
			$urlparams['Itemid'] = 'INT';
 | 
			
		||||
		}
 | 
			
		||||
		parent::display($cache, $urlparams);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function edit()
 | 
			
		||||
	{
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		$mainframe = JFactory::getApplication();
 | 
			
		||||
		$params = K2HelperUtilities::getParams('com_k2');
 | 
			
		||||
		$language = JFactory::getLanguage();
 | 
			
		||||
		$language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
 | 
			
		||||
		if (version_compare(JVERSION, '1.6.0', 'ge'))
 | 
			
		||||
		{
 | 
			
		||||
			JHtml::_('behavior.framework');
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			JHTML::_('behavior.mootools');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// CSS
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.css?v=2.6.7');
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.frontend.css?v=2.6.7');
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/templates/system/css/general.css');
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/templates/system/css/system.css');
 | 
			
		||||
 | 
			
		||||
		// JS
 | 
			
		||||
		K2HelperHTML::loadjQuery(true);
 | 
			
		||||
		$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.7&sitepath='.JURI::root(true).'/');
 | 
			
		||||
 | 
			
		||||
		$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
 | 
			
		||||
		$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
		$view = $this->getView('item', 'html');
 | 
			
		||||
		$view->setLayout('itemform');
 | 
			
		||||
 | 
			
		||||
		if ($params->get('category'))
 | 
			
		||||
		{
 | 
			
		||||
			JRequest::setVar('catid', $params->get('category'));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// Look for template files in component folders
 | 
			
		||||
		$view->addTemplatePath(JPATH_COMPONENT.DS.'templates');
 | 
			
		||||
		$view->addTemplatePath(JPATH_COMPONENT.DS.'templates'.DS.'default');
 | 
			
		||||
 | 
			
		||||
		// Look for overrides in template folder (K2 template structure)
 | 
			
		||||
		$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates');
 | 
			
		||||
		$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.'default');
 | 
			
		||||
 | 
			
		||||
		// Look for overrides in template folder (Joomla! template structure)
 | 
			
		||||
		$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'default');
 | 
			
		||||
		$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2');
 | 
			
		||||
 | 
			
		||||
		// Look for specific K2 theme files
 | 
			
		||||
		if ($params->get('theme'))
 | 
			
		||||
		{
 | 
			
		||||
			$view->addTemplatePath(JPATH_COMPONENT.DS.'templates'.DS.$params->get('theme'));
 | 
			
		||||
			$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.'templates'.DS.$params->get('theme'));
 | 
			
		||||
			$view->addTemplatePath(JPATH_SITE.DS.'templates'.DS.$mainframe->getTemplate().DS.'html'.DS.'com_k2'.DS.$params->get('theme'));
 | 
			
		||||
		}
 | 
			
		||||
		$view->display();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function add()
 | 
			
		||||
	{
 | 
			
		||||
		$this->edit();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function cancel()
 | 
			
		||||
	{
 | 
			
		||||
		$this->setRedirect(JURI::root(true));
 | 
			
		||||
		return false;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function save()
 | 
			
		||||
	{
 | 
			
		||||
		$mainframe = JFactory::getApplication();
 | 
			
		||||
		JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		$language = JFactory::getLanguage();
 | 
			
		||||
		$language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'item.php');
 | 
			
		||||
		$model = new K2ModelItem;
 | 
			
		||||
		$model->save(true);
 | 
			
		||||
		$mainframe->close();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function deleteAttachment()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'item.php');
 | 
			
		||||
		$model = new K2ModelItem;
 | 
			
		||||
		$model->deleteAttachment();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function tag()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'tag.php');
 | 
			
		||||
		$model = new K2ModelTag;
 | 
			
		||||
		$model->addTag();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function tags()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'tag.php');
 | 
			
		||||
		$model = new K2ModelTag;
 | 
			
		||||
		$model->tags();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function download()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'item.php');
 | 
			
		||||
		$model = new K2ModelItem;
 | 
			
		||||
		$model->download();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function extraFields()
 | 
			
		||||
	{
 | 
			
		||||
		$mainframe = JFactory::getApplication();
 | 
			
		||||
		$language = JFactory::getLanguage();
 | 
			
		||||
		$language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
		$itemID = JRequest::getInt('id', NULL);
 | 
			
		||||
 | 
			
		||||
		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
 | 
			
		||||
		$catid = JRequest::getInt('cid');
 | 
			
		||||
		$category = JTable::getInstance('K2Category', 'Table');
 | 
			
		||||
		$category->load($catid);
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'extrafield.php');
 | 
			
		||||
		$extraFieldModel = new K2ModelExtraField;
 | 
			
		||||
 | 
			
		||||
		$extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
 | 
			
		||||
 | 
			
		||||
		$output = '<table class="admintable" id="extraFields">';
 | 
			
		||||
		$counter = 0;
 | 
			
		||||
		if (count($extraFields))
 | 
			
		||||
		{
 | 
			
		||||
			foreach ($extraFields as $extraField)
 | 
			
		||||
			{
 | 
			
		||||
 | 
			
		||||
				if ($extraField->type == 'header')
 | 
			
		||||
				{
 | 
			
		||||
					$output .= '<tr><td colspan="2" ><h4 class="k2ExtraFieldHeader">'.$extraField->name.'</h4></td></tr>';
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					$output .= '<tr><td align="right" class="key"><label for="K2ExtraField_'.$extraField->id.'">'.$extraField->name.'</label></td>';
 | 
			
		||||
					$output .= '<td>'.$extraFieldModel->renderExtraField($extraField, $itemID).'</td></tr>';
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
				$counter++;
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		$output .= '</table>';
 | 
			
		||||
 | 
			
		||||
		if ($counter == 0)
 | 
			
		||||
			$output = JText::_('K2_THIS_CATEGORY_DOESNT_HAVE_ASSIGNED_EXTRA_FIELDS');
 | 
			
		||||
 | 
			
		||||
		echo $output;
 | 
			
		||||
		$mainframe->close();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function checkin()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$model->checkin();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function vote()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$model->vote();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function getVotesNum()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$model->getVotesNum();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function getVotesPercentage()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$model->getVotesPercentage();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function comment()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$model->comment();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function resetHits()
 | 
			
		||||
	{
 | 
			
		||||
		JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'item.php');
 | 
			
		||||
		$model = new K2ModelItem;
 | 
			
		||||
		$model->resetHits();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function resetRating()
 | 
			
		||||
	{
 | 
			
		||||
		JRequest::checkToken() or jexit('Invalid Token');
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'models'.DS.'item.php');
 | 
			
		||||
		$model = new K2ModelItem;
 | 
			
		||||
		$model->resetRating();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function media()
 | 
			
		||||
	{
 | 
			
		||||
		K2HelperHTML::loadjQuery(true, true);
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		$params = K2HelperUtilities::getParams('com_k2');
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
		$language = JFactory::getLanguage();
 | 
			
		||||
		$language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
		$user = JFactory::getUser();
 | 
			
		||||
		if ($user->guest)
 | 
			
		||||
		{
 | 
			
		||||
			$uri = JFactory::getURI();
 | 
			
		||||
			if (K2_JVERSION != '15')
 | 
			
		||||
			{
 | 
			
		||||
				$url = 'index.php?option=com_users&view=login&return='.base64_encode($uri->toString());
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				$url = 'index.php?option=com_user&view=login&return='.base64_encode($uri->toString());
 | 
			
		||||
			}
 | 
			
		||||
			$mainframe = JFactory::getApplication();
 | 
			
		||||
			$mainframe->redirect(JRoute::_($url, false), JText::_('K2_YOU_NEED_TO_LOGIN_FIRST'));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// CSS
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.css?v=2.6.7');
 | 
			
		||||
 | 
			
		||||
		// JS
 | 
			
		||||
		K2HelperHTML::loadjQuery(true);
 | 
			
		||||
		$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.7&sitepath='.JURI::root(true).'/');
 | 
			
		||||
		$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
 | 
			
		||||
		$view = $this->getView('media', 'html');
 | 
			
		||||
		$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'media'.DS.'tmpl');
 | 
			
		||||
		$view->setLayout('default');
 | 
			
		||||
		$view->display();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function connector()
 | 
			
		||||
	{
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		$user = JFactory::getUser();
 | 
			
		||||
		if ($user->guest)
 | 
			
		||||
		{
 | 
			
		||||
			JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		require_once (JPATH_COMPONENT_ADMINISTRATOR.DS.'controllers'.DS.'media.php');
 | 
			
		||||
		$controller = new K2ControllerMedia();
 | 
			
		||||
		$controller->connector();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function users()
 | 
			
		||||
	{
 | 
			
		||||
 | 
			
		||||
		$itemID = JRequest::getInt('itemID');
 | 
			
		||||
		JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
 | 
			
		||||
		$item = JTable::getInstance('K2Item', 'Table');
 | 
			
		||||
		$item->load($itemID);
 | 
			
		||||
		if (!K2HelperPermissions::canAddItem() && !K2HelperPermissions::canEditItem($item->created_by, $item->catid))
 | 
			
		||||
		{
 | 
			
		||||
			JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
		}
 | 
			
		||||
		$K2Permissions = K2Permissions::getInstance();
 | 
			
		||||
		if (!$K2Permissions->permissions->get('editAll'))
 | 
			
		||||
		{
 | 
			
		||||
			JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
 | 
			
		||||
		}
 | 
			
		||||
		JRequest::setVar('tmpl', 'component');
 | 
			
		||||
		$mainframe = JFactory::getApplication();
 | 
			
		||||
		$params = JComponentHelper::getParams('com_k2');
 | 
			
		||||
		$language = JFactory::getLanguage();
 | 
			
		||||
		$language->load('com_k2', JPATH_ADMINISTRATOR);
 | 
			
		||||
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
 | 
			
		||||
		if (version_compare(JVERSION, '1.6.0', 'ge'))
 | 
			
		||||
		{
 | 
			
		||||
			JHtml::_('behavior.framework');
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			JHTML::_('behavior.mootools');
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// CSS
 | 
			
		||||
		$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.css?v=2.6.7');
 | 
			
		||||
 | 
			
		||||
		// JS
 | 
			
		||||
		K2HelperHTML::loadjQuery(true);
 | 
			
		||||
		$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.js?v=2.6.7&sitepath='.JURI::root(true).'/');
 | 
			
		||||
 | 
			
		||||
		$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views');
 | 
			
		||||
		$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
 | 
			
		||||
		$view = $this->getView('users', 'html');
 | 
			
		||||
		$view->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'users'.DS.'tmpl');
 | 
			
		||||
		$view->setLayout('element');
 | 
			
		||||
		$view->display();
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										88
									
								
								components/com_k2/controllers/itemlist.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										88
									
								
								components/com_k2/controllers/itemlist.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,88 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @version		$Id: itemlist.php 1960 2013-04-11 11:46:46Z lefteris.kavadas $
 | 
			
		||||
 * @package		K2
 | 
			
		||||
 * @author		JoomlaWorks http://www.joomlaworks.net
 | 
			
		||||
 * @copyright	Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 | 
			
		||||
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// no direct access
 | 
			
		||||
defined('_JEXEC') or die ;
 | 
			
		||||
 | 
			
		||||
jimport('joomla.application.component.controller');
 | 
			
		||||
 | 
			
		||||
class K2ControllerItemlist extends K2Controller
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	public function display($cachable = false, $urlparams = array())
 | 
			
		||||
	{
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$format = JRequest::getWord('format', 'html');
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
		$viewType = $document->getType();
 | 
			
		||||
		$view = $this->getView('itemlist', $viewType);
 | 
			
		||||
		$view->setModel($model);
 | 
			
		||||
		$user = JFactory::getUser();
 | 
			
		||||
		if ($user->guest)
 | 
			
		||||
		{
 | 
			
		||||
			$cache = true;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			$cache = false;
 | 
			
		||||
		}
 | 
			
		||||
		if (K2_JVERSION != '15')
 | 
			
		||||
		{
 | 
			
		||||
			$urlparams['limit'] = 'UINT';
 | 
			
		||||
			$urlparams['limitstart'] = 'UINT';
 | 
			
		||||
			$urlparams['id'] = 'INT';
 | 
			
		||||
			$urlparams['tag'] = 'STRING';
 | 
			
		||||
			$urlparams['searchword'] = 'STRING';
 | 
			
		||||
			$urlparams['day'] = 'INT';
 | 
			
		||||
			$urlparams['year'] = 'INT';
 | 
			
		||||
			$urlparams['month'] = 'INT';
 | 
			
		||||
			$urlparams['print'] = 'INT';
 | 
			
		||||
			$urlparams['lang'] = 'CMD';
 | 
			
		||||
			$urlparams['Itemid'] = 'INT';
 | 
			
		||||
		}
 | 
			
		||||
		parent::display($cache, $urlparams);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function calendar()
 | 
			
		||||
	{
 | 
			
		||||
		require_once (JPATH_SITE.DS.'modules'.DS.'mod_k2_tools'.DS.'includes'.DS.'calendarClass.php');
 | 
			
		||||
		require_once (JPATH_SITE.DS.'modules'.DS.'mod_k2_tools'.DS.'helper.php');
 | 
			
		||||
		$mainframe = JFactory::getApplication();
 | 
			
		||||
		$month = JRequest::getInt('month');
 | 
			
		||||
		$year = JRequest::getInt('year');
 | 
			
		||||
		$months = array(JText::_('K2_JANUARY'), JText::_('K2_FEBRUARY'), JText::_('K2_MARCH'), JText::_('K2_APRIL'), JText::_('K2_MAY'), JText::_('K2_JUNE'), JText::_('K2_JULY'), JText::_('K2_AUGUST'), JText::_('K2_SEPTEMBER'), JText::_('K2_OCTOBER'), JText::_('K2_NOVEMBER'), JText::_('K2_DECEMBER'), );
 | 
			
		||||
		$days = array(JText::_('K2_SUN'), JText::_('K2_MON'), JText::_('K2_TUE'), JText::_('K2_WED'), JText::_('K2_THU'), JText::_('K2_FRI'), JText::_('K2_SAT'), );
 | 
			
		||||
		$cal = new MyCalendar;
 | 
			
		||||
		$cal->setMonthNames($months);
 | 
			
		||||
		$cal->setDayNames($days);
 | 
			
		||||
		$cal->category = JRequest::getInt('catid');
 | 
			
		||||
		$cal->setStartDay(1);
 | 
			
		||||
		if (($month) && ($year))
 | 
			
		||||
		{
 | 
			
		||||
			echo $cal->getMonthView($month, $year);
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			echo $cal->getCurrentMonthView();
 | 
			
		||||
		}
 | 
			
		||||
		$mainframe->close();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	function module()
 | 
			
		||||
	{
 | 
			
		||||
		$document = JFactory::getDocument();
 | 
			
		||||
		$view = $this->getView('itemlist', 'raw');
 | 
			
		||||
		$model = $this->getModel('itemlist');
 | 
			
		||||
		$view->setModel($model);
 | 
			
		||||
		$model = $this->getModel('item');
 | 
			
		||||
		$view->setModel($model);
 | 
			
		||||
		$view->module();
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										35
									
								
								components/com_k2/controllers/latest.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								components/com_k2/controllers/latest.php
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
<?php
 | 
			
		||||
/**
 | 
			
		||||
 * @version		$Id: latest.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
 | 
			
		||||
 * @package		K2
 | 
			
		||||
 * @author		JoomlaWorks http://www.joomlaworks.net
 | 
			
		||||
 * @copyright	Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
 | 
			
		||||
 * @license		GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 | 
			
		||||
 */
 | 
			
		||||
// no direct access
 | 
			
		||||
defined('_JEXEC') or die;
 | 
			
		||||
 | 
			
		||||
jimport('joomla.application.component.controller');
 | 
			
		||||
 | 
			
		||||
class K2ControllerLatest extends K2Controller
 | 
			
		||||
{
 | 
			
		||||
    public function display($cachable = false, $urlparams = array())
 | 
			
		||||
    {
 | 
			
		||||
        $view = $this->getView('latest', 'html');
 | 
			
		||||
        $model = $this->getModel('itemlist');
 | 
			
		||||
        $view->setModel($model);
 | 
			
		||||
        $itemModel = $this->getModel('item');
 | 
			
		||||
        $view->setModel($itemModel);
 | 
			
		||||
        $user = JFactory::getUser();
 | 
			
		||||
        if ($user->guest)
 | 
			
		||||
        {
 | 
			
		||||
            $cache = true;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            $cache = false;
 | 
			
		||||
        }
 | 
			
		||||
        parent::display($cache);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user