Example #1
0
 function registerToolbar()
 {
     $parentId = JRequest::getVar('parentid', 0);
     // JToolBarHelper::title( text, iconfilename )
     if ($parentId) {
         if ($parentId) {
             $parent = Komento::getTable('comments');
             $parent->load($parentId);
         }
         JToolBarHelper::title(JText::_('COM_KOMENTO_COMMENTS_TITLE_CHILD_OF') . $parentId, 'comments');
         JToolBarHelper::back(JText::_('COM_KOMENTO_BACK'), 'index.php?option=com_komento&view=comments&parentid=' . $parent->parent_id);
     } else {
         JToolBarHelper::title(JText::_('COM_KOMENTO_COMMENTS_TITLE'), 'comments');
         JToolBarHelper::back(JText::_('COM_KOMENTO_ADMIN_HOME'), 'index.php?option=com_komento');
     }
     JToolBarHelper::divider();
     if (Komento::joomlaVersion() >= '3.0') {
         JToolBarHelper::custom('stick', 'star', '', JText::_('COM_KOMENTO_STICK'));
         JToolBarHelper::custom('unstick', 'star-empty', '', JText::_('COM_KOMENTO_UNSTICK'));
     } else {
         JToolBarHelper::custom('stick', 'kmt-stick', '', JText::_('COM_KOMENTO_STICK'));
         JToolBarHelper::custom('unstick', 'kmt-unstick', '', JText::_('COM_KOMENTO_UNSTICK'));
     }
     JToolBarHelper::divider();
     JToolBarHelper::publishList();
     JToolBarHelper::unpublishList();
     JToolBarHelper::divider();
     JToolBarHelper::deleteList();
 }
Example #2
0
 function preview()
 {
     $id = JRequest::getInt('id');
     $table = Komento::getTable('mailq');
     $table->load($id);
     $ajax = Komento::getAjax();
     $ajax->success($table->body, $table->type);
     $ajax->send();
 }
Example #3
0
	public function add( $type, $comment_id, $uid )
	{
		$table	= Komento::getTable( 'activities' );

		$table->type		= $type;
		$table->comment_id	= $comment_id;
		$table->uid			= $uid;
		$table->created		= Komento::getDate()->toMySQL();
		$table->published	= 1;

		return $table->store();
	}
Example #4
0
 function migrateSettings()
 {
     $ajax = Komento::getAjax();
     $fromTable = Komento::getTable('configs');
     $toTable = Komento::getTable('configs');
     $component = JRequest::getVar('component');
     $currentComponent = JRequest::getVar('currentComponent');
     $fromTable->load($component);
     $toTable->load($currentComponent);
     $toTable->params = $fromTable->params;
     $toTable->store();
     $ajax->success();
     $ajax->send();
 }
Example #5
0
	public function attach( $id, $uid )
	{
		$table = Komento::getTable( 'uploads' );
		$state = $table->load( $id );

		if( !$state )
		{
			return false;
		}

		$table->uid = $uid;

		return $table->store();
	}
Example #6
0
	/**
	 * Generates a random captcha image
	 *
	 **/
	function display($cachable = false, $urlparams = false)
	{
		$id			= JRequest::getInt( 'captcha-id' , '' );
		$captcha	= Komento::getTable( 'Captcha' , 'KomentoTable' );

		if( ob_get_length() !== false )
		{
			while (@ ob_end_clean());
			if( function_exists( 'ob_clean' ) )
			{
				@ob_clean();
			}
		}

		// clearing the oudated keys.
		$captcha->clear();

		// load the captcha records.
		$captcha->load( $id );

		if( !$captcha->id )
		{
			return false;
		}

		// @task: Generate a very random integer and take only 5 chars max.
		$hash	= JString::substr( md5( rand( 0, 9999 ) ) , 0 , 5 );
	    $captcha->response	= $hash;
		$captcha->store();

	    // Captcha width and height
	    $width	= 100;
	    $height = 20;

	    $image	= ImageCreate( $width , $height );
	    $white	= ImageColorAllocate($image, 255, 255, 255);
	    $black	= ImageColorAllocate($image, 0, 0, 0);
	    $gray	= ImageColorAllocate($image, 204, 204, 204);

	    ImageFill( $image , 0 , 0 , $white );
		ImageString( $image , 5 , 30 , 3 , $hash , $black );
		ImageRectangle( $image , 0 , 0 , $width - 1 , $height - 1 , $gray );
		imageline( $image , 0 , $height / 2 , $width , $height / 2 , $gray );
		imageline( $image , $width / 2 , 0 , $width / 2 , $height , $gray );

		header( 'Content-type: image/jpeg' );
	    ImageJpeg( $image );
	    ImageDestroy($image);
	    exit;
	}
