예제 #1
0
    public function renderSetting($text, $configName, $type = 'checkbox', $options = '')
    {
        $type = 'render' . $type;
        $config = Komento::getKonfig();
        $state = $config->get($configName, '');
        ob_start();
        ?>
		<tr>
			<td width="300" class="key">
				<span class="<?php 
        echo $configName;
        ?>
"><?php 
        echo JText::_($text);
        ?>
</span>
			</td>
			<td valign="top">
				<div class="has-tip">
					<div class="tip"><i></i><?php 
        echo JText::_($text . '_DESC');
        ?>
</div>
					<?php 
        echo $this->{$type}($configName, $state, $options);
        ?>
				</div>
			</td>
		</tr>

	<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
예제 #2
0
    public function renderSetting($text, $configName, $type = 'checkbox', $options = '')
    {
        $type = 'render' . $type;
        $config = Komento::getKonfig();
        $state = $config->get($configName, '');
        ob_start();
        ?>
		<div class="form-group">
			<label class="col-md-5 control-label">
				<span class="<?php 
        echo $configName;
        ?>
"><?php 
        echo JText::_($text);
        ?>
</span>
			</label>
			<div class="col-md-7">
				<div class="has-tip">
					<div class="tip"><i></i><?php 
        echo JText::_($text . '_DESC');
        ?>
</div>
					<?php 
        echo $this->{$type}($configName, $state, $options);
        ?>
				</div>
			</div>
		</div>

	<?php 
        $html = ob_get_contents();
        ob_end_clean();
        return $html;
    }
예제 #3
0
 public function __construct($config = array())
 {
     $document = JFactory::getDocument();
     //load dialog stylesheet in backend
     KomentoDocumentHelper::loadHeaders();
     $config = Komento::getConfig();
     $konfig = Komento::getKonfig();
     $toolbar = JToolbar::getInstance('toolbar');
     $toolbar->addButtonPath(KOMENTO_ADMIN_ROOT . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'images');
     if ($document->getType() == 'html') {
         require_once KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'configuration.php';
         $configuration = KomentoConfiguration::getInstance();
         $configuration->attach();
     }
     $version = str_ireplace('.', '', Komento::komentoVersion());
     $document->addScript(rtrim(JURI::root(), '/') . '/administrator/components/com_komento/assets/js/admin.js?' . $version);
     $document->addStyleSheet(rtrim(JURI::root(), '/') . '/administrator/components/com_komento/assets/css/reset.css?' . $version);
     $document->addStyleSheet(rtrim(JURI::root(), '/') . '/components/com_komento/assets/css/common.css?' . $version);
     $document->addStyleSheet(rtrim(JURI::root(), '/') . '/administrator/components/com_komento/assets/css/style.css?' . $version);
     // For the sake of loading the core.js in Joomla 1.6 (1.6.2 onwards)
     if (Komento::joomlaVersion() >= '1.6') {
         JHTML::_('behavior.framework');
     }
     parent::__construct($config);
 }
예제 #4
0
	public function send( $max = 5 )
	{
		$konfig		= Komento::getKonfig();

		if( $konfig->get( 'disable_mailq' ) )
		{
			return false;
		}

		$db			= Komento::getDBO();
		$config		= Komento::getConfig();

		$sql = Komento::getSql();

		$sql->select( '#__komento_mailq' )
			->column( 'id' )
			->where( 'status', 0 )
			->order( 'created' )
			->limit( $max );

		$result = $sql->loadObjectList();

		if(! empty($result))
		{
			foreach($result as $mail)
			{
				$mailq	= Komento::getTable('mailq');
				$mailq->load($mail->id);

				$sendHTML = $mailq->type == 'html' ? 1 : 0;

				$state = 0;

				if( empty( $mailq->recipient ) )
				{
					$state = 1;
				}

				//send emails.
				if( Komento::isJoomla15() )
				{
					$state = JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}
				else
				{
					$mail = JFactory::getMailer();
					$state = $mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
				}

				if( $state )
				{
					// update the status to 1 == proccessed
					$mailq->status  = 1;
					$mailq->store();
				}
			}
		}
	}
예제 #5
0
 public function init()
 {
     $obj = new stdClass();
     $obj->config = Komento::getConfig();
     $obj->konfig = Komento::getKonfig();
     $obj->my = Komento::getProfile();
     $obj->acl = Komento::getHelper('acl');
     $obj->session = JFactory::getSession();
     $this->_system = $obj;
 }
예제 #6
0
 public function display($tpl = null)
 {
     $konfig = Komento::getKonfig();
     $id = JRequest::getInt('id', 0);
     // @task: If profiles are disabled, do not show the profile here.
     if (!$konfig->get('profile_enable')) {
         $app = JFactory::getApplication();
         $app->redirect('index.php', JText::_('COM_KOMENTO_PROFILE_SYSTEM_DISABLED'));
         $app->close();
     }
     $profileModel = Komento::getModel('Profile');
     $activityModel = Komento::getModel('Activity');
     $commentsModel = Komento::getModel('Comments');
     $actionsModel = Komento::getModel('Actions');
     $count = new stdClass();
     $user = JFactory::getUser();
     if ($id === 0 && $user->id > 0) {
         $id = $user->id;
     }
     // Block non-exists profile
     if (!$profileModel->exists($id)) {
         echo JText::_('COM_KOMENTO_PROFILE_NOT_FOUND');
         return;
     }
     // TODO: Block custom profile id
     // ..
     $profile = Komento::getProfile($id);
     // $activities		= $activityModel->getUserActivities( $profile->id );
     $count->totalComments = $commentsModel->getTotalComment($profile->id);
     $count->likesReceived = $actionsModel->getLikesReceived($profile->id);
     $count->likesGiven = $actionsModel->getLikesGiven($profile->id);
     // Set Pathway
     // Check if Komento profile menu item exist before setting profile pathway
     $app = JFactory::getApplication();
     $menu = $app->getMenu();
     $item = $menu->getActive();
     if (empty($item) || $item->query['view'] != 'profile') {
         $this->setPathway(JText::_('COM_KOMENTO_PROFILE'), '');
     }
     $this->setPathway($profile->getName(), '');
     // Set browser title
     $document = JFactory::getDocument();
     $document->setTitle(JText::_('COM_KOMENTO_USER_PROFILE') . ' - ' . $profile->getName());
     // set component to com_komento
     Komento::setCurrentComponent('com_komento');
     $theme = Komento::getTheme();
     $theme->set('profile', $profile);
     $theme->set('count', $count);
     // $theme->set( 'activities', $activities );
     echo $theme->fetch('profile/profile.php');
 }
예제 #7
0
	public function __construct()
	{
		$konfig = Komento::getKonfig();
		$config = Komento::getConfig();

		// @legacy: If environment is set to production, change to static.
		$environment = $konfig->get('komento_environment');
		if ($environment=='production') {
			$environment='static';
		}

		$this->fullName		= 'Komento';
		$this->shortName	= 'kmt';
		$this->environment	= $environment;
		$this->mode			= $konfig->get('komento_mode');
		$this->version		= (string) Komento::getHelper( 'Version' )->getLocalVersion();
		$this->baseUrl		= Komento::getHelper( 'Document' )->getBaseUrl();
		$this->token		= Komento::_( 'getToken' );

		$newConfig = clone $config->toObject();
		$newKonfig = clone $konfig->toObject();

		unset( $newConfig->antispam_recaptcha_private_key );
		unset( $newConfig->antispam_recaptcha_public_key );
		unset( $newConfig->antispam_akismet_key );
		unset( $newConfig->layout_phpbb_path );
		unset( $newConfig->layout_phpbb_url );
		unset( $newKonfig->layout_phpbb_path );
		unset( $newKonfig->layout_phpbb_url );

		$this->options     = array(
			"responsive"	=> (bool) $config->get('enable_responsive'),
			"jversion"		=> Komento::joomlaVersion(),
			"spinner"		=> JURI::root() . 'media/com_komento/images/loader.gif',
			"view"			=> JRequest::getString( 'view', '' ),
			"guest"			=> Komento::getProfile()->guest ? 1 : 0,
			"config"		=> $newConfig,
			"konfig"		=> $newKonfig,
			"acl"			=> Komento::getACL(),
			"element"		=> new stdClass()
		);

		parent::__construct();
	}
예제 #8
0
 public static function loadHeaders()
 {
     if (!self::$loaded) {
         $url = KomentoDocumentHelper::getBaseUrl();
         $resourcePath = $url . '&tmpl=component&no_html=1&controller=foundry&task=getResource&kmtcomponent=' . JRequest::getCmd('option', '');
         $document = JFactory::getDocument();
         $config = Komento::getConfig();
         $konfig = Komento::getKonfig();
         $acl = Komento::getAcl();
         $guest = Komento::getProfile()->guest ? 1 : 0;
         if ($document->getType() != 'html') {
             return true;
         }
         // only temporary to load development css
         // waiting chang to finalise reset.css and comments.css
         self::addTemplateCss('common.css');
         // self::addTemplateCss( 'comments.css' );
         // Load KomentoConfiguration class
         require_once KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'configuration.php';
         // Get configuration instance
         $configuration = KomentoConfiguration::getInstance();
         // Attach configuration to headers
         $configuration->attach();
         if ($config->get('layout_inherit_kuro_css', 1) && $config->get('layout_theme') != 'wireframe') {
             $document->addStylesheet(JURI::root() . 'components/com_komento/themes/kuro/css/style.css');
         }
         // support for RTL sites
         // forcertl = 1 for dev purposes
         if (($document->direction == 'rtl' || JRequest::getInt('forcertl') == 1) && $config->get('layout_theme') != 'wireframe') {
             $document->addStylesheet(JURI::root() . 'components/com_komento/themes/kuro/css/style-rtl.css');
         }
         $document->addStylesheet(JURI::root() . 'media/foundry/3.1/styles/dialog/default.css');
         $document->addStylesheet(JURI::root() . 'media/foundry/3.1/styles/fancybox/default.css');
         self::load('style', 'css', 'themes');
         // load SH css if config is on
         if ($config->get('enable_syntax_highlighting')) {
             $shtheme = $config->get('syntaxhighlighter_theme', 'default');
             self::load('syntaxhighlighter/' . $shtheme, 'css', 'assets');
         }
         self::$loaded = true;
     }
     return self::$loaded;
 }
예제 #9
0
function KomentoBuildRoute( &$query )
{
	// Declare static variables.
	static $items;
	static $default;
	static $dashboard;
	static $profile;
	static $rss;

	// Initialise variables.
	$segments	= array();
	$konfig		= Komento::getKonfig();

	// Get the relevant menu items if not loaded.
	if (empty($items))
	{
		// Get all relevant menu items.
		$app	= JFactory::getApplication();
		$menu	= $app->getMenu();
		$items	= $menu->getItems('component', 'com_komento');

		// Build an array of serialized query strings to menu item id mappings.
		for ($i = 0, $n = count($items); $i < $n; $i++)
		{
			// Check to see if we have found the dashboard menu item.
			if (empty($dashboard) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'dashboard'))
			{
				$dashboard = $items[$i]->id;
			}

			// Check to see if we have found the profile menu item.
			if (empty($profile) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'profile'))
			{
				$profile = $items[$i]->id;
			}

			// Check to see if we have found the registration menu item.
			if (empty($feed) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'rss'))
			{
				$rss = $items[$i]->id;
			}
		}

		// Set the default menu item to use for com_users if possible.
		// Do not set default because different item uses different menu. It wouldn't make sense if RSS link is using profile menu item to generate
		// if ($dashboard)
		// {
		// 	$default = $dashboard;
		// }
		// elseif ($profile)
		// {
		// 	$default = $profile;
		// }
		// elseif ($feed)
		// {
		// 	$default = $rss;
		// }
	}

	if (!empty($query['view']))
	{
		if( !isset( $query['Itemid'] ) )
		{
			// Set menu item directly with the view as the variable string
			// Profile link should be generated with $profile item id
			// If the view is 'profile', then itemid shouhld be set with $profile
			// If the view is 'rss', then the itemid should be set with $rss
			$query['Itemid'] = ${$query['view']};
			// $query['Itemid'] = $default;
		}

		// If itemid is empty, then append the view into segments
		// If itemid is not empty, then no need to append segments as the itemid title will be in the address
		if( empty( $query['Itemid'] ) )
		{
			$segments[] = $query['view'];
		}

		switch ($query['view'])
		{
			case 'rss':
				if ($query['Itemid'] == $rss)
				{
					unset ($query['view']);
				}
				break;
			case 'profile':
				if ($query['Itemid'] == $profile)
				{
					unset ($query['view']);
				}
				// Only append the user id if not "me".
				$user = JFactory::getUser();
				if (!empty($query['id']) && ($query['id'] != $user->id)) {
					$segments[] = $query['id'];
				}
				unset ($query['id']);

				break;
			default:
			case 'dashboard':
				if (!empty($query['view'])) {
					$segments[] = $query['view'];
				}
				unset ($query['view']);
				if ($query['Itemid'] == $dashboard) {
					unset ($query['view']);
				}
				break;
		}
	}

	return $segments;
}
예제 #10
0
 /**
  * Process comments data
  **/
 public static function process($row, $admin = 0)
 {
     if (isset($row->processed) && $row->processed) {
         return $row;
     }
     Komento::setCurrentComponent($row->component);
     $config = Komento::getConfig();
     $konfig = Komento::getKonfig();
     $user = JFactory::getUser()->id;
     $commentsModel = Komento::getModel('comments');
     Komento::import('helper', 'date');
     // Duplicate created date first before lapsed time messing up the original date
     $row->unformattedDate = $row->created;
     // get number of child for each comment
     $row->childs = $commentsModel->getTotalChilds($row->id);
     // set url to proper url
     if (!empty($row->url)) {
         // Add 'http://' if not present
         $row->url = 0 === strpos($row->url, 'http') ? $row->url : 'http://' . $row->url;
     }
     // 1. Load article and article details
     $application = Komento::loadApplication($row->component)->load($row->cid);
     if ($application === false) {
         $application = Komento::getErrorApplication($row->component, $row->cid);
     }
     // set component title
     $row->componenttitle = $application->getComponentName();
     // set content title
     $row->contenttitle = $application->getContentTitle();
     // get permalink
     $row->pagelink = $application->getContentPermalink();
     $row->permalink = $row->pagelink . '#kmt-' . $row->id;
     // set parentlink
     if ($row->parent_id != 0) {
         $row->parentlink = $row->pagelink . '#kmt-' . $row->parent_id;
     }
     // to be reassign
     $row->shortlink = $row->permalink;
     // set extension object
     // use this to check if application is able to load article details
     // if row->extension is false, means error loading article details
     $row->extension = $application;
     if ($admin == 0) {
         // frontend
         $actionsModel = Komento::getModel('actions');
         $socialHelper = Komento::getHelper('social');
         // parse comments HTML
         $row->comment = self::parseComment($row->comment);
         // author's object
         $row->author = Komento::getProfile($row->created_by);
         // don't convert for guest
         if ($row->created_by != 0 && $row->created_by != $row->author->id) {
             if ($config->get('enable_orphanitem_convert')) {
                 KomentoCommentHelper::convertOrphanitem($row->id);
             }
         }
         if ($row->created_by != 0) {
             switch ($config->get('name_type')) {
                 case 'username':
                     // force username
                     $row->name = $row->author->getUsername();
                     break;
                 case 'name':
                     $row->name = $row->author->getName();
                     break;
                 case 'default':
                 default:
                     // default name to profile if name is null
                     if (empty($row->name)) {
                         $row->name = $row->author->getName();
                     }
                     break;
             }
         } else {
             if (empty($row->name)) {
                 $row->name = JText::_('COM_KOMENTO_GUEST');
             } else {
                 if ($config->get('guest_label')) {
                     $row->name = JText::_('COM_KOMENTO_GUEST') . ' - ' . $row->name;
                 }
             }
         }
         // set datetime
         if ($config->get('enable_lapsed_time')) {
             $row->created = KomentoDateHelper::getLapsedTime($row->unformattedDate);
         } else {
             $dateformat = $config->get('date_format');
             $row->created = KomentoDateHelper::toFormat(KomentoDateHelper::dateWithOffSet($row->created), $dateformat);
             // $row->created = Komento::getDate( $row->created )->toFormat( $dateformat );
         }
         // get actions likes
         $row->likes = $actionsModel->countAction('likes', $row->id);
         // get user liked
         $row->liked = $actionsModel->liked($row->id, $user);
         // get user reported
         $row->reported = $actionsModel->reported($row->id, $user);
     } else {
         // backend
         // format comments
         $row->comment = nl2br(Komento::getHelper('comment')->parseBBCode($row->comment));
         $row->created = KomentoDateHelper::dateWithOffSet($row->created);
     }
     $row->processed = true;
     return $row;
 }
