Modules

Gleez_Comment

Core comment class.

package
Gleez
category
Comment
author
Sandeep Sangamreddi - Gleez
copyright
© 2012 Gleez Technologies
license
http://gleezcms.org/license

Class declared in MODPATH/gleez/classes/gleez/comment.php on line 11.

Constants

STATUS_UNAPPROVED

integer 0

STATUS_APPROVED

integer 1

STATUS_SPAM

integer 2

STATUS_DELETED

integer 3

COMMENT_HIDDEN

integer 0

COMMENT_CLOSED

integer 1

COMMENT_OPEN

integer 2

COMMENT

integer 0

PINGBACK

integer 1

TRACKBACK

integer 2

Methods

public static bulk_actions( ) (defined in Gleez_Comment)

list of actions @param boolean true for dropdown for bult actions @return array states

Source Code

public static function bulk_actions( $list = FALSE )
{
s = array(
lish'   => array(
abel' => __('Publish the selected comments'),
allback' => 'Comment::bulk_update',
rguments' => array('updates' => array('status' => 'publish')),

                        'draft' => array(
abel' => __('Unpublish the selected comments'),
allback' => 'Comment::bulk_update',
rguments' => array('updates' => array('status' => 'draft')),

                        'spam'   => array(
abel' => __('Mark Selected Comments as Spam'),
allback' => 'Comment::bulk_update',
rguments' => array('updates' => array('status' => 'spam')),

                        'delete'    => array(
abel' => __('Delete the selected comments'),
allback' => NULL,



w module developers to override
s = Module::action('comment_bulk_actions', $states);

st)

ons = array();
ch ($values as $operation => $array) $options[$operation] = $array['label'];

n $options;


        return $values;
}

public static bulk_update( ) (defined in Gleez_Comment)

Source Code

public static function bulk_update(array $ids, array $actions)
{
	//Message::debug( Debug::vars($type));
	$posts = ORM::factory('comment')->where('id', 'IN', $ids)->find_all();
	foreach($posts as $post)
	{
		foreach ($actions as $name => $value)
		{
			$post->$name = $value;
		}
		$post->save();
	}
	
}

public create_list( ) (defined in Gleez_Comment)

List comments

Source Code

public function create_list($parent_id = 0, $state = 'publish', $url, $page, $config, $admin = FALSE)
{
	// Get total number of comments
	if ($parent_id == 0)
	{
		Kohana::$log->add(LOG::DEBUG, 'Fetching all '.$state.' comments');
		$total = ORM::factory('comment', array(
			'status' => $state,
		))->count_all();
	}
	else
	{
		Kohana::$log->add(LOG::DEBUG, 'Fetching '.$state.' comments for parent id='.$parent_id);
		$total = ORM::factory('comment', array(
			'status'  => $state,
			'parent'  => $parent_id,
		))->count_all();
	}

	// Check if there are any comments to display
	if ($total == 0) return FALSE;

}

public static form( ) (defined in Gleez_Comment)

Source Code

public static function form($controller, $item, $_action = FALSE, $captcha = FALSE)
{
        $view = View::factory('comment/form')
                        ->set('use_captcha', $captcha)
                        ->set('action', Request::current()->uri())
t('is_edit', FALSE)
t('auth', Auth::instance())
t('destination', array())
t('item', $item)
nd('errors', $errors)
                        ->bind('post', $post);

form action eitehr from model or action param
tem->url ) $view->set('action', (string)$item->url);
        if( $_action ) 	 $view->set('action', $_action);

if captcha necessary
        if( $captcha )

cha = Captcha::instance();
->set('captcha', $captcha);


 the comment model
        $post = ORM::factory('comment');
        
ontroller->valid_post('comment') )

es = Arr::merge( array('post_id' => $item->id, 'type' => $item->type), $_POST);


t->values($values)->save();
post->status != 'publish')

sage::success(__('Your comment has been queued for review by
   site administrators and will be published after approval.') );



sage::success(__('Your comment has been posted.', array(':title' => $post->title)) );


ave the anonymous user information to a cookie for reuse.
User::is_guest()) {
r::cookie_save(array(
'name'  => $post->guest_name,
'email' => $post->guest_email,
'url'   => $post->guest_url
));


na::$log->add(LOG::INFO, 'Comment: :title has posted.', array(':title' => $post->title) );

direct to post page
troller->request->redirect( Request::current()->uri() );

                catch (ORM_Validation_Exception $e)

ors =  $e->errors('models');
age::error(__('Please see the erros below!'));



        return $view;
}

public static status( ) (defined in Gleez_Comment)

list of status @return array statuses

Source Code

public static function status()
{
s = array(
                        'publish'   => __('Publish'),
                        'draft'     => __('Unpublish'),
                        'spam'      => __('Spam'),
ete'    => __('Delete'),


s = Module::action('comment_status', $states);
        return $values;
}

public static valid_state( ) (defined in Gleez_Comment)

Make sure that the state is legal.

Source Code

public static function valid_state($value)
{
 in_array( $value, array_keys( Comment::status() ) );
}
Documentation comments powered by Disqus