Example #7
0
 public function save($data)
 {
     $component = $data['component'];
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
     $component = JString::strtolower(JString::trim($component));
     unset($data['component']);
     $config = Komento::getTable('Configs');
     $config->load($component);
     $config->component = $component;
     $json = Komento::getJSON();
     $config->params = $json->encode($data);
     $result = $config->store();
     // Save it
     if (!$result) {
         return false;
     }
     return true;
 }
Example #8
0
 function display($tpl = null)
 {
     //initialise variables
     $document = JFactory::getDocument();
     $user = JFactory::getUser();
     $mainframe = JFactory::getApplication();
     $components = array();
     $result = Komento::getHelper('components')->getAvailableComponents();
     if (Komento::joomlaVersion() >= '1.6') {
         if (!$user->authorise('komento.manage.comments', 'com_komento')) {
             $mainframe->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
             $mainframe->close();
         }
     }
     //Load pane behavior
     jimport('joomla.html.pane');
     $commentId = JRequest::getVar('commentid', '');
     $comment = Komento::getTable('Comments');
     $comment->load($commentId);
     $this->comment = $comment;
     // Set default values for new entries.
     if (empty($comment->created)) {
         Komento::import('helper', 'date');
         $date = KomentoDateHelper::getDate();
         $now = KomentoDateHelper::toFormat($date);
         $comment->created = $now;
         $comment->published = true;
     }
     // Set all non published comments to unpublished
     if ($comment->published != 1) {
         $comment->published = 0;
     }
     // @task: Translate each component with human readable name.
     foreach ($result as $item) {
         $components[] = JHTML::_('select.option', $item, Komento::loadApplication($item)->getComponentName());
     }
     $this->assignRef('comment', $comment);
     $this->assignRef('components', $components);
     parent::display($tpl);
 }
Example #9
0
	public function getAttachments( $uid )
	{
		$sql = Komento::getSql();

		$sql->select( '#__komento_uploads' )
			->where( 'uid', $uid )
			->order( 'created' );

		$result = $sql->loadObjectList();

		$attachments = array();

		foreach( $result as $row )
		{
			$table = Komento::getTable( 'uploads' );
			$table->bind( $row );

			$attachments[] = $table;
		}

		return $attachments;
	}
Example #10
0
	public function getReloadSyntax()
	{
		if ($currentId = JRequest::getInt( 'captcha-id' ))
		{
			$ref	= Komento::getTable( 'Captcha' , 'KomentoTable' );
			$ref->load( $currentId );
			$ref->delete();
		}

		// Regenerate a new captcha object
		$captcha	= Komento::getTable( 'Captcha' , 'KomentoTable' );
		$captcha->created	= Komento::getDate()->toMySQL();
		$captcha->store();

		$url	= $this->getCaptchaUrl( $captcha->id );

		$reloadData = array(
			'image'	=> $url,
			'id'	=> $captcha->id
		);

		return $reloadData;
	}
Example #11
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();
	}
Example #12
0
	<?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');
        $table->store();
        $activity->uid = $config->get('orphanitem_ownership');
    }
    ?>
	<div class="mod-item stream kmt-activity-<?php 
    echo $activity->id;
    ?>
">
		<div class="stream-head stream-<?php 
    echo $activity->type;
    ?>
">
			<i class="stream-type"></i>
Example #13
0
 function migrate()
 {
     $params = JRequest::getVar('params');
     $comments = $this->model->getData((object) $params['data']);
     $count = count($comments);
     foreach ($comments as $comment) {
         if ($comment->cid == 'kmt-none') {
             continue;
         }
         $comment->parent_id = 0;
         $this->kmtmodel->updateCommentLftRgt($comment);
         $newComment = Komento::getTable('comments');
         $newComment->bind($comment);
         $newComment->store();
     }
     $newStart = $params['data']['start'] + $count;
     $this->ajax->update($count);
     $this->ajax->success($newStart);
     $this->ajax->send();
 }
