Source for file _comments.ctrl.php
Documentation is available at _comments.ctrl.php
* This file implements the UI controller for managing comments.
* Quam Plures - {@link http://quamplures.net/}
* Released under GNU GPL License - {@link http://quamplures.net/license.html}
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal Open Source relicensing agreement:
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
param( 'action', 'string', 'list' );
* Init the objects we want to work on.
param( 'comment_ID', 'integer', true );
$edited_Comment_Item = & $edited_Comment->get_Item();
$Blog = & $BlogCache->get_by_ID( $blog );
$current_User->check_perm( 'blog_comments', 'edit', true, $blog );
// Where are we going to redirect to?
param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&blog='. $blog. '&p='. $edited_Comment->item_ID, '&' ) );
{ // No blog could be selected
$Messages->add( T_('You have no permission to edit comments.' ), 'error' );
{ // Selected a new blog:
$Blog = & $BlogCache->get_by_ID( $blog );
$AdminUI->set_path( 'items' ); // Sublevel may be attached below
$AdminUI->title = $AdminUI->title_titlearea = T_('Editing comment'). ' #'. $edited_Comment->ID;
// fp> TODO: $edited_Comment->load_from_Request( true );
if( ! $edited_Comment->get_author_User() )
{ // If this is not a member comment
param( 'newcomment_author', 'string', true );
param( 'newcomment_author_email', 'string' );
param( 'newcomment_author_url', 'string' );
$edited_Comment->set( 'author', $newcomment_author );
$edited_Comment->set( 'author_email', $newcomment_author_email );
param_check_url( 'newcomment_author_url', 'posting', '' ); // Give posting permissions here
$edited_Comment->set( 'author_url', $newcomment_author_url );
param( 'content', 'html' );
param( 'post_autobr', 'integer', ($comments_use_autobr == 'always') ? 1 : 0 );
param_check_html( 'content', T_('Invalid comment text.'), '#', $post_autobr ); // Check this is backoffice content (NOT with comment rules)
$edited_Comment->set( 'content', get_param( 'content' ) );
if( $current_User->check_perm( 'edit_timestamp' ))
param_date( 'comment_issue_date', T_('Please enter a valid comment date.'), true );
{ // only set it, if a date was given:
param( 'comment_rating', 'integer', NULL );
$edited_Comment->set_from_Request( 'rating' );
param( 'comment_status', 'string', 'published' );
$edited_Comment->set_from_Request( 'status' );
param( 'comment_nofollow', 'integer', 0 );
$edited_Comment->set_from_Request( 'nofollow' );
if( $Messages->count('error') )
{ // There have been some validation errors:
$edited_Comment->dbupdate(); // Commit update to the DB
$Messages->add( T_('Comment has been updated.'), 'success' );
$edited_Comment->set('status', 'published' );
$edited_Comment->dbupdate(); // Commit update to the DB
$Messages->add( T_('Comment has been published.'), 'success' );
$edited_Comment->set('status', 'deprecated' );
$edited_Comment->dbupdate(); // Commit update to the DB
$Messages->add( T_('Comment has been deprecated.'), 'success' );
// fp> TODO: non JS confirm
$edited_Comment->dbdelete();
$Messages->add( T_('Comment has been deleted.'), 'success' );
$AdminUI->title = $AdminUI->title_titlearea = T_('Latest comments');
param( 'show_statuses', 'array', array(), true ); // Array of cats to restrict to
// Generate available blogs list:
$AdminUI->set_coll_list_params( 'blog_comments', 'edit',
array( 'ctrl' => 'comments' ), NULL, '' );
* We do this here instead of _header because we need to include all filter params into regenerate_url()
$AdminUI->append_path_level( 'comments' );
* List of comments to display:
$CommentList = new CommentList( $Blog, "'comment','trackback'", $show_statuses, '', '', 'DESC', '', 20 );
$AdminUI->set_path( 'items', 'comments' );
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
$AdminUI->disp_html_head();
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
$AdminUI->disp_body_top();
case 'update': // on error
$AdminUI->disp_payload_begin();
$AdminUI->disp_view( 'comments/views/_comment.form.php' );
$AdminUI->disp_payload_end();
$AdminUI->disp_payload_begin();
$AdminUI->disp_view( 'comments/views/_browse_comments.view.php' );
$AdminUI->disp_payload_end();
// Display body bottom, debug info and close </html>:
$AdminUI->disp_global_footer();
|