Plugin Directory

Changeset 701681


Ignore:
Timestamp:
04/22/2013 05:43:15 PM (13 years ago)
Author:
phikai
Message:

Single Event Import

Location:
runkeeper-activity-feed/trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • runkeeper-activity-feed/trunk/readme.txt

    r687190 r701681  
    55Requires at least: 3.5
    66Tested up to: 3.5.1
    7 Stable tag: 1.3.1
     7Stable tag: 1.4.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    4242== Frequently Asked Questions ==
    4343
    44 None yet!
     44= I get this error: "Fatal error: Call to undefined function date_create_from_format()" =
     45
     46This function was introduced in PHP 5.3, so you'll need to check with your hosting provider to make sure you're using at least PHP 5.3.
    4547
    4648== Screenshots ==
     
    5355== Changelog ==
    5456
    55 = 1.3.1=
     57= 1.4.0 =
     58* NEW FEATURE: Single Activity Import based on Activity ID
     59
     60= 1.3.1 =
    5661* BUG FIX: Update RunKeeper API Library with Records Method
    5762
  • runkeeper-activity-feed/trunk/runkeeper-wordpress-activity-feed.php

    r687190 r701681  
    66Description: A plugin to automatically draft posts of all your Runkeeper Activities.
    77Author: A. Kai Armstrong
    8 Version: 1.3.1
     8Version: 1.4.0
    99Author URI: http://www.kaiarmstrong.com
    1010*/
     
    3939define('YAMLPATH', TOZRKPATH.'includes/yaml/');
    4040define('RUNKEEPERAPIPATH', TOZRKPATH.'includes/runkeeperAPI/');
    41 define('CONFIGPATH', TOZRKPATH.'includes/');
     41define('TOZRKCONFIGPATH', TOZRKPATH.'includes/');
    4242
    4343require(YAMLPATH.'lib/sfYamlParser.php');
     
    5151    /* API initialization */
    5252    $toz_rkAPI = new runkeeperAPI(
    53         CONFIGPATH.'rk-api.yml' /* api_conf_file */
     53        TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
    5454    );
    5555    if ($toz_rkAPI->api_created == false) {
     
    197197                <input type="submit" class="button-primary" value="<?php _e('Reset Options') ?>" /></p>
    198198            </form></p>
     199            <hr />
     200            <p><form method="post" action="">
     201                <p>Import a Single Post based on ID:
     202                <input type="hidden" name="action" value="toz_rk_import_single" />
     203                <input type="text" name="rkActivity_id" value="Activity ID" class="regular-text code" />
     204                <input type="submit" class="button-primary" value="<?php _e('Import Single') ?>" /></p>
     205            </form></p>
     206            <hr />
    199207            <p><form method="post" action="">
    200208                <p>Import all (1000) of your previous activities:
     
    205213            <?php if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_import_old' )) { ?>
    206214                <h3>Historical Import</h3>
    207                 <?php toz_rk_import_old(); ?>
    208             <?php } else {
    209                 //Do Nothing
     215                <?php toz_rk_import_old();
     216            } else if ( isset($_POST['action']) && ( $_POST['action'] == 'toz_rk_import_single' )) { ?>
     217                <h3>Single Activity Import</h3>
     218                <?php toz_rk_import_single($_POST['rkActivity_id']);
     219            } else {
     220                //DO NOTHING
    210221            }
    211222        } ?>
     
    228239function toz_rk_schedule_event() {
    229240    $toz_schedule_rkAPI = new runkeeperAPI(
    230         CONFIGPATH.'rk-api.yml' /* api_conf_file */
     241        TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
    231242    );
    232243    if ($toz_schedule_rkAPI->api_created == false) {
     
    272283}
    273284
     285//Import a Single Event based on ID
     286function toz_rk_import_single($rkActivity_id) {
     287    $toz_import_single_rkAPI = new runkeeperAPI(
     288        TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
     289    );
     290    if ($toz_import_single_rkAPI->api_created == false) {
     291        echo 'error '.$toz_import_single_rkAPI->api_last_error; /* api creation problem */
     292        exit();
     293    }
     294
     295    $toz_rk_auth_code = get_option( 'toz_rk_auth_code' );
     296    if ( !empty($toz_rk_auth_code) ) {
     297        $toz_import_single_rkAPI->setRunkeeperToken( get_option( 'toz_rk_access_token' ) );
     298    }
     299   
     300    if ( !empty($rkActivity_id) ) {
     301   
     302        $rkActivity_uri = '/fitnessActivities/' . $rkActivity_id;
     303
     304        $rkActivity_detailed = $toz_import_single_rkAPI->doRunkeeperRequest('FitnessActivity','Read', '', $rkActivity_uri);
     305        $rkActivity_detailed_array = (array) $rkActivity_detailed;
     306
     307        toz_rk_post($rkActivity_detailed_array);                           
     308               
     309    } else {
     310        echo $toz_import_single_rkAPI->api_last_error;
     311        print_r($toz_import_single_rkAPI->request_log);
     312    }
     313}
    274314
    275315//This is how we import all the old posts.
    276316function toz_rk_import_old() {
    277317    $toz_import_rkAPI = new runkeeperAPI(
    278         CONFIGPATH.'rk-api.yml' /* api_conf_file */
     318        TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
    279319    );
    280320    if ($toz_import_rkAPI->api_created == false) {
  • runkeeper-activity-feed/trunk/runkeeper-wordpress-records-widget.php

    r687180 r701681  
    3838
    3939            $toz_widget_rkAPI = new runkeeperAPI(
    40                 CONFIGPATH.'rk-api.yml' /* api_conf_file */
     40                TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
    4141            );
    4242            if ($toz_widget_rkAPI->api_created == false) {
     
    104104   
    105105            $toz_widget_form_rkAPI = new runkeeperAPI(
    106                 CONFIGPATH.'rk-api.yml' /* api_conf_file */
     106                TOZRKCONFIGPATH.'rk-api.yml'    /* api_conf_file */
    107107            );
    108108            if ($toz_widget_form_rkAPI->api_created == false) {
Note: See TracChangeset for help on using the changeset viewer.