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