1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

Bit of work on the comments manager

This commit is contained in:
CaMer0n 2009-11-04 03:07:44 +00:00
parent d9b92d401a
commit ac57a2aee3
5 changed files with 167 additions and 134 deletions

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/comment.php,v $
| $Revision: 1.6 $
| $Date: 2009-09-29 17:43:13 $
| $Author: secretr $
| $Revision: 1.7 $
| $Date: 2009-11-04 03:07:39 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
@ -22,11 +22,122 @@ if (!getperms("B"))
header("location:".e_BASE."index.php");
exit;
}
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'),
'main/options' => array('caption'=> 'Settings', 'perm' => '0'),
// '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;
protected $pluginName = 'comments';
protected $table = "comments";
protected $pid = "comment_id";
protected $perPage = 20;
protected $batchDelete = true;
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'comment_id' => array('title'=> ID, 'type' => 'int', 'width' =>'5%', 'forced'=> TRUE, 'primary'=>TRUE),
'comment_item_id' => array('title'=> "item id", 'type' => 'text', 'width' => 'auto'),
'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name
'comment_author_id' => array('title'=> "authorID", 'type' => 'text', 'width' => 'auto'), // User name
'comment_author_name' => array('title'=> "authorName", 'type' => 'text', 'width' => 'auto'), // User name
'comment_comment' => array('title'=> "comment", 'type' => 'text', 'width' => 'auto'), // Display name
'comment_datestamp' => array('title'=> "datestamp", 'type' => 'text', 'width' => 'auto'), // User name
'comment_blocked' => array('title'=> "blocked", 'type' => 'text', 'width' => 'auto'), // Photo
'comment_ip' => array('title'=> "IP", 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)
'comment_type' => array('title'=> "Type", 'type' => 'method', 'width' => '10%', 'thclass' => 'center', 'filter'=>TRUE,'batch'=>TRUE ), // No real vetting
'comment_lock' => array('title'=> "Lock", 'type' => 'text', 'width' => 'auto'),
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center')
);
//required (but should be optional) - default column user prefs
protected $fieldpref = array('checkboxes', 'comment_id', 'comment_item_id', 'comment_author_id', 'comment_author_name', 'comment_subject', 'comment_type', 'options');
// optional, if $pluginName == 'core', core prefs will be used, else e107::getPluginConfig($pluginName);
protected $prefs = array(
'pref_type' => array('title'=> 'type', 'type'=>'text'),
'pref_folder' => array('title'=> 'folder', 'type' => 'boolean'),
'pref_name' => array('title'=> 'name', 'type' => 'text')
);
protected $listQry = "SELECT * FROM #comments"; // without any Order or Limit.
protected $editQry = "SELECT * FROM #comments WHERE comment_id = {ID}";
}
//TODO Block and Unblock buttons
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.
{
if($mode == 'list')
{
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;
sort($types);
return $types;
}
}
}
new comments_admin();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php");
exit;
/*
if (e_QUERY)
{
$temp = explode("-", e_QUERY);
@ -66,107 +177,15 @@ if (e_QUERY)
}
else
{
$cm= new comment_manager;
$cm->commentList();
// $cm= new comment_manager;
// $cm->commentList();
}
// echo "<script type='text/javascript'>window.history.go(-1);</script>\n";
require_once(e_ADMIN."footer.php");
class comment_manager
{
var $fields;
var $fieldpref;
function comment_manager()
{
global $user_pref;
$this->fieldpref = (varset($user_pref['admin_cpage_columns'])) ? $user_pref['admin_cpage_columns'] : array("comment_id","comment_pid","comment_item_id","comment_subject","comment_comment","comment_author","comment_datestamp");
//TODO Add LANS
$this->fields = array(
'comment_id' => array('title'=> ID, 'width'=>'5%', 'forced'=> TRUE),
'comment_item_id' => array('title'=> "item id", 'type' => 'text', 'width' => 'auto'),
'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name
'comment_author' => array('title'=> "author", 'type' => 'text', 'width' => 'auto'), // User name
'comment_comment' => array('title'=> "comment", 'type' => 'text', 'width' => 'auto'), // Display name
'comment_datestamp' => array('title'=> "date", 'type' => 'text', 'width' => 'auto'), // User name
'comment_blocked' => array('title'=> "blocked", 'type' => 'text', 'width' => 'auto'), // Photo
'comment_ip' => array('title'=> "IP", 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)
'comment_type' => array('title'=> "Type", 'type' => 'text', 'width' => '10%', 'thclass' => 'center' ), // No real vetting
'comment_lock' => array('title'=> "Lock", 'type' => 'text', 'width' => 'auto'),
// 'page_ip_restrict' => array('title'=> LAN_USER_07, 'type' => 'text', 'width' => 'auto'), // Avatar
'options' => array('title'=> LAN_OPTIONS, 'forced'=>TRUE, 'width' => '10%', 'thclass' => 'center last')
);
}
function commentList()
{
global $pref;
$sql = e107::getDb();
$frm = e107::getSingleton('e_form');
$sql -> db_Select("comments", "*");
$text = "<form method='post' action='".e_SELF."?".e_QUERY."'>
<fieldset id='core-comment-list'>
<legend class='e-hideme'>".CUSLAN_5."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>".
$frm->colGroup($this->fields,$this->fieldpref).
$frm->thead($this->fields,$this->fieldpref).
"<tbody>";
while($row = $sql-> db_Fetch())
{
$text .= "<tr>
<td>{$row['comment_id']}</td>";
$text .= (in_array("comment_item_id",$this->fieldpref)) ? "<td>".($row['comment_item_id'])."</td>" : "";
$text .= (in_array("comment_subject",$this->fieldpref)) ? "<td>".($row['comment_subject'])."</td>" : "";
$text .= (in_array("comment_author",$this->fieldpref)) ? "<td>".($row['comment_author_name'])."</td>" : "";
$text .= (in_array("comment_comment",$this->fieldpref)) ? "<td>".($row['comment_comment'])."</td>" : "";
$text .= (in_array("comment_datestamp",$this->fieldpref)) ? "<td>".strftime($pref['shortdate'],$row['comment_datestamp'])."</td>" : "";
$text .= (in_array("comment_ip",$this->fieldpref)) ? "<td>".($row['comment_ip'])."</td>" : "";
$text .= (in_array("comment_type",$this->fieldpref)) ? "<td class='center'>".($row['comment_type'])."</td>" : "";
$text .= (in_array("comment_lock",$this->fieldpref)) ? "<td class='center'>".($row['comment_lock'] ? ADMIN_TRUE_ICON : "&nbsp;")."</td>" : "";
}
$text .= "
</tbody>
</table>
</fieldset>
</form>
";
e107::getRender()->tablerender($caption,$text);
}
*/
}
?>

