Location: PHPKode > projects > Anahita Social Engine > dependencies/plg_system_socialengine/socialengine/uikit/comment/controller/commentable.php
<?php


class AnUikitCommentControllerCommentable extends KMixinAbstract
{ 
	public function __construct($options=array())
	{
		parent::__construct($options);
		
		$this->_mixer->registerAuthentication(array('addComment','deleteComment'));
		
		$this->_mixer->registerFunctionBefore(array('addComment','deleteComment'), 'getStory');
				
		$default = array(
			''
		);
	}
	
/**
	 * Comment on a story
	 * @return 
	 */
	public function _actionComment()
	{	
		
		$comment = KFactory::get('lib.anahita.domain.factory.model')->get($this->_story_comment_model, array(
			'node'      => $this->story ,
			'author'    => $this->getViewer() ,
			'body'      => KRequest::get('request.body', 'string')
		));
		
		if ( KFactory::get('lib.anahita.domain.context')->save() ) {
			
			$app = $this->getApplication();
			
			$comment->mixin( KFactory::tmp('lib.anahita.uikit.story.action.comment', array('mixer'=>$comment,'view'=>$this->view())) );
						
			KFactory::get('lib.anahita.uikit.comment')
				->setComment($comment)->display();
		}
	}
		
	/**
	 * Delete a story comment
	 * @return 
	 */
	public function _actionDeletecomment()
	{
		$comment = $this->story->comments
				->where('id','=', KRequest::get('request.cid','int',0))->fetch();
		
		if ( !$comment ) 
			return;
		
		$comment->markDeleted();

		KFactory::get('lib.anahita.domain.context')->save();
	}	
}
Return current item: Anahita Social Engine