Plugin Directory

Changeset 995586


Ignore:
Timestamp:
09/23/2014 06:06:08 PM (12 years ago)
Author:
sebstein
Message:

merge feature branch import-all-branch into trunk 993754:995583

Location:
g-crossposting/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • g-crossposting/trunk

  • g-crossposting/trunk/admin.php

    r912911 r995586  
    1818// remove any old messages from cookie
    1919$g_crossposting_msg = null;
     20
     21// provide admins a hook to trigger manual import of ALL activities
     22if (array_key_exists('g_crossposting_manual_import_all', $_GET)) {
     23    $total_activities = g_crossposting_update_all();
     24    g_crossposting_add_error('g_crossposting_err_import_all', __('Manual import of all '.$total_activities.' Google+ activities done.', 'g-crossposting'));
     25}
    2026
    2127// provide admins a hook to trigger manual import of activities
     
    252258    _e('manually check for new activities and import them', 'g-crossposting');
    253259    echo '</a></div>';
    254 /*
    255     $options = g_crossposting_get_settings();
    256 
    257     // get latest Google+ activities
    258     $ch = curl_init("https://www.googleapis.com/plus/v1/people/{$options['gplusid']}/activities/public?alt=json&maxResults={$options['maxactivities']}&key={$options['apikey']}");
    259     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    260     $activities = curl_exec($ch);
    261     curl_close($ch);
    262 
    263 $activities = json_decode($activities);
    264 
    265 $no_posts = 0;
    266 $no_shares = 0;
    267 $no_unknown = 0;
    268 
    269 foreach($activities->items as $item) {
    270     switch ($item->verb) {
    271         case 'post':
    272             $no_posts++;
    273             break;
    274         case 'share':
    275             $no_shares++;
    276             break;
    277         default:
    278             $no_unknown++;
    279             break;
    280     }
    281        
    282 }
    283 print 'Found '.count($activities->items).' public activities on your Google+ account.<br />';
    284 print 'You got '.$no_posts.' posts.<br />';
    285 print 'You got '.$no_shares.' shares.<br />';
    286 print 'You got '.$no_unknown.' unknown activities.<br />';
    287 
    288 print '<pre>';
    289 foreach($activities->items as $item) {
    290 print '----------------new item---------------\n';
    291 var_dump($item);
    292 }
    293 print '</pre>';
    294 */
    295 
     260
     261    echo '<div id="g-crossposting-manual-import-all"><strong>';
     262    _e('Manual mass import ALL:', 'g-crossposting');
     263    echo '</strong> <a href="?page=g-crossposting-key-config&amp;g_crossposting_manual_import_all=true">';
     264    _e('manually check for ALL activities and import them', 'g-crossposting');
     265    echo '</a></div>';
    296266    echo '</div>';
    297267}
  • g-crossposting/trunk/g-crossposting.php

    r912911 r995586  
    44    Plugin URI: http://wordpress.org/extend/plugins/g-crossposting/
    55    Description: Imports your public Google+ activities in your Wordpress blog.
    6     Version: 1.5.0
     6    Version: 1.6.0
    77    Author: Sebastian Stein
    88    Author URI: http://sebstein.hpfsc.de/
     
    144144
    145145/**
    146  *  checks Google+ for new activities and posts them
     146 *  checks Google+ for new activities and post them
    147147 */
    148148function g_crossposting_update() {
     
    174174    // basic validation showed that we might have valid connection settings
    175175    // now do an actual connect to see if we are able to connect
    176     if (g_crossposting_api_activities_list($options['gplusid'], $options['apikey'], 1) == null) {
     176    if (g_crossposting_api_activities_list($options['gplusid'], $options['apikey'], 1, "") == null) {
    177177        // either settings are wrong or gplus is offline
    178178
     
    215215 *  @return array with activities or null
    216216 */
    217 function g_crossposting_api_activities_list($p_gplusid, $p_apikey, $p_maxactivities) {
     217function g_crossposting_api_activities_list($p_gplusid, $p_apikey, $p_maxactivities, $p_pagetoken) {
    218218    // get list of latest p_maxactivities activities
    219     $ch = curl_init("https://www.googleapis.com/plus/v1/people/{$p_gplusid}/activities/public?alt=json&maxResults={$p_maxactivities}&key={$p_apikey}");
     219    $ch = curl_init("https://www.googleapis.com/plus/v1/people/{$p_gplusid}/activities/public?alt=json&maxResults={$p_maxactivities}&key={$p_apikey}&pageToken={$p_pagetoken}");
    220220    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    221221    $activities = curl_exec($ch);
     
    245245    // get activities from Google+
    246246    $activities = g_crossposting_api_activities_list($options['gplusid'],
    247                             $options['apikey'], $options['maxactivities']);
     247                            $options['apikey'], $options['maxactivities'], "");
    248248    if ($activities == null) {
    249249        return null;
     
    277277    // go through all given activities and post them
    278278    $latest_activity_id = null;
     279    $posts_updated = 0;
    279280    foreach ($activities as $activity) {
    280281        // store ID of latest activity so that we know what was posted already
     
    299300            continue;
    300301        }
     302
     303        // we found a new post, so let's increment our counter
     304        $posts_updated++;
    301305
    302306        // get options to configure way how activities get imported
     
    415419        }
    416420    }
     421    return $posts_updated;
    417422}
    418423
     
    506511    return FALSE;
    507512}
     513
     514/**
     515*  checks Google+ for all activities and posts them
     516*/
     517function g_crossposting_update_all() {
     518    // first check if all settings are in place
     519    if (! g_crossposting_is_enabled()) {
     520        return;
     521    }
     522
     523    // get all activities
     524    $all_activities = array();
     525    $all_activities = g_crossposting_get_all_activities();
     526    if ($all_activities == null) {
     527        return;
     528    }
     529
     530    // post new activities on blog
     531    $new_activities_count = g_crossposting_post_new($all_activities);
     532    return $new_activities_count.' out of '.count($all_activities);
     533}
     534
     535/**
     536*  returns all activities
     537*
     538*  @return array of all activities found on Google+
     539*/
     540function g_crossposting_get_all_activities() {
     541    // load options
     542    $options = g_crossposting_get_settings();
     543
     544    // go through all activities
     545    $all_activities = array();
     546    $nextPageToken = null;
     547    do
     548    {
     549        $activities = g_crossposting_api_activities_list($options['gplusid'],
     550                            $options['apikey'], $options['maxactivities'], $nextPageToken);
     551        if ($activities == null) {
     552            return null;
     553        }
     554
     555        $nextPageToken = $activities->nextPageToken;
     556        foreach ($activities->items as $activity)
     557        {
     558            $all_activities[] = $activity;
     559        }
     560    }
     561    while($nextPageToken != null);
     562
     563    if (count($all_activities) > 0) {
     564        return $all_activities;
     565    } else {
     566        return null;
     567    }
     568}
  • g-crossposting/trunk/lang/g-crossposting-de_DE.po

    r807770 r995586  
    9595msgstr "Änderungen speichern"
    9696
    97 #: admin.php:257
     97#: admin.php:256
    9898#@ g-crossposting
    9999msgid "Manual mass import:"
     
    101101
    102102#: admin.php:54
     103#@ g-crossposting
    103104msgid "Authentication Settings"
    104105msgstr "Anmeldeinformationen für Google+"
    105106
    106107#: admin.php:55
     108#@ g-crossposting
    107109msgid "Setup Options"
    108110msgstr "Verhalten des Plugins"
    109111
    110 #: admin.php:259
     112#: admin.php:258
    111113#@ g-crossposting
    112114msgid "manually check for new activities and import them"
    113115msgstr "auf neue Aktivitäten prüfen und diese sofort importieren"
     116
     117#: admin.php:262
     118#@ g-crossposting
     119msgid "Manual mass import ALL:"
     120msgstr "Manueller Massenimport aller Aktivitäten:"
     121
     122#: admin.php:264
     123#@ g-crossposting
     124msgid "manually check for ALL activities and import them"
     125msgstr "manuellen Import aller Aktivitäten anstoßen"
    114126
    115127#: g-crossposting.php:89
     
    141153
    142154#. Author URI of the plugin/theme
     155#@ g-crossposting
    143156msgid "http://sebstein.hpfsc.de/"
    144157msgstr "http://sebstein.hpfsc.de/"
  • g-crossposting/trunk/lang/g-crossposting.pot

    r807770 r995586  
    8787msgstr ""
    8888
    89 #: admin.php:257
     89#: admin.php:256
    9090msgid "Manual mass import:"
    9191msgstr ""
    9292
    93 #: admin.php:259
     93#: admin.php:258
    9494msgid "manually check for new activities and import them"
     95msgstr ""
     96
     97#: admin.php:262
     98msgid "Manual mass import ALL:"
     99msgstr ""
     100
     101#: admin.php:264
     102msgid "manually check for ALL activities and import them"
    95103msgstr ""
    96104
  • g-crossposting/trunk/readme.txt

    r989584 r995586  
    55Requires at least: 3.0.0
    66Tested up to: 4.0
    7 Stable tag: 1.5.0
     7Stable tag: 1.6.0
    88
    99Imports your public Google+ activities in your Wordpress blog.
     
    127127== Changelog ==
    128128
     129= 1.6.0 =
     130
     131* Plugin settings now provide a link to manually import ALL Google+ activities.
     132  Many thanks to krischel for providing this patch!
     133
    129134= 1.5.0 =
    130135
Note: See TracChangeset for help on using the changeset viewer.