View File

@ -9,8 +9,8 @@
* Core SQL
*
* $Source: /cvs_backup/e107_0.8/e107_admin/sql/core_sql.php,v $
* $Revision: 1.29 $
* $Date: 2009-10-26 09:53:09 $
* $Revision: 1.30 $
* $Date: 2009-11-04 03:07:39 $
* $Author: e107coders $
*/
@ -271,7 +271,7 @@ CREATE TABLE online (
online_flag tinyint(3) unsigned NOT NULL default '0',
online_user_id varchar(100) NOT NULL default '',
online_ip varchar(45) NOT NULL default '',
online_location varchar(100) NOT NULL default '',
online_location varchar(1024) NOT NULL default '',
online_pagecount tinyint(3) unsigned NOT NULL default '0',
online_active int(10) unsigned NOT NULL default '0'
) TYPE=MyISAM;

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/comment_class.php,v $
| $Revision: 1.31 $
| $Date: 2009-11-03 20:57:10 $
| $Author: e107steved $
| $Revision: 1.32 $
| $Date: 2009-11-04 03:07:39 $
| $Author: e107coders $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT'))
@ -31,6 +31,16 @@ require_once (e_FILE."shortcode/batch/comment_shortcodes.php");
class comment
{
public $known_types = array(
0 => "news",
1 => 'content',
2 => 'download',
3 => 'faq',
4 => 'poll',
5 => 'docs',
6 => 'bugtrack'
);
/**
* Display the comment editing form
*
@ -571,31 +581,13 @@ class comment
{
return $type;
}
switch ($type)
else
{
case '0':
$type = "news";
break;
case '1':
$type = 'content';
break;
case '2':
$type = 'download';
break;
case '3':
$type = 'faq';
break;
case '4':
$type = 'poll';
break;
case '5':
$type = 'docs';
break;
case '6':
$type = 'bugtrack';
break;
if(varset($this->known_types[$type]))
{
return $this->known_types[$type];
}
}
return $type;
}
/**

View File

@ -9,9 +9,9 @@
* e107 Main
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/e107_class.php,v $
* $Revision: 1.62 $
* $Date: 2009-10-31 17:57:15 $
* $Author: secretr $
* $Revision: 1.63 $
* $Date: 2009-11-04 03:07:39 $
* $Author: e107coders $
*/
if (!defined('e107_INIT')) { exit; }
@ -134,6 +134,7 @@ class e107
'e_admin_ui' => '{e_HANDLER}admin_handler.php',
'e_admin_form_ui' => '{e_HANDLER}admin_handler.php',
'DHTML_Calendar' => '{e_HANDLER}calendar/calendar_class.php',
'comment' => '{e_HANDLER}comment_class.php',
);
/**
@ -803,9 +804,17 @@ class e107
return self::getSingleton('notify', true);
}
/**
* Retrieve Xml handler singleton object
* @return e_online
*/
public static function getXml()
{
return self::getSingleton('xmlClass', true);
}
/**
* Retrieve online users handler singleton object
*
* @return e_online
*/
public static function getOnline()
@ -813,9 +822,18 @@ class e107
return self::getSingleton('e_online', true);
}
/**
* Retrieve comments handler singleton object
* @return comment
*/
public static function getComment()
{
return self::getSingleton('comment', true);
}
/**
* Retrieve message handler singleton
*
* @return eMessage
*/
public static function getMessage()

View File

@ -1,7 +1,7 @@
<?php
/*
* Copyright e107 Inc e107.org, Licensed under GNU GPL (http://www.gnu.org/licenses/gpl.txt)
* $Id: lan_admin.php,v 1.31 2009-10-23 18:14:42 secretr Exp $
* $Id: lan_admin.php,v 1.32 2009-11-04 03:07:44 e107coders Exp $
*
* Admin Language File
*/
@ -304,3 +304,7 @@ define("LAN_IMAGEMANAGER", "Image Manager");
define("LAN_MOREINFO","More Information...");
define("LAN_COMMENTMAN", "Comments Manager");
define("LAN_FILTER", "Filter");
define("LAN_NO_RECORDS", "No Records Found");