diff --git a/comment.php b/comment.php index ac62acca9..f98df23be 100644 --- a/comment.php +++ b/comment.php @@ -113,30 +113,35 @@ if(e_AJAX_REQUEST) // TODO improve security if(vartrue($_POST['comment'])) // ajax render comment { $pid = intval(varset($_POST['pid'], 0)); // ID of the specific comment being edited (nested comments - replies) - + $row = array(); $clean_authorname = $_POST['author_name']; $clean_comment = $_POST['comment']; $clean_subject = $_POST['subject']; $_SESSION['comment_author_name'] = $clean_authorname; - $newid = e107::getComment()->enter_comment($clean_authorname, $clean_comment, $_POST['table'], intval($_POST['itemid']), $pid, $clean_subject); + + $row['comment_item_id'] = intval($_POST['itemid']); + $row['comment_type'] = e107::getComment()->getCommentType($tp->toDB($_POST['table'],true)); + $row['comment_subject'] = $tp->toDB($_POST['subject']); + $row['comment_comment'] = $tp->toDB($_POST['comment']); + $row['user_image'] = USERIMAGE; + $row['user_id'] = (USERID) ? USERID : 0; + $row['user_name'] = USERNAME; + $row['comment_author_name'] = $tp->toDB($clean_authorname); + $row['comment_datestamp'] = time(); + $row['comment_blocked'] = (check_class($pref['comments_moderate']) ? 2 : 0); + $row['comment_share'] = ($_POST['comment_share']); + + $newid = e107::getComment()->enter_comment($row); + + + // $newid = e107::getComment()->enter_comment($clean_authorname, $clean_comment, $_POST['table'], intval($_POST['itemid']), $pid, $clean_subject); if(is_numeric($newid) && ($_GET['mode'] == 'submit')) { - $row = array(); - $row['comment_id'] = $newid; - $row['comment_item_id'] = intval($_POST['itemid']); - $row['comment_type'] = e107::getComment()->getCommentType($tp->toDB($_POST['table'],true)); - $row['comment_subject'] = $tp->toDB($_POST['subject']); - $row['comment_comment'] = $tp->toDB($_POST['comment']); - $row['user_image'] = USERIMAGE; - $row['user_id'] = (USERID) ? USERID : 0; - $row['user_name'] = USERNAME; - $row['comment_author_name'] = $tp->toDB($clean_authorname); - $row['comment_datestamp'] = time(); - $row['comment_blocked'] = (check_class($pref['comments_moderate']) ? 2 : 0); + $row['comment_id'] = $newid; $width = ($pid) ? 5 : 0; $ret['html'] = "\n\n"; diff --git a/e107_admin/sql/core_sql.php b/e107_admin/sql/core_sql.php index 5778bf0ed..e642f7fdd 100644 --- a/e107_admin/sql/core_sql.php +++ b/e107_admin/sql/core_sql.php @@ -103,6 +103,7 @@ CREATE TABLE comments ( comment_ip varchar(45) NOT NULL default '', comment_type varchar(20) NOT NULL default '0', comment_lock tinyint(1) unsigned NOT NULL default '0', + comment_share tinyint(1) unsigned NOT NULL default '0', PRIMARY KEY (comment_id), KEY comment_blocked (comment_blocked), KEY comment_author_id (comment_author_id) diff --git a/e107_core/shortcodes/batch/comment_shortcodes.php b/e107_core/shortcodes/batch/comment_shortcodes.php index 8b1ec1f47..9d7a56697 100644 --- a/e107_core/shortcodes/batch/comment_shortcodes.php +++ b/e107_core/shortcodes/batch/comment_shortcodes.php @@ -372,6 +372,15 @@ class comment_shortcodes extends e_shortcode $SIGNATURE = (isset($this->var['user_signature']) && $this->var['user_signature'] ? $tp->toHTML($this->var['user_signature'], true) : ''); return $SIGNATURE; } + + function sc_comment_share($parm='') + { + return e107::getForm()->checkbox('comment_share',1,true). "Share on Facebook"; + + } + + + } /* diff --git a/e107_handlers/comment_class.php b/e107_handlers/comment_class.php index 44adf53e1..bd5bd8dbf 100644 --- a/e107_handlers/comment_class.php +++ b/e107_handlers/comment_class.php @@ -563,7 +563,7 @@ class comment * Add a comment to an item * e-token POST value should be always valid when using this method. * - * @param unknown_type $author_name + * @param string or array $data - $author_name or array of all values. * @param unknown_type $comment * @param unknown_type $table * @param integer $id - reference of item in source table to which comment is linked @@ -573,9 +573,27 @@ class comment */ - function enter_comment($author_name, $comment, $table, $id, $pid, $subject, $rateindex = FALSE) + function enter_comment($data, $comment='', $table='', $id='', $pid='', $subject='', $rateindex = FALSE) { //rateindex : the posted value from the rateselect box (without the urljump) (see function rateselect()) + + if(is_array($data)) + { + $table = $data['comment_type']; + $id = intval($data['comment_item_id']); + $pid = intval($data['comment_pid']); + $subject = $data['comment_subject']; + $comment = $data['comment_comment']; + $author_name = $data['comment_author_name']; + $comment_share = intval($data['comment_share']); + $comment_datestamp = $data['comment_datestamp']; + } + else + { + $author_name = $data; //BC Fix. + } + + global $e_event,$e107,$rater; $sql = e107::getDb(); @@ -673,7 +691,8 @@ class comment 'comment_blocked' => ($this->moderateComment($pref['comments_moderate']) ? 2 : 0), 'comment_ip' => $ip, 'comment_type' => $tp->toDB($type, true), - 'comment_lock' => 0 //Not locked by default + 'comment_lock' => 0,//Not locked by default + 'comment_share' => $comment_share ); //SecretR: new event 'prepostcomment' - allow plugin hooks - e.g. Spam Check diff --git a/e107_themes/templates/comment_template.php b/e107_themes/templates/comment_template.php index 641a4059b..4fb3c4841 100644 --- a/e107_themes/templates/comment_template.php +++ b/e107_themes/templates/comment_template.php @@ -77,8 +77,11 @@ $sc_style['AUTHOR_INPUT']['post'] = ""; $sc_style['COMMENT_INPUT']['pre'] = "";// COMLAN_8 $sc_style['COMMENT_INPUT']['post'] = ""; -$sc_style['COMMENT_BUTTON']['pre'] = "
"; +$sc_style['COMMENT_BUTTON']['pre'] = ""; +$sc_style['COMMENT_BUTTON']['post'] = ""; + +$sc_style['COMMENT_SHARE']['pre'] = ""; +$sc_style['COMMENT_SHARE']['post'] = ""; $sc_style['COMMENT_RATE']['pre'] = '