Example #14
0
	public function mark( $type = '0' )
	{
		$commentTable = Komento::getTable( 'Comments' );
		$commentTable->bind($this->getProperties());
		$userId		= JFactory::getUser()->id;

		// remove all reported flags
		$actionsModel = Komento::getModel( 'Actions' );
		$actionsModel->removeAction('spam', $commentTable->id, 'all');
		$actionsModel->removeAction('offensive', $commentTable->id, 'all');
		$actionsModel->removeAction('offtopic', $commentTable->id, 'all');

		$commentTable->flag = $type;
		$commentTable->flag_by = $userId;

		if( !$commentTable->store() )
		{
			$this->setError( 'Comment mark failed' );
			return false;
		}

		return true;
	}
Example #15
0
	public function process( $action, $comment )
	{
		// process all activities and 3rd party integration here

		// Due to the possible conflict data of $comment->created containing lapsed time instead of raw date, we use the table object directly instead

		if( !( $comment instanceof KomentoTableComments ) )
		{
			$id = 0;

			if( is_int( $comment ) || is_string( $comment ) )
			{
				$id = $comment;
			}

			if( $comment instanceof KomentoComment )
			{
				$id = $comment->id;
			}

			$comment = Komento::getTable( 'comments' );
			$comment->load( $id );
		}

		if( $action != 'remove' && $comment->published != 1 )
		{
			return false;
		}

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

		if( $application === false)
		{
			$application = Komento::getErrorApplication( $comment->component, $comment->cid );
		}

		$pagelink = $application->getContentPermalink();
		$permalink = $pagelink . '#' . $comment->id;
		$author = $application->getAuthorId();
		$title = $application->getContentTitle();

		if( $profile->id == 0 )
		{
			return false;
		}

		// native activity
		if( ( $action == 'comment' && $config->get( 'activities_comment' ) ) || ( $action == 'reply' && $config->get( 'activities_reply' ) ) || ( $action == 'like' && $config->get( 'activities_like' ) ) )
		{
			$this->addActivity( $action, $comment->id, $comment->created_by );
		}

		// Add jomsocial activity
		if( $action == 'comment' && $config->get( 'jomsocial_enable_comment' ) )
		{
			$this->addJomSocialActivityComment( $comment );
		}
		if( $action == 'reply' && $config->get( 'jomsocial_enable_reply' ) )
		{
			$this->addJomSocialActivityReply( $comment );
		}
		if( $action == 'like' && $config->get( 'jomsocial_enable_like' ) )
		{
			$this->addJomSocialActivityLike( $comment, $profile->id );
		}

		// Add jomsocial userpoints
		if( $config->get( 'jomsocial_enable_userpoints' ) )
		{
			switch( $action )
			{
				case 'comment':
					Komento::addJomSocialPoint( 'com_komento.comment.add' );
					Komento::addJomSocialPoint( 'com_komento.comment.add.author', $author );
					break;

				case 'reply':
					Komento::addJomSocialPoint( 'com_komento.comment.reply' );
					break;

				case 'like':
					Komento::addJomSocialPoint( 'com_komento.comment.like' );
					Komento::addJomSocialPoint( 'com_komento.comment.liked', $comment->created_by );
					break;

				case 'unlike':
					Komento::addJomSocialPoint( 'com_komento.comment.unlike' );
					Komento::addJomSocialPoint( 'com_komento.comment.unliked', $comment->created_by );
					break;

				case 'report':
					Komento::addJomSocialPoint( 'com_komento.comment.report' );
					Komento::addJomSocialPoint( 'com_komento.comment.reported', $comment->created_by );
					break;

				case 'unreported':
					Komento::addJomSocialPoint( 'com_komento.comment.unreport' );
					Komento::addJomSocialPoint( 'com_komento.comment.unreported', $comment->created_by );
					break;

				case 'stick':
					Komento::addJomSocialPoint( 'com_komento.comment.sticked' );
					break;

				case 'unstick':
					Komento::addJomSocialPoint( 'com_komento.comment.unsticked' );
					break;

				case 'remove':
					Komento::addJomSocialPoint( 'com_komento.comment.removed' );
					Komento::addJomSocialPoint( 'com_komento.comment.removed.author', $author );
					break;
			}
		}

		// Add aup
		if( $config->get( 'enable_aup' ) )
		{
			switch( $action )
			{
				case 'comment':
					Komento::addAUP( 'plgaup_komento_post_comment', $comment->created_by, 'komento_post_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_POST_COMMENT', $permalink, $title ) );
					Komento::addAUP( 'plgaup_komento_add_comment_author', $author, 'komento_post_comment_on_' . $comment->component . '_' . $comment->cid, JText::sprintf( 'COM_KOMENTO_AUP_POST_COMMENT', $permalink, $title ) );
					break;

				case 'reply':
					Komento::addAUP( 'plgaup_komento_reply_comment', $comment->created_by, 'komento_reply_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_REPLY_COMMENT', $permalink, $title ) );
					break;

				case 'like':
					Komento::addAUP( 'plgaup_komento_like_comment', $profile->id, 'komento_like_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_LIKE_COMMENT', $permalink, $title ) );
					Komento::addAUP( 'plgaup_komento_comment_liked', $comment->created_by, 'komento_comment_liked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_LIKED', $permalink, $title ) );
					break;

				case 'unlike':
					Komento::addAUP( 'plgaup_komento_unlike_comment', $profile->id, 'komento_unlike_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_UNLIKE_COMMENT', $permalink, $title ) );
					Komento::addAUP( 'plgaup_komento_comment_unliked', $comment->created_by, 'komento_comment_unliked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNLIKED', $permalink, $title ) );
					break;
				case 'report':
					Komento::addAUP( 'plgaup_komento_report_comment', $profile->id, 'komento_report_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_REPORT_COMMENT', $permalink, $title ) );
					Komento::addAUP( 'plgaup_komento_comment_reported', $comment->created_by, 'komento_comment_reported_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_REPORTED', $permalink, $title ) );
					break;
				case 'unreport':
					Komento::addAUP( 'plgaup_komento_unreport_comment', $profile->id, 'komento_unreport_comment_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_UNREPORT_COMMENT', $permalink, $title ) );
					Komento::addAUP( 'plgaup_komento_comment_unreported', $comment->created_by, 'komento_comment_unreported_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNREPORTED', $permalink, $title ) );
					break;
				case 'stick':
					Komento::addAUP( 'plgaup_komento_comment_sticked', $comment->created_by, 'komento_comment_sticked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_STICKED', $permalink, $title ) );
					break;
				case 'unstick':
					Komento::addAUP( 'plgaup_komento_comment_unsticked', $comment->created_by, 'komento_comment_unsticked_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_UNSTICKED', $permalink, $title ) );
					break;
				case 'remove':
					Komento::addAUP( 'plgaup_komento_comment_removed', $comment->created_by, 'komento_comment_removed_' . $comment->id, JText::sprintf( 'COM_KOMENTO_AUP_COMMENT_REMOVED', $pagelink, $title ) );
					Komento::addAUP( 'plgaup_komento_remove_comment_author', $author, 'komento_remove_comment_on_' . $comment->component . '_' . $comment->cid, JText::sprintf( 'COM_KOMENTO_AUP_REMOVED_COMMENT_AUTHOR', $pagelink, $title ) );
					break;
			}
		}

		// Add Discuss points
		if( $config->get( 'enable_discuss_points' ) )
		{
			switch( $action )
			{
				case 'comment':
					Komento::addDiscussPoint( 'komento.add.comment', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_ADD_COMMENT', $title ) );
					Komento::addDiscussPoint( 'komento.add.comment.article.author', $author, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_ADD_COMMENT_ARTICLE_AUTHOR', $title ) );
					break;

				case 'reply':
					Komento::addDiscussPoint( 'komento.reply.comment', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REPLY_COMMENT', $title ) );
					break;

				case 'like':
					Komento::addDiscussPoint( 'komento.like.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_LIKE_COMMENT', $title ) );
					Komento::addDiscussPoint( 'komento.comment.liked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_LIKED', $title ) );
					break;

				case 'unlike':
					Komento::addDiscussPoint( 'komento.unlike.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_UNLIKE_COMMENT', $title ) );
					Komento::addDiscussPoint( 'komento.comment.unliked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNLIKED', $title ) );
					break;
				case 'report':
					Komento::addDiscussPoint( 'komento.report.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REPORT_COMMENT', $title ) );
					Komento::addDiscussPoint( 'komento.comment.reported', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_REPORTED', $title ) );
					break;
				case 'unreport':
					Komento::addDiscussPoint( 'komento.unreport.comment', $profile->id, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_UNREPORT_COMMENT', $title ) );
					Komento::addDiscussPoint( 'komento.comment.unreported', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNREPORTED', $title ) );
					break;
				case 'stick':
					Komento::addDiscussPoint( 'komento.comment.sticked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_STICKED', $title ) );
					break;
				case 'unstick':
					Komento::addDiscussPoint( 'komento.comment.unsticked', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_UNSTICKED', $title ) );
					break;
				case 'remove':
					Komento::addDiscussPoint( 'komento.comment.removed', $comment->created_by, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_COMMENT_REMOVED', $title ) );
					Komento::addDiscussPoint( 'komento.remove.comment.article.author', $author, JText::sprintf( 'COM_KOMENTO_DISCUSS_HISTORY_REMOVE_COMMENT_ARTICLE_AUTHOR', $title ) );
					break;
			}
		}

		if( $config->get( 'enable_easysocial_points' ) )
		{
			$es	= Komento::getHelper( 'EasySocial' );

			switch( $action )
			{
				case 'comment':
					$es->assignPoints( 'komento.add.comment' , $comment->created_by, $comment); //Add points to user when a user post a comment.
					$es->assignPoints( 'komento.add.comment.article.author' , $author, $comment); //Add points for article author when a user posts a new comment on that article.
					break;

				case 'reply':
					$es->assignPoints( 'komento.reply.comment', $comment->created_by, $comment); //Add points to user when a user reply to a comment.
					break;

				case 'like':
					$es->assignPoints( 'komento.like.comment' , $profile->id ); //Add points to user when a user likes a comment.
					$es->assignPoints( 'komento.comment.liked' , $comment->created_by ); //Add points to comment author when a user likes the comment. *?
					break;

				case 'unlike':
					$es->assignPoints( 'komento.unlike.comment' , $profile->id ); //Add points to user when a user unlikes a comment.
					$es->assignPoints( 'komento.comment.unliked' , $comment->created_by ); //Deduct points to comment author when a user unlike the comment.
					break;
				case 'report':
					$es->assignPoints( 'komento.report.comment' , $profile->id ); // Add points to user when a user reports a comment.
					$es->assignPoints( 'komento.comment.reported' , $comment->created_by ); //Deduct points to comment author when a comment is reported.
					break;
				case 'unreport':
					$es->assignPoints( 'komento.unreport.comment' , $profile->id ); // Deduct points to user when a user unreports a comment.
					$es->assignPoints( 'komento.comment.unreported' , $comment->created_by ); //Add points to comment author when a comment is unreported.
					break;
				case 'stick':

					$es->assignPoints( 'komento.comment.sticked' , $comment->created_by ); //Add points to comment author when a comment is sticked.
					break;
				case 'unstick':
					$es->assignPoints( 'komento.comment.unsticked' , $comment->created_by ); //Deduct points to comment author when a comment is unsticked.
					break;
				case 'remove':
					$es->assignPoints( 'komento.comment.removed' , $comment->created_by ); //Deduct points to comment author when a comment is removed.
					$es->assignPoints( 'komento.remove.comment.article.author' , $author ); //Deduct points for article author when a comment is removed from that article.
					break;
				case 'upload':
					$es->assignPoints( 'komento.upload.attachments' , $comment->created_by ); //Deduct points to comment author when a comment is removed.
					break;
			}
		}

		if( $config->get( 'enable_easysocial_badges' ) )
		{
			$es 	= Komento::getHelper( 'EasySocial' );

			switch( $action )
			{
				case 'comment':
					$es->assignBadge( 'komento.add.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_ADD_COMMENTS_MESSAGE' ) );
					break;

				case 'reply':
					$es->assignBadge( 'komento.reply.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_REPLY_COMMENTS_MESSAGE' ) );
					break;

				case 'like':
					$es->assignBadge( 'komento.like.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_LIKE_COMMENTS_MESSAGE' ) );
					break;

				case 'report':
					$es->assignBadge( 'komento.report.comment', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_REPORT_COMMENTS_MESSAGE' ) );
					break;

				case 'upload':
					$es->assignBadge( 'komento.upload.attachments', JText::_( 'COM_KOMENTO_EASYSOCIAL_BADGES_UPLOAD_COMMENTS_MESSAGE' ) );
					break;
			}
		}

		if( $config->get( 'notification_es_enable' ) && ( $config->get( 'notification_es_event_new_' . $action ) ) )
		{
			$es 	= Komento::getHelper( 'EasySocial' );

			$es->notify( $action, $comment );
		}

		// If action is reply and sync comment is on, then we don't create a stream
		// If comment params->source is from com_easysocial, then we don't create a stream
		if( ( ( in_array( $action, array( 'comment', 'like' ) ) && $config->get( 'enable_easysocial_stream_' . $action ) ) || $action === 'reply' && !$config->get( 'enable_easysocial_sync_comment' ) ) && ( empty( $comment->params->source ) || $comment->params->source !== 'com_easysocial' ) )
		{
			$es 	= Komento::getHelper( 'EasySocial' );
			$es->createStream( $action, $comment );
		}

		if( $action === 'reply' && $config->get( 'enable_easysocial_sync_comment' ) && empty( $comment->params->social->source ) )
		{
			$es = Komento::getHelper( 'EasySocial' );
			$es->injectComment( $comment );
		}

		if( $action === 'remove' && $config->get( 'enable_easysocial_sync_comment' ) )
		{
			$es = Komento::getHelper( 'EasySocial' );
			$es->removeComment( $comment );
		}

		if( $action === 'like' && $config->get( 'enable_easysocial_sync_like' ) )
		{
			$es = Komento::getHelper( 'EasySocial' );
			$es->injectLike( $comment );
		}

		if( $action === 'unlike' && $config->get( 'enable_easysocial_sync_like' ) )
		{
			$es = Komento::getHelper( 'EasySocial' );
			$es->removeLike( $comment );
		}
	}
