Changeset 95 for trunk/wp-content/plugins/xpressme/include
- Timestamp:
- Mar 3, 2009, 8:33:23 PM (16 years ago)
- Location:
- trunk/wp-content/plugins/xpressme/include
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-content/plugins/xpressme/include/custom_functions.php
r75 r95 148 148 } 149 149 } 150 // xoops db 151 function get_xpress_dir_path() 152 { 153 return ABSPATH; 154 } 155 156 function get_xpress_dir_name() 157 { 158 return basename(ABSPATH); 159 } 160 161 function get_wp_prefix_only() 162 { 163 $dir_name = get_xpress_dir_name(); 164 $prefix = $dir_name; 165 if ($prefix == 'wordpress') $prefix = 'wp'; 166 167 $prefix = $prefix . '_'; 168 return $prefix; 169 } 170 171 function get_xoops_prefix() 172 { 173 $ret =XOOPS_DB_PREFIX . '_'; 174 return $ret; 175 } 176 function get_wp_prefix() 177 { 178 $prefix = get_xoops_prefix() . get_wp_prefix_only(); 179 return $prefix; 180 } 181 182 function get_xpress_modid() 183 { 184 global $xoops_db; 185 186 $modulename = get_xpress_dir_name(); 187 $sql = "SELECT mid FROM " . get_xoops_prefix() . "modules WHERE dirname = '$modulename'"; 188 $mid = $xoops_db->get_var($sql); 189 return $mid; 190 } 191 192 function block_cache_refresh() 193 { 194 global $xoops_db; 195 $mid = get_xpress_modid(); 196 $sql = "SELECT bid,options,func_file FROM " . get_xoops_prefix() . "newblocks WHERE mid = $mid"; 197 $blocks = $xoops_db->get_results($sql); 198 $mydirname = get_xpress_dir_name(); 199 require_once get_xpress_dir_path() . '/include/xpress_block_render.php'; 200 201 202 foreach($blocks as $block){ 203 $func_file = $block->func_file; 204 $call_theme_function_name = str_replace(".php", "", $func_file); 205 $inc_theme_file_name = str_replace(".php", "", $func_file) . '_theme.php'; 206 $cache_title = str_replace(".php", "", $func_file); 207 $blockID = $block->bid; 208 $options = explode("|", $block->options); 209 210 $block_theme_file = get_block_file_path($mydirname,$inc_theme_file_name); 211 require_once $block_theme_file; 212 $block_render = $call_theme_function_name($options); //The block name and the called function name should be assumed to be the same name. 213 $xml['block'] = $block_render; 214 xpress_block_cache_write($mydirname,$cache_title. $blockID, $xml); 215 } 216 } 150 217 151 218 152 // views count -
trunk/wp-content/plugins/xpressme/include/notify_functions.php
r91 r95 1 1 <?php 2 2 3 3 function onaction_publish_post_notify($new_status, $old_status, $post) 4 4 { 5 5 if ($new_status == 'publish'){ 6 include_once dirname(__FILE__) . '/notification.inc.sub.php';7 6 do_PostNotifications($post->ID,'newpost'); 8 7 } … … 11 10 function onaction_edit_post_notify($post_id) 12 11 { 13 include_once ABSPATH . '/include/notification.inc.sub.php';14 12 do_PostNotifications($post_id,'editpost'); 15 13 } … … 21 19 22 20 if ($status ==1){ 23 include_once ABSPATH . '/include/notification.inc.sub.php';24 21 do_CommentNotifications($commentID, $post_id); 25 22 } else { 26 require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ; 27 $notification_handler =& xoops_gethandler( 'notification' ) ; 28 $notification_handler->triggerEvent( 'global' , 0 , 'waiting') ; 23 do_CommentWaiting($commentID, $post_id); 29 24 } 30 25 } … … 35 30 $status = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID = $commentID"); 36 31 if(is_null($status)) return; 37 // $status = wp_get_comment_status($commentID);38 32 if ($status == 1){ 39 33 onaction_comment_notify($commentID); … … 41 35 } 42 36 37 function Notification_triggerEvent($category, $item_id, $event, $extra_tags=array(), $user_list=array(), $omit_user_id=null) 38 { 39 global $xoops_db,$xoops_config; 40 //When notifying by a private message, 41 //it is evaded that the data base becomes read-only as a result of the check on the referrer and the method. 42 if (is_wp_cron_page_call() ){ 43 $_SERVER['HTTP_REFERER'] = 'http://'. $_SERVER[HTTP_HOST] . $_SERVER['PHP_SELF']; 44 $_SERVER['REQUEST_METHOD'] = 'POST'; 45 } 46 if (is_xmlrpc_call() ){ 47 $_SERVER['HTTP_REFERER'] = 'http://'. $_SERVER[HTTP_HOST] . $_SERVER['PHP_SELF']; 48 $_SERVER['REQUEST_METHOD'] = 'POST'; 49 } 50 51 include_once $xoops_config->xoops_mainfile_path; // load XOOPS System 52 include_once $xoops_config->xoops_root_path . '/include/notification_functions.php' ; 53 $module_id = get_xpress_modid() ; 54 $notification_handler =& xoops_gethandler( 'notification' ) ; 55 $notification_handler->triggerEvent($category, $item_id, $event, $extra_tags, $user_list, $module_id, $omit_user_id); 56 } 57 58 function do_CommentWaiting($commentID, $comment_post_ID) 59 { 60 // global $xoops_config; 61 // require_once $xoops_config->xoops_mainfile_path; 62 // xoops_mainfile_path; 63 // require_once XOOPS_ROOT_PATH . '/include/notification_functions.php' ; 64 // $notification_handler =& xoops_gethandler( 'notification' ) ; 65 Notification_triggerEvent( 'global' , 0 , 'waiting') ; 66 } 67 68 69 function do_CommentNotifications($commentID, $comment_post_ID) 70 { 71 global $xoops_config , $xoops_db; 72 73 $xpress_prefix = get_wp_prefix() ; 74 75 $table_term_relationships = $xpress_prefix .'term_relationships'; 76 $table_term_taxonomy = $xpress_prefix .'term_taxonomy'; 77 $table_terms = $xpress_prefix .'terms'; 78 $table_categories = $xpress_prefix .'categories'; 79 $wp_post = $xpress_prefix .'posts'; 80 $wp_options = $xpress_prefix .'options'; 81 $wp_users = $xpress_prefix .'users'; 82 $wp_comments = $xpress_prefix .'comments'; 83 $post_id = $comment_post_ID; 84 85 $post_title = get_the_title($post_id); 86 $post_url = get_permalink($post_id). '#comment'; 87 $blog_name = get_bloginfo('name'); 88 89 // query 90 $sql = "SELECT post_author FROM ".$wp_post." WHERE ID=$comment_post_ID "; 91 $post_author = $xoops_db->get_var($sql); 92 93 $sql = "SELECT display_name FROM $wp_users WHERE ID ='$post_author'"; 94 $user_name = $xoops_db->get_var($sql); 95 96 $comment_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ; 97 Notification_triggerEvent('global' , 0 , 'comment' , $comment_tags , false); 98 Notification_triggerEvent('author' , $post_author , 'comment' , $comment_tags , false); 99 Notification_triggerEvent('post' , $comment_post_ID , 'comment' , $comment_tags , false); 100 101 // categorie notification 102 if (get_xpress_db_version() < 6124){ 103 $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; 104 } else { 105 $sql2 = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 106 $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 "; 107 $sql2 .= "WHERE ($table_term_relationships.object_id =" . $comment_post_ID.") AND ($table_term_taxonomy.taxonomy='category')"; 108 } 109 $categories = $xoops_db->get_results($sql); 110 foreach($categories as $categorie){ 111 $cat_id = $categorie->cat_ID; 112 $cat_name = $categorie->cat_name; 113 $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 ) ; 114 Notification_triggerEvent('category' , $cat_id , 'comment' , $comment_tags , false); 115 116 } 117 } 118 119 function do_PostNotifications($post_id,$not_event) 120 { 121 global $xoops_config, $xoops_db; 122 xpress_debug(); 123 124 125 126 // $not_event: newpost,editpost ; $commentID, $comment_post_ID) 127 128 $xpress_prefix = get_wp_prefix() ; 129 130 $table_term_relationships = $xpress_prefix .'term_relationships'; 131 $table_term_taxonomy = $xpress_prefix .'term_taxonomy'; 132 $table_terms = $xpress_prefix .'terms'; 133 $table_categories = $xpress_prefix .'categories'; 134 $wp_post = $xpress_prefix .'posts'; 135 $wp_options = $xpress_prefix .'options'; 136 $wp_users = $xpress_prefix .'users'; 137 $wp_comments = $xpress_prefix .'comments'; 138 139 $post_title = get_the_title($post_id); 140 $post_url = get_permalink($post_id). '#comment'; 141 $blog_name = get_bloginfo('name'); 142 143 // query 144 $sql = "SELECT post_author FROM ".$wp_post." WHERE ID=$post_id "; 145 $post_author = $xoops_db->get_var($sql); 146 147 $sql = "SELECT display_name FROM $wp_users WHERE ID ='$post_author'"; 148 $user_name = $xoops_db->get_var($sql); 149 150 $posts_tags = array( 'XPRESS_AUTH_NAME' =>$user_name,'XPRESS_BLOG_NAME' =>$blog_name,'XPRESS_POST_TITLE' => $post_title , 'XPRESS_POST_URL' => $post_url ) ; 151 152 switch ($not_event) { 153 case 'newpost' : 154 Notification_triggerEvent('global' , 0 , 'newpost' , $posts_tags , false); 155 Notification_triggerEvent('author' , $post_author , 'newpost' , $posts_tags , false); 156 157 // categorie notification 158 if (get_xpress_db_version() < 6124){ 159 $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; 160 } else { 161 $sql2 = "SELECT $table_term_relationships.object_id, $table_terms.term_id AS cat_ID, $table_terms.name AS cat_name "; 162 $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 "; 163 $sql2 .= "WHERE ($table_term_relationships.object_id =" . $post_id.") AND ($table_term_taxonomy.taxonomy='category')"; 164 } 165 $categories = $xoops_db->get_results($sql); 166 foreach($categories as $categorie){ 167 $cat_id = $categorie->cat_ID; 168 $cat_name = $categorie->cat_name; 169 $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 ) ; 170 Notification_triggerEvent('category' , $cat_id , 'newpost' , $posts_tags , false); 171 } 172 break; 173 case 'editpost' : 174 Notification_triggerEvent('post' , $post_id , 'editpost' , $posts_tags , false); 175 break; 176 default : 177 } 178 } 179 43 180 ?> -
trunk/wp-content/plugins/xpressme/include/user_sync_xoops.php
r87 r95 43 43 $db_groups_users_link = get_xoops_prefix() . 'groups_users_link'; 44 44 $db_group_role = get_wp_prefix() . 'group_role'; 45 $db_groups = get_xoops_prefix() . 'groups'; 45 46 46 47 $sql = "SELECT * "; 47 48 $sql .= "FROM $db_groups_users_link "; 48 49 $sql .= "LEFT JOIN $db_group_role ON $db_groups_users_link.groupid = $db_group_role.groupid "; 50 $sql .= "LEFT JOIN $db_groups ON $db_groups_users_link.groupid = $db_groups.groupid "; 49 51 $sql .= "WHERE uid = $uid"; 50 51 52 $user_groups = $xoops_db->get_results($sql); 52 53 $ans['capabillities'] = ''; … … 54 55 55 56 foreach($user_groups as $user_group){ 57 if ($user_group->group_type == 'Admin'){ 58 $ans['capabillities'] = 'administrator'; 59 $ans['allway_update'] = 0; 60 break; 61 } 56 62 $before_level = get_role_level($ans['capabillities']); 63 57 64 $now_level = get_role_level($user_group->role); 58 65 if ($now_level > $before_level){ … … 80 87 function user_sync_to_wordpress($sync_uid = 0, &$message){ 81 88 global $xoops_db; 82 global $xoopsModule; 83 84 if( is_object($xoopsModule)) { 85 $db_xoops_users = get_xoops_prefix() . 'users'; 86 $db_xpress_users = get_wp_prefix() . 'users'; 87 88 $message = 'Do Sync'; 89 90 if ($sync_uid == 0) { 91 $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users"; 89 90 $db_xoops_users = get_xoops_prefix() . 'users'; 91 $db_xpress_users = get_wp_prefix() . 'users'; 92 93 $message = 'Do Sync'; 94 95 if ($sync_uid == 0) { 96 $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users"; 97 } else { 98 $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users WHERE uid = $sync_uid"; 99 } 100 101 $xoops_users = $xoops_db->get_results($xu_sql); 102 if (empty($xoops_users)){ 103 $message .= '...ERR ('. $xu_sql . ')'; 104 return false; 105 } 106 107 foreach($xoops_users as $xoops_user){ 108 $role = get_xoops_group_role($xoops_user->uid); 109 $capabillities_name = $role['capabillities']; 110 $allway_update = $role['allway_update']; 111 if (empty($capabillities_name)){ 112 $message .= "...PASS '" . $xoops_user->uname ."'[uid=".$xoops_user->uid ."](not xpress user)"; 113 if ($sync_uid != 0){ 114 $message .= '...NOT XPRESS USER ' . $xoops_user->uname; 115 return false; 116 } 92 117 } else { 93 $xu_sql = "SELECT uid ,name ,uname ,pass ,email, url, user_regdate, user_aim, user_yim FROM $db_xoops_users WHERE uid = $sync_uid"; 94 } 95 96 $xoops_users = $xoops_db->get_results($xu_sql); 97 if (empty($xoops_users)){ 98 $message .= '...ERR ('. $xu_sql . ')'; 99 return false; 100 } 101 102 foreach($xoops_users as $xoops_user){ 103 $role = get_xoops_group_role($xoops_user->uid); 104 $capabillities_name = $role['capabillities']; 105 $allway_update = $role['allway_update']; 106 if (empty($capabillities_name)){ 107 $message .= "...PASS '" . $xoops_user->uname ."'[uid=".$xoops_user->uid ."](not xpress user)"; 108 if ($sync_uid != 0){ 109 $message .= '...NOT XPRESS USER ' . $xoops_user->uname; 110 return false; 118 $user_regist_time = date('Y-m-d H:i:s' , $xoops_user->user_regdate); 119 $user_status = 0; 120 $user_display_name =empty($xoops_user->name) ? $xoops_user->uname :$xoops_user->name ; 121 122 $is_update = false; 123 124 $wp_user_id = get_wp_user_id($xoops_user->uname) ; 125 if ($wp_user_id){ 126 $wu_sql = "UPDATE $db_xpress_users "; 127 $wu_sql .= 'SET '; 128 $wu_sql .= "user_pass = '$xoops_user->pass', "; 129 $wu_sql .= "user_email = '$xoops_user->email', "; 130 $wu_sql .= "user_url = '$xoops_user->url', "; 131 $wu_sql .= "user_nicename = '$xoops_user->uname', "; 132 $wu_sql .= "user_registered = '$user_regist_time', "; 133 $wu_sql .= "user_status = 0 "; 134 $wu_sql .= "WHERE (user_login = '$xoops_user->uname' )"; 135 136 $xoops_db->query($wu_sql); 137 if ($allway_update){ 138 $sycc_user = new WP_User($wp_user_id); 139 $sycc_user->set_role($capabillities_name); 140 $message .= '...UPDATE ' . $user_login_name . '(' . $capabillities_name . ')'; 141 142 } else { 143 $message .= '...UPDATE ' . $user_login_name . '(Level Not Change)'; 111 144 } 112 } else { 113 $user_regist_time = date('Y-m-d H:i:s' , $xoops_user->user_regdate); 114 $user_status = 0; 115 $user_display_name =empty($xoops_user->name) ? $xoops_user->uname :$xoops_user->name ; 116 117 $is_update = false; 118 119 $wp_user_id = get_wp_user_id($xoops_user->uname) ; 120 if ($wp_user_id){ 121 $wu_sql = "UPDATE $db_xpress_users "; 122 $wu_sql .= 'SET '; 123 $wu_sql .= "user_pass = '$xoops_user->pass', "; 124 $wu_sql .= "user_email = '$xoops_user->email', "; 125 $wu_sql .= "user_url = '$xoops_user->url', "; 126 $wu_sql .= "user_nicename = '$xoops_user->uname', "; 127 $wu_sql .= "user_registered = '$user_regist_time', "; 128 $wu_sql .= "user_status = 0 "; 129 $wu_sql .= "WHERE (user_login = '$xoops_user->uname' )"; 130 131 $xoops_db->query($wu_sql); 132 if ($allway_update){ 133 $sycc_user = new WP_User($wp_user_id); 134 $sycc_user->set_role($capabillities_name); 135 $message .= '...UPDATE ' . $user_login_name . '(' . $capabillities_name . ')'; 136 137 } else { 138 $message .= '...UPDATE ' . $user_login_name . '(Level Not Change)'; 139 } 140 }else{ 141 $wu_sql = "INSERT INTO $db_xpress_users "; 142 $wu_sql .= "(user_login , user_pass ,user_email , user_url , user_nicename " ; 143 $wu_sql .= " , user_registered , user_status , display_name) "; 144 $wu_sql .= "VALUES "; 145 $wu_sql .= "('$xoops_user->uname', '$xoops_user->pass', '$xoops_user->email', '$xoops_user->url', '$xoops_user->uname' "; 146 $wu_sql .= " , '$user_regist_time', $user_status, '$user_display_name')"; 147 $xoops_db->query($wu_sql); 145 }else{ 146 $wu_sql = "INSERT INTO $db_xpress_users "; 147 $wu_sql .= "(user_login , user_pass ,user_email , user_url , user_nicename " ; 148 $wu_sql .= " , user_registered , user_status , display_name) "; 149 $wu_sql .= "VALUES "; 150 $wu_sql .= "('$xoops_user->uname', '$xoops_user->pass', '$xoops_user->email', '$xoops_user->url', '$xoops_user->uname' "; 151 $wu_sql .= " , '$user_regist_time', $user_status, '$user_display_name')"; 152 $xoops_db->query($wu_sql); 148 153 // $wp_user_id = get_wp_user_id($user_login_name) ; 149 $wp_user_id = mysql_insert_id(); 150 $sycc_user = new WP_User($wp_user_id); 151 $sycc_user->set_role($capabillities_name); 152 $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')'; 153 } 154 155 $user_nickname = empty($xoops_user->name) ? $xoops_user->uname :$xoops_user->name ; 156 $user_rich_editing = 'true'; 157 $user_first_name = $xoops_user->uname; 158 $user_last_name = ''; 159 $user_description = ''; 160 $user_jabber = ''; 161 162 update_usermeta( $wp_user_id,'nickname',$user_nickname); 163 update_usermeta( $wp_user_id,'first_name',$user_first_name); 164 update_usermeta( $wp_user_id,'last_name',$user_last_name); 165 update_usermeta( $wp_user_id,'description',$user_description); 166 update_usermeta( $wp_user_id,'jabber',$user_jabber); 167 update_usermeta( $wp_user_id,'aim',$xoops_user->user_aim); 168 update_usermeta( $wp_user_id,'yim',$xoops_user->user_yim); 169 if ($is_update === false ) { 170 update_usermeta( $wp_user_id,'rich_editing',$user_rich_editing); 171 } 172 } 173 } 174 $message .= "...END"; 175 return true; 176 } 154 $wp_user_id = mysql_insert_id(); 155 $sycc_user = new WP_User($wp_user_id); 156 $sycc_user->set_role($capabillities_name); 157 $message .= '...INSERT ' . $user_login_name . '(' . $capabillities_name . ')'; 158 } 159 160 $user_nickname = empty($xoops_user->name) ? $xoops_user->uname :$xoops_user->name ; 161 $user_rich_editing = 'true'; 162 $user_first_name = $xoops_user->uname; 163 $user_last_name = ''; 164 $user_description = ''; 165 $user_jabber = ''; 166 167 update_usermeta( $wp_user_id,'nickname',$user_nickname); 168 update_usermeta( $wp_user_id,'first_name',$user_first_name); 169 update_usermeta( $wp_user_id,'last_name',$user_last_name); 170 update_usermeta( $wp_user_id,'description',$user_description); 171 update_usermeta( $wp_user_id,'jabber',$user_jabber); 172 update_usermeta( $wp_user_id,'aim',$xoops_user->user_aim); 173 update_usermeta( $wp_user_id,'yim',$xoops_user->user_yim); 174 if ($is_update === false ) { 175 update_usermeta( $wp_user_id,'rich_editing',$user_rich_editing); 176 } 177 } 178 } 179 $message .= "...END"; 180 return true; 177 181 } 178 182
Note: See TracChangeset
for help on using the changeset viewer.