예제 #11
0
 public static function log($var, $force = 0)
 {
     if ($force == 1 || Komento::getKonfig()->get('komento_environment') == 'development') {
         $debugroot = KOMENTO_HELPERS . DIRECTORY_SEPARATOR . 'debug' . DIRECTORY_SEPARATOR;
         if (JFile::exists($debugroot . 'fb.php') && JFile::exists($debugroot . 'FirePHP.class.php')) {
             include_once $debugroot . 'fb.php';
             fb($var);
         }
         if (JFile::exists($debugroot . 'chromephp.php')) {
             include_once $debugroot . 'chromephp.php';
             ChromePhp::log($var);
         }
     }
 }
예제 #12
0
	/**
	 * Push the email notification to MailQ
	 * @param	string	$type			type of notification
	 * @param	string	$recipient		recipient (subscribers,admins,author,me)
	 * @param	array	$options		various options
	 *
	 * @return nothing
	 */
	public function push( $type, $recipients, $options = array() )
	{
		if( !empty( $options['commentId'] ) )
		{
			$comment = Komento::getComment( $options['commentId'] );
			$options['comment'] = $comment;
			$options['component'] = $comment->component;
			$options['cid'] = $comment->cid;

			$options['comment'] = Komento::getHelper( 'comment' )->process( $options['comment'] );


			unset( $options['commentId'] );
		}

		if( !isset( $options['component'] ) || !isset( $options['cid'] ) )
		{
			return;
		}

		if( $type == 'new' && $options['comment']->parent_id )
		{
			$type = 'reply';
		}

		$recipients		= explode(',', $recipients);
		$rows			= array();
		$skipMe			= true;

		// process requested recipients first
		foreach ($recipients as $recipient)
		{
			$recipient		= 'get' . ucfirst( strtolower( trim($recipient) ) );

			if( !method_exists($this, $recipient) )
			{
				continue;
			}

			if( $recipient == 'getMe' )
			{
				$skipMe = false;
			}

			$result = $this->$recipient( $type, $options );

			// stacking up all the emails and details
			$rows	= $rows + $result;
		}

		// process usergroups notification based on notification type
		$rows = $rows + $this->getUsergroups( $type );

		if( $type == 'report' )
		{
			$admins = $this->getAdmins();

			foreach( $admins as $admin )
			{
				if( isset($rows[$options['comment']->email]) && $options['comment']->email === $admin->email )
				{
					$skipMe = false;
				}
			}
		}

		if( empty($rows) )
		{
			return;
		}

		// Do not send to the commentor/actor
		if( $skipMe && isset($rows[$options['comment']->email]) )
		{
			unset( $rows[$options['comment']->email] );
		}

		$lang = JFactory::getLanguage();

		// Load English first as fallback
		$konfig = Komento::getKonfig();
		if( $konfig->get( 'enable_language_fallback' ) )
		{
			$lang->load( 'com_komento', JPATH_ROOT, 'en-GB', true );
		}

		// Load site's selected language
		$lang->load( 'com_komento', JPATH_ROOT, $lang->getDefault(), true );

		// Load user's preferred language file
		$lang->load( 'com_komento', JPATH_ROOT, null, true );

		$jconfig	= JFactory::getConfig();
		$data		= $this->prepareData( $type, $options );
		$template	= $this->prepareTemplate( $type, $options );
		$subject	= $this->prepareTitle( $type, $options );

		$mailfrom	= Komento::_( 'JFactory::getConfig', 'mailfrom' );
		$fromname	= Komento::_( 'JFactory::getConfig', 'fromname' );

		$config	= Komento::getConfig();
		$sendHTML = $config->get( 'notification_sendmailinhtml' ) ? 'html' : 'text';

		// Storing notifications into mailq
		foreach ($rows as $row)
		{
			if( Komento::trigger( 'onBeforeSendNotification', array( 'component' => $options['component'], 'cid' => $options['cid'], 'recipient' => &$row ) ) === false )
			{
				continue;
			}

			if( empty( $row->email ) )
			{
				continue;
			}

			$body	= $this->getTemplateBuffer( $template, $data, array( 'recipient' => $row ) );
			$mailQ	= Komento::getTable( 'mailq' );
			$mailQ->mailfrom	= $mailfrom;
			$mailQ->fromname	= $fromname;
			$mailQ->recipient	= $row->email;
			$mailQ->subject		= $subject;
			$mailQ->body		= $body;
			$mailQ->created		= Komento::getDate()->toMySQL();
			$mailQ->type		= $sendHTML;
			$mailQ->status		= 0;
			$result = $mailQ->store();
		}
	}