Example #16
0
	public function getNotificationTarget( $target, $action, $comment )
	{
		$ids = array();

		switch( $target )
		{
			case 'usergroup':
				$gids = $this->config->get( 'notification_es_to_usergroup_' . $action );

				if( !empty( $gids ) )
				{
					if( !is_array( $gids ) )
					{
						$gids = explode( ',', $gids );
					}

					foreach( $gids as $gid )
					{
						$ids += Komento::getUsersByGroup( $gid );
					}
				}
			break;

			case 'author':
				if( $this->config->get( 'notification_es_to_author' ) )
				{
					$application = Komento::loadApplication( $comment->component )->load( $comment->cid );

					$author = $application->getAuthorId();

					if( !empty( $author ) )
					{
						$ids = array( $author );
					}
				}
			break;

			case 'parent':
				if( !empty( $comment->parent_id ) )
				{
					$parent = Komento::getTable( 'comments' );
				    $state = $parent->load( $comment->parent_id );

				     if( $state && !empty( $parent->created_by ) )
				     {
				      $ids = array( $parent->created_by );
				     }
				}
			break;

			case 'owner':
				if( !empty( $comment->created_by ) )
				{
					$ids = array( $comment->created_by );
				}
			break;

			case 'participant':
				if( $this->config->get( 'notification_es_to_participant' ) )
				{
					$options = array(
						'component' => $comment->component,
						'cid' => $comment->cid,
						'noguest' => true,
						'state' => 1
					);

					$model = Komento::getModel( 'comments' );
					$ids = $model->getUsers( $options );
				}
			break;
		}

		return $ids;
	}
