Core comment class.
Class declared in MODPATH/gleez/classes/gleez/comment.php on line 11.
integer 0
integer 1
integer 2
integer 3
integer 0
integer 1
integer 2
integer 0
integer 1
integer 2
list of actions @param boolean true for dropdown for bult actions @return array states
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 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();
}
}
List comments
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 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;
}
list of status @return array statuses
public static function status()
{
s = array(
'publish' => __('Publish'),
'draft' => __('Unpublish'),
'spam' => __('Spam'),
ete' => __('Delete'),
s = Module::action('comment_status', $states);
return $values;
}
Make sure that the state is legal.
public static function valid_state($value)
{
in_array( $value, array_keys( Comment::status() ) );
}