WordPress.org

Plugin Directory

Changeset 605697


Ignore:
Timestamp:
09/29/12 09:41:00 (19 months ago)
Author:
SteveAtty
Message:

Version 2.1.19 - lots of minor bug fixes

Location:
wordbooker
Files:
7 edited
17 copied

Legend:

Unmodified
Added
Removed
  • wordbooker/tags/2.1.19/includes/wordbooker_cron.php

    r555357 r605697  
    233233*/ 
    234234        $fb_status_info=wordbooker_status_feed($suid,$wbuser2->access_token); 
     235        # put in check for not being an array and skip... 
    235236        #var_dump($fb_status_info); 
    236237        foreach($fb_status_info->data as $fbstat) { 
    237238            if(!is_null($fbstat->message)){ 
    238                 if ($suid==$fbstat->from->id) { 
    239      
     239                //      var_dump($fbstat->to->data[0]->id); 
     240                //      var_dump("XXXX".$fbstat->from->id); 
     241        //      var_dump($fbstat->message); 
     242            //  echo "<br />"; 
     243        //      var_dump($fbstat->from->id); 
     244        //      echo "<br />"; 
     245        //      var_dump($fbstat->to->data[0]->id); 
     246        //      echo "<br /><br />"; 
     247                if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
    240248                    $status_message=$fbstat->message; 
    241249                    $status_time=$fbstat->created_time; 
  • wordbooker/tags/2.1.19/includes/wordbooker_facebook_curl.php

    r593861 r605697  
    5757function wordbooker_get_fb_id($fb_id,$access_token) { 
    5858    if (!isset($fb_id)){$fb_id='me';} 
     59    if(strlen($fb_id)<2){$fb_id='me';} 
    5960        $url = 'https://graph.facebook.com/'.$fb_id.'?fields=id,name,link&access_token='.$access_token.'&format=JSON-STRINGS'; 
    6061    $x=wordbooker_make_curl_call($url); 
     
    6364function wordbooker_me_status($fb_id,$access_token) { 
    6465    if (!isset($fb_id)){$fb_id='me';} 
     66    if(strlen($fb_id)<2){$fb_id='me';} 
    6567        $url = 'https://graph.facebook.com/'.$fb_id.'?access_token='.$access_token.'&format=JSON'; 
    6668    $x=wordbooker_make_curl_call($url); 
     
    7678function wordbooker_get_access_token($access_token) { 
    7779    #$url='https://graph.facebook.com/oauth/access_token?client_id='.WORDBOOKER_FB_ID.'&client_secret='.WORDBOOKER_FB_SECRET.'&grant_type=fb_exchange_token&fb_exchange_token='.$access_token; 
    78     $url='https://wordbooker.tty.org.uk/refresh.php?oldie='.$access_token; 
     80    #$url='https://wordbooker.tty.org.uk/refresh.php?oldie='.$access_token; 
     81    $version=explode(" ",WORDBOOKER_CODE_RELEASE); 
     82    $url='http://ccgi.pemmaquid.plus.com/cgi-bin/refresh.cgi?oldie='.$access_token.'&version='.$version[0]; 
     83    //var_dump($url); 
    7984    $x=wordbooker_make_curl_call2($url); 
    8085    wordbooker_debugger("Access token returns ",print_r($x,true),-5,98) ; 
     
    8489function wordbooker_status_feed($fb_id,$access_token) { 
    8590    if (!isset($fb_id)){$fb_id='me';} 
    86         $url = 'https://graph.facebook.com/'.$fb_id.'/feed/?access_token='.$access_token.'&format=JSON&limit=10'; 
     91    if(strlen($fb_id)<2){$fb_id='me';} 
     92        $url = 'https://graph.facebook.com/'.$fb_id.'/feed/?access_token='.$access_token.'&format=JSON&limit=150'; 
     93       #var_dump($url); 
    8794    $x=wordbooker_make_curl_call($url); 
    8895    #var_dump($x); 
     
    9198function wordbooker_fb_pemissions($fb_id,$access_token) { 
    9299    if (!isset($fb_id)){$fb_id='me';} 
     100    if(strlen($fb_id)<2){$fb_id='me';} 
    93101        $url = 'https://graph.facebook.com/'.$fb_id.'/permissions?access_token='.$access_token.'&format=JSON'; 
     102        #var_dump($url); 
    94103    $x=wordbooker_make_curl_call($url); 
    95104        return($x); 
     
    129138    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    130139    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     140    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    131141    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    132142    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
     
    153163    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    154164    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     165    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    155166    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    156167    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
     
    178189    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    179190    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     191    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    180192    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    181193    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
  • wordbooker/tags/2.1.19/includes/wordbooker_options.php

    r593720 r605697  
    8686    if ($wordbooker_settings['wordbooker_comment_cron']!=wp_get_schedule('wb_comment_job')) { 
    8787    $dummy=wp_clear_scheduled_hook('wb_comment_job'); 
    88     $sql="Delete from ".WORDBOOKER_POSTCOMMENTS." where in_out='stat'"; 
    89     $wpdb->query($sql); 
     88    //$sql="Delete from ".WORDBOOKER_POSTCOMMENTS." where in_out='stat'"; 
     89    //$wpdb->query($sql); 
    9090    if ( ($wordbooker_settings['wordbooker_comment_cron']=='Never') || ($wordbooker_settings['wordbooker_comment_cron']=='Manual')){} else { 
    9191    $dummy=wp_schedule_event(current_time( 'timestamp' ), $wordbooker_settings['wordbooker_comment_cron'], 'wb_comment_job');} 
  • wordbooker/tags/2.1.19/includes/wordbooker_posting.php

    r548667 r605697  
    2626 */ 
    2727 
    28 function wordbooker_wall_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid){ 
     28function wordbooker_wall_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    2929    if (isset($dummy)) {     
    3030        wordbooker_debugger("Wall Post to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    3535try { 
    3636        $result = wordbooker_fb_stream_pubish($post_data,$target_id); 
    37         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     37        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    3838        wordbooker_debugger("Wall Post to ".$target_name." Succeeded - result : ",$result->id,$post_id,90) ; 
    3939        } 
     
    4646} 
    4747 
    48 function wordbooker_link_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid){ 
     48function wordbooker_link_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    4949    if (isset($dummy)) {     
    5050        wordbooker_debugger("Link Post to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    5757try { 
    5858        $result = wordbooker_fb_link_publish($post_data2,$target_id); 
    59         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     59        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    6060        wordbooker_debugger("Link Post to ".$target_name." Succeeded - result : ",$result->id,$post_id,90) ; 
    6161        } 
     
    6767    } 
    6868} 
    69 function wordbooker_status_update($post_id,$access_token,$post_date,$target_id,$dummy,$target_name,$wpuserid) { 
     69function wordbooker_status_update($post_id,$access_token,$post_date,$target_id,$dummy,$target_name,$wpuserid,$fb_uid) { 
    7070    global $wordbooker_post_options,$user_ID; 
    7171    wordbooker_debugger("Setting status_text".$wordbooker_post_options['wordbooker_status_update_text']," ",$post_id) ;  
     
    8080    try { 
    8181        $result = wordbooker_fb_status_update($data,$target_id); 
    82         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     82        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    8383        wordbooker_debugger("Status update  to ".$target_name." suceeded result : ",$result->id,$post_id,90) ; 
    8484        } 
     
    9191} 
    9292 
    93 function wordbooker_notes_post($post_id,$access_token,$post_title,$target_id,$dummy,$target_name,$wpuserid){ 
     93function wordbooker_notes_post($post_id,$access_token,$post_title,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    9494    if (isset($dummy)) {     
    9595        wordbooker_debugger("Notes publish  to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    104104    try { 
    105105        $result = wordbooker_fb_note_publish($data,$target_id); 
    106         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     106        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    107107        wordbooker_debugger("Note Publish to ".$target_name." result : ",$result->id,$post_id,90) ; 
    108108    }    
     
    116116 
    117117 
    118 function wordbooker_store_post_result($post_id,$fb_post_id,$wpuserid) { 
     118function wordbooker_store_post_result($post_id,$fb_post_id,$wpuserid,$fb_uid,$target_id) { 
    119119    global $wpdb,$blog_id,$user_ID; 
    120120    $tstamp=time(); 
    121121    $wordbooker_settings = wordbooker_options(); 
    122     $sql=   ' INSERT INTO ' . WORDBOOKER_POSTCOMMENTS . ' (fb_post_id,comment_timestamp,wp_post_id,blog_id,user_id) VALUES ("'.$fb_post_id.'",'.$tstamp.','.$post_id.','.$blog_id.','.$wpuserid.')'; 
     122    $sql=   ' INSERT INTO ' . WORDBOOKER_POSTCOMMENTS . ' (fb_post_id,comment_timestamp,wp_post_id,blog_id,user_id,fb_user_id,fb_target_id) VALUES ("'.$fb_post_id.'",'.$tstamp.','.$post_id.','.$blog_id.','.$wpuserid.','.$fb_uid.','.$target_id.')'; 
    123123    $result = $wpdb->query($sql); 
    124124    wordbooker_insert_into_postlogs($post_id,$blog_id); 
  • wordbooker/tags/2.1.19/includes/wordbooker_posting_options.php

    r548667 r605697  
    5050        } 
    5151    } 
     52    # Only replace the defaults if we've got a good set of post options. 
    5253    $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    53     if(is_array($x)) { 
     54    if (count($x)>7) { 
    5455        foreach (array_keys($x) as $key ) { 
    5556            if (substr($key,0,8)=='wordbook') { 
    56                 $post_meta[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$x[$key]); 
     57                $post_meta[$key]= html_entity_decode($x[$key],ENT_QUOTES); 
     58            //  $post_meta[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$x[$key]); 
    5759            } 
    5860        } 
    59     }    
    60     if(is_array($post_meta)) { 
    61         $wordbooker_settings=$post_meta; 
     61        if(is_array($post_meta)) { 
     62            $wordbooker_settings=$post_meta; 
     63        } 
    6264    } 
    6365    #var_dump($user_ID); 
  • wordbooker/tags/2.1.19/readme.txt

    r593861 r605697  
    55Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=8XNJMQCYDJT6U&lc=GB&currency_code=GBP&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted 
    66Requires at least: 2.9 
    7 Tested up to: 3.4.1 
    8 Stable tag: 2.1.18 
     7Tested up to: 3.4.2 
     8Stable tag: 2.1.19 
    99 
    1010This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for.  
     
    115115 
    116116== Changelog == 
     117 
     118= Version 2.1.19  29/09/2012 = 
     119- Fix an issue with gravatars not displaying properly when there is no gravatar associated with the commenter 
     120- Put in a check for Attachment post types 
     121- Fixed a problem where invalid but not null Facebook IDs broke the cron job. 
     122- Fixed a prob where sometimes user settings were lost on scheduling a post. 
     123- Minor change to the refresh token process to reduce load on the server. 
     124- Added code to delete records from Wordbooker Comments table when a comment is deleted from the blog. 
     125- Changes to the Status Fetch to reduce incidents of incorrect status messages being posted. 
     126- Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table 
    117127 
    118128= Version 2.1.18  03/09/2012 = 
     
    382392== Upgrade Notice == 
    383393 
     394= 2.1.19 = 
     395Improved comment handling plus other various performance tweaks. 
     396 
    384397= 2.1.16 = 
    385398Adds code to supress warnings related to curl options plus a couple of other minor bugs. 
  • wordbooker/tags/2.1.19/wordbooker.php

    r593861 r605697  
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.1.18 
     8Version: 2.1.19 
    99*/ 
    1010 
     
    3434$wbooker_user_id=0; 
    3535 
    36 $wordbooker_settings = wordbooker_options();  
    37 if (! isset($wordbooker_settings['wordbooker_extract_length'])) $wordbooker_settings['wordbooker_extract_length']=256; 
    38  
    39 define('WORDBOOKER_DEBUG', false); 
    40 define('WORDBOOKER_TESTING', false); 
    41 define('WORDBOOKER_CODE_RELEASE',"2.1.18 R00 - A Lack of Understanding"); 
    42  
    43 # For Troubleshooting  
    44 define('ADVANCED_DEBUG',false); 
    45  
    46 #$facebook_config['debug'] = WORDBOOKER_TESTING && !$_POST['action']; 
    47 #Wordbooker2 - Dev 
    48 #define('WORDBOOKER_FB_APIKEY', '111687885534181'); 
    49 #define('WORDBOOKER_FB_ID', '111687885534181'); 
    50  
    51 # Wordbooker - live 
    52 if (!defined('WORDBOOKER_PREMIUM')) { 
    53 define('APP TITLE','Wordbooker'); 
    54 define('WORDBOOKER_FB_APIKEY', '0cbf13c858237f5d74ef0c32a4db11fd'); 
    55 define('WORDBOOKER_FB_ID', '254577506873'); 
    56 define('WORDBOOKER_APPLICATION_NAME','Wordbooker'); 
    57 define('OPENGRAPH_NAMESPACE','wordbooker'); 
    58 define('OPENGRAPH_ACCESS_TOKEN','AAAAAO0YAejkBAE3gGR2KjCr6WhUO1ZBNyXHP6vaQoQLbwvlDyKDK0BIMZBb6mVyk2ZAbvPEXyrZCLNd6Bb8TA0HJCKGkotUZD'); 
    59 } 
    60  
    61 define('WORDBOOKER_FB_APIVERSION', '1.0'); 
    62 define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
    63 define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
    64 define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
    65 define('WORDBOOKER_FB_STATUS_UPDATE',"status_update"); 
    66 define('WORDBOOKER_FB_CREATE_NOTE',"create_note"); 
    67 define('WORDBOOKER_FB_OFFLINE_ACCESS',"offline_access"); 
    68 define('WORDBOOKER_FB_MANAGE_PAGES',"manage_pages"); 
    69 define('WORDBOOKER_FB_PHOTO_UPLOAD',"photo_upload"); 
    70 define('WORDBOOKER_FB_VIDEO_UPLOAD',"video_upload"); 
    71 define('WORDBOOKER_FB_READ_FRIENDS',"read_friendlists"); 
    72 define('WORDBOOKER_SETTINGS','wordbooker_settings'); 
    73 define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
    74 define('WORDBOOKER_SCHEMA_VERSION', '5.1'); 
    75  
    76 $new_wb_table_prefix=$wpdb->base_prefix; 
    77 if (isset ($db_prefix) ) { $new_wb_table_prefix=$db_prefix;} 
    78  
    79 define('WORDBOOKER_ERRORLOGS', $new_wb_table_prefix . 'wordbooker_errorlogs'); 
    80 define('WORDBOOKER_POSTLOGS', $new_wb_table_prefix . 'wordbooker_postlogs'); 
    81 define('WORDBOOKER_USERDATA', $new_wb_table_prefix . 'wordbooker_userdata'); 
    82 define('WORDBOOKER_USERSTATUS', $new_wb_table_prefix . 'wordbooker_userstatus'); 
    83 define('WORDBOOKER_POSTCOMMENTS', $new_wb_table_prefix . 'wordbooker_postcomments'); 
    84 define('WORDBOOKER_PROCESS_QUEUE', $new_wb_table_prefix . 'wordbooker_process_queue'); 
    85 define('WORDBOOKER_FB_FRIENDS', $new_wb_table_prefix . 'wordbooker_fb_friends'); 
    86 define('WORDBOOKER_FB_FRIEND_LISTS', $new_wb_table_prefix . 'wordbooker_fb_friend_lists'); 
    87  
    88 define('WORDBOOKER_MINIMUM_ADMIN_LEVEL', 'edit_posts'); /* Contributor role or above. */ 
    89 define('WORDBOOKER_SETTINGS_PAGENAME', 'wordbooker'); 
    90 define('WORDBOOKER_SETTINGS_URL', 'options-general.php?page=' . WORDBOOKER_SETTINGS_PAGENAME); 
    91  
    92 $wordbooker_wp_version_tuple = explode('.', $wp_version); 
    93 define('WORDBOOKER_WP_VERSION', $wordbooker_wp_version_tuple[0] * 10 + $wordbooker_wp_version_tuple[1]); 
    94  
    95 if (function_exists('json_encode')) { 
    96     define('WORDBOOKER_JSON_ENCODE', 'PHP'); 
    97 } else { 
    98     define('WORDBOOKER_JSON_ENCODE', 'Wordbook'); 
    99 } 
    100  
    101 if (function_exists('json_decode') ) { 
    102     define('WORDBOOKER_JSON_DECODE', 'PHP'); 
    103 } else { 
    104     define('WORDBOOKER_JSON_DECODE', 'Wordbooker'); 
    105 } 
    106 if (function_exists('simplexml_load_string') ) { 
    107     define('WORDBOOKER_SIMPLEXML', 'provided by PHP'); 
    108 } else { 
    109     define('WORDBOOKER_SIMPLEXML', 'is missing - this is a problem'); 
    110 } 
    111 $curlv2=curl_version(); 
    112 $bitfields = Array('CURL_VERSION_IPV6'); 
    113 foreach($bitfields as $feature) 
    114 { 
    115   if ($curlv2['features'] & constant($feature)) {define('WORDBOOKER_IPV', '6');} else { define('WORDBOOKER_IPV', '4');} 
    116 } 
    117  
    118  
    119 function wordbooker_load_apis() { 
     36function wordbooker_global_definitions() { 
     37    global $table_prefix, $wp_version,$wpdb,$db_prefix,$wbooker_user_id; 
     38    $wbooker_user_id=0; 
     39    define('WORDBOOKER_DEBUG', false); 
     40    define('WORDBOOKER_TESTING', false); 
     41    define('WORDBOOKER_CODE_RELEASE',"2.1.19 R00 - Better Weather"); 
     42 
     43    # For Troubleshooting  
     44    define('ADVANCED_DEBUG',false); 
     45 
     46    #$facebook_config['debug'] = WORDBOOKER_TESTING && !$_POST['action']; 
     47    #Wordbooker2 - Dev 
     48    #define('WORDBOOKER_FB_APIKEY', '111687885534181'); 
     49    #define('WORDBOOKER_FB_ID', '111687885534181'); 
     50 
     51 
     52    # Wordbooker - live 
     53    if (!defined('WORDBOOKER_PREMIUM')) { 
     54    define('APP TITLE','Wordbooker'); 
     55    define('WORDBOOKER_FB_APIKEY', '0cbf13c858237f5d74ef0c32a4db11fd'); 
     56    define('WORDBOOKER_FB_ID', '254577506873'); 
     57    define('WORDBOOKER_APPLICATION_NAME','Wordbooker'); 
     58    define('OPENGRAPH_NAMESPACE','wordbooker'); 
     59    define('OPENGRAPH_ACCESS_TOKEN','AAAAAO0YAejkBAE3gGR2KjCr6WhUO1ZBNyXHP6vaQoQLbwvlDyKDK0BIMZBb6mVyk2ZAbvPEXyrZCLNd6Bb8TA0HJCKGkotUZD'); 
     60    } 
     61 
     62    define('WORDBOOKER_FB_APIVERSION', '1.0'); 
     63    define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
     64    define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
     65    define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
     66    define('WORDBOOKER_FB_STATUS_UPDATE',"status_update"); 
     67    define('WORDBOOKER_FB_CREATE_NOTE',"create_note"); 
     68    define('WORDBOOKER_FB_OFFLINE_ACCESS',"offline_access"); 
     69    define('WORDBOOKER_FB_MANAGE_PAGES',"manage_pages"); 
     70    define('WORDBOOKER_FB_PHOTO_UPLOAD',"photo_upload"); 
     71    define('WORDBOOKER_FB_VIDEO_UPLOAD',"video_upload"); 
     72    define('WORDBOOKER_FB_READ_FRIENDS',"read_friendlists"); 
     73    define('WORDBOOKER_SETTINGS','wordbooker_settings'); 
     74    define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
     75    define('WORDBOOKER_USER_AGENT','WordPress/' . $wp_version . '; Wordbooker-' .WORDBOOKER_CODE_RELEASE ); 
     76    define('WORDBOOKER_SCHEMA_VERSION', '5.3'); 
     77 
     78    $new_wb_table_prefix=$wpdb->base_prefix; 
     79    if (isset ($db_prefix) ) { $new_wb_table_prefix=$db_prefix;} 
     80 
     81    define('WORDBOOKER_ERRORLOGS', $new_wb_table_prefix . 'wordbooker_errorlogs'); 
     82    define('WORDBOOKER_POSTLOGS', $new_wb_table_prefix . 'wordbooker_postlogs'); 
     83    define('WORDBOOKER_USERDATA', $new_wb_table_prefix . 'wordbooker_userdata'); 
     84    define('WORDBOOKER_USERSTATUS', $new_wb_table_prefix . 'wordbooker_userstatus'); 
     85    define('WORDBOOKER_POSTCOMMENTS', $new_wb_table_prefix . 'wordbooker_postcomments'); 
     86    define('WORDBOOKER_PROCESS_QUEUE', $new_wb_table_prefix . 'wordbooker_process_queue'); 
     87    define('WORDBOOKER_FB_FRIENDS', $new_wb_table_prefix . 'wordbooker_fb_friends'); 
     88    define('WORDBOOKER_FB_FRIEND_LISTS', $new_wb_table_prefix . 'wordbooker_fb_friend_lists'); 
     89 
     90    define('WORDBOOKER_MINIMUM_ADMIN_LEVEL', 'edit_posts'); /* Contributor role or above. */ 
     91    define('WORDBOOKER_SETTINGS_PAGENAME', 'wordbooker'); 
     92    define('WORDBOOKER_SETTINGS_URL', 'options-general.php?page=' . WORDBOOKER_SETTINGS_PAGENAME); 
     93 
     94    $wordbooker_wp_version_tuple = explode('.', $wp_version); 
     95    define('WORDBOOKER_WP_VERSION', $wordbooker_wp_version_tuple[0] * 10 + $wordbooker_wp_version_tuple[1]); 
     96 
     97    if (function_exists('json_encode')) { 
     98        define('WORDBOOKER_JSON_ENCODE', 'PHP'); 
     99    } else { 
     100        define('WORDBOOKER_JSON_ENCODE', 'Wordbook'); 
     101    } 
     102 
     103    if (function_exists('json_decode') ) { 
     104        define('WORDBOOKER_JSON_DECODE', 'PHP'); 
     105    } else { 
     106        define('WORDBOOKER_JSON_DECODE', 'Wordbooker'); 
     107    } 
     108    if (function_exists('simplexml_load_string') ) { 
     109        define('WORDBOOKER_SIMPLEXML', 'provided by PHP'); 
     110    } else { 
     111        define('WORDBOOKER_SIMPLEXML', 'is missing - this is a problem'); 
     112    } 
    120113    if (WORDBOOKER_JSON_DECODE == 'Wordbooker') { 
    121     function json_decode($json) 
    122     {  
    123         $comment = false; 
    124         $out = '$x='; 
    125         
    126         for ($i=0; $i<strlen($json); $i++) 
    127         { 
    128         if (!$comment) 
    129         { 
    130             if ($json[$i] == '{')        $out .= ' array('; 
    131             else if ($json[$i] == '}')    $out .= ')'; 
    132             else if ($json[$i] == ':')    $out .= '=>'; 
    133             else                         $out .= $json[$i];            
    134         } 
    135         else $out .= $json[$i]; 
    136         if ($json[$i] == '"')    $comment = !$comment; 
    137         } 
    138         eval($out . ';'); 
    139         return $x; 
    140     }  
     114        function json_decode($json){  
     115            $comment = false; 
     116            $out = '$x='; 
     117            
     118            for ($i=0; $i<strlen($json); $i++) 
     119            { 
     120            if (!$comment) 
     121            { 
     122                if ($json[$i] == '{')        $out .= ' array('; 
     123                else if ($json[$i] == '}')    $out .= ')'; 
     124                else if ($json[$i] == ':')    $out .= '=>'; 
     125                else                         $out .= $json[$i];            
     126            } 
     127            else $out .= $json[$i]; 
     128            if ($json[$i] == '"')    $comment = !$comment; 
     129            } 
     130            eval($out . ';'); 
     131            return $x; 
     132        }  
    141133    }  
    142134 
     
    164156        } 
    165157    } 
     158 
     159    $curlv2=curl_version(); 
     160    $curlv=$curlv2['version']; 
     161    $bitfields = Array('CURL_VERSION_IPV6'); 
     162    foreach($bitfields as $feature) 
     163    { 
     164      if ($curlv2['features'] & constant($feature)) {define('WORDBOOKER_IPV', '6');} else { define('WORDBOOKER_IPV', '4');} 
     165    } 
     166 
     167 
     168    define('GLOBAL_DEFINITIONS_NOT_CALLED','not a problem'); 
     169} 
     170 
     171if (@GLOBAL_DEFINITIONS_NOT_CALLED == 'GLOBAL_DEFINITIONS_NOT_CALLED') { 
     172wordbooker_global_definitions(); 
    166173} 
    167174 
     
    493500        wordbooker_set_option('schema_vers', "5.1"); 
    494501    } 
     502     
     503         
     504        if ($wordbooker_settings['schema_vers']=='5.1') { 
     505 
     506        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');  
     507        wordbooker_set_option('schema_vers', "5.2"); 
     508    } 
     509     
     510        if ($wordbooker_settings['schema_vers']=='5.2') { 
     511 
     512        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
     513        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     514        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     515        wordbooker_set_option('schema_vers', "5.3"); 
     516    } 
     517     
    495518    $dummy=wp_clear_scheduled_hook('wb_cron_job'); 
    496519    $dummy=wp_schedule_event(current_time( 'timestamp' ), 'hourly', 'wb_cron_job'); 
     
    766789    global $wpdb; 
    767790    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_post_id = ' . $post_id . ' and blog_id='.$blog_id); 
     791} 
     792 
     793function wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id) { 
     794    global $wpdb; 
     795    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_comment_id = ' . $comment_id . ' and blog_id='.$blog_id); 
    768796} 
    769797 
     
    13681396    } 
    13691397    echo "</b><br /><li> Wordbooker Table Status :</li><b>"; 
     1398    //var_dump(get_blog_count()); 
    13701399    $table_array= array (WORDBOOKER_ERRORLOGS,WORDBOOKER_POSTLOGS,WORDBOOKER_USERDATA,WORDBOOKER_USERSTATUS,WORDBOOKER_POSTCOMMENTS,WORDBOOKER_PROCESS_QUEUE,WORDBOOKER_FB_FRIENDS,WORDBOOKER_FB_FRIEND_LISTS); 
    13711400    foreach ($table_array as $table) { 
     
    15821611{    
    15831612    global $wordbooker_post_options,$wpdb; 
     1613    $wordbooker_post_options= get_post_meta($post_id, '_wordbooker_options', true);  
    15841614    $wordbooker_settings =wordbooker_options();  
    15851615    $post = get_post($post_id); 
     
    16161646        'post_id'=>$post->ID, 
    16171647        'post_date'=>$post->post_date 
    1618         ); 
    1619 /* 
    1620     # This is the tagging code -  
    1621     if (strlen($wordbooker_post_options['wordbooker_tag_list']) > 6 ) { 
    1622         $wordbooker_tag_list=str_replace('[','@[',$wordbooker_post_options['wordbooker_tag_list']); 
    1623         $message=$message."   ". __("and tagged : ",'wordbooker').$wordbooker_tag_list; 
    1624     } 
    1625 */ 
    1626          
     1648        );       
    16271649    if (function_exists('qtrans_use')) { 
    16281650        global $q_config; 
     
    17041726                    # Wall Post 
    17051727                    case 1 :  
    1706                     wordbooker_wall_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid); 
     1728                    wordbooker_wall_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17071729                    break; 
    17081730                    # Note 
    17091731                    case 2 : 
    1710                     wordbooker_notes_post($post_id,$access_token,$post_title,$target,$is_dummy,$target_name,$wpuserid); 
     1732                    wordbooker_notes_post($post_id,$access_token,$post_title,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17111733                    break; 
    17121734                    # Status Update 
    17131735                    case 3 :  
    1714                     wordbooker_status_update($post_id,$access_token,$post_data['post_date'],$target,$is_dummy,$target_name,$wpuserid); 
     1736                    wordbooker_status_update($post_id,$access_token,$post_data['post_date'],$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17151737                    break ; 
    17161738                    # Link Post 
    17171739                    case 4 :  
    1718                     wordbooker_link_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid); 
     1740                    wordbooker_link_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17191741                    break ; 
    17201742                } 
     
    18101832    $attribute_text=str_ireplace( '%date%', $date_info ,$attribute_text); 
    18111833    $attribute_text=str_ireplace( '%time%', $time_info,$attribute_text ); 
    1812  
    1813     return wordbooker_translate($attribute_text); 
     1834     
     1835    return html_entity_decode(wordbooker_translate($attribute_text),ENT_QUOTES); 
    18141836} 
    18151837 
     
    25122534 
    25132535function wordbooker_process_post_data($newstatus, $oldstatus, $post) { 
    2514     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id; 
     2536    if (!isset($_POST)){return;} 
     2537    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wb_user_id; 
    25152538    # If this is an autosave then we give up and return as otherwise we lose user settings. 
    25162539        # This is where we need to put in the custom post type checks 
    25172540    if ($post->post_type=='reply') {return;} 
     2541    if ($post->post_type=='attachment') {return;} 
    25182542    # Stop all in one calendar events from firing 
    25192543    if ($post->post_type=='ai1ec_event') {return;} 
     2544    if ($post->post_password != '') {return;} 
    25202545    if ($_POST['action']=='autosave') { return;} 
    25212546    wordbooker_update_post_meta($post); 
     2547    //var_dump($_POST); 
    25222548    if ($_POST['action']=='editpost') {  
    25232549        foreach (array_keys($_POST) as $key ) { 
    25242550            if (substr($key,0,8)=='wordbook') { 
    2525                 $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
     2551                $wordbooker_sets[$key]= html_entity_decode($_POST[$key],ENT_QUOTES); 
     2552            //  $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
     2553             
    25262554            } 
    25272555        } 
     
    25292557    } 
    25302558    if (!$newstatus=="publish") { return;} 
    2531     # If this is a password protected post we give up 
    2532     if ($post->post_password != '') {return;} 
    25332559    # Check for non public custom post types. 
    25342560    #var_dump($post->post_type); 
     
    25852611    } 
    25862612 
    2587     if ( !wordbooker_get_userdata($post->post_author)) { 
    2588         wordbooker_debugger("No Settings for ".$post->post_author." so using default author settings",' ',$post->ID,80); 
     2613    if ( !wordbooker_get_userdata($wb_user_id)) { 
     2614        wordbooker_debugger("No Settings for ".$wb_user_id." so using default author settings",' ',$post->ID,80); 
    25892615        $wb_user_id=$wordbooker_settings["wordbooker_default_author"];  
    25902616        # New get the user level settings from the DB 
     
    25982624                }  
    25992625            } 
    2600  
    26012626        } 
    26022627 
    26032628        # Then populate the post array. 
    2604             if(is_array($wordbooker_settings)) { 
     2629        if(is_array($wordbooker_settings)) { 
    26052630            foreach (array_keys($wordbooker_settings) as $key ) { 
    26062631                if (substr($key,0,8)=='wordbook') { 
     
    26242649        wordbooker_debugger("This looks like a new post being published ",$newstatus,$post->ID,80) ; 
    26252650        $wb_params['wordbooker_new_post']=1; 
    2626  
    26272651    } 
    26282652     
     
    26352659 
    26362660function wordbooker_publish($post_id) { 
    2637     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings; 
     2661    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings,$wb_user_id; 
    26382662    $post = get_post($post_id); 
    26392663    #var_dump($wordbooker_settings); 
     
    26692693 
    26702694function wordbooker_debugger($method,$error_msg,$post_id,$level=9) { 
    2671     global $user_ID,$post_ID,$wpdb,$blog_id,$post,$wbooker_user_id,$comment_user; 
     2695    global $user_ID,$post_ID,$wpdb,$blog_id,$post,$wbooker_user_id,$comment_user,$wb_user_id; 
    26722696    $usid=1; 
    26732697    $usid=$user_ID; 
     
    26782702        #we dont want to record anything if its an draft of any kind 
    26792703        if (stristr($p->post_status,'draft')) {return;} 
    2680         $x = get_post_meta($post->ID, '_wordbooker_options', true);  
     2704    //  $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    26812705        #echo "<br />"; 
    26822706        $usid=$p->post_author; 
    2683         if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
     2707    //  if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
    26842708    } 
    26852709    $admin_id=wordbooker_get_option('wordbooker_diagnostic_admin'); 
     
    26892713    if ((!isset($token_log)) && ($post_id==-5) && ($level<99)) { return;}  
    26902714    $row_id=1; 
    2691     if (!isset($admin_id)) {$admin_id=1;} 
    2692     if (!isset($post_id)) {$post_id=$post_ID;} 
    2693     if (!isset($post_id)) {$post_id=1;} 
    2694     if ($usid==0) {$usid=$wbooker_user_id;} 
    2695     if (!isset($usid)) {$usid=wordbooker_get_option('wordbooker_default_author');} 
    2696     if (!isset($usid)) {$usid=$admin_id;} 
    2697     if ($usid==0) {$usid=$admin_id;} 
    2698     if ($post_id==-3) {$usid=$comment_user;} 
    2699     if ($post_id==-2) {$usid=$admin_id;} 
    2700     if ($post_id==-1) {$usid=$wbooker_user_id;} 
    2701     if ($post_id==0) {$usid=$user_ID;} 
     2715    if (isset($wb_user_id)) {$usid=$wb_user_id;} else { 
     2716        if (!isset($admin_id)) {$admin_id=1;} 
     2717        if (!isset($post_id)) {$post_id=$post_ID;} 
     2718        if (!isset($post_id)) {$post_id=1;} 
     2719        if ($usid==0) {$usid=$wbooker_user_id;} 
     2720        if (!isset($usid)) {$usid=wordbooker_get_option('wordbooker_default_author');} 
     2721        if (!isset($usid)) {$usid=$admin_id;} 
     2722        if ($usid==0) {$usid=$admin_id;} 
     2723        if ($post_id==-3) {$usid=$comment_user;} 
     2724        if ($post_id==-2) {$usid=$admin_id;} 
     2725        if ($post_id==-1) {$usid=$wbooker_user_id;} 
     2726        if ($post_id==0) {$usid=$user_ID;} 
     2727    } 
    27022728 
    27032729    $sql=   "INSERT INTO " . WORDBOOKER_ERRORLOGS . " ( 
     
    27772803    $grav_url= "https://graph.facebook.com/".$fb_id."/picture?type=square"; 
    27782804    } 
     2805    if (strlen($grav_url)>1) { 
    27792806    $avatar = "<img src='".$grav_url."'  height='".$size."' width='".$size."' class='avatar avatar-40 photo' /> "; 
     2807    } 
    27802808    return $avatar; 
    27812809} 
     
    28082836    return array_merge($schedules); 
    28092837} 
     2838 
     2839function wordbooker_comment_row ( $actions, $comment ) { 
     2840    global $user_ID, $wpdb,$blog_id,$wp; 
     2841    $sql='SELECT 1 FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_comment_id = ' . $comment->comment_ID . ' and blog_id='.$blog_id; 
     2842    $result = $wpdb->query($sql); 
     2843    if ($result>0){ 
     2844          $nonce = wp_create_nonce("wordbooker_comment_nonce"); 
     2845        $link = admin_url('admin-ajax.php?action=wordbookercommentflip&id='.$comment->comment_ID.'&_wbnonce='.$nonce); 
     2846        $actions['wordbooker'] = '<a href="' . $link . '">' . __( 'Remove Wordbooker Record', 'wordbooker' ) . '</a>'; 
     2847    } 
     2848    return $actions; 
     2849} 
     2850 
     2851function wordbookercommentflip () { 
     2852    global $wpdb,$blog_id;$wp; 
     2853    $wp_list_table = _get_list_table('WP_Comments_List_Table'); 
     2854    $pagenum = $wp_list_table->get_pagenum(); 
     2855    $nonce =$_REQUEST['_wbnonce']; 
     2856    $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); 
     2857    $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); 
     2858    if ( ( wp_verify_nonce($nonce, 'wordbooker_comment_nonce')) && ('wordbookercommentflip' == $_REQUEST['action'] )) { 
     2859        $comment_id = absint( $_REQUEST['id'] ); 
     2860        $r = wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id); 
     2861    } 
     2862    wp_safe_redirect($redirect_to); 
     2863}    
    28102864     
    28112865/* Post/page maintenance and publishing hooks. */ 
     
    28262880    add_action('transition_post_status', 'wordbooker_process_post_data',10,3); 
    28272881    add_action('delete_post', 'wordbooker_delete_post'); 
     2882    add_action('delete_comment', 'wordbooker_delete_comment'); 
    28282883    add_action('wb_cron_job', 'wordbooker_poll_facebook'); 
    28292884    add_action('wb_comment_job', 'wordbooker_poll_comments'); 
     
    28312886    add_action('wp_footer', 'wordbooker_footer'); 
    28322887    add_filter('language_attributes', 'wordbooker_schema'); 
     2888    add_filter('comment_row_actions', 'wordbooker_comment_row', 10, 2 ); 
     2889    add_action( 'wp_ajax_wordbookercommentflip', 'wordbookercommentflip'); 
    28332890    $wordbooker_fb_gravatars=wordbooker_get_option('wordbooker_no_facebook_gravatars'); 
    28342891    if (!isset($wordbooker_fb_gravatars)){ 
  • wordbooker/trunk/includes/wordbooker_cron.php

    r555357 r605697  
    233233*/ 
    234234        $fb_status_info=wordbooker_status_feed($suid,$wbuser2->access_token); 
     235        # put in check for not being an array and skip... 
    235236        #var_dump($fb_status_info); 
    236237        foreach($fb_status_info->data as $fbstat) { 
    237238            if(!is_null($fbstat->message)){ 
    238                 if ($suid==$fbstat->from->id) { 
    239      
     239                //      var_dump($fbstat->to->data[0]->id); 
     240                //      var_dump("XXXX".$fbstat->from->id); 
     241        //      var_dump($fbstat->message); 
     242            //  echo "<br />"; 
     243        //      var_dump($fbstat->from->id); 
     244        //      echo "<br />"; 
     245        //      var_dump($fbstat->to->data[0]->id); 
     246        //      echo "<br /><br />"; 
     247                if (($suid==$fbstat->from->id) && (is_null($fbstat->to->data[0]->id ) )) { 
    240248                    $status_message=$fbstat->message; 
    241249                    $status_time=$fbstat->created_time; 
  • wordbooker/trunk/includes/wordbooker_facebook_curl.php

    r593861 r605697  
    5757function wordbooker_get_fb_id($fb_id,$access_token) { 
    5858    if (!isset($fb_id)){$fb_id='me';} 
     59    if(strlen($fb_id)<2){$fb_id='me';} 
    5960        $url = 'https://graph.facebook.com/'.$fb_id.'?fields=id,name,link&access_token='.$access_token.'&format=JSON-STRINGS'; 
    6061    $x=wordbooker_make_curl_call($url); 
     
    6364function wordbooker_me_status($fb_id,$access_token) { 
    6465    if (!isset($fb_id)){$fb_id='me';} 
     66    if(strlen($fb_id)<2){$fb_id='me';} 
    6567        $url = 'https://graph.facebook.com/'.$fb_id.'?access_token='.$access_token.'&format=JSON'; 
    6668    $x=wordbooker_make_curl_call($url); 
     
    7678function wordbooker_get_access_token($access_token) { 
    7779    #$url='https://graph.facebook.com/oauth/access_token?client_id='.WORDBOOKER_FB_ID.'&client_secret='.WORDBOOKER_FB_SECRET.'&grant_type=fb_exchange_token&fb_exchange_token='.$access_token; 
    78     $url='https://wordbooker.tty.org.uk/refresh.php?oldie='.$access_token; 
     80    #$url='https://wordbooker.tty.org.uk/refresh.php?oldie='.$access_token; 
     81    $version=explode(" ",WORDBOOKER_CODE_RELEASE); 
     82    $url='http://ccgi.pemmaquid.plus.com/cgi-bin/refresh.cgi?oldie='.$access_token.'&version='.$version[0]; 
     83    //var_dump($url); 
    7984    $x=wordbooker_make_curl_call2($url); 
    8085    wordbooker_debugger("Access token returns ",print_r($x,true),-5,98) ; 
     
    8489function wordbooker_status_feed($fb_id,$access_token) { 
    8590    if (!isset($fb_id)){$fb_id='me';} 
    86         $url = 'https://graph.facebook.com/'.$fb_id.'/feed/?access_token='.$access_token.'&format=JSON&limit=10'; 
     91    if(strlen($fb_id)<2){$fb_id='me';} 
     92        $url = 'https://graph.facebook.com/'.$fb_id.'/feed/?access_token='.$access_token.'&format=JSON&limit=150'; 
     93       #var_dump($url); 
    8794    $x=wordbooker_make_curl_call($url); 
    8895    #var_dump($x); 
     
    9198function wordbooker_fb_pemissions($fb_id,$access_token) { 
    9299    if (!isset($fb_id)){$fb_id='me';} 
     100    if(strlen($fb_id)<2){$fb_id='me';} 
    93101        $url = 'https://graph.facebook.com/'.$fb_id.'/permissions?access_token='.$access_token.'&format=JSON'; 
     102        #var_dump($url); 
    94103    $x=wordbooker_make_curl_call($url); 
    95104        return($x); 
     
    129138    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    130139    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     140    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    131141    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    132142    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
     
    153163    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    154164    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     165    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    155166    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    156167    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
     
    178189    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); 
    179190    curl_setopt($ch, CURLOPT_TIMEOUT, 60); 
     191    curl_setopt($ch,CURLOPT_USERAGENT,WORDBOOKER_USER_AGENT); 
    180192    curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/fb_ca_chain_bundle.crt'); 
    181193    if (WORDBOOKER_IPV==6 && isset($wordbooker_settings['wordbooker_use_curl_4'])) { 
  • wordbooker/trunk/includes/wordbooker_options.php

    r593720 r605697  
    8686    if ($wordbooker_settings['wordbooker_comment_cron']!=wp_get_schedule('wb_comment_job')) { 
    8787    $dummy=wp_clear_scheduled_hook('wb_comment_job'); 
    88     $sql="Delete from ".WORDBOOKER_POSTCOMMENTS." where in_out='stat'"; 
    89     $wpdb->query($sql); 
     88    //$sql="Delete from ".WORDBOOKER_POSTCOMMENTS." where in_out='stat'"; 
     89    //$wpdb->query($sql); 
    9090    if ( ($wordbooker_settings['wordbooker_comment_cron']=='Never') || ($wordbooker_settings['wordbooker_comment_cron']=='Manual')){} else { 
    9191    $dummy=wp_schedule_event(current_time( 'timestamp' ), $wordbooker_settings['wordbooker_comment_cron'], 'wb_comment_job');} 
  • wordbooker/trunk/includes/wordbooker_posting.php

    r548667 r605697  
    2626 */ 
    2727 
    28 function wordbooker_wall_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid){ 
     28function wordbooker_wall_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    2929    if (isset($dummy)) {     
    3030        wordbooker_debugger("Wall Post to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    3535try { 
    3636        $result = wordbooker_fb_stream_pubish($post_data,$target_id); 
    37         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     37        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    3838        wordbooker_debugger("Wall Post to ".$target_name." Succeeded - result : ",$result->id,$post_id,90) ; 
    3939        } 
     
    4646} 
    4747 
    48 function wordbooker_link_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid){ 
     48function wordbooker_link_post($post_id,$access_token,$post_title,$post_data,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    4949    if (isset($dummy)) {     
    5050        wordbooker_debugger("Link Post to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    5757try { 
    5858        $result = wordbooker_fb_link_publish($post_data2,$target_id); 
    59         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     59        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    6060        wordbooker_debugger("Link Post to ".$target_name." Succeeded - result : ",$result->id,$post_id,90) ; 
    6161        } 
     
    6767    } 
    6868} 
    69 function wordbooker_status_update($post_id,$access_token,$post_date,$target_id,$dummy,$target_name,$wpuserid) { 
     69function wordbooker_status_update($post_id,$access_token,$post_date,$target_id,$dummy,$target_name,$wpuserid,$fb_uid) { 
    7070    global $wordbooker_post_options,$user_ID; 
    7171    wordbooker_debugger("Setting status_text".$wordbooker_post_options['wordbooker_status_update_text']," ",$post_id) ;  
     
    8080    try { 
    8181        $result = wordbooker_fb_status_update($data,$target_id); 
    82         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     82        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    8383        wordbooker_debugger("Status update  to ".$target_name." suceeded result : ",$result->id,$post_id,90) ; 
    8484        } 
     
    9191} 
    9292 
    93 function wordbooker_notes_post($post_id,$access_token,$post_title,$target_id,$dummy,$target_name,$wpuserid){ 
     93function wordbooker_notes_post($post_id,$access_token,$post_title,$target_id,$dummy,$target_name,$wpuserid,$fb_uid){ 
    9494    if (isset($dummy)) {     
    9595        wordbooker_debugger("Notes publish  to ".$target_name." Test Only",'No Post Made',$post_id,90) ; 
     
    104104    try { 
    105105        $result = wordbooker_fb_note_publish($data,$target_id); 
    106         wordbooker_store_post_result($post_id,$result->id,$wpuserid); 
     106        wordbooker_store_post_result($post_id,$result->id,$wpuserid,$fb_uid,$target_id); 
    107107        wordbooker_debugger("Note Publish to ".$target_name." result : ",$result->id,$post_id,90) ; 
    108108    }    
     
    116116 
    117117 
    118 function wordbooker_store_post_result($post_id,$fb_post_id,$wpuserid) { 
     118function wordbooker_store_post_result($post_id,$fb_post_id,$wpuserid,$fb_uid,$target_id) { 
    119119    global $wpdb,$blog_id,$user_ID; 
    120120    $tstamp=time(); 
    121121    $wordbooker_settings = wordbooker_options(); 
    122     $sql=   ' INSERT INTO ' . WORDBOOKER_POSTCOMMENTS . ' (fb_post_id,comment_timestamp,wp_post_id,blog_id,user_id) VALUES ("'.$fb_post_id.'",'.$tstamp.','.$post_id.','.$blog_id.','.$wpuserid.')'; 
     122    $sql=   ' INSERT INTO ' . WORDBOOKER_POSTCOMMENTS . ' (fb_post_id,comment_timestamp,wp_post_id,blog_id,user_id,fb_user_id,fb_target_id) VALUES ("'.$fb_post_id.'",'.$tstamp.','.$post_id.','.$blog_id.','.$wpuserid.','.$fb_uid.','.$target_id.')'; 
    123123    $result = $wpdb->query($sql); 
    124124    wordbooker_insert_into_postlogs($post_id,$blog_id); 
  • wordbooker/trunk/includes/wordbooker_posting_options.php

    r548667 r605697  
    5050        } 
    5151    } 
     52    # Only replace the defaults if we've got a good set of post options. 
    5253    $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    53     if(is_array($x)) { 
     54    if (count($x)>7) { 
    5455        foreach (array_keys($x) as $key ) { 
    5556            if (substr($key,0,8)=='wordbook') { 
    56                 $post_meta[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$x[$key]); 
     57                $post_meta[$key]= html_entity_decode($x[$key],ENT_QUOTES); 
     58            //  $post_meta[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$x[$key]); 
    5759            } 
    5860        } 
    59     }    
    60     if(is_array($post_meta)) { 
    61         $wordbooker_settings=$post_meta; 
     61        if(is_array($post_meta)) { 
     62            $wordbooker_settings=$post_meta; 
     63        } 
    6264    } 
    6365    #var_dump($user_ID); 
  • wordbooker/trunk/readme.txt

    r593861 r605697  
    55Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=8XNJMQCYDJT6U&lc=GB&currency_code=GBP&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted 
    66Requires at least: 2.9 
    7 Tested up to: 3.4.1 
    8 Stable tag: 2.1.18 
     7Tested up to: 3.4.2 
     8Stable tag: 2.1.19 
    99 
    1010This plugin allows you to cross-post your blog posts to your Facebook Wall and to any Facebook Fan Page / Group that you are an administrator for.  
     
    115115 
    116116== Changelog == 
     117 
     118= Version 2.1.19  29/09/2012 = 
     119- Fix an issue with gravatars not displaying properly when there is no gravatar associated with the commenter 
     120- Put in a check for Attachment post types 
     121- Fixed a problem where invalid but not null Facebook IDs broke the cron job. 
     122- Fixed a prob where sometimes user settings were lost on scheduling a post. 
     123- Minor change to the refresh token process to reduce load on the server. 
     124- Added code to delete records from Wordbooker Comments table when a comment is deleted from the blog. 
     125- Changes to the Status Fetch to reduce incidents of incorrect status messages being posted. 
     126- Added option to Comment Admin page to remove a comment entry from the Wordbooker Comments table 
    117127 
    118128= Version 2.1.18  03/09/2012 = 
     
    382392== Upgrade Notice == 
    383393 
     394= 2.1.19 = 
     395Improved comment handling plus other various performance tweaks. 
     396 
    384397= 2.1.16 = 
    385398Adds code to supress warnings related to curl options plus a couple of other minor bugs. 
  • wordbooker/trunk/wordbooker.php

    r593861 r605697  
    66Author: Steve Atty  
    77Author URI: http://wordbooker.tty.org.uk 
    8 Version: 2.1.18 
     8Version: 2.1.19 
    99*/ 
    1010 
     
    3434$wbooker_user_id=0; 
    3535 
    36 $wordbooker_settings = wordbooker_options();  
    37 if (! isset($wordbooker_settings['wordbooker_extract_length'])) $wordbooker_settings['wordbooker_extract_length']=256; 
    38  
    39 define('WORDBOOKER_DEBUG', false); 
    40 define('WORDBOOKER_TESTING', false); 
    41 define('WORDBOOKER_CODE_RELEASE',"2.1.18 R00 - A Lack of Understanding"); 
    42  
    43 # For Troubleshooting  
    44 define('ADVANCED_DEBUG',false); 
    45  
    46 #$facebook_config['debug'] = WORDBOOKER_TESTING && !$_POST['action']; 
    47 #Wordbooker2 - Dev 
    48 #define('WORDBOOKER_FB_APIKEY', '111687885534181'); 
    49 #define('WORDBOOKER_FB_ID', '111687885534181'); 
    50  
    51 # Wordbooker - live 
    52 if (!defined('WORDBOOKER_PREMIUM')) { 
    53 define('APP TITLE','Wordbooker'); 
    54 define('WORDBOOKER_FB_APIKEY', '0cbf13c858237f5d74ef0c32a4db11fd'); 
    55 define('WORDBOOKER_FB_ID', '254577506873'); 
    56 define('WORDBOOKER_APPLICATION_NAME','Wordbooker'); 
    57 define('OPENGRAPH_NAMESPACE','wordbooker'); 
    58 define('OPENGRAPH_ACCESS_TOKEN','AAAAAO0YAejkBAE3gGR2KjCr6WhUO1ZBNyXHP6vaQoQLbwvlDyKDK0BIMZBb6mVyk2ZAbvPEXyrZCLNd6Bb8TA0HJCKGkotUZD'); 
    59 } 
    60  
    61 define('WORDBOOKER_FB_APIVERSION', '1.0'); 
    62 define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
    63 define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
    64 define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
    65 define('WORDBOOKER_FB_STATUS_UPDATE',"status_update"); 
    66 define('WORDBOOKER_FB_CREATE_NOTE',"create_note"); 
    67 define('WORDBOOKER_FB_OFFLINE_ACCESS',"offline_access"); 
    68 define('WORDBOOKER_FB_MANAGE_PAGES',"manage_pages"); 
    69 define('WORDBOOKER_FB_PHOTO_UPLOAD',"photo_upload"); 
    70 define('WORDBOOKER_FB_VIDEO_UPLOAD',"video_upload"); 
    71 define('WORDBOOKER_FB_READ_FRIENDS',"read_friendlists"); 
    72 define('WORDBOOKER_SETTINGS','wordbooker_settings'); 
    73 define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
    74 define('WORDBOOKER_SCHEMA_VERSION', '5.1'); 
    75  
    76 $new_wb_table_prefix=$wpdb->base_prefix; 
    77 if (isset ($db_prefix) ) { $new_wb_table_prefix=$db_prefix;} 
    78  
    79 define('WORDBOOKER_ERRORLOGS', $new_wb_table_prefix . 'wordbooker_errorlogs'); 
    80 define('WORDBOOKER_POSTLOGS', $new_wb_table_prefix . 'wordbooker_postlogs'); 
    81 define('WORDBOOKER_USERDATA', $new_wb_table_prefix . 'wordbooker_userdata'); 
    82 define('WORDBOOKER_USERSTATUS', $new_wb_table_prefix . 'wordbooker_userstatus'); 
    83 define('WORDBOOKER_POSTCOMMENTS', $new_wb_table_prefix . 'wordbooker_postcomments'); 
    84 define('WORDBOOKER_PROCESS_QUEUE', $new_wb_table_prefix . 'wordbooker_process_queue'); 
    85 define('WORDBOOKER_FB_FRIENDS', $new_wb_table_prefix . 'wordbooker_fb_friends'); 
    86 define('WORDBOOKER_FB_FRIEND_LISTS', $new_wb_table_prefix . 'wordbooker_fb_friend_lists'); 
    87  
    88 define('WORDBOOKER_MINIMUM_ADMIN_LEVEL', 'edit_posts'); /* Contributor role or above. */ 
    89 define('WORDBOOKER_SETTINGS_PAGENAME', 'wordbooker'); 
    90 define('WORDBOOKER_SETTINGS_URL', 'options-general.php?page=' . WORDBOOKER_SETTINGS_PAGENAME); 
    91  
    92 $wordbooker_wp_version_tuple = explode('.', $wp_version); 
    93 define('WORDBOOKER_WP_VERSION', $wordbooker_wp_version_tuple[0] * 10 + $wordbooker_wp_version_tuple[1]); 
    94  
    95 if (function_exists('json_encode')) { 
    96     define('WORDBOOKER_JSON_ENCODE', 'PHP'); 
    97 } else { 
    98     define('WORDBOOKER_JSON_ENCODE', 'Wordbook'); 
    99 } 
    100  
    101 if (function_exists('json_decode') ) { 
    102     define('WORDBOOKER_JSON_DECODE', 'PHP'); 
    103 } else { 
    104     define('WORDBOOKER_JSON_DECODE', 'Wordbooker'); 
    105 } 
    106 if (function_exists('simplexml_load_string') ) { 
    107     define('WORDBOOKER_SIMPLEXML', 'provided by PHP'); 
    108 } else { 
    109     define('WORDBOOKER_SIMPLEXML', 'is missing - this is a problem'); 
    110 } 
    111 $curlv2=curl_version(); 
    112 $bitfields = Array('CURL_VERSION_IPV6'); 
    113 foreach($bitfields as $feature) 
    114 { 
    115   if ($curlv2['features'] & constant($feature)) {define('WORDBOOKER_IPV', '6');} else { define('WORDBOOKER_IPV', '4');} 
    116 } 
    117  
    118  
    119 function wordbooker_load_apis() { 
     36function wordbooker_global_definitions() { 
     37    global $table_prefix, $wp_version,$wpdb,$db_prefix,$wbooker_user_id; 
     38    $wbooker_user_id=0; 
     39    define('WORDBOOKER_DEBUG', false); 
     40    define('WORDBOOKER_TESTING', false); 
     41    define('WORDBOOKER_CODE_RELEASE',"2.1.19 R00 - Better Weather"); 
     42 
     43    # For Troubleshooting  
     44    define('ADVANCED_DEBUG',false); 
     45 
     46    #$facebook_config['debug'] = WORDBOOKER_TESTING && !$_POST['action']; 
     47    #Wordbooker2 - Dev 
     48    #define('WORDBOOKER_FB_APIKEY', '111687885534181'); 
     49    #define('WORDBOOKER_FB_ID', '111687885534181'); 
     50 
     51 
     52    # Wordbooker - live 
     53    if (!defined('WORDBOOKER_PREMIUM')) { 
     54    define('APP TITLE','Wordbooker'); 
     55    define('WORDBOOKER_FB_APIKEY', '0cbf13c858237f5d74ef0c32a4db11fd'); 
     56    define('WORDBOOKER_FB_ID', '254577506873'); 
     57    define('WORDBOOKER_APPLICATION_NAME','Wordbooker'); 
     58    define('OPENGRAPH_NAMESPACE','wordbooker'); 
     59    define('OPENGRAPH_ACCESS_TOKEN','AAAAAO0YAejkBAE3gGR2KjCr6WhUO1ZBNyXHP6vaQoQLbwvlDyKDK0BIMZBb6mVyk2ZAbvPEXyrZCLNd6Bb8TA0HJCKGkotUZD'); 
     60    } 
     61 
     62    define('WORDBOOKER_FB_APIVERSION', '1.0'); 
     63    define('WORDBOOKER_FB_DOCPREFIX','http://wiki.developers.facebook.com/index.php/'); 
     64    define('WORDBOOKER_FB_PUBLISH_STREAM', 'publish_stream'); 
     65    define('WORDBOOKER_FB_READ_STREAM', 'read_stream'); 
     66    define('WORDBOOKER_FB_STATUS_UPDATE',"status_update"); 
     67    define('WORDBOOKER_FB_CREATE_NOTE',"create_note"); 
     68    define('WORDBOOKER_FB_OFFLINE_ACCESS',"offline_access"); 
     69    define('WORDBOOKER_FB_MANAGE_PAGES',"manage_pages"); 
     70    define('WORDBOOKER_FB_PHOTO_UPLOAD',"photo_upload"); 
     71    define('WORDBOOKER_FB_VIDEO_UPLOAD',"video_upload"); 
     72    define('WORDBOOKER_FB_READ_FRIENDS',"read_friendlists"); 
     73    define('WORDBOOKER_SETTINGS','wordbooker_settings'); 
     74    define('WORDBOOKER_OPTION_SCHEMAVERS', 'schema_vers'); 
     75    define('WORDBOOKER_USER_AGENT','WordPress/' . $wp_version . '; Wordbooker-' .WORDBOOKER_CODE_RELEASE ); 
     76    define('WORDBOOKER_SCHEMA_VERSION', '5.3'); 
     77 
     78    $new_wb_table_prefix=$wpdb->base_prefix; 
     79    if (isset ($db_prefix) ) { $new_wb_table_prefix=$db_prefix;} 
     80 
     81    define('WORDBOOKER_ERRORLOGS', $new_wb_table_prefix . 'wordbooker_errorlogs'); 
     82    define('WORDBOOKER_POSTLOGS', $new_wb_table_prefix . 'wordbooker_postlogs'); 
     83    define('WORDBOOKER_USERDATA', $new_wb_table_prefix . 'wordbooker_userdata'); 
     84    define('WORDBOOKER_USERSTATUS', $new_wb_table_prefix . 'wordbooker_userstatus'); 
     85    define('WORDBOOKER_POSTCOMMENTS', $new_wb_table_prefix . 'wordbooker_postcomments'); 
     86    define('WORDBOOKER_PROCESS_QUEUE', $new_wb_table_prefix . 'wordbooker_process_queue'); 
     87    define('WORDBOOKER_FB_FRIENDS', $new_wb_table_prefix . 'wordbooker_fb_friends'); 
     88    define('WORDBOOKER_FB_FRIEND_LISTS', $new_wb_table_prefix . 'wordbooker_fb_friend_lists'); 
     89 
     90    define('WORDBOOKER_MINIMUM_ADMIN_LEVEL', 'edit_posts'); /* Contributor role or above. */ 
     91    define('WORDBOOKER_SETTINGS_PAGENAME', 'wordbooker'); 
     92    define('WORDBOOKER_SETTINGS_URL', 'options-general.php?page=' . WORDBOOKER_SETTINGS_PAGENAME); 
     93 
     94    $wordbooker_wp_version_tuple = explode('.', $wp_version); 
     95    define('WORDBOOKER_WP_VERSION', $wordbooker_wp_version_tuple[0] * 10 + $wordbooker_wp_version_tuple[1]); 
     96 
     97    if (function_exists('json_encode')) { 
     98        define('WORDBOOKER_JSON_ENCODE', 'PHP'); 
     99    } else { 
     100        define('WORDBOOKER_JSON_ENCODE', 'Wordbook'); 
     101    } 
     102 
     103    if (function_exists('json_decode') ) { 
     104        define('WORDBOOKER_JSON_DECODE', 'PHP'); 
     105    } else { 
     106        define('WORDBOOKER_JSON_DECODE', 'Wordbooker'); 
     107    } 
     108    if (function_exists('simplexml_load_string') ) { 
     109        define('WORDBOOKER_SIMPLEXML', 'provided by PHP'); 
     110    } else { 
     111        define('WORDBOOKER_SIMPLEXML', 'is missing - this is a problem'); 
     112    } 
    120113    if (WORDBOOKER_JSON_DECODE == 'Wordbooker') { 
    121     function json_decode($json) 
    122     {  
    123         $comment = false; 
    124         $out = '$x='; 
    125         
    126         for ($i=0; $i<strlen($json); $i++) 
    127         { 
    128         if (!$comment) 
    129         { 
    130             if ($json[$i] == '{')        $out .= ' array('; 
    131             else if ($json[$i] == '}')    $out .= ')'; 
    132             else if ($json[$i] == ':')    $out .= '=>'; 
    133             else                         $out .= $json[$i];            
    134         } 
    135         else $out .= $json[$i]; 
    136         if ($json[$i] == '"')    $comment = !$comment; 
    137         } 
    138         eval($out . ';'); 
    139         return $x; 
    140     }  
     114        function json_decode($json){  
     115            $comment = false; 
     116            $out = '$x='; 
     117            
     118            for ($i=0; $i<strlen($json); $i++) 
     119            { 
     120            if (!$comment) 
     121            { 
     122                if ($json[$i] == '{')        $out .= ' array('; 
     123                else if ($json[$i] == '}')    $out .= ')'; 
     124                else if ($json[$i] == ':')    $out .= '=>'; 
     125                else                         $out .= $json[$i];            
     126            } 
     127            else $out .= $json[$i]; 
     128            if ($json[$i] == '"')    $comment = !$comment; 
     129            } 
     130            eval($out . ';'); 
     131            return $x; 
     132        }  
    141133    }  
    142134 
     
    164156        } 
    165157    } 
     158 
     159    $curlv2=curl_version(); 
     160    $curlv=$curlv2['version']; 
     161    $bitfields = Array('CURL_VERSION_IPV6'); 
     162    foreach($bitfields as $feature) 
     163    { 
     164      if ($curlv2['features'] & constant($feature)) {define('WORDBOOKER_IPV', '6');} else { define('WORDBOOKER_IPV', '4');} 
     165    } 
     166 
     167 
     168    define('GLOBAL_DEFINITIONS_NOT_CALLED','not a problem'); 
     169} 
     170 
     171if (@GLOBAL_DEFINITIONS_NOT_CALLED == 'GLOBAL_DEFINITIONS_NOT_CALLED') { 
     172wordbooker_global_definitions(); 
    166173} 
    167174 
     
    493500        wordbooker_set_option('schema_vers', "5.1"); 
    494501    } 
     502     
     503         
     504        if ($wordbooker_settings['schema_vers']=='5.1') { 
     505 
     506        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_FB_FRIENDS. ' ADD FULLTEXT `name_idx` (`name`)');  
     507        wordbooker_set_option('schema_vers', "5.2"); 
     508    } 
     509     
     510        if ($wordbooker_settings['schema_vers']=='5.2') { 
     511 
     512        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_USERDATA. '  DROP PRIMARY KEY , ADD PRIMARY KEY ( `user_ID` , `blog_id` ) ');  
     513        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. '  ADD `FB_USER_ID` VARCHAR( 120 ) NOT NULL '); 
     514        $result = $wpdb->query('ALTER TABLE '. WORDBOOKER_POSTCOMMENTS. ' ADD `FB_TARGET_ID` VARCHAR( 120 ) NOT NULL '); 
     515        wordbooker_set_option('schema_vers', "5.3"); 
     516    } 
     517     
    495518    $dummy=wp_clear_scheduled_hook('wb_cron_job'); 
    496519    $dummy=wp_schedule_event(current_time( 'timestamp' ), 'hourly', 'wb_cron_job'); 
     
    766789    global $wpdb; 
    767790    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_post_id = ' . $post_id . ' and blog_id='.$blog_id); 
     791} 
     792 
     793function wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id) { 
     794    global $wpdb; 
     795    $result = $wpdb->query('DELETE FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_comment_id = ' . $comment_id . ' and blog_id='.$blog_id); 
    768796} 
    769797 
     
    13681396    } 
    13691397    echo "</b><br /><li> Wordbooker Table Status :</li><b>"; 
     1398    //var_dump(get_blog_count()); 
    13701399    $table_array= array (WORDBOOKER_ERRORLOGS,WORDBOOKER_POSTLOGS,WORDBOOKER_USERDATA,WORDBOOKER_USERSTATUS,WORDBOOKER_POSTCOMMENTS,WORDBOOKER_PROCESS_QUEUE,WORDBOOKER_FB_FRIENDS,WORDBOOKER_FB_FRIEND_LISTS); 
    13711400    foreach ($table_array as $table) { 
     
    15821611{    
    15831612    global $wordbooker_post_options,$wpdb; 
     1613    $wordbooker_post_options= get_post_meta($post_id, '_wordbooker_options', true);  
    15841614    $wordbooker_settings =wordbooker_options();  
    15851615    $post = get_post($post_id); 
     
    16161646        'post_id'=>$post->ID, 
    16171647        'post_date'=>$post->post_date 
    1618         ); 
    1619 /* 
    1620     # This is the tagging code -  
    1621     if (strlen($wordbooker_post_options['wordbooker_tag_list']) > 6 ) { 
    1622         $wordbooker_tag_list=str_replace('[','@[',$wordbooker_post_options['wordbooker_tag_list']); 
    1623         $message=$message."   ". __("and tagged : ",'wordbooker').$wordbooker_tag_list; 
    1624     } 
    1625 */ 
    1626          
     1648        );       
    16271649    if (function_exists('qtrans_use')) { 
    16281650        global $q_config; 
     
    17041726                    # Wall Post 
    17051727                    case 1 :  
    1706                     wordbooker_wall_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid); 
     1728                    wordbooker_wall_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17071729                    break; 
    17081730                    # Note 
    17091731                    case 2 : 
    1710                     wordbooker_notes_post($post_id,$access_token,$post_title,$target,$is_dummy,$target_name,$wpuserid); 
     1732                    wordbooker_notes_post($post_id,$access_token,$post_title,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17111733                    break; 
    17121734                    # Status Update 
    17131735                    case 3 :  
    1714                     wordbooker_status_update($post_id,$access_token,$post_data['post_date'],$target,$is_dummy,$target_name,$wpuserid); 
     1736                    wordbooker_status_update($post_id,$access_token,$post_data['post_date'],$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17151737                    break ; 
    17161738                    # Link Post 
    17171739                    case 4 :  
    1718                     wordbooker_link_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid); 
     1740                    wordbooker_link_post($post_id,$access_token,$post_title,$wordbooker_fb_post ,$target,$is_dummy,$target_name,$wpuserid,$wbuser->facebook_id); 
    17191741                    break ; 
    17201742                } 
     
    18101832    $attribute_text=str_ireplace( '%date%', $date_info ,$attribute_text); 
    18111833    $attribute_text=str_ireplace( '%time%', $time_info,$attribute_text ); 
    1812  
    1813     return wordbooker_translate($attribute_text); 
     1834     
     1835    return html_entity_decode(wordbooker_translate($attribute_text),ENT_QUOTES); 
    18141836} 
    18151837 
     
    25122534 
    25132535function wordbooker_process_post_data($newstatus, $oldstatus, $post) { 
    2514     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id; 
     2536    if (!isset($_POST)){return;} 
     2537    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wb_user_id; 
    25152538    # If this is an autosave then we give up and return as otherwise we lose user settings. 
    25162539        # This is where we need to put in the custom post type checks 
    25172540    if ($post->post_type=='reply') {return;} 
     2541    if ($post->post_type=='attachment') {return;} 
    25182542    # Stop all in one calendar events from firing 
    25192543    if ($post->post_type=='ai1ec_event') {return;} 
     2544    if ($post->post_password != '') {return;} 
    25202545    if ($_POST['action']=='autosave') { return;} 
    25212546    wordbooker_update_post_meta($post); 
     2547    //var_dump($_POST); 
    25222548    if ($_POST['action']=='editpost') {  
    25232549        foreach (array_keys($_POST) as $key ) { 
    25242550            if (substr($key,0,8)=='wordbook') { 
    2525                 $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
     2551                $wordbooker_sets[$key]= html_entity_decode($_POST[$key],ENT_QUOTES); 
     2552            //  $wordbooker_sets[$key]=str_replace( array('&amp;','&quot;','&#039;','&lt;','&gt;','&nbsp;&nbsp;'),array('&','"','\'','<','>',"\t"),$_POST[$key]); 
     2553             
    25262554            } 
    25272555        } 
     
    25292557    } 
    25302558    if (!$newstatus=="publish") { return;} 
    2531     # If this is a password protected post we give up 
    2532     if ($post->post_password != '') {return;} 
    25332559    # Check for non public custom post types. 
    25342560    #var_dump($post->post_type); 
     
    25852611    } 
    25862612 
    2587     if ( !wordbooker_get_userdata($post->post_author)) { 
    2588         wordbooker_debugger("No Settings for ".$post->post_author." so using default author settings",' ',$post->ID,80); 
     2613    if ( !wordbooker_get_userdata($wb_user_id)) { 
     2614        wordbooker_debugger("No Settings for ".$wb_user_id." so using default author settings",' ',$post->ID,80); 
    25892615        $wb_user_id=$wordbooker_settings["wordbooker_default_author"];  
    25902616        # New get the user level settings from the DB 
     
    25982624                }  
    25992625            } 
    2600  
    26012626        } 
    26022627 
    26032628        # Then populate the post array. 
    2604             if(is_array($wordbooker_settings)) { 
     2629        if(is_array($wordbooker_settings)) { 
    26052630            foreach (array_keys($wordbooker_settings) as $key ) { 
    26062631                if (substr($key,0,8)=='wordbook') { 
     
    26242649        wordbooker_debugger("This looks like a new post being published ",$newstatus,$post->ID,80) ; 
    26252650        $wb_params['wordbooker_new_post']=1; 
    2626  
    26272651    } 
    26282652     
     
    26352659 
    26362660function wordbooker_publish($post_id) { 
    2637     global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings; 
     2661    global $user_ID, $user_identity, $user_login, $wpdb, $blog_id,$wordbooker_settings,$wb_user_id; 
    26382662    $post = get_post($post_id); 
    26392663    #var_dump($wordbooker_settings); 
     
    26692693 
    26702694function wordbooker_debugger($method,$error_msg,$post_id,$level=9) { 
    2671     global $user_ID,$post_ID,$wpdb,$blog_id,$post,$wbooker_user_id,$comment_user; 
     2695    global $user_ID,$post_ID,$wpdb,$blog_id,$post,$wbooker_user_id,$comment_user,$wb_user_id; 
    26722696    $usid=1; 
    26732697    $usid=$user_ID; 
     
    26782702        #we dont want to record anything if its an draft of any kind 
    26792703        if (stristr($p->post_status,'draft')) {return;} 
    2680         $x = get_post_meta($post->ID, '_wordbooker_options', true);  
     2704    //  $x = get_post_meta($post->ID, '_wordbooker_options', true);  
    26812705        #echo "<br />"; 
    26822706        $usid=$p->post_author; 
    2683         if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
     2707    //  if(isset($x['wordbooker_override_author'])) {$usid=$user_ID;} 
    26842708    } 
    26852709    $admin_id=wordbooker_get_option('wordbooker_diagnostic_admin'); 
     
    26892713    if ((!isset($token_log)) && ($post_id==-5) && ($level<99)) { return;}  
    26902714    $row_id=1; 
    2691     if (!isset($admin_id)) {$admin_id=1;} 
    2692     if (!isset($post_id)) {$post_id=$post_ID;} 
    2693     if (!isset($post_id)) {$post_id=1;} 
    2694     if ($usid==0) {$usid=$wbooker_user_id;} 
    2695     if (!isset($usid)) {$usid=wordbooker_get_option('wordbooker_default_author');} 
    2696     if (!isset($usid)) {$usid=$admin_id;} 
    2697     if ($usid==0) {$usid=$admin_id;} 
    2698     if ($post_id==-3) {$usid=$comment_user;} 
    2699     if ($post_id==-2) {$usid=$admin_id;} 
    2700     if ($post_id==-1) {$usid=$wbooker_user_id;} 
    2701     if ($post_id==0) {$usid=$user_ID;} 
     2715    if (isset($wb_user_id)) {$usid=$wb_user_id;} else { 
     2716        if (!isset($admin_id)) {$admin_id=1;} 
     2717        if (!isset($post_id)) {$post_id=$post_ID;} 
     2718        if (!isset($post_id)) {$post_id=1;} 
     2719        if ($usid==0) {$usid=$wbooker_user_id;} 
     2720        if (!isset($usid)) {$usid=wordbooker_get_option('wordbooker_default_author');} 
     2721        if (!isset($usid)) {$usid=$admin_id;} 
     2722        if ($usid==0) {$usid=$admin_id;} 
     2723        if ($post_id==-3) {$usid=$comment_user;} 
     2724        if ($post_id==-2) {$usid=$admin_id;} 
     2725        if ($post_id==-1) {$usid=$wbooker_user_id;} 
     2726        if ($post_id==0) {$usid=$user_ID;} 
     2727    } 
    27022728 
    27032729    $sql=   "INSERT INTO " . WORDBOOKER_ERRORLOGS . " ( 
     
    27772803    $grav_url= "https://graph.facebook.com/".$fb_id."/picture?type=square"; 
    27782804    } 
     2805    if (strlen($grav_url)>1) { 
    27792806    $avatar = "<img src='".$grav_url."'  height='".$size."' width='".$size."' class='avatar avatar-40 photo' /> "; 
     2807    } 
    27802808    return $avatar; 
    27812809} 
     
    28082836    return array_merge($schedules); 
    28092837} 
     2838 
     2839function wordbooker_comment_row ( $actions, $comment ) { 
     2840    global $user_ID, $wpdb,$blog_id,$wp; 
     2841    $sql='SELECT 1 FROM ' . WORDBOOKER_POSTCOMMENTS . ' WHERE wp_comment_id = ' . $comment->comment_ID . ' and blog_id='.$blog_id; 
     2842    $result = $wpdb->query($sql); 
     2843    if ($result>0){ 
     2844          $nonce = wp_create_nonce("wordbooker_comment_nonce"); 
     2845        $link = admin_url('admin-ajax.php?action=wordbookercommentflip&id='.$comment->comment_ID.'&_wbnonce='.$nonce); 
     2846        $actions['wordbooker'] = '<a href="' . $link . '">' . __( 'Remove Wordbooker Record', 'wordbooker' ) . '</a>'; 
     2847    } 
     2848    return $actions; 
     2849} 
     2850 
     2851function wordbookercommentflip () { 
     2852    global $wpdb,$blog_id;$wp; 
     2853    $wp_list_table = _get_list_table('WP_Comments_List_Table'); 
     2854    $pagenum = $wp_list_table->get_pagenum(); 
     2855    $nonce =$_REQUEST['_wbnonce']; 
     2856    $redirect_to = remove_query_arg( array( 'trashed', 'untrashed', 'deleted', 'spammed', 'unspammed', 'approved', 'unapproved', 'ids' ), wp_get_referer() ); 
     2857    $redirect_to = add_query_arg( 'paged', $pagenum, $redirect_to ); 
     2858    if ( ( wp_verify_nonce($nonce, 'wordbooker_comment_nonce')) && ('wordbookercommentflip' == $_REQUEST['action'] )) { 
     2859        $comment_id = absint( $_REQUEST['id'] ); 
     2860        $r = wordbooker_delete_comment_from_commentlogs($comment_id,$blog_id); 
     2861    } 
     2862    wp_safe_redirect($redirect_to); 
     2863}    
    28102864     
    28112865/* Post/page maintenance and publishing hooks. */ 
     
    28262880    add_action('transition_post_status', 'wordbooker_process_post_data',10,3); 
    28272881    add_action('delete_post', 'wordbooker_delete_post'); 
     2882    add_action('delete_comment', 'wordbooker_delete_comment'); 
    28282883    add_action('wb_cron_job', 'wordbooker_poll_facebook'); 
    28292884    add_action('wb_comment_job', 'wordbooker_poll_comments'); 
     
    28312886    add_action('wp_footer', 'wordbooker_footer'); 
    28322887    add_filter('language_attributes', 'wordbooker_schema'); 
     2888    add_filter('comment_row_actions', 'wordbooker_comment_row', 10, 2 ); 
     2889    add_action( 'wp_ajax_wordbookercommentflip', 'wordbookercommentflip'); 
    28332890    $wordbooker_fb_gravatars=wordbooker_get_option('wordbooker_no_facebook_gravatars'); 
    28342891    if (!isset($wordbooker_fb_gravatars)){ 
Note: See TracChangeset for help on using the changeset viewer.