Example #17
0
 public static function convertOrphanitem($id)
 {
     $config = Komento::getConfig();
     $comment = Komento::getTable('comments');
     $comment->load($id);
     $comment->created_by = $config->get('orphanitem_ownership');
     $comment->store();
     return true;
 }
Example #18
0
	public function getMe( $type, $options )
	{
		$obj		= new stdClass();
		$my			= JFactory::getUser();

		if( empty( $my->id ) )
		{
			if( $type === 'confirm' && isset( $options['subscribeId'] ) )
			{
				$subscribeTable = Komento::getTable( 'subscription' );
				$subscribeTable->load( $options['subscribeId'] );

				$obj->id		= 0;
				$obj->fullname	= $subscribeTable->fullname;
				$obj->email		= $subscribeTable->email;

				return array( $obj->email => $obj );
			}

			return array();
		}

		$obj->id		= $my->id;
		$obj->fullname	= JText::_( $my->name );
		$obj->email		= $my->email;

		return array( $my->email => $obj );
	}
Example #19
0
 public function save($data)
 {
     $component = $data['target_component'];
     unset($data['target_component']);
     $cid = $data['target_id'];
     unset($data['target_id']);
     $type = $data['target_type'];
     unset($data['target_type']);
     Komento::import('helper', 'acl');
     $defaultset = KomentoACLHelper::getEmptySet(true);
     foreach ($defaultset as $key => $value) {
         if (isset($data[$key])) {
             $defaultset->{$key} = $data[$key] ? true : false;
         }
     }
     $table = Komento::getTable('Acl');
     $table->compositeLoad($cid, $type, $component);
     $json = Komento::getJSON();
     $table->rules = $json->encode($defaultset);
     return $table->store();
 }
