| 1 |
<?php |
<?php |
| 2 |
// $Id: comment_subscribe.module,v 1.2.2.3 2008/12/22 09:40:51 zyxware Exp $ |
// $Id: comment_subscribe.module,v 1.2.2.4 2008/12/27 05:44:52 zyxware Exp $ |
| 3 |
|
|
| 4 |
/** |
/** |
| 5 |
* @file |
* @file |
| 72 |
$items = array(); |
$items = array(); |
| 73 |
global $user; |
global $user; |
| 74 |
$items['admin/content/comment_subscribe'] = array( |
$items['admin/content/comment_subscribe'] = array( |
| 75 |
'title' => t('Comment Subscribe'), |
'title' => t('Comment Subscribe'), |
| 76 |
'description' => t('Comment follow-up mail subscription.'), |
'description' => t('Comment follow-up mail subscription.'), |
| 77 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 78 |
'page arguments' => array('comment_subscribe_settings'), |
'page arguments' => array('comment_subscribe_settings'), |
| 79 |
'access arguments' => array('administer comment_subscribe'), |
'access arguments' => array('administer comment_subscribe'), |
| 80 |
'type' => MENU_NORMAL_ITEM, |
'type' => MENU_NORMAL_ITEM, |
| 81 |
'file' => 'comment_subscribe.admin.inc' |
'file' => 'comment_subscribe.admin.inc' |
| 82 |
); |
); |
| 83 |
$items['comment_subscribe'] = array( |
$items['comment_subscribe'] = array( |
| 84 |
'title' => t('Comment Subscribe') , |
'title' => t('Comment Subscribe') , |
| 85 |
'page callback' => 'comment_subscribe_page', |
'page callback' => 'comment_subscribe_page', |
| 86 |
'access callback' => 'user_access', |
'access callback' => 'user_access', |
| 87 |
'access arguments' => array('disable comments'), |
'access arguments' => array('disable comments'), |
| 88 |
'type' => MENU_CALLBACK |
'type' => MENU_CALLBACK |
| 89 |
); |
); |
| 90 |
return $items; |
return $items; |
| 91 |
} |
} |
| 92 |
/** |
/** |
| 120 |
$op = isset($_POST['op']) ? $_POST['op'] : ''; |
$op = isset($_POST['op']) ? $_POST['op'] : ''; |
| 121 |
if ($op == t('Preview')) { |
if ($op == t('Preview')) { |
| 122 |
drupal_set_message(t('ATTENTION: your comment is NOT YET posted - |
drupal_set_message(t('ATTENTION: your comment is NOT YET posted - |
| 123 |
please click the post button to confirm your post' ) |
please click the post button to confirm your post' ) |
| 124 |
); |
); |
| 125 |
//extra submit button on top |
//extra submit button on top |
| 126 |
if (!form_get_errors() && ((variable_get('comment_preview', |
if (!form_get_errors() && ((variable_get('comment_preview', |
| 127 |
COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) |
COMMENT_PREVIEW_REQUIRED) == COMMENT_PREVIEW_OPTIONAL) |
| 128 |
|| ($op == t('Preview')) || ($op == t('Save')))) { |
|| ($op == t('Preview')) || ($op == t('Save')))) { |
| 129 |
$form['submitextra'] = array( |
$form['submitextra'] = array( |
| 130 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 131 |
'#title' => t('Comment is not posted yet - please click |
'#title' => t('Comment is not posted yet - please click |
| 132 |
post button to confirm your post'), |
post button to confirm your post'), |
| 133 |
'#weight' => -99, |
'#weight' => -99, |
| 134 |
'#collapsible' => FALSE |
'#collapsible' => FALSE |
| 135 |
); |
); |
| 136 |
$form['submitextra']['submit'] = array('#type' => 'submit', |
$form['submitextra']['submit'] = array('#type' => 'submit', |
| 137 |
'#value' => t('Save'), '#weight' => -20); |
'#value' => t('Save'), '#weight' => -20); |
| 138 |
} |
} |
| 139 |
} |
} |
| 140 |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
| 141 |
$form['commentsubscribenode'] = array( |
$form['commentsubscribenode'] = array( |
| 142 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 143 |
'#prefix' => '<div id = "comment_suscribe">', |
'#prefix' => '<div id = "comment_suscribe">', |
| 144 |
'#suffix' => '</div>', |
'#suffix' => '</div>', |
| 145 |
'#title' => t('Email me about all replies to this article.'), |
'#title' => t('Email me about all replies to this article.'), |
| 146 |
'#default_value' => ($user->uid != 0)?$user->comment_subscribe_mailalert:variable_get |
'#default_value' => ($user->uid != 0)?$user->comment_subscribe_mailalert:variable_get |
| 147 |
("comment_subscribe_default_anon_mailalert", FALSE) |
("comment_subscribe_default_anon_mailalert", FALSE) |
| 148 |
); |
); |
| 149 |
} |
} |
| 150 |
else if ( ($user->uid == 0) || ( variable_get( |
else if ( ($user->uid == 0) || ( variable_get( |
| 151 |
"comment_subscribe_regged_checkbox", TRUE) ) ) { |
"comment_subscribe_regged_checkbox", TRUE) ) ) { |
| 152 |
$form['commentsubscribe'] = array( |
$form['commentsubscribe'] = array( |
| 153 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 154 |
'#prefix' => '<div id = "comment_suscribe">', |
'#prefix' => '<div id = "comment_suscribe">', |
| 155 |
'#suffix' => '</div>', |
'#suffix' => '</div>', |
| 156 |
'#title' => t('Email me about replies to this comment.'), |
'#title' => t('Email me about replies to this comment.'), |
| 157 |
'#default_value' => ($user->uid != 0)?$user->comment_subscribe_mailalert:variable_get |
'#default_value' => ($user->uid != 0)?$user->comment_subscribe_mailalert:variable_get |
| 158 |
("comment_subscribe_default_anon_mailalert", TRUE) |
("comment_subscribe_default_anon_mailalert", TRUE) |
| 159 |
); |
); |
| 160 |
} |
} |
| 161 |
else { |
else { |
| 183 |
$form['nodesubscribe'] = array( |
$form['nodesubscribe'] = array( |
| 184 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 185 |
'#prefix' => '<div id = "comment_suscribe">', |
'#prefix' => '<div id = "comment_suscribe">', |
| 186 |
'#suffix' => '</div>', |
'#suffix' => '</div>', |
| 187 |
'#title' => t('Email me about replies to this node.'), |
'#title' => t('Email me about replies to this node.'), |
| 188 |
'#default_value' => ($user->uid != 0?$subscribestatus:1) |
'#default_value' => ($user->uid != 0?$subscribestatus:1) |
| 189 |
); |
); |
| 212 |
'#type' => 'checkbox', |
'#type' => 'checkbox', |
| 213 |
'#title' => t('Receive comment follow-up notification e-mails'), |
'#title' => t('Receive comment follow-up notification e-mails'), |
| 214 |
'#default_value' => isset($edit['comment_subscribe_mailalert']) ? $edit['comment_subscribe_mailalert'] : 1, |
'#default_value' => isset($edit['comment_subscribe_mailalert']) ? $edit['comment_subscribe_mailalert'] : 1, |
| 215 |
'#description' => t('Check this box to receive e-mail notification for follow-up comments to comments you posted. ') |
'#description' => t('Check this box to receive e-mail notification for follow-up comments to comments you posted. ') |
| 216 |
); |
); |
| 217 |
return $form; |
return $form; |
| 218 |
} |
} |
| 227 |
switch($op) { |
switch($op) { |
| 228 |
case 'publish': |
case 'publish': |
| 229 |
//Converting array to object |
//Converting array to object |
| 230 |
if( is_array( $comment ) ) { |
if( is_array( $comment ) ) { |
| 231 |
|
|
| 232 |
$comment = (object)$comment; |
$comment = (object)$comment; |
| 233 |
} |
} |
| 234 |
_comment_subscribe_mailalert($comment); |
_comment_subscribe_mailalert($comment); |
| 235 |
break; |
break; |
| 236 |
case 'update': |
case 'update': |
| 237 |
//If node subscription is selected |
//If node subscription is selected |
| 238 |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
| 239 |
$sql = "update {z_commentsubscribe} set subscribenode =%d where |
$sql = "UPDATE {z_commentsubscribe} SET subscribenode =%d WHERE |
| 240 |
cid = %d"; |
cid = %d"; |
| 241 |
db_query($sql, $comment['commentsubscribenode'], $comment['cid']); |
db_query($sql, $comment['commentsubscribenode'], $comment['cid']); |
| 242 |
} |
} |
| 243 |
//If comment reply subscription is selected |
//If comment reply subscription is selected |
| 244 |
else { |
else { |
| 245 |
$sql = "update {z_commentsubscribe} set subscribe = %d where |
$sql = "UPDATE {z_commentsubscribe} SET subscribe = %d UPDATE |
| 246 |
cid = %d"; |
cid = %d"; |
| 247 |
db_query($sql, $comment['commentsubscribe'], $comment['cid']); |
db_query($sql, $comment['commentsubscribe'], $comment['cid']); |
| 248 |
} |
} |
| 249 |
break; |
break; |
| 250 |
case 'insert': |
case 'insert': |
| 251 |
case 'Save': |
case 'Save': |
| 252 |
//Get pid from comment for current cid ,get the parents for |
//Get pid from comment for current cid ,get the parents for |
| 253 |
//this cid |
//this cid |
| 254 |
$notifyval = 0; |
$notifyval = 0; |
| 255 |
$parentrslt = db_fetch_object(db_query("SELECT pid FROM |
$parentrslt = db_fetch_object(db_query("SELECT pid FROM |
| 256 |
{comments} |
{comments} |
| 257 |
WHERE cid = %d", $comment['cid'])); |
WHERE cid = %d", $comment['cid'])); |
| 258 |
$strparents = $parentrslt->pid.','; |
$strparents = $parentrslt->pid.','; |
| 259 |
$prvparnt = db_fetch_object(db_query("SELECT parents FROM |
$prvparnt = db_fetch_object(db_query("SELECT parents FROM |
| 260 |
{z_commentsubscribe} |
{z_commentsubscribe} |
| 261 |
WHERE cid = %d", $parentrslt->pid)); |
WHERE cid = %d", $parentrslt->pid)); |
| 262 |
$parents = $prvparnt->parents.$strparents; |
$parents = $prvparnt->parents.$strparents; |
| 263 |
//Checking which option is selected ie checking |
//Checking which option is selected ie checking |
| 264 |
//whether node reply or comment reply is chosen. |
//whether node reply or comment reply is chosen. |
| 265 |
//According to the selection flag subscription is saved. |
//According to the selection flag subscription is saved. |
| 266 |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
if(variable_get("comment_subscribe_node_alert",FALSE)) { |
| 267 |
$sql = "insert into {z_commentsubscribe} (cid, parents, subscribenode) |
$sql = "INSERT INTO {z_commentsubscribe} (cid, parents, subscribenode) |
| 268 |
values(%d, '%s', %d)"; |
VALUES(%d, '%s', %d)"; |
| 269 |
db_query($sql, $comment['cid'], $parents, $comment['commentsubscribenode']); |
db_query($sql, $comment['cid'], $parents, $comment['commentsubscribenode']); |
| 270 |
} |
} |
| 271 |
else { |
else { |
| 272 |
$sql = "insert into {z_commentsubscribe} (cid,parents,subscribe) |
$sql = "INSERT INTO {z_commentsubscribe} (cid,parents,subscribe) VALUES(%d, '%s', %d)"; |
| 273 |
values(%d, '%s', %d)"; |
db_query($sql, $comment['cid'], $parents, $comment['commentsubscribe']); |
| 274 |
db_query($sql, $comment['cid'], $parents, $comment['commentsubscribe']); |
} |
|
} |
|
| 275 |
break; |
break; |
| 276 |
case 'delete': |
case 'delete': |
| 277 |
$sql = "DELETE FROM {z_commentsubscribe} WHERE cid = %d or |
$sql = "DELETE FROM {z_commentsubscribe} WHERE cid = %d OR INSTR(parents, '%s,') "; |
| 278 |
instr(parents, '%s,') "; |
db_query($sql, $comment->cid,$comment->cid); |
|
db_query($sql, $comment->cid,$comment->cid); |
|
| 279 |
break; |
break; |
| 280 |
} |
} |
| 281 |
} |
} |
| 307 |
$commsubj= $comment->subject; |
$commsubj= $comment->subject; |
| 308 |
//Get the parents and mailid of a particular comment |
//Get the parents and mailid of a particular comment |
| 309 |
$parentrslt = db_fetch_object(db_query("SELECT parents, |
$parentrslt = db_fetch_object(db_query("SELECT parents, |
| 310 |
IF(length(c.mail)<1, ifnull(u.mail,u.init), |
IF(length(c.mail)<1, IFNULL(u.mail,u.init), |
| 311 |
c.mail) mail FROM {z_commentsubscribe} zc |
c.mail) mail FROM {z_commentsubscribe} zc |
| 312 |
LEFT JOIN {comments} c on zc.cid = c.cid |
LEFT JOIN {comments} c ON zc.cid = c.cid |
| 313 |
LEFT JOIN {users} u on u.uid = c.uid |
LEFT JOIN {users} u ON u.uid = c.uid |
| 314 |
WHERE zc.cid = %d", $cid)); |
WHERE zc.cid = %d", $cid)); |
| 315 |
if($parentrslt->parents != NULL) { |
if($parentrslt->parents != NULL) { |
| 316 |
$arrparents =explode(',',$parentrslt->parents); |
$arrparents =explode(',',$parentrslt->parents); |
| 317 |
$parents .= $arrparents[0]; |
$parents .= $arrparents[0]; |
| 318 |
for($i = 1; $i< count($arrparents)-1 ; $i++) { |
for($i = 1; $i< count($arrparents)-1 ; $i++) { |
| 319 |
$parents .=','; |
$parents .=','; |
| 329 |
"SELECT DISTINCT c.cid,u.init,c.uid,c.name,c.nid, ". |
"SELECT DISTINCT c.cid,u.init,c.uid,c.name,c.nid, ". |
| 330 |
" (case when length(c.mail)<1 then coalesce (u.mail,u.init) else c.mail end) AS mail ". |
" (case when length(c.mail)<1 then coalesce (u.mail,u.init) else c.mail end) AS mail ". |
| 331 |
" FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid=c.uid ". |
" FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid=c.uid ". |
| 332 |
" LEFT JOIN {z_commentsubscribe} zc on zc.cid=c.cid ". |
" LEFT JOIN {z_commentsubscribe} zc on zc.cid=c.cid ". |
| 333 |
" WHERE nid=%d AND ((zc.cid IN (%s) AND subscribe=1) OR subscribenode=1 ) AND c.status=0 ". |
" WHERE nid=%d AND ((zc.cid IN (%s) AND subscribe=1) OR subscribenode=1 ) AND c.status=0 ". |
| 334 |
" AND LENGTH(case when LENGTH(c.mail)<1 then coalesce(u.mail,u.init) else c.mail end)>1 ". |
" AND LENGTH(case when LENGTH(c.mail)<1 then coalesce(u.mail,u.init) else c.mail end)>1 ". |
| 335 |
" AND (case when LENGTH(c.mail)<1 then coalesce(u.mail,u.init) else c.mail end) like '%@%.%' ". |
" AND (case when LENGTH(c.mail)<1 then coalesce(u.mail,u.init) else c.mail end) like '%@%.%' ". |
| 342 |
$result = db_query('SELECT DISTINCT c.cid,u.init,c.uid,c.name,c.nid, |
$result = db_query('SELECT DISTINCT c.cid,u.init,c.uid,c.name,c.nid, |
| 343 |
IF(length(c.mail)<1, ifNULL(u.mail,u.init), c.mail) mail |
IF(length(c.mail)<1, ifNULL(u.mail,u.init), c.mail) mail |
| 344 |
FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid=c.uid |
FROM {comments} c LEFT OUTER JOIN {users} u ON u.uid=c.uid |
| 345 |
LEFT JOIN {z_commentsubscribe} zc on zc.cid=c.cid |
LEFT JOIN {z_commentsubscribe} zc ON zc.cid=c.cid |
| 346 |
WHERE nid=%d AND ((zc.cid IN (%s) AND subscribe=1) OR subscribenode=1 )AND c.status=0 |
WHERE nid=%d AND ((zc.cid IN (%s) AND subscribe=1) OR subscribenode=1 )AND c.status=0 |
| 347 |
AND LENGTH(IF(LENGTH(c.mail)<1, ifNULL(u.mail,u.init),c.mail))>1 |
AND LENGTH(IF(LENGTH(c.mail)<1, ifNULL(u.mail,u.init),c.mail))>1 |
| 348 |
AND IF(LENGTH(c.mail)<1, ifNULL(u.mail,u.init),c.mail) like |
AND IF(LENGTH(c.mail)<1, ifNULL(u.mail,u.init),c.mail) like |
| 354 |
); |
); |
| 355 |
} |
} |
| 356 |
$count=0; |
$count=0; |
| 357 |
while ($alert = db_fetch_object($result)) { |
while ($alert = db_fetch_object($result)) { |
| 358 |
$mailid = $alert->mail; |
$mailid = $alert->mail; |
| 359 |
$subject = t('!site :: new comment for your post.', array( |
$subject = t('!site :: new comment for your post.', array( |
| 360 |
'!site' => variable_get('site_name', 'drupal'))); |
'!site' => variable_get('site_name', 'drupal'))); |
| 361 |
$message = t((variable_get('comment_subscribe_default_mailtext', |
$message = t((variable_get('comment_subscribe_default_mailtext', |
| 362 |
DEFAULT_MAILTEXT)), |
DEFAULT_MAILTEXT)), |
| 363 |
array( |
array( |
| 364 |
'!commname' => $commname, |
'!commname' => $commname, |
| 365 |
'!commtext' => $commtext, |
'!commtext' => $commtext, |
| 366 |
'!commsubj' => $commsubj, |
'!commsubj' => $commsubj, |
| 367 |
'!comment_url' => url('node/'.$nid,array('absolute' => TRUE))."#comment-". |
'!comment_url' => url('node/'.$nid,array('absolute' => TRUE))."#comment-". |
| 368 |
$cid, |
$cid, |
| 369 |
'!node_title' => $node->title, |
'!node_title' => $node->title, |
| 370 |
'!node_teaser' => $node->teaser, |
'!node_teaser' => $node->teaser, |
| 371 |
'!mission' => variable_get('site_mission', ''), |
'!mission' => variable_get('site_mission', ''), |
| 372 |
'!node_body' => $node->body, |
'!node_body' => $node->body, |
| 373 |
'!name' => $alert->name, |
'!name' => $alert->name, |
| 374 |
'!site' => variable_get('site_name', 'drupal'), |
'!site' => variable_get('site_name', 'drupal'), |
| 375 |
'!uri' => $base_url, |
'!uri' => $base_url, |
| 376 |
'!uri_brief' => substr($base_url, strlen('http://')), |
'!uri_brief' => substr($base_url, strlen('http://')), |
| 377 |
'!date' => format_date(time()), |
'!date' => format_date(time()), |
| 378 |
'!login_uri' => url('user', array('absolute' => TRUE)), |
'!login_uri' => url('user', array('absolute' => TRUE)), |
| 379 |
'!edit_uri' => url('user/'. $alert->uid .'/edit', array('absolute' => TRUE) |
'!edit_uri' => url('user/'. $alert->uid .'/edit', array('absolute' => TRUE) |
| 380 |
), |
), |
| 381 |
'!link1' => url('comment_subscribe/disable/nodepost/'.$nid.'/'. |
'!link1' => url('comment_subscribe/disable/nodepost/'.$nid.'/'. |
| 382 |
md5($mailid), array('absolute' => TRUE)), |
md5($mailid), array('absolute' => TRUE)), |
| 383 |
'!link2' => url('comment_subscribe/disable/postrply/'.$alert-> |
'!link2' => url('comment_subscribe/disable/postrply/'.$alert-> |
| 384 |
cid.'/'.md5($mailid), array('absolute' => TRUE)), |
cid.'/'.md5($mailid), array('absolute' => TRUE)), |
| 385 |
) |
) |
| 386 |
); |
); |
| 387 |
$_SESSION['subject'] = $subject; |
$_SESSION['subject'] = $subject; |
| 388 |
$_SESSION['message'] = $message; |
$_SESSION['message'] = $message; |
| 389 |
drupal_mail( "comment_subscribe", |
drupal_mail( "comment_subscribe", |
| 390 |
'mail_user', |
'mail_user', |
| 391 |
$alert->mail, |
$alert->mail, |
| 395 |
'header' => $header, |
'header' => $header, |
| 396 |
)); |
)); |
| 397 |
|
|
| 398 |
$count++; |
$count++; |
| 399 |
if (($alert->uid)!=0) |
if (($alert->uid)!=0) |
| 400 |
$mylink =l( $mailid , 'user/'. $alert->uid .'/edit') ; |
$mylink =l( $mailid , 'user/'. $alert->uid .'/edit') ; |
| 401 |
else |
else |
| 402 |
$mylink =$mailid; |
$mylink =$mailid; |
| 403 |
// Add an entry to the watchdog log. |
// Add an entry to the watchdog log. |
| 404 |
watchdog('comment_subscribe', 'Subscribe !link', array('!link' => $mylink), |
watchdog('comment_subscribe', 'Subscribe !link', array('!link' => $mylink), |
| 405 |
WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, array('fragment' => 'comment-'. $alert->cid))); |
WATCHDOG_NOTICE, l(t('source comment'), 'node/'. $nid, array('fragment' => 'comment-'. $alert->cid))); |
| 406 |
// revert to previous (site default) locale |
// revert to previous (site default) locale |
| 407 |
$locale = $initial_locale; |
$locale = $initial_locale; |
| 408 |
} |
} |
| 409 |
//Sending mail to author of the post, if he subscribed comments to the node |
//Sending mail to author of the post, if he subscribed comments to the node |
| 410 |
if ( $GLOBALS['db_type']=='pgsql') { |
if ( $GLOBALS['db_type']=='pgsql') { |
| 425 |
DEFAULT_AUTHOR_MAILTEXT)), |
DEFAULT_AUTHOR_MAILTEXT)), |
| 426 |
array( |
array( |
| 427 |
'!commname' => $commname, |
'!commname' => $commname, |
| 428 |
'!comment_url' => url('node/'.$nid,array('absolute' => TRUE))."#comment-". |
'!comment_url' => url('node/'.$nid,array('absolute' => TRUE))."#comment-". |
| 429 |
$cid, |
$cid, |
| 430 |
'!node_title' => $node->title, |
'!node_title' => $node->title, |
| 431 |
'!mission' => variable_get('site_mission', ''), |
'!mission' => variable_get('site_mission', ''), |
| 432 |
'!name' => $alert->name, |
'!name' => $alert->name, |
| 453 |
$breadcrumb = NULL; |
$breadcrumb = NULL; |
| 454 |
$op = $_POST["op"]; |
$op = $_POST["op"]; |
| 455 |
$edit = $_POST["edit"]; |
$edit = $_POST["edit"]; |
| 456 |
$page_content=" "; |
$page_content=" "; |
| 457 |
if (empty($op)) { |
if (empty($op)) { |
| 458 |
$op = arg(1); |
$op = arg(1); |
| 459 |
} |
} |
| 476 |
else if ( strcmp($type, 'nodepost') == 0 ) { |
else if ( strcmp($type, 'nodepost') == 0 ) { |
| 477 |
if ( $GLOBALS['db_type']=='pgsql') { |
if ( $GLOBALS['db_type']=='pgsql') { |
| 478 |
db_query(" |
db_query(" |
| 479 |
UPDATE {z_commentsubscribe} cs set subscribe=0 , subscribenode = 0 |
UPDATE {z_commentsubscribe} cs SET subscribe=0 , subscribenode = 0 |
| 480 |
WHERE cs.cid in (SELECT c.cid from {comments} c inner join {users} u on c.uid=u.uid and c.nid= %d |
WHERE cs.cid IN (SELECT c.cid FROM {comments} c INNER JOIN {users} u ON c.uid=u.uid AND c.nid= %d |
| 481 |
AND md5(case when length(c.mail)<1 then u.mail else c.mail end) = '%s')", $arg, arg(4)); |
AND md5(case WHEN LENGTH(c.mail)<1 THEN u.mail ELSE c.mail end) = '%s')", $arg, arg(4)); |
| 482 |
} |
} |
| 483 |
else { |
else { |
| 484 |
db_query("UPDATE {comments} c , {users} u , |
db_query("UPDATE {comments} c , {users} u , |
| 496 |
//Get the maximum cid for a particular comment of a givenid |
//Get the maximum cid for a particular comment of a givenid |
| 497 |
if ( $GLOBALS['db_type']=='pgsql') { |
if ( $GLOBALS['db_type']=='pgsql') { |
| 498 |
$lstcid = db_fetch_object(db_query(" |
$lstcid = db_fetch_object(db_query(" |
| 499 |
SELECT max(zc.cid) as maxcid FROM {z_commentsubscribe} zc |
SELECT MAX(zc.cid) AS maxcid FROM {z_commentsubscribe} zc |
| 500 |
LEFT JOIN {comments} c on c.cid = zc.cid |
LEFT JOIN {comments} c ON c.cid = zc.cid |
| 501 |
LEFT OUTER JOIN {users} u ON u.uid=c.uid |
LEFT OUTER JOIN {users} u ON u.uid=c.uid |
| 502 |
WHERE subscribe = 1 AND parents ~ '%s,' |
WHERE subscribe = 1 AND parents ~ '%s,' |
| 503 |
AND md5(case when LENGTH( c.mail ) <1 then u.mail else c.mail end ) = '%s'", $arg, arg(4))); |
AND md5(CASE WHEN LENGTH( c.mail ) <1 THEN u.mail ELSE c.mail END ) = '%s'", $arg, arg(4))); |
| 504 |
} |
} |
| 505 |
else { |
else { |
| 506 |
//Get the maximum cid for a particular comment of a givenid |
//Get the maximum cid for a particular comment of a givenid |
| 507 |
$lstcid = db_fetch_object(db_query("SELECT max(zc.cid) as |
$lstcid = db_fetch_object(db_query("SELECT max(zc.cid) AS |
| 508 |
maxcid FROM {z_commentsubscribe} zc |
maxcid FROM {z_commentsubscribe} zc |
| 509 |
LEFT JOIN {comments} c on c.cid = zc.cid |
LEFT JOIN {comments} c ON c.cid = zc.cid |
| 510 |
LEFT OUTER JOIN {users} u ON u.uid=c.uid |
LEFT OUTER JOIN {users} u ON u.uid=c.uid |
| 511 |
WHERE subscribe = 1 AND instr(parents ,'%s') AND md5(IF( |
WHERE subscribe = 1 AND instr(parents ,'%s') AND md5(IF( |
| 512 |
LENGTH( c.mail ) <1, u.mail, c.mail ) ) = '%s'", $arg, arg(4))); |
LENGTH( c.mail ) <1, u.mail, c.mail ) ) = '%s'", $arg, arg(4))); |
| 513 |
} |
} |
| 514 |
if ( $lstcid->maxcid ) |
if ( $lstcid->maxcid ) |
| 534 |
*/ |
*/ |
| 535 |
function comment_subscribe_enable() { |
function comment_subscribe_enable() { |
| 536 |
|
|
| 537 |
$num_rows_result = db_fetch_object(db_query("SELECT count(*) AS num FROM {comments} c")); |
$num_rows_result = db_fetch_object(db_query("SELECT COUNT(*) AS num FROM {comments} c")); |
| 538 |
|
|
| 539 |
if ( $num_rows_result-> num != 0 ) { |
if ( $num_rows_result-> num != 0 ) { |
| 540 |
//If comment_subscribe module is enabled in a live site. |
//If comment_subscribe module is enabled in a live site. |
| 541 |
//For previous comments an entry in z_commentsubscribe is |
//For previous comments an entry in z_commentsubscribe is |
| 542 |
//generated using the below code. |
//generated using the below code. |
| 543 |
$level = 1; |
$level = 1; |
| 544 |
$ifcondition = "if(c". $level .".pid <> 0, concat(c". $level .".pid, ','),'')"; |
$ifcondition = "IF (c". $level .".pid <> 0, CONCAT(c". $level .".pid, ','),'')"; |
| 545 |
$table = "c". $level; |
$table = "c". $level; |
| 546 |
$join =NULL; |
$join =NULL; |
| 547 |
|
|
| 550 |
|
|
| 551 |
if ($level != 1) { |
if ($level != 1) { |
| 552 |
$prvlevel = $level - 1; |
$prvlevel = $level - 1; |
| 553 |
$join .= " join {comments} c". $level ." on c". $prvlevel .".pid=c". $level .".cid"; |
$join .= " JOIN {comments} c". $level ." ON c". $prvlevel .".pid=c". $level .".cid"; |
| 554 |
} |
} |
| 555 |
$sql = "SELECT c1.cid, concat('0,', ". $ifcondition ." ) AS parents FROM {comments} c1 ". $join; |
$sql = "SELECT c1.cid, concat('0,', ". $ifcondition ." ) AS parents FROM {comments} c1 ". $join; |
| 556 |
$result = db_fetch_array(db_query($sql)); |
$result = db_fetch_array(db_query($sql)); |
| 561 |
} |
} |
| 562 |
$level++; |
$level++; |
| 563 |
$table = "c" . $level; |
$table = "c" . $level; |
| 564 |
$ifcondition = " if(c". $level ." .pid <> 0, concat(c". $level ." . pid, ','),''),". $ifcondition; |
$ifcondition = " IF(c". $level ." .pid <> 0, CONCAT(c". $level ." . pid, ','),''),". $ifcondition; |
| 565 |
}while ( $result != NULL ); |
}while ( $result != NULL ); |
| 566 |
$sql = str_replace('join', 'left join', $origsql); |
$sql = str_replace('JOIN', 'LEFT JOIN', $origsql); |
| 567 |
$sql = str_replace('AS parents', 'AS parents, 0 as subscribe, 0 as subscribenode', $sql); |
$sql = str_replace('AS parents', 'AS parents, 0 AS subscribe, 0 AS subscribenode', $sql); |
| 568 |
$sql = "INSERT INTO {z_commentsubscribe} (cid, parents, subscribe, subscribenode) ". $sql ." |
$sql = "INSERT INTO {z_commentsubscribe} (cid, parents, subscribe, subscribenode) ". $sql ." |
| 569 |
left join {z_commentsubscribe} cs on c1.cid = cs.cid where cs.subscribe is NULL"; |
LEFT JOIN {z_commentsubscribe} cs ON c1.cid = cs.cid WHERE cs.subscribe IS NULL"; |
| 570 |
db_query($sql); |
db_query($sql); |
| 571 |
//Insert previous node informations in to the z_nodesubscribe table. |
//Insert previous node informations in to the z_nodesubscribe table. |
| 572 |
db_query("INSERT INTO {z_nodesubscribe} (nid, uid) select nid,uid from node"); |
db_query("INSERT INTO {z_nodesubscribe} (nid, uid) SELECT nid,uid FROM node"); |
| 573 |
} |
} |
| 574 |
} |
} |