Exemple #1
0
	function mark()
	{
		$type		= JRequest::getVar('type');
		$id			= JRequest::getInt('id');
		$userId		= JFactory::getUser()->id;

		$ajax		= Komento::getHelper('Ajax');
		$commentObj	= Komento::getComment( $id );

		$commentObj->load( $id );
		$commentObj->flag = $type;
		$commentObj->flag_by = $userId;

		if( !$commentObj->save() )
		{
			$ajax->fail();
			$ajax->send();
		}

		$ajax->success();
		$ajax->send();
	}
Exemple #2
0
	public function download()
	{
		$id	= JRequest::getInt( 'id' );

		// need to get component to check acl because controller link component is com_komento

		$filetable = Komento::getTable( 'uploads' );
		if( !$filetable->load( $id ) )
		{
			echo JText::_( 'COM_KOMENTO_ATTACHMENT_INVALID_ID' );
			exit;
		}

		$comment = Komento::getComment( $filetable->uid );

		$profile = Komento::getProfile();
		if( !$profile->allow( 'download_attachment', $comment->component ) )
		{
			echo JText::_( 'COM_KOMENTO_ATTACHMENT_NO_PERMISSION' );
			exit;
		}

		return $filetable->download();
	}
Exemple #3
0
	public function addJomSocialActivityLike( $comment, $uid )
	{
		if( !is_object( $comment ) )
		{
			$comment = Komento::getComment( $comment );
		}

		$comment = Komento::getHelper( 'comment' )->process( $comment );
		$comment->comment = JString::substr( strip_tags( $comment->comment ), 0 , Komento::getConfig()->get( 'jomsocial_comment_length' ) );

		$options = array(
			'title'			=> JText::sprintf('COM_KOMENTO_JOMSOCIAL_ACTIVITY_LIKED_COMMENT', $comment->permalink, $comment->pagelink, $comment->extension->getContentTitle() ),
			'content'		=> $comment->comment,
			'cmd'			=> 'komento.comment.like',
			// 'app'			=> $comment->component,
			// due to js 2.8
			'app'			=> 'komento',
			'cid'			=> $comment->cid,
			'actor'			=> $uid,
			'comment_id'	=> $comment->id,
			'comment_type'	=> 'com_komento.comments',
			'like_id'		=> $comment->id,
			'like_type'		=> 'com_komento.likes'
		);
		self::addJomSocialActivity( $options );
	}
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */
defined('_JEXEC') or die('Restricted access');
if ($system->config->get('enable_reply_reference') && $row->parent_id != 0) {
    ?>
<span class="inReplyTo kmt-inreplyto">
	<?php 
    if ($system->config->get('enable_threaded')) {
        $name = '';
        $parent = Komento::getComment($row->parent_id, true);
        echo JText::sprintf('COM_KOMENTO_COMMENT_IN_REPLY_TO_NAME', $row->parentlink, $parent->name);
        // echo JText::sprintf( 'COM_KOMENTO_COMMENT_IN_REPLY_TO_NAME', $row->parentlink, $parent->name );
    } else {
        // non threaded no need to show name, because will have parent comment as a popup when hover over comment id
        echo JText::sprintf('COM_KOMENTO_COMMENT_IN_REPLY_TO', $row->parentlink, $row->parent_id);
        // echo JText::sprintf( 'COM_KOMENTO_COMMENT_IN_REPLY_TO', $row->parentlink, $row->parent_id );
    }
    $parent = '';
    if ($system->konfig->get('parent_preload')) {
        $parent = Komento::getComment($row->parent_id);
    }
    $parentTheme = Komento::getTheme(true);
    $parentTheme->set('parent', $parent);
    echo $parentTheme->fetch('comment/item/parent.php');
    ?>
</span>
<?php 
}
Exemple #5
0
* Komento is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Restricted access');
?>

<div class="kmt-mod mod_komento_activities kmt-mod-activities<?php 
echo $params->get('moduleclass_sfx');
?>
">
	<?php 
