Changeset 1622

Show
Ignore:
Timestamp:
12/22/2006 11:15:11 AM (2 years ago)
Author:
jeena
Message:

added hooks for comments

Location:
trunk
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/comments.php

    r1595 r1622  
    101101                email                   = '".$data['email']."',  
    102102                homepage                = '".$data['homepage']."',  
    103                 content             = '".$data['content']."',  
    104                 mail_by_comment = '".$data['mail_by_comment']."'  
     103                content                 = '".$data['content']."',  
     104                mail_by_comment         = '".$data['mail_by_comment']."'  
    105105            WHERE id = '".$data['id']."' LIMIT 1;";  
    106106      
  • trunk/log.php

    r1617 r1622  
    6464 
    6565 $com_form = strip($_POST); 
     66 if(!isset($com_form['type'])) $com_form['type'] = ""; 
    6667 $error = com_check_errors($com_form); 
    6768 
     
    110111 
    111112   ### Plugin Hook 
    112    $com_form = $plugins->callHook('newComment', $com_form); 
     113   $com_form = $plugins->callHook('newComment', $com_form, $blogentry); 
    113114 
    114115   $com = escape_for_mysql($com_form); 
     
    124125                        reference, 
    125126                        mail_by_comment, 
    126                         date 
     127                        date, 
     128                                                                                                type 
    127129                  ) 
    128130           VALUES ( 
     
    135137            '".$blogentry['id']."', 
    136138            '".$com['mail_by_comment']."', 
    137             NOW() 
     139            NOW(), 
     140                                                '".$com['type']."' 
    138141           )";  
    139142 
     
    170173     else { 
    171174 
    172       if(JLOG_INFO_BY_COMMENT === true) { 
     175             $mail['topic'] = $l['admin']['comments_mailsubject']." - ".$blogentry['topic']; 
    173176       $mail['headers'] = "From: "; 
    174177       if(!empty($com_form['name'])) $mail['headers'] .= str_replace(array("\n", "\r"), "", $com_form['name']); 
     
    176179       if(!empty($com_form['email'])) $mail['headers'] .= " <".str_replace(array("\n", "\r"), "", $com_form['email']).">"; 
    177180       $mail['headers'] .= "\r\nX-Mailer: PHP/".phpversion(); 
    178  
    179181 
    180182       $mail['text'] = $l['admin']['comments_mail_txt']." »".$blogentry['topic']."«\n- -\n"; 
     
    187189       $mail['text'] .= "\n\n".$l['admin']['kill_c_email']."\n".JLOG_PATH."/admin/comments.php?action=trash&id=".$cid; 
    188190 
    189        @mail(JLOG_EMAIL, $l['admin']['comments_mailsubject']." - ".$blogentry['topic'], $mail['text'], $mail['headers']); 
     191                   ### Plugin Hook 
     192                   $mail = $plugins->callHook('adminMail', $mail, $blogentry); 
     193                          
     194       if(empty($mail['nomail']) and JLOG_INFO_BY_COMMENT) @mail(JLOG_EMAIL, $mail['topic'], $mail['text'], $mail['headers']); 
    190195      } 
    191196 
     197                        $mail['topic'] = $l['comments_mailsubject']." - ".$blogentry['topic']; 
    192198      $mail['headers'] = "From: ".JLOG_WEBSITE." <".JLOG_EMAIL.">\r\n" 
    193199                        ."X-Mailer: PHP/".phpversion(); 
    194200 
    195       $mail['text'] = $l['comments_mail_txt']." »".$blogentry['topic']."«\n- -\n"; 
    196       if(!empty($com_form['name'])) $mail['text'] .= $com_form['name']; 
    197       else $mail['text'] .= $l['comments_anonym']; 
    198       if(!empty($com_form['city'])) $mail['text'] .= " ".$l['comments_from']." ".$com_form['city']; 
    199       $mail['text'] .= " ".$l['comments_posted']." ".$date.":\n\n"; 
    200       $mail['text'] .= html_entity_decode(strip_tags($bbcomments->parse($com_form['content']))); 
    201       $mail['text'] .= "\n\n".str_replace ( '&amp;', '&', blog($blogentry['date'], $blogentry['url']))."#c".$cid.""; 
    202       $mail['text'] .= "\n-- \n".$l['comments_stop_receiving']."\n"; 
    203       $mail['text'] .= JLOG_PATH."/stop.php?id=".$blogentry['id']."&email="; 
     201      $mail['all_text'] = $l['comments_mail_txt']." »".$blogentry['topic']."«\n- -\n"; 
     202      if(!empty($com_form['name'])) $mail['all_text'] .= $com_form['name']; 
     203      else $mail['all_text'] .= $l['comments_anonym']; 
     204      if(!empty($com_form['city'])) $mail['all_text'] .= " ".$l['comments_from']." ".$com_form['city']; 
     205      $mail['all_text'] .= " ".$l['comments_posted']." ".$date.":\n\n"; 
     206      $mail['all_text'] .= html_entity_decode(strip_tags($bbcomments->parse($com_form['content']))); 
     207      $mail['all_text'] .= "\n\n".str_replace ( '&amp;', '&', blog($blogentry['date'], $blogentry['url']))."#c".$cid.""; 
     208      $mail['all_text'] .= "\n-- \n".$l['comments_stop_receiving']."\n"; 
     209      $mail['all_text'] .= JLOG_PATH."/stop.php?id=".$blogentry['id']."&email="; 
    204210 
    205211      while ($data = $comment_mail->fetch()) { 
    206        if($data['email'] != $com['email']) { 
    207            @mail($data['email'], $l['comments_mailsubject']." - ".$blogentry['topic'], $mail['text'].$data['email'], $mail['headers']); 
    208        } 
    209       } 
    210      } 
    211     $c['form_content'] .= "<p id='entryform'>".$l['comments_thx']."</p>".com_javascript_variables(); 
    212    } 
     212       if($data['email'] != $com_form['email']) { 
     213 
     214                                 $mail['mail_to'] = $data['email']; 
     215                                         $mail['text'] = $mail['all_text'].$data['email']; 
     216                                  
     217                                         ### Plugin Hook 
     218                                 $mail = $plugins->callHook('commentorMail', $mail, $blogentry); 
     219 
     220           if(empty($mail['nomail'])) @mail($mail['mail_to'], $mail['topic'], $mail['text'], $mail['headers']); 
     221                                } 
     222        } 
     223         } 
     224   $c['form_content'] .= "<p id='entryform'>".$l['comments_thx']."</p>".com_javascript_variables(); 
    213225  } 
    214226 } 
  • trunk/scripts/comments.php

    r1575 r1622  
    129129 
    130130   ### Plugin Hook 
    131   $comment = $plugins->callHook('showComment', $comment, $data, $nr); 
     131        $comment = $plugins->callHook('showComment', $comment, $data, $nr); 
    132132 
    133133 return $comment; 
  • trunk/scripts/general.func.php

    r1595 r1622  
    207207         $com = array(); 
    208208         while($c = $comments->fetch()) $com[$c['reference']] = $c['count']; 
     209                                  
     210                                 ### Plugin Hook 
     211                                 global $plugins; 
     212                           $com = $plugins->callHook('countComments', $com); 
     213                         
    209214         return $com; 
    210215} 
  • trunk/scripts/jlogPlugins.class.php

    r1541 r1622  
    2222    function hook_permalink       ($t) { return $t; } // string permalink + string date + string url + string section 
    2323    function hook_xmlrpcPermalink ($t) { return $t; } // string url 
     24                function hook_countComments   ($t) { return $t; } // array with id and count 
     25                function hook_adminMail       ($t) { return $t; } // array with mail + array blogentry 
     26                function hook_commentorMail   ($t) { return $t; } // array with mail + array blogentry 
    2427 
    25   /* Parameters functions */ 
    26 /* 
    27     function saveConfigData($name, $t) { 
    28     echo  get_class($this); 
    29         return false; 
    30     } 
    31  
    32     function loadConfigData($name, $t) { 
    33         return false; 
    34     } 
    35 */ 
    3628} 
    3729