Example #20
0
 function save($comment)
 {
     $new = Komento::getTable('comments');
     $new->component = $this->component;
     $new->cid = $this->cid;
     $new->comment = $comment->comment;
     $new->name = $comment->name;
     $new->email = $comment->email;
     $new->url = $comment->url;
     $new->created = $comment->created;
     $new->created_by = $comment->created_by;
     $new->published = $comment->published;
     $new->sent = $comment->sent;
     $new->parent_id = $comment->parent_id;
     $new->depth = $comment->depth;
     $new->lft = $comment->lft;
     $new->rgt = $comment->rgt;
     if ($this->publishingState !== 'inherit') {
         $new->published = $this->publishingState;
     }
     if (!$new->store()) {
         return false;
     }
     return $new;
 }
Example #21
0
 function saveColumns()
 {
     $columns = array('comment', 'published', 'edit', 'component', 'article', 'date', 'author', 'email', 'homepage', 'ip', 'latitude', 'longitude', 'address', 'id');
     $message = JText::_('COM_KOMENTO_COMMENTS_COLUMNS_SAVED');
     $type = 'message';
     $data = JRequest::get('post');
     foreach ($data as $key => $value) {
         if (!in_array(str_replace('column_', '', $key), $columns)) {
             unset($data[$key]);
         }
     }
     $config = Komento::getTable('configs');
     $config->load('com_komento_reports_columns');
     $config->component = 'com_komento_reports_columns';
     $params = $config ? $config->params : '';
     $registry = Komento::getRegistry($params, 'json');
     $registry->extend($data);
     $config->params = $registry->toString('json');
     if (!$config->store()) {
         $message = $config->getError();
         $type = 'error';
     }
     $this->setRedirect('index.php?option=com_komento&view=reports', $message, $type);
 }