foreach ($activities as $activity) {
    $activity->comment = Komento::getComment($activity->comment_id, $process = true);
    $activity->comment->comment = strip_tags($activity->comment->comment);
    // trim comment length
    if (JString::strlen($activity->comment->comment) > $params->get('maxcommentlength')) {
        $activity->comment->comment = JString::substr($activity->comment->comment, 0, $params->get('maxcommentlength')) . '...';
    }
    // trim title length
    if (JString::strlen($activity->comment->contenttitle) > $params->get('maxtitlelength')) {
        $activity->comment->contenttitle = JString::substr($activity->comment->contenttitle, 0, $params->get('maxtitlelength')) . '...';
    }
    $profile = Komento::getProfile($activity->uid);
    $config = Komento::getConfig($activity->comment->component);
    if ($activity->uid != 0 && $profile->id != $activity->uid && $config->get('enable_orphanitem_convert')) {
        $table = Komento::getTable('activities');
        $table->load($activity->id);
        $table->uid = $config->get('orphanitem_ownership');
Exemple #6
0
	public static function allow( $type, $comment = '', $component = '', $cid = '' )
	{
		// for complicated acl situations
		// $type = ['edit', 'delete', 'publish', 'unpublish', 'stick', 'delete_attachment'];

		if( !empty( $comment ) && ( empty( $component ) || empty( $cid ) ) )
		{
			if( !is_object( $comment ) )
			{
				$comment = Komento::getComment( $comment );
			}

			$component = $comment->component;
			$cid = $comment->cid;
		}

		if( empty( $component ) || empty( $cid ) )
		{
			return false;
		}

		$profile		= Komento::getProfile();
		$application	= Komento::loadApplication( $component )->load( $cid );

		Komento::setCurrentComponent( $component );

		switch( $type )
		{
			case 'edit':
				if( $profile->id != 0 && ($profile->allow( 'edit_all_comment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_edit_comment' ) ) || ( $profile->id == $comment->created_by && $profile->allow( 'edit_own_comment' ))))
				{
					return true;
				}
				break;
			case 'delete':
				if( $profile->id != 0 && ($profile->allow( 'delete_all_comment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_delete_comment' ) ) || ( $profile->id == $comment->created_by && $profile->allow( 'delete_own_comment' ))))
				{
					return true;
				}
				break;
			case 'publish':
				if( $profile->allow( 'publish_all_comment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_publish_comment' ) ) )
				{
					return true;
				}
				break;
			case 'unpublish':
				if( $profile->allow( 'unpublish_all_comment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_unpublish_comment' ) ) )
				{
					return true;
				}
				break;
			case 'stick':
				if( $profile->allow( 'stick_all_comment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_stick_comment' ) ) )
				{
					return true;
				}
				break;
			case 'like':
				if( $profile->allow( 'like_comment' ) )
				{
					return true;
				}
				break;
			case 'report':
				if( $profile->allow( 'report_comment' ) )
				{
					return true;
				}
				break;
			case 'delete_attachment':
				if( $profile->allow( 'delete_all_attachment' ) || ( $profile->id == $application->getAuthorId() && $profile->allow( 'author_delete_attachment' ) ) || ( $profile->id == $comment->created_by && $profile->allow( 'delete_own_attachment' ) ) )
				{
					return true;
				}
				break;
		}

		return false;
	}
 public function onAfterSaveComment($comment)
 {
     CSubscriptionsHelper::subscribe_record($this->_item->id);
     ATlog::log($this->_item, ATlog::COM_NEW, $comment->id);
     CEventsHelper::notify('record', CEventsHelper::_COMMENT_NEW, $this->_item->id, $this->_item->section_id, JFactory::getApplication()->input->getInt('cat_id'), $comment->id, 0, $this->_item);
     if ($comment->parent_id > 0) {
         $parent = Komento::getComment($comment->parent_id);
         if ($parent->created_by) {
             CEventsHelper::notify('record', CEventsHelper::_COMMENT_REPLY, $this->_item->id, $this->_item->section_id, JFactory::getApplication()->input->getInt('cat_id'), $parent->id, 0, $this->_item, 2, $parent->created_by);
         }
     }
     $this->_update_comments($comment->cid);
 }
 public function approveComment()
 {
     $id = JRequest::getInt('commentId', '');
     $comment = Komento::getComment($id);
     Komento::setCurrentComponent($comment->component);
     $acl = Komento::getHelper('acl');
     $type = 'message';
     $message = '';
     if (!$acl->allow('publish', $comment)) {
         $type = 'error';
         $message = JText::_('COM_KOMENTO_NOT_ALLOWED');
         $this->setRedirect('index.php?option=com_komento', $message, $type);
         return false;
     }
     $model = Komento::getModel('comments');
     if ($model->publish($id)) {
         $message = JText::_('COM_KOMENTO_COMMENTS_COMMENT_PUBLISHED');
     } else {
         $message = JText::_('COM_KOMENTO_COMMENTS_COMMENT_PUBLISH_ERROR');
         $type = 'error';
     }
     $this->setRedirect('index.php?option=com_komento', $message, $type);
     return true;
 }
 function getCommentDepth($id)
 {
     $comment = Komento::getComment($id);
     $component = $comment->component;
     $cid = $comment->cid;
     $query = 'SELECT COUNT(`parent`.`id`)-1 AS `depth`';
     $query .= ' FROM `#__komento_comments` AS `node`';
     $query .= ' INNER JOIN `#__komento_comments` AS `parent` on parent.component = node.component and node.cid = parent.cid';
     $query .= ' WHERE `node`.`component` = ' . $this->db->Quote($component);
     $query .= ' AND `node`.`cid` = ' . $this->db->Quote($cid);
     $query .= ' AND `node`.`id` = ' . $this->db->Quote($id);
     $query .= ' AND `node`.`lft` BETWEEN `parent`.`lft` AND `parent`.`rgt`';
     $query .= ' GROUP BY `node`.`id`';
     $this->db->setQuery($query);
     $result = $this->db->loadObject();
     return $result->depth;
 }
	/**
	 * 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();
		}
	}
Exemple #11
0
	public function getParent( $process = 0, $admin = 0 )
	{
		if( empty( $this->parent_id ) )
		{
			return false;
		}

		$parent = Komento::getComment( $this->parent_id, $process, $admin );

		return $parent;
	}
Exemple #12
0
	public function approveComment()
	{
		$token = JRequest::getVar( 'token', '' );

		if( empty( $token ) )
		{
			echo JText::_( 'COM_KOMENTO_INVALID_TOKEN' );
			exit;
		}

		$hashkeys = Komento::getTable( 'hashkeys' );

		if( !$hashkeys->loadByKey( $token ) )
		{
			echo JText::_( 'COM_KOMENTO_INVALID_TOKEN' );
			exit;
		}

		if( empty( $hashkeys->uid ) )
		{
			echo JText::_( 'COM_KOMENTO_APPROVE_COMMENT_INVALID_COMMENT_ID' );
			exit;
		}

		$comment = Komento::getComment( $hashkeys->uid );

		// If this hashkey has been used, then either redirect to the comment or throw error
		if( $hashkeys->state )
		{
			if( $comment->published != 1 )
			{
				echo JText::_( 'COM_KOMENTO_APPROVE_COMMENT_ADMIN_REMOVED_COMMENT' );
				exit;
			}

		}
		else
		{
			$state = $comment->publish();

			if( !$state )
			{
				$error = $comment->getError();

				if( empty( $error ) )
				{
					$error = JText::_( 'COM_KOMENTO_APPROVE_COMMENT_ERROR_OCCURED' );
				}

				echo $error;
				exit;
			}

			$hashkeys->state = 1;
			$hashkeys->store();
		}

		$mainframe = JFactory::getApplication();
		$mainframe->redirect( $comment->getPermalink() );

		return;
	}
Exemple #13
0
	function addAction($type, $comment_id, $user_id)
	{
		$comment	= Komento::getComment( $comment_id );

		$now			= Komento::getDate()->toMySQL();

		$actionsTable	= Komento::getTable( 'actions' );

		$actionsTable->type			= $type;
		$actionsTable->comment_id	= $comment_id;
		$actionsTable->action_by	= $user_id;
		$actionsTable->actioned		= $now;

		if(!$actionsTable->store())
		{
			return false;
			// return JText::_( 'COM_KOMENTO_LIKES_ERROR_SAVING_LIKES' );
		}

		return $actionsTable->id;
	}
Exemple #14
0
	private function subscribe( $type = 'comment', $component, $cid, $commentId = 0, $userid = 0, $name, $email )
	{
		if( $commentId !== 0 && ( !$component || !$cid ) )
		{
			$comment = Komento::getComment( $commentId );
			$component = $comment->component;
			$cid = $comment->cid;
		}

		if( !$component || !$cid )
		{
			return false;
		}

		$subscriptionExist = Komento::getModel( 'subscription' )->checkSubscriptionExist( $component, $cid, $userid, $email, $type );

		if( !$subscriptionExist )
		{
			$data = array(
				'type'		=> $type,
				'component' => $component,
				'cid'		=> $cid,
				'userid'	=> $userid,
				'fullname'	=> $name,
				'email'		=> $email,
				'created'	=> Komento::getDate()->toMySQL(),
				'published'	=> 1
			);

			$config = Komento::getConfig();

			if( $config->get( 'subscription_confirmation' ) )
			{
				$data['published'] = 0;
			}

			$subscribeTable = Komento::getTable( 'subscription' );

			$subscribeTable->bind( $data );

			if( !$subscribeTable->store() )
			{
				return false;
			}

			if( $config->get( 'subscription_confirmation' ) )
			{
				Komento::getHelper( 'Notification' )->push( 'confirm', 'me', array( 'component' => $component, 'cid' => $cid, 'subscribeId' => $subscribeTable->id, 'commentId' => $commentId ) );
			}
		}

		return true;
	}