[61] | 1 | <?php
|
---|
| 2 | function do_CommentNotifications($commentID, $comment_post_ID)
|
---|
| 3 | {
|
---|
| 4 | $xpress_prefix = $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
| 5 | if ($xpress_prefix == 'wordpress') $xpress_prefix = 'wp';
|
---|
| 6 | $db =& Database::getInstance() ;
|
---|
| 7 | $myts =& MyTextsanitizer::getInstance() ;
|
---|
| 8 |
|
---|
| 9 | $table_term_relationships = $db->prefix($xpress_prefix."_term_relationships");
|
---|
| 10 | $table_term_taxonomy = $db->prefix($xpress_prefix."_term_taxonomy");
|
---|
| 11 | $table_terms = $db->prefix($xpress_prefix."_terms");
|
---|
| 12 | $table_categories = $db->prefix($xpress_prefix."_categories");
|
---|
| 13 | $wp_post = $db->prefix($xpress_prefix."_posts");
|
---|
| 14 | $wp_options = $db->prefix($xpress_prefix."_options");
|
---|
| 15 | $wp_users = $db->prefix($xpress_prefix."_users");
|
---|
| 16 | $wp_comments = $db->prefix($xpress_prefix."_comments");
|
---|
| 17 | $post_id = $comment_post_ID;
|
---|
| 18 |
|
---|
| 19 | $post_title = get_the_title($post_id);
|
---|
| 20 | $post_url = get_permalink($post_id). '#comment';
|
---|
| 21 | $blog_name = get_bloginfo('name');
|
---|
| 22 |
|
---|
| 23 | /*
|
---|
| 24 | $sql = "SELECT option_value FROM $wp_options WHERE option_name ='blogname'";
|
---|
| 25 | $blog_row = $db->fetchArray( $db->query( $sql ) ) ;
|
---|
| 26 | if( empty( $blog_row ) ) return false;
|
---|
| 27 | $blog_name = $blog_row['option_value'];
|
---|
| 28 | */
|
---|
| 29 | // query
|
---|
| 30 | $sql = "SELECT * FROM ".$wp_post." WHERE ID=$comment_post_ID ";
|
---|
| 31 | $post_row = $db->fetchArray( $db->query( $sql ) ) ;
|
---|
| 32 | if( empty( $post_row ) ) return false;
|
---|
| 33 | // $post_title = $post_row['post_title'];
|
---|
| 34 | $post_author = $post_row['post_author'];
|
---|
| 35 |
|
---|
| 36 | $sql = "SELECT display_name FROM $wp_users WHERE ID ='$post_author'";
|
---|
| 37 | $blog_row = $db->fetchArray( $db->query( $sql ) ) ;
|
---|
| 38 | if( empty( $blog_row ) ) return false;
|
---|
| 39 | $user_name = $blog_row['display_name'];
|
---|
| 40 |
|
---|
| 41 | require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ;
|
---|
| 42 | // non-module integration returns false quickly
|
---|
| 43 |
|
---|
| 44 | if( ! is_object($GLOBALS["xoopsModule"]) ) return false ;
|
---|
| 45 | $not_modid = $GLOBALS["xoopsModule"]->getVar('mid') ;
|
---|
| 46 |
|
---|
| 47 | $comment_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ;
|
---|
| 48 | $notification_handler =& xoops_gethandler( 'notification' ) ;
|
---|
| 49 | $notification_handler->triggerEvent( 'global' , 0 , 'comment' , $comment_tags , false , $not_modid ) ;
|
---|
| 50 | $notification_handler->triggerEvent( 'author' , $post_author , 'comment' , $comment_tags , false , $not_modid ) ;
|
---|
| 51 | $notification_handler->triggerEvent( 'post' , $comment_post_ID , 'comment' , $comment_tags , false , $not_modid ) ;
|
---|
| 52 |
|
---|
| 53 | // categorie notification
|
---|
| 54 | include(XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/wp-includes/version.php');
|
---|
| 55 | if ($wp_db_version < 6124){
|
---|
| 56 | $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$comment_post_ID;
|
---|
| 57 | } else {
|
---|
| 58 | $sql2 = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
|
---|
| 59 | $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
|
---|
| 60 | $sql2 .= "WHERE ($table_term_relationships.object_id =" . $comment_post_ID.") AND ($table_term_taxonomy.taxonomy='category')";
|
---|
| 61 | }
|
---|
| 62 | $res2 = $db->query($sql2);
|
---|
| 63 | while($row2 = $db->fetchArray($res2)){
|
---|
| 64 | $cat_id = $row2['cat_ID'];
|
---|
| 65 | $cat_name = $row2['cat_name'];
|
---|
| 66 | $comment_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_CAT_TITLE' => $cat_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ;
|
---|
| 67 | $notification_handler->triggerEvent( 'category' , $cat_id , 'comment' , $comment_tags , false , $not_modid ) ;
|
---|
| 68 | }
|
---|
| 69 | }
|
---|
| 70 |
|
---|
| 71 | function do_PostNotifications($post_id,$not_event)
|
---|
| 72 | {
|
---|
| 73 | // $not_event: newpost,editpost ; $commentID, $comment_post_ID)
|
---|
| 74 |
|
---|
| 75 | $xpress_prefix = $mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
|
---|
| 76 | if ($xpress_prefix == 'wordpress') $xpress_prefix = 'wp';
|
---|
| 77 | $db =& Database::getInstance() ;
|
---|
| 78 | $myts =& MyTextsanitizer::getInstance() ;
|
---|
| 79 |
|
---|
| 80 | $table_term_relationships = $db->prefix($xpress_prefix."_term_relationships");
|
---|
| 81 | $table_term_taxonomy = $db->prefix($xpress_prefix."_term_taxonomy");
|
---|
| 82 | $table_terms = $db->prefix($xpress_prefix."_terms");
|
---|
| 83 | $table_categories = $db->prefix($xpress_prefix."_categories");
|
---|
| 84 | $wp_post = $db->prefix($xpress_prefix."_posts");
|
---|
| 85 | $wp_options = $db->prefix($xpress_prefix."_options");
|
---|
| 86 | $wp_users = $db->prefix($xpress_prefix."_users");
|
---|
| 87 | $wp_comments = $db->prefix($xpress_prefix."_comments");
|
---|
| 88 |
|
---|
| 89 | $post_title = get_the_title($post_id);
|
---|
| 90 | $post_url = get_permalink($post_id). '#comment';
|
---|
| 91 | $blog_name = get_bloginfo('name');
|
---|
| 92 |
|
---|
| 93 | // query
|
---|
| 94 | $sql = "SELECT * FROM ".$wp_post." WHERE ID=$post_id ";
|
---|
| 95 | $post_row = $db->fetchArray( $db->query( $sql ) ) ;
|
---|
| 96 | if( empty( $post_row ) ) return false;
|
---|
| 97 | // $post_title = $post_row['post_title'];
|
---|
| 98 | $post_author = $post_row['post_author'];
|
---|
| 99 |
|
---|
| 100 | $sql = "SELECT display_name FROM $wp_users WHERE ID ='$post_author'";
|
---|
| 101 | $blog_row = $db->fetchArray( $db->query( $sql ) ) ;
|
---|
| 102 | if( empty( $blog_row ) ) return false;
|
---|
| 103 | $user_name = $blog_row['display_name'];
|
---|
| 104 |
|
---|
| 105 | require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ;
|
---|
| 106 | // non-module integration returns false quickly
|
---|
| 107 |
|
---|
| 108 | if( ! is_object($GLOBALS["xoopsModule"]) ) return false ;
|
---|
| 109 | $not_modid = $GLOBALS["xoopsModule"]->getVar('mid') ;
|
---|
| 110 |
|
---|
| 111 | $posts_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ;
|
---|
| 112 |
|
---|
| 113 | $notification_handler =& xoops_gethandler( 'notification' ) ;
|
---|
| 114 | switch ($not_event) {
|
---|
| 115 | case 'newpost' :
|
---|
| 116 | $notification_handler->triggerEvent( 'global' , 0 , 'newpost' , $posts_tags , false , $not_modid ) ;
|
---|
| 117 | $notification_handler->triggerEvent( 'author' , $post_author , 'newpost' , $posts_tags , false , $not_modid ) ;
|
---|
| 118 |
|
---|
| 119 | // categorie notification
|
---|
| 120 | include(XOOPS_ROOT_PATH . '/modules/'.$mydirname . '/wp-includes/version.php');
|
---|
| 121 | if ($wp_db_version < 6124){
|
---|
| 122 | $sql2 = "SELECT c.cat_ID, c.cat_name FROM ".$table_categories." c, ".$table_post2cat." p2c WHERE c.cat_ID = p2c.category_id AND p2c.post_id=".$post_id;
|
---|
| 123 | } else {
|
---|
| 124 | $sql2 = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name ";
|
---|
| 125 | $sql2 .= "FROM $table_term_relationships INNER JOIN ($table_term_taxonomy INNER JOIN $table_terms ON $table_term_taxonomy.term_id = $table_terms.term_id) ON $table_term_relationships.term_taxonomy_id = $table_term_taxonomy.term_taxonomy_id ";
|
---|
| 126 | $sql2 .= "WHERE ($table_term_relationships.object_id =" . $post_id.") AND ($table_term_taxonomy.taxonomy='category')";
|
---|
| 127 | }
|
---|
| 128 | $res2 = $db->query($sql2);
|
---|
| 129 | while($row2 = $db->fetchArray($res2)){
|
---|
| 130 | $cat_id = $row2['cat_ID'];
|
---|
| 131 | $cat_name = $row2['cat_name'];
|
---|
| 132 | $posts_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_CAT_TITLE' => $cat_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ;
|
---|
| 133 | $notification_handler->triggerEvent( 'category' , $cat_id , 'newpost' , $posts_tags , false , $not_modid ) ;
|
---|
| 134 | }
|
---|
| 135 | break;
|
---|
| 136 | case 'editpost' :
|
---|
| 137 | $notification_handler->triggerEvent( 'post' , $post_id , 'editpost' , $posts_tags , false , $not_modid ) ;
|
---|
| 138 | break;
|
---|
| 139 | default :
|
---|
| 140 | }
|
---|
| 141 | }
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 |
|
---|
| 146 | ?> |
---|