2006-12-02 04:36:16 +00:00
< ? php
/*
+ ----------------------------------------------------------------------------+
| e107 website system
|
2009-11-18 01:06:08 +00:00
| Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
2006-12-02 04:36:16 +00:00
| http :// e107 . org
2009-11-18 01:06:08 +00:00
|
2006-12-02 04:36:16 +00:00
|
| Released under the terms and conditions of the
| GNU General Public License ( http :// gnu . org ) .
|
| $Source : / cvs_backup / e107_0 . 8 / e107_admin / comment . php , v $
2010-02-10 18:18:01 +00:00
| $Revision $
| $Date $
| $Author $
2006-12-02 04:36:16 +00:00
+----------------------------------------------------------------------------+
*/
require_once ( " ../class2.php " );
2009-05-08 21:50:19 +00:00
if ( ! getperms ( " B " ))
{
2006-12-02 04:36:16 +00:00
header ( " location: " . e_BASE . " index.php " );
exit ;
}
2009-08-30 08:23:51 +00:00
2009-11-23 04:03:40 +00:00
include_lan ( e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_prefs.php' );
2009-11-04 03:07:44 +00:00
class comments_admin extends e_admin_dispatcher
{
protected $modes = array (
'main' => array (
'controller' => 'comments_admin_ui' ,
'path' => null ,
'ui' => 'comments_admin_form_ui' ,
'uipath' => null
)
);
protected $adminMenu = array (
'main/list' => array ( 'caption' => 'Manage' , 'perm' => '0' ),
// 'main/create' => array('caption'=> LAN_CREATE, 'perm' => '0'),
2009-11-05 00:11:56 +00:00
'main/prefs' => array ( 'caption' => 'Settings' , 'perm' => '0' ),
2009-11-04 03:07:44 +00:00
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => '0')
);
protected $adminMenuAliases = array (
'main/edit' => 'main/list'
);
protected $menuTitle = 'Comments' ;
}
class comments_admin_ui extends e_admin_ui
{
protected $pluginTitle = LAN_COMMENTMAN ;
2009-11-05 17:32:19 +00:00
protected $pluginName = 'core' ;
2009-11-04 03:07:44 +00:00
protected $table = " comments " ;
2009-11-05 17:32:19 +00:00
/**
* If present this array will be used to build your list query
* You can link fileds from $field array with 'table' parameter , which should equal to a key ( table ) from this array
* 'leftField' , 'rightField' and 'fields' attributes here are required , the rest is optional
*
* @ var array [ optional ]
*/
protected $tableJoin = array (
2009-11-10 19:13:07 +00:00
'u.user' => array ( 'leftField' => 'comment_author_id' , 'rightField' => 'user_id' , 'fields' => '*' /*, 'leftTable' => '', 'joinType' => 'LEFT JOIN', 'whereJoin' => 'AND u.user_ban=0', 'where' => ''*/ )
2009-11-05 17:32:19 +00:00
);
//protected $listQry = "SELECT SQL_CALC_FOUND_ROWS * FROM #comments"; // without any Order or Limit.
2009-11-06 18:37:23 +00:00
//protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
2009-11-05 17:32:19 +00:00
2009-11-04 03:07:44 +00:00
protected $pid = " comment_id " ;
2009-11-04 03:37:56 +00:00
protected $perPage = 10 ;
2009-11-04 03:07:44 +00:00
protected $batchDelete = true ;
2009-11-06 18:37:23 +00:00
//TODO - finish 'user' type, set 'data' to all editable fields, set 'noedit' for all non-editable fields
2009-11-04 03:07:44 +00:00
protected $fields = array (
2009-11-07 11:20:34 +00:00
'checkboxes' => array ( 'title' => '' , 'type' => null , 'width' => '5%' , 'forced' => TRUE , 'thclass' => 'center' , 'class' => 'center' ),
2009-11-11 20:57:34 +00:00
'comment_id' => array ( 'title' => LAN_ID , 'type' => 'number' , 'width' => '5%' , 'forced' => TRUE ),
'comment_item_id' => array ( 'title' => " item id " , 'type' => 'number' , 'width' => '5%' ),
2009-11-07 11:20:34 +00:00
'comment_subject' => array ( 'title' => " subject " , 'type' => 'text' , 'width' => 'auto' , 'thclass' => 'left first' ), // Display name
2009-11-11 20:57:34 +00:00
'comment_comment' => array ( 'title' => " comment " , 'type' => 'bbarea' , 'width' => '30%' , 'readParms' => 'expand=...&truncate=50&bb=1' ), // Display name
'comment_author_id' => array ( 'title' => " author " , 'type' => 'user' , 'data' => 'int' , 'width' => 'auto' , 'writeParms' => 'nameField=comment_author_name' ), // User id
'comment_author_name' => array ( 'title' => " authorName " , 'type' => 'user' , 'width' => 'auto' , 'readParms' => 'idField=comment_author_id&link=1' , 'noedit' => true , 'forceSave' => true ), // User name
'u.user_name' => array ( 'title' => " System user " , 'type' => 'user' , 'width' => 'auto' , 'readParms' => 'idField=comment_author_id&link=1' , 'noedit' => true ), // User name
2009-11-07 11:20:34 +00:00
'comment_datestamp' => array ( 'title' => " datestamp " , 'type' => 'datestamp' , 'width' => 'auto' ), // User date
'comment_blocked' => array ( 'title' => " blocked " , 'type' => 'boolean' , 'data' => 'int' , 'thclass' => 'center' , 'class' => 'center' , 'filter' => true , 'batch' => true , 'width' => 'auto' ), // Photo
2009-11-09 12:23:45 +00:00
'comment_ip' => array ( 'title' => " IP " , 'type' => 'ip' , 'width' => '10%' , 'thclass' => 'center' ), // Real name (no real vetting)
2009-11-17 23:23:08 +00:00
'comment_type' => array ( 'title' => " Type " , 'type' => 'method' , 'width' => '10%' , 'filter' => TRUE ),
2009-11-07 11:20:34 +00:00
'comment_lock' => array ( 'title' => " Lock " , 'type' => 'boolean' , 'data' => 'int' , 'thclass' => 'center' , 'class' => 'center' , 'filter' => true , 'batch' => true , 'width' => 'auto' ),
'options' => array ( 'title' => LAN_OPTIONS , 'type' => null , 'forced' => TRUE , 'width' => '10%' , 'thclass' => 'center last' , 'class' => 'center' )
2009-11-04 03:07:44 +00:00
);
//required (but should be optional) - default column user prefs
2009-11-04 03:37:56 +00:00
protected $fieldpref = array ( 'checkboxes' , 'comment_id' , 'comment_item_id' , 'comment_author_id' , 'comment_author_name' , 'comment_subject' , 'comment_comment' , 'comment_type' , 'options' );
2009-11-04 03:07:44 +00:00
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
2009-11-23 04:03:40 +00:00
protected $prefs = array (
'anon_post' => array ( 'title' => PRFLAN_32 , 'type' => 'boolean' ),
'comments_icon' => array ( 'title' => PRFLAN_89 , 'type' => 'boolean' ),
'nested_comments' => array ( 'title' => PRFLAN_88 , 'type' => 'boolean' ),
'allowCommentEdit' => array ( 'title' => PRFLAN_90 , 'type' => 'boolean' ),
'comments_disabled' => array ( 'title' => PRFLAN_161 , 'type' => 'boolean' ),
'comments_emoticons' => array ( 'title' => PRFLAN_166 , 'type' => 'boolean' )
2009-11-04 03:07:44 +00:00
);
2009-11-23 04:03:40 +00:00
2009-11-04 03:07:44 +00:00
}
2009-11-04 03:37:56 +00:00
//TODO Block and Unblock buttons, moderated comments?
2009-11-04 03:07:44 +00:00
class comments_admin_form_ui extends e_admin_form_ui
{
function comment_type ( $curVal , $mode ) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
2009-11-04 23:47:15 +00:00
{
2009-11-05 00:11:56 +00:00
if ( $mode == 'read' )
2009-11-04 03:07:44 +00:00
{
return e107 :: getComment () -> getTable ( $curVal );
return $curVal . ' (custom!)' ;
}
if ( $mode == 'filter' ) // Custom Filter List for release_type
{
$sql = e107 :: getDb ();
$sql -> db_Select_gen ( 'SELECT * FROM #comments GROUP BY comment_type' );
while ( $row = $sql -> db_Fetch ())
{
$id = $row [ 'comment_type' ];
$list [ $id ] = e107 :: getComment () -> getTable ( $id );
}
return $list ;
}
if ( $mode == 'batch' )
{
$types = e107 :: getComment () -> known_types ;
2009-11-07 11:20:34 +00:00
asort ( $types );
2009-11-04 03:07:44 +00:00
return $types ;
}
}
}
new comments_admin ();
require_once ( e_ADMIN . " auth.php " );
2009-08-30 08:23:51 +00:00
2009-11-04 03:07:44 +00:00
e107 :: getAdminUI () -> runPage ();
2009-08-30 08:23:51 +00:00
2009-11-04 03:07:44 +00:00
require_once ( e_ADMIN . " footer.php " );
exit ;
2009-08-30 08:23:51 +00:00
2009-11-04 03:07:44 +00:00
/*
2009-05-08 21:50:19 +00:00
if ( e_QUERY )
{
2006-12-02 04:36:16 +00:00
$temp = explode ( " - " , e_QUERY );
$action = $temp [ 0 ];
$id = intval ( $temp [ 1 ]);
$item = $temp [ 2 ];
$c_item = $temp [ 3 ];
2009-05-08 21:50:19 +00:00
if ( $sql -> select ( 'comments' , '*' , 'comment_id=' . $id ))
{
$comment = $sql -> db_Fetch ();
if ( $action == " block " )
{
$sql -> db_Update ( " comments " , " comment_blocked='1' WHERE comment_id= " . $id );
2006-12-02 04:36:16 +00:00
}
2009-05-08 21:50:19 +00:00
if ( $action == " unblock " )
{
$sql -> db_Update ( " comments " , " comment_blocked='0' WHERE comment_id= " . $id );
}
if ( $action == " delete " )
{
$sql -> db_Delete ( " comments " , " comment_id= " . $id );
switch ( $comment [ 'comment_type' ])
{
case '0' :
case 'news' : // Need to update count in news record as well
$sql2 -> db_Update ( 'news' , 'news_comment_total = CAST(GREATEST(CAST(news_comment_total AS SIGNED) - 1, 0) AS UNSIGNED) WHERE news_id=' . $comment [ 'comment_item_id' ]);
break ;
2006-12-02 04:36:16 +00:00
}
}
2009-05-08 21:50:19 +00:00
if ( ! $e107cache -> clear ( $item ))
{
2006-12-02 04:36:16 +00:00
$tmp = explode ( " ? " , $item );
$item = $tmp [ 0 ] . " ?news. " . $c_item ;
$e107cache -> clear ( $item );
2009-05-08 21:50:19 +00:00
}
2006-12-02 04:36:16 +00:00
}
}
2009-08-30 08:23:51 +00:00
else
{
2009-11-04 03:07:44 +00:00
// $cm= new comment_manager;
// $cm->commentList();
2009-08-30 08:23:51 +00:00
}
// echo "<script type='text/javascript'>window.history.go(-1);</script>\n";
2009-11-04 03:07:44 +00:00
*/
2009-08-30 08:23:51 +00:00
2006-12-02 04:36:16 +00:00
?>