Example #22
0
 private function fixItemStructure($id, &$boundary, $depth)
 {
     $item = Komento::getTable('comments');
     $item->load($id);
     $item->lft = $boundary++;
     $item->rgt = $boundary++;
     $item->depth = $depth;
     $item->store();
 }
Example #23
0
 /**
  * Retrieve Komento's configuration.
  *
  * @return	object	JParameter object.
  **/
 public static function getConfig($component = '', $default = true)
 {
     static $configs = array();
     $component = $component ? $component : (self::$component ? self::$component : 'com_content');
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
     if (empty($configs[$component])) {
         if ($default) {
             //load default ini data first
             $file = KOMENTO_ADMIN_ROOT . DIRECTORY_SEPARATOR . 'configuration.json';
             $config = Komento::getRegistry(JFile::read($file), 'json');
             $config->default = clone $config->toObject();
         } else {
             $config = Komento::getRegistry();
         }
         // get config stored in db
         $dbConfig = Komento::getTable('configs');
         $dbConfig->load($component);
         $stored = Komento::getRegistry($dbConfig->params, 'json');
         $config->extend($stored);
         $config->_current = $component;
         $configs[$component] = $config;
     }
     return $configs[$component];
 }
Example #24
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;
	}
Example #25
0
	public function confirmSubscription( $id )
	{
		if( !$id )
		{
			return false;
		}

		$subscriptionTable = Komento::getTable( 'subscription' );
		$subscriptionTable->load( $id );
		$subscriptionTable->published = 1;
		return $subscriptionTable->store();
	}
Example #26
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;
	}
Example #27
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;
	}
Example #28
0
 public function populatedb()
 {
     $db = Komento::getDBO();
     $articles = array('8', '50', '35');
     $authors = array('0' => 'Alien', '42' => 'Super User', '62' => 'Jason');
     $comments = array('hahaha :) love you', 'me too!!!', 'this is a link http://test.com', '[b]bbcode in use[/b] :( f**k you');
     $parentmap = array();
     $counter = 0;
     $date = Komento::getDate();
     for ($i = 0; $i < 20000; $i++) {
         $date->sub(new DateInterval('PT' . (20001 - $i) . 'S'));
         $modulo = $i % 3;
         $set = (int) ($i / 3);
         $setmodulo = (int) ($set / 3);
         $factor = $setmodulo * 6;
         $level = $set % 3 + 1;
         $lft = $level + $factor;
         $rgt = 7 - $level + $factor;
         $author = array_rand($authors);
         $article = $articles[$modulo];
         $comment = array_rand($comments);
         $parentid = 0;
         if ($level > 1) {
             $parentid = $parentmap[$article][$setmodulo][$level - 1];
         }
         $table = Komento::getTable('comments');
         $table->component = 'com_content';
         $table->comment = $comments[$comment];
         $table->cid = $article;
         $table->lft = $lft;
         $table->rgt = $rgt;
         $table->published = 1;
         $table->name = $authors[$author];
         $table->created_by = $author;
         $table->created = $date->toMySQL();
         $table->parent_id = $parentid;
         $result = $table->store();
         if (!$result) {
             var_dump($table);
             exit;
         }
         $parentmap[$article][$setmodulo][$level] = $table->id;
     }
     echo 'done';
     exit;
 }
