diff --git a/e107_admin/comment.php b/e107_admin/comment.php
index 546653403..447c1d2ce 100644
--- a/e107_admin/comment.php
+++ b/e107_admin/comment.php
@@ -82,16 +82,17 @@ class comments_admin_ui extends e_admin_ui
protected $fields = array(
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
'comment_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE),
- 'comment_item_id' => array('title'=> "item id", 'type' => 'number', 'width' => '5%'),
+ 'comment_type' => array('title'=> "Type", 'type' => 'method', 'width' => '10%', 'filter'=>TRUE),
+
+ 'comment_item_id' => array('title'=> "item id", 'type' => 'number', 'width' => '5%'),
'comment_subject' => array('title'=> "subject", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left first'), // Display name
'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
- '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
+ 'comment_datestamp' => array('title'=> LAN_DATESTAMP, 'type' => 'datestamp', 'width' => 'auto'), // User date
+ 'comment_blocked' => array('title'=> "Status", 'type' => 'method', 'data'=> 'int', 'thclass' => 'center', 'class'=>'center', 'filter' => true, 'batch' => true, 'width' => 'auto'), // Photo
'comment_ip' => array('title'=> "IP", 'type' => 'ip', 'width' => '10%', 'thclass' => 'center' ), // Real name (no real vetting)
- 'comment_type' => array('title'=> "Type", 'type' => 'method', 'width' => '10%', 'filter'=>TRUE),
'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')
);
@@ -144,6 +145,27 @@ class comments_admin_form_ui extends e_admin_form_ui
return $types;
}
}
+
+ function comment_blocked($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function.
+ {
+
+
+
+ if($mode == 'read')
+ {
+ $blocked = array("","blocked","pending");
+ return $blocked[$curVal];
+ }
+
+ if($mode == 'filter' || $mode == 'batch') // Custom Filter List for release_type
+ {
+ $blocked = array("approved","blocked","pending");
+ return $blocked;
+ }
+
+ }
+
+
}
new comments_admin();
diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php
index 5528697bb..153819f1b 100644
--- a/e107_admin/prefs.php
+++ b/e107_admin/prefs.php
@@ -1312,6 +1312,13 @@ $text .= "
+
+ Moderate Comments:
+
+ ".$frm->radio_switch('comments_moderate', $pref['comments_moderate'], LAN_YES, LAN_NO)."
+
+
+
diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php
index 51c1e54e6..56d9d1c64 100644
--- a/e107_core/shortcodes/batch/comment_shortcodes.php
+++ b/e107_core/shortcodes/batch/comment_shortcodes.php
@@ -2,7 +2,7 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2009 e107 Inc (e107.org)
+ * Copyright (C) 2008-2012 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
@@ -15,28 +15,49 @@
*/
if (!defined('e107_INIT')) { exit; }
-//include_once(e_HANDLER.'shortcode_handler.php');
-//$comment_shortcodes = e107::getScParser()->parse_scbatch(__FILE__);
class comment_shortcodes extends e_shortcode
{
var $var;
- function sc_subject($parm)
+ function sc_subject_input($parm)
{
+ $tp = e107::getParser();
+ $pref = e107::getPref();
- global $SUBJECT, $comrow, $pref, $NEWIMAGE, $tp;
- if (isset($pref['nested_comments']) && $pref['nested_comments']) {
- $SUBJECT = $NEWIMAGE." ".(empty($this->var['comment_subject']) ? $subject : $tp->toHTML($this->var['comment_subject'], TRUE));
- } else {
- $SUBJECT = '';
+ if(vartrue($pref['nested_comments']))
+ {
+ return "";
}
- return $SUBJECT;
+
+ return;
}
- function sc_username($parm)
+
+ function sc_subject($parm)
{
+ $tp = e107::getParser();
+ $pref = e107::getPref();
+
+ global $SUBJECT, $NEWIMAGE;
+
+ if (vartrue($pref['nested_comments']))
+ {
+ $SUBJECT = $NEWIMAGE." ".(empty($this->var['comment_subject']) ? $subject : $tp->toHTML($this->var['comment_subject'], TRUE));
+ }
+ else
+ {
+ $SUBJECT = '';
+ }
+
+ return $SUBJECT;
+
+ }
+
+
+ function sc_username($parm)
+ {
global $USERNAME;
if (isset($this->var['user_id']) && $this->var['user_id'])
{
@@ -52,19 +73,24 @@ class comment_shortcodes extends e_shortcode
}
- function sc_TIMEDATE($parm)
+ function sc_timedate($parm)
{
global $TIMEDATE, $datestamp, $gen;
$datestamp = $gen->convert_date($this->var['comment_datestamp'], "short");
return $datestamp;
}
+
function sc_reply($parm)
{
- global $REPLY, $action, $pref, $table, $id, $thisaction, $thistable, $thisid;
+ global $REPLY, $action, $table, $id, $thisaction, $thistable, $thisid;
+
+ $pref = e107::getPref();
$REPLY = '';
- if($this->var['comment_lock'] != "1"){
- if ($thisaction == "comment" && $pref['nested_comments']) {
+ if($this->var['comment_lock'] != "1" && $this->var['comment_blocked'] < 1)
+ {
+ if ($thisaction == "comment" && $pref['nested_comments'])
+ {
$REPLY = "".COMLAN_326." ";
}
}
@@ -105,9 +131,7 @@ class comment_shortcodes extends e_shortcode
function sc_avatar($parm)
{
-
-
-
+
// --------- Legacy Code below for those who still want to use it.
global $AVATAR;
@@ -125,12 +149,14 @@ class comment_shortcodes extends e_shortcode
return $this->var['user_image'];
}
+
function sc_comments($parm)
{
global $COMMENTS;
return (isset($this->var['user_id']) && $this->var['user_id'] ? COMLAN_99.": ".$this->var['user_comments'] : COMLAN_194)." ";
}
+
function sc_joined($parm)
{
global $JOINED, $gen;
@@ -142,28 +168,134 @@ class comment_shortcodes extends e_shortcode
return $JOINED;
}
+
+ function sc_comment_itemid($parm) // for ajax item id.
+ {
+ return 'comment-'.intval($this->var['comment_id']);
+ }
+
+ function sc_comment_moderate($parm)
+ {
+ if(!getperms('0') && !getperms("B"))
+ {
+ return;
+ }
+
+ $url = e_PAGE."?".e_QUERY;
+
+ $unblock = "[".COMLAN_1." ] ";
+ $block = "[".COMLAN_2." ] ";
+ $delete = "[".COMLAN_3." ] ";
+ $userinfo = "[".COMLAN_4." ]";
+
+ return $unblock.$block.$delete.$userinfo;
+ }
+
+
+
+ function sc_comment_button($parm)
+ {
+ if($this->mode == 'edit')
+ {
+ return " var['eaction'] == "edit" ? COMLAN_320 : COMLAN_9)."' />";
+ }
+
+ }
+
+
+ function sc_author_input($parm)
+ {
+ if($this->mode == 'edit')
+ {
+ if (ANON == TRUE && USER == FALSE) // (anonymous comments - if allowed)
+ {
+ return "";
+ }
+ }
+ }
+
+
+ function sc_rate_input($parm)
+ {
+ return $this->var['rate'];
+ }
+
+
+ function sc_comment_input($parm)
+ {
+ $options = array(
+ 'class' => 'tbox input comment-input',
+ 'placeholder' => "Leave a message..." // TODO Lan
+ );
+
+ if($parm == 'bbcode')
+ {
+ return e107::getForm()->bbarea('comment',$this->var['comval'],'comment','comment-'.$this->var['itemid'],'large',$options);
+ }
+ else
+ {
+ return e107::getForm()->textarea('comment',$this->var['comval'], 5, 80,$options);
+ }
+ }
+
+
+ function sc_user_avatar($parm)
+ {
+ $this->var['user_id'] = USERID;
+ $this->var['user_image'] = USERIMAGE;
+ return $this->sc_comment_avatar($parm);
+ }
+
+
function sc_comment($parm)
{
- global $COMMENT, $pref;
+ // global $COMMENT, $pref;
$tp = e107::getParser();
- return (isset($this->var['comment_blocked']) && $this->var['comment_blocked'] ? COMLAN_0 : $tp->toHTML($this->var['comment_comment'], TRUE, FALSE, $this->var['user_id']));
+ if($this->var['comment_blocked'] == 1)
+ {
+ return COMLAN_0;
+ }
+
+ return $tp->toHTML($this->var['comment_comment'], TRUE, FALSE, $this->var['user_id']);
}
+ function sc_comment_status($parm)
+ {
+ switch ($this->var['comment_blocked'])
+ {
+ case 2:
+ return "Pending Approval"; // TODO LAN
+ break;
+
+ case 1:
+ return COMLAN_0;
+ break;
+
+ default:
+
+ break;
+ }
+ }
+
+
+
function sc_commentedit($parm)
{
- global $COMMENTEDIT, $pref, $comment_edit_query;
- if ($pref['allowCommentEdit'] && USER && $this->var['user_id'] == USERID && $this->var['comment_lock'] != "1")
+ global $COMMENTEDIT, $comment_edit_query;
+ $pref = e107::getPref();
+
+ if ($pref['allowCommentEdit'] && USER && $this->var['user_id'] == USERID && ($this->var['comment_lock'] < 1))
{
- $adop_icon = (file_exists(THEME."images/commentedit.png") ? THEME_ABS."images/commentedit.png" : e_IMAGE_ABS."admin_images/edit_16.png");
+ $adop_icon = (file_exists(THEME."images/commentedit.png") ? " " : "Edit");
//Searching for '.' is BAD!!! It breaks mod rewritten requests. Why is this needed at all?
if (strstr(e_QUERY, "&"))
{
- return " ";
+ return "";
}
else
{
// return " ";
- return " ";
+ return "";
}
}
else
@@ -172,12 +304,14 @@ class comment_shortcodes extends e_shortcode
}
}
+
function sc_rating($parm)
{
global $RATING;
return $RATING;
}
+
function sc_ipaddress($parm)
{
global $IPADDRESS, $e107;
@@ -185,6 +319,7 @@ class comment_shortcodes extends e_shortcode
return (ADMIN ? "".COMLAN_330." ".e107::getIPHandler()->ipDecode($this->var['comment_ip'])." " : "");
}
+
function sc_level($parm)
{
global $LEVEL, $pref;
@@ -193,6 +328,7 @@ class comment_shortcodes extends e_shortcode
return ($this->var['user_admin'] ? $ldata[0] : $ldata[1]);
}
+
function sc_location($parm)
{
global $LOCATION;
@@ -200,6 +336,7 @@ class comment_shortcodes extends e_shortcode
return (isset($this->var['user_location']) && $this->var['user_location'] ? COMLAN_313.": ".$tp->toHTML($this->var['user_location'], TRUE) : '');
}
+
function sc_signature($parm)
{
global $SIGNATURE;
diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml
index c7ca21128..f5e8f25ff 100644
--- a/e107_core/xml/default_install.xml
+++ b/e107_core/xml/default_install.xml
@@ -25,6 +25,7 @@
0
0
0
+ 0
0
0
e107cookie
diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php
index 4f8ce7144..ad2773b39 100644
--- a/e107_handlers/comment_class.php
+++ b/e107_handlers/comment_class.php
@@ -51,12 +51,60 @@ class comment
{
require_once(e107::coreTemplatePath('comment'));
}
- else // BC
+ elseif(!$COMMENT_TEMPLATE) // BC template.
{
+ global $sc_style;
+ /*
+ $COMMENTSTYLE = "
+
+
+
+
+
+
+ {AVATAR}{COMMENTS}{JOINED}
+
+
+ {COMMENT}
+ {RATING}
+ {IPADDRESS}
+ {LEVEL}
+ {LOCATION}
+ {SIGNATURE}
+
+
+
+ ";
+ */
$COMMENT_TEMPLATE['ITEM_START'] = "";
$COMMENT_TEMPLATE['ITEM'] = $COMMENTSTYLE;
$COMMENT_TEMPLATE['ITEM_END'] = "";
$COMMENT_TEMPLATE['LAYOUT'] = "{COMMENTS}{COMMENTFORM}{MODERATE}";
+ $COMMENT_TEMPLATE['FORM'] = "
+ {SUBJECT_INPUT}
+ {AUTHOR_INPUT}
+ {RATE_INPUT}
+ {COMMENT_INPUT}
+ {COMMENT_BUTTON}
+
";
+
+ $sc_style['SUBJECT_INPUT']['pre'] = "".COMLAN_324." ";
+ $sc_style['SUBJECT_INPUT']['post'] = " ";
+
+ $sc_style['AUTHOR_INPUT']['pre'] = "".COMLAN_16." ";
+ $sc_style['AUTHOR_INPUT']['post'] = " ";
+
+ $sc_style['RATE_INPUT']['pre'] = "".COMLAN_327.": ";
+ $sc_style['RATE_INPUT']['post'] = " ";
+
+ $sc_style['COMMENT_INPUT']['pre'] = "".COMLAN_8.": ";
+
+ $sc_style['COMMENT_BUTTON']['pre'] = " ";
+
}
$this->template = $COMMENT_TEMPLATE;
@@ -78,8 +126,12 @@ class comment
function form_comment($action, $table, $id, $subject, $content_type, $return = FALSE, $rating = FALSE, $tablerender = TRUE)
{
//rating : boolean, to show rating system in comment
- global $pref, $sql, $tp;
- if(isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
+
+ $pref = e107::getPref();
+ $sql = e107::getDb();
+ $tp = e107::getParser();
+
+ if(vartrue($pref['comments_disabled']))
{
return;
}
@@ -98,24 +150,7 @@ class comment
//FIXME - e_REQUEST_URI?
//e_SELF."?".e_QUERY
- $text = "\n";
-
- //TODO Add Template
-
if ($tablerender)
{
$text = $ns->tablerender($caption, $text, '', TRUE);
@@ -258,13 +298,13 @@ class comment
global $thisaction,$thistable,$thisid,$e107;
- if (isset($pref['comments_disabled']) && $pref['comments_disabled'] == TRUE)
+ if (vartrue($pref['comments_disabled']))
{
return;
}
$comrow = $row;
- e107::getScBatch('comment')->setParserVars($row);
+
$thistable = $table;
$thisid = $id;
@@ -292,21 +332,14 @@ class comment
define("IMAGE_new_comments", (file_exists(THEME."images/new_comments.png") ? " " : " "));
}
- $ns = new e107table;
+// $ns = new e107table;
if (!$gen || !is_object($gen))
{
$gen = new convert;
- }
-
- $url = e_PAGE."?".e_QUERY;
-
- $unblock = "[".COMLAN_1." ] ";
- $block = "[".COMLAN_2." ] ";
- $delete = "[".COMLAN_3." ] ";
- $userinfo = "[".COMLAN_4." ]";
-
+ }
+ e107::getScBatch('comment')->setParserVars($row);
$COMMENT_TEMPLATE = $this->template;
if ($pref['nested_comments'])
@@ -314,24 +347,10 @@ class comment
$width2 = 100 - $width;
$total_width = "95%";
if ($width)
- {
-
-
+ {
$renderstyle = $COMMENT_TEMPLATE['ITEM_START'];
$renderstyle .= "".$COMMENT_TEMPLATE['ITEM']."
";
- $renderstyle .= $COMMENT_TEMPLATE['ITEM_END'];
-
- /*
- $renderstyle = "
-
-
-
- ".$COMMENTSTYLE."
-
-
-
";
- * */
-
+ $renderstyle .= $COMMENT_TEMPLATE['ITEM_END'];
}
else
{
@@ -399,6 +418,8 @@ class comment
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
WHERE comment_item_id='".intval($thisid)."' AND comment_type='".$tp->toDB($type, true)."' AND comment_pid='".intval($comrow['comment_id'])."'
+ AND (c.comment_blocked = 0 OR (c.comment_blocked > 0 AND c.comment_author_id = ".intval(USERID)."))
+
ORDER BY comment_datestamp
";
$sql_nc = new db; /* a new db must be created here, for nested comment */
@@ -438,12 +459,13 @@ class comment
function enter_comment($author_name, $comment, $table, $id, $pid, $subject, $rateindex = FALSE)
{
//rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect())
- global $e_event,$e107,$pref,$rater;
+ global $e_event,$e107,$rater;
$sql = e107::getDb();
$sql2 = e107::getDb('sql2');
$tp = e107::getParser();
$e107cache = e107::getCache();
+ $pref = e107::getPref();
if ($this->getCommentPermissions() != 'rw') return;
@@ -530,7 +552,7 @@ class comment
'comment_author_email' => $tp->toDB($cuser_mail),
'comment_datestamp' => $_t,
'comment_comment' => $comment,
- 'comment_blocked' => 0, //Not blocked by default
+ 'comment_blocked' => (vartrue($pref['comments_moderate']) ? 2 : 0),
'comment_ip' => $ip,
'comment_type' => $tp->toDB($type, true),
'comment_lock' => 0 //Not locked by default
@@ -760,12 +782,17 @@ class comment
"SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
- WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' AND c.comment_pid='0' ORDER BY c.comment_datestamp"
+ WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' AND c.comment_pid='0'
+ AND (c.comment_blocked = 0 OR (c.comment_blocked > 0 AND c.comment_author_id = ".intval(USERID)."))
+ ORDER BY c.comment_datestamp"
:
"SELECT c.*, u.*, ue.* FROM #comments AS c
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
LEFT JOIN #user_extended AS ue ON c.comment_author_id = ue.user_extended_id
- WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."' ORDER BY c.comment_datestamp";
+ WHERE c.comment_item_id='".intval($id)."' AND c.comment_type='".$tp->toDB($type, true)."'
+ AND (c.comment_blocked = 0 OR (c.comment_blocked > 0 AND c.comment_author_id = ".intval(USERID)."))
+
+ ORDER BY c.comment_datestamp";
$text = "";
$comment = '';
@@ -801,7 +828,10 @@ class comment
if (ADMIN && getperms("B"))
{
- $modcomment = " ";
+ $modcomment = "";
}
}
diff --git a/e107_themes/templates/comment_template.php b/e107_themes/templates/comment_template.php
index 0dfcd3ebd..ed7d9328d 100644
--- a/e107_themes/templates/comment_template.php
+++ b/e107_themes/templates/comment_template.php
@@ -17,7 +17,7 @@
if (!defined('e107_INIT')) { exit; }
if (!defined("USER_WIDTH")){ define("USER_WIDTH", "width:100%"); }
-global $sc_style, $comment_shortcodes;
+global $sc_style;
global $pref, $comrow, $row2, $tp, $NEWIMAGE, $USERNAME, $RATING;
$sc_style['SUBJECT']['pre'] = "";
@@ -29,11 +29,8 @@ $sc_style['USERNAME']['post'] = " ";
$sc_style['TIMEDATE']['pre'] = "";
$sc_style['TIMEDATE']['post'] = "";
-$sc_style['REPLY']['pre'] = "";
-$sc_style['REPLY']['post'] = "";
-
-$sc_style['AVATAR']['pre'] = "";
-$sc_style['AVATAR']['post'] = "
";
+$sc_style['AVATAR']['pre'] = "";
+$sc_style['AVATAR']['post'] = "";
$sc_style['COMMENTS']['pre'] = "";
$sc_style['COMMENTS']['post'] = " ";
@@ -59,115 +56,91 @@ $sc_style['LOCATION']['post'] = " ";
$sc_style['SIGNATURE']['pre'] = "";
$sc_style['SIGNATURE']['post'] = " ";
-/*
-$COMMENTSTYLE = "
-
-
-
-
-
-
- {AVATAR}{COMMENTS}{JOINED}
-
-
- {COMMENT}
- {RATING}
- {IPADDRESS}
- {LEVEL}
- {LOCATION}
- {SIGNATURE}
-
-
-
- ";
-*/
+
// from e107.org
+$sc_style['REPLY']['pre'] = "";
-
-$sc_style['COMMENTEDIT']['pre'] = '
';
+$sc_style['COMMENTEDIT']['pre'] = '';
$sc_style['COMMENT_AVATAR']['pre'] = '';
$sc_style['COMMENT_AVATAR']['post'] = '
';
+$sc_style['SUBJECT_INPUT']['pre'] = ""; //COMLAN_324
+$sc_style['SUBJECT_INPUT']['post'] = "";
+
+$sc_style['AUTHOR_INPUT']['pre'] = ""; // COMLAN_16
+$sc_style['AUTHOR_INPUT']['post'] = "";
+
+$sc_style['RATE_INPUT']['pre'] = "".COMLAN_327."";
+$sc_style['RATE_INPUT']['post'] = "";
+
+$sc_style['COMMENT_INPUT']['pre'] = "";// COMLAN_8
+$sc_style['COMMENT_INPUT']['post'] = "";
+
+$sc_style['COMMENT_BUTTON']['pre'] = "";
+
+$sc_style['USER_AVATAR']['pre'] = '';
+$sc_style['USER_AVATAR']['post'] = '
';
+
+
+
+
+$COMMENT_TEMPLATE['FORM'] = "
+
+
";
+
$COMMENT_TEMPLATE['ITEM'] = '
-