if( !JFile::exists( $helper ) )
{
	return;
}

// load all dependencies
require_once( $helper );
// KomentoDocumentHelper::loadHeaders();
KomentoDocumentHelper::load( 'module', 'css', 'assets' );
JFactory::getLanguage()->load( 'com_komento' , JPATH_ROOT );

// initialise all data
$profile	= Komento::getProfile();
$config		= Komento::getConfig();
$konfig		= Komento::getKonfig();

/* $params
limit
component
sort = latest/likes
filtersticked
showtitle
showcomponent
showavatar
showauthor
lapsedtime
maxcommenttext
maxtitletext */

// todo: filter by category
예제 #14
0
	/**
	 * Displays the user's points
	 *
	 * @since	1.0
	 * @access	public
	 * @param	string
	 * @return
	 */
	public function getPoints( $id )
	{
		if( !$this->exists() )
		{
			return false;
		}

		$konfig		= Komento::getKonfig();
		$config		= Komento::getConfig();

		if( !$config->get( 'integrations_easysocial_points' ) )
		{
			return;
		}

		$theme 	= new CodeThemes();

		$user 	= Foundry::user( $id );

		$theme->set( 'user' , $user );
		$output = $theme->fetch( 'easysocial.points.php' );

		return $output;
	}
예제 #15
0
	function getActivities()
	{
		$loadMore = JRequest::getInt( 'loadMore', 0 );

		$ajax = Komento::getAjax();
		$model = Komento::getModel( 'activity' );
		$konfig = Komento::getKonfig();

		$uid = JRequest::getInt( 'uid' );
		$start = JRequest::getInt( 'start', 0 );
		$limit = JRequest::getInt( 'limit', 10 );

		$options = array(
			'start' => $start,
			'limit' => $limit
			);

		$type = array();

		if( $konfig->get( 'profile_activities_comments' ) )
		{
			$type[] = 'comment';
		}
		if( $konfig->get( 'profile_activities_replies' ) )
		{
			$type[] = 'reply';
		}
		if( $konfig->get( 'profile_activities_likes' ) )
		{
			$type[] = 'like';
		}

		$options['type'] = implode( ',', $type );

		$activities = $model->getUserActivities( $uid, $options );
		$total = '';

		if( !$loadMore )
		{
			$total = $model->getTotalUserActivities( $uid, $options );
		}
		$count = count( $activities );

		$theme = Komento::getTheme();
		$theme->set( 'items', $activities );
		$theme->set( 'total', $total );

		$html = '';

		if( $loadMore )
		{
			$html = $theme->fetch( 'profile/activities/list.php' );
		}
		else
		{
			$html = $theme->fetch( 'profile/activities.php' );
		}

		$ajax->success( $html, $count, $total);
		$ajax->send();
	}