Example #29
0
 function getPopularComments($component = 'all', $cid = 'all', $options = array())
 {
     // define default values
     $defaultOptions = array('start' => 0, 'limit' => 10, 'userid' => 'all', 'sticked' => 'all', 'published' => 1, 'minimumlikes' => 0, 'random' => 0, 'threaded' => 0);
     $querySelect = '';
     $queryWhere = array();
     $queryGroup = '';
     $queryOrder = '';
     $queryLimit = '';
     // take the input values and clear unexisting keys
     $options = Komento::mergeOptions($defaultOptions, $options);
     $querySelect = 'SELECT comments.*, COUNT(actions.comment_id) AS likes FROM ' . $this->db->nameQuote('#__komento_comments') . ' AS comments';
     $querySelect .= ' LEFT JOIN ' . $this->db->nameQuote('#__komento_actions') . ' AS actions ON comments.id = actions.comment_id';
     if ($component !== 'all') {
         $queryWhere[] = 'comments.component = ' . $this->db->quote($component);
     }
     if ($cid !== 'all') {
         if (is_array($cid)) {
             $cid = implode(',', $cid);
         }
         if (empty($cid)) {
             $queryWhere[] = 'comments.cid = 0';
         } else {
             $queryWhere[] = 'comments.cid IN (' . $cid . ')';
         }
     }
     if ($options['userid'] !== 'all') {
         $queryWhere[] = 'comments.created_by = ' . $this->db->quote($options['userid']);
     }
     if ($options['published'] !== 'all') {
         $queryWhere[] = 'comments.published = ' . $this->db->quote($options['published']);
     }
     if ($options['sticked'] !== 'all') {
         $queryWhere[] = 'comments.sticked = ' . $this->db->quote(1);
     }
     $queryWhere[] = 'actions.type = ' . $this->db->quote('likes');
     if (count($queryWhere) > 0) {
         $queryWhere = ' WHERE ' . implode(' AND ', $queryWhere);
     } else {
         $queryWhere = '';
     }
     $queryGroup = ' GROUP BY actions.comment_id';
     if ($options['minimumlikes'] > 0) {
         $queryGroup .= ' HAVING likes >= ' . $options['minimumlikes'];
     }
     $queryOrder = ' ORDER BY likes DESC, created DESC';
     $queryLimit = ' LIMIT ' . $options['start'] . ',' . $options['limit'];
     $query = $querySelect . $queryWhere . $queryGroup . $queryOrder . $queryLimit;
     $this->db->setQuery($query);
     $result = $this->db->loadObjectList();
     // build random
     if ($options['random']) {
         $result = $this->buildRandom($result, $options);
     }
     $comments = array();
     foreach ($result as $row) {
         if (!$options['threaded']) {
             $row->depth = 0;
         }
         $table = Komento::getTable('comments');
         $table->bind($row);
         $comments[] = $table;
     }
     return $comments;
 }
Example #30
0
	public function addMailq($component, $cid)
	{
		$config = Komento::getConfig();

		$subscribers = Komento::getModel('subscription')->getSubscribers($component, $cid);

		$mainframe	= JFactory::getApplication();
		$mailfrom	= $mainframe->getCfg( 'mailfrom' );
		$fromname 	= $mainframe->getCfg( 'fromname' );

		if( $config->get( 'admin_email' ) )
		{
			// get from config if config exist
		}

		if( count( $subscribers ) > 0 )
		{
			foreach( $subscribers as $subscriber )
			{
				$data = array(
					'mailfrom'	=> $mailfrom,
					'fromname'	=> $fromname,
					'recipient'	=> $subscriber->email,
					'subject'	=> 'new email',
					'body'		=> 'body',
					'created'	=> Komento::getDate()->toMySQL(),
					'status'	=> 0
				);

				$mailqTable = Komento::getTable( 'mailq' );

				$mailqTable->bind( $data );
				$mailqTable->store();
			}

			return true;
		}

		return false;
	}