Plugin Directory

Changeset 613541


Ignore:
Timestamp:
10/17/2012 08:18:52 AM (13 years ago)
Author:
oshingler
Message:
 
Location:
olimometer
Files:
65 added
3 edited

Legend:

Unmodified
Added
Removed
  • olimometer/trunk/olimometer-class.php

    r608691 r613541  
    3737    public $olimometer_overlay_x = 0;
    3838    public $olimometer_overlay_y = 0;
     39    public $olimometer_stayclassypid = 0;
    3940   
    4041    private $olimometer_default_link = "http://www.olivershingler.co.uk/oliblog/olimometer/";
     
    7677        $this->olimometer_overlay_x = $query_results['olimometer_overlay_x'];
    7778        $this->olimometer_overlay_y = $query_results['olimometer_overlay_y'];
     79        $this->olimometer_stayclassypid = $query_results['olimometer_stayclassypid'];
    7880       
    7981        if($query_results['olimometer_link'] == "" || $query_results['olimometer_link'] == null) {
     
    161163                                                                'olimometer_overlay_image' => $this->olimometer_overlay_image,
    162164                                                                'olimometer_overlay_x' => $this->olimometer_overlay_x,
    163                                                                 'olimometer_overlay_y' => $this->olimometer_overlay_y
     165                                                                'olimometer_overlay_y' => $this->olimometer_overlay_y,
     166                                                                'olimometer_stayclassypid' => $this->olimometer_stayclassypid
    164167                                                                 ) );
    165168           
     
    195198                                'olimometer_overlay_image' => $this->olimometer_overlay_image,
    196199                                'olimometer_overlay_x' => $this->olimometer_overlay_x,
    197                                 'olimometer_overlay_y' => $this->olimometer_overlay_y
     200                                'olimometer_overlay_y' => $this->olimometer_overlay_y,
     201                                'olimometer_stayclassypid' => $this->olimometer_stayclassypid
    198202                        ),
    199203                        array( 'olimometer_id' => $this->olimometer_id )
     
    255259            }
    256260        }
     261
     262        // If StayClassy integration is configured, get the current balance and save it
     263        if($this->olimometer_use_paypal == 2) {
     264            $olimometer_stayclassy_balance = $this->getStayClassy($this->olimometer_stayclassypid);
     265            if($olimometer_stayclassy_balance == false) {
     266                // If PayPal link is broken, set balance to 0
     267                $olimometer_stayclassy_balance = 0;
     268            }
     269            else {
     270                    if($this->olimometer_progress_value == ($olimometer_stayclassy_balance) ) {
     271                        // PayPal balance hasn't changed since we last checked so don't do anything
     272                    }
     273                    else {
     274                        // It has changed, so save it
     275                        $this->olimometer_progress_value = $olimometer_stayclassy_balance;
     276                        $this->save();
     277                    }
     278            }
     279        }
    257280   
    258281   
     
    266289            $the_olimometer_text = $the_olimometer_text." class='".$css_class."'";
    267290        }
    268         $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.40'></a>";
     291        $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.41'></a>";
    269292       
    270293        return $the_olimometer_text;
     
    272295    }
    273296   
    274    
     297    // Gets the total_raised value from StayClassy.org for a given PID.
     298    function getStayClassy($PID) {
     299        $json = file_get_contents("http://www.stayclassy.org/api/project-info?pid=$PID");
     300
     301        $jsonIterator = new RecursiveIteratorIterator(
     302        new RecursiveArrayIterator(json_decode($json, TRUE)),
     303        RecursiveIteratorIterator::SELF_FIRST);
     304   
     305        $return_value = 0;
     306
     307            foreach ($jsonIterator as $key => $val) {
     308                if(is_array($val)) {
     309                    //$return_text = $return_text . "$key:\n";
     310                } else {
     311                    if($key == "total_raised") {
     312                        $return_value = $val;
     313                    }
     314                    //$return_text = $return_text . "$key => $val\n";
     315                }
     316            }
     317
     318        return $return_value;
     319    }
    275320   
    276321    // The following function is for PayPal balance retrieval
  • olimometer/trunk/olimometer.php

    r608691 r613541  
    66Author: Oliver Shingler
    77Author URI: http://www.olivershingler.co.uk
    8 Version: 2.40
     8Version: 2.41
    99*/
    1010
     
    150150    $an_olimometer->olimometer_overlay_x = $_REQUEST['olimometer_overlay_x'];
    151151    $an_olimometer->olimometer_overlay_y = $_REQUEST['olimometer_overlay_y'];
     152    $an_olimometer->olimometer_stayclassypid = $_REQUEST['olimometer_stayclassypid'];
    152153   
    153154    // Save it
     
    217218
    218219<script language="javascript">
     220
     221    /*
    219222    function olimometer_progress_disable() {
    220         document.olimometer_form1.olimometer_progress_value.readOnly = true;
    221         document.olimometer_form1.olimometer_paypal_username.readOnly = false;
    222         document.olimometer_form1.olimometer_paypal_password.readOnly = false;
    223         document.olimometer_form1.olimometer_paypal_signature.readOnly = false;
    224         document.olimometer_form1.olimometer_paypal_extra_value.readOnly = false;
     223    document.olimometer_form1.olimometer_progress_value.readOnly = true;
     224    document.olimometer_form1.olimometer_paypal_username.readOnly = false;
     225    document.olimometer_form1.olimometer_paypal_password.readOnly = false;
     226    document.olimometer_form1.olimometer_paypal_signature.readOnly = false;
     227    document.olimometer_form1.olimometer_paypal_extra_value.readOnly = false;
    225228    }
    226229
    227230    function olimometer_progress_enable() {
    228         document.olimometer_form1.olimometer_progress_value.readOnly = false;
    229         document.olimometer_form1.olimometer_paypal_username.readOnly = true;
    230         document.olimometer_form1.olimometer_paypal_password.readOnly = true;
    231         document.olimometer_form1.olimometer_paypal_signature.readOnly = true;
    232         document.olimometer_form1.olimometer_paypal_extra_value.readOnly = true;
    233     }
    234 
     231    document.olimometer_form1.olimometer_progress_value.readOnly = false;
     232    document.olimometer_form1.olimometer_paypal_username.readOnly = true;
     233    document.olimometer_form1.olimometer_paypal_password.readOnly = true;
     234    document.olimometer_form1.olimometer_paypal_signature.readOnly = true;
     235    document.olimometer_form1.olimometer_paypal_extra_value.readOnly = true;
     236    }*/
     237
     238    function olimometer_progress($progress_type) {
     239        // 0 = Manual
     240        // 1 = PayPal
     241        // 2 = StayClassy
     242        if ($progress_type == 0) {
     243            // Enable manual
     244            olimometer_disable_manual(false);
     245            // Disable PayPal
     246            olimometer_disable_paypal(true);
     247            // Disable StayClassy
     248            olimometer_disable_stayclassy(true);
     249        }
     250        if ($progress_type == 1) {
     251            // Enable PayPal
     252            olimometer_disable_paypal(false);
     253            // Disable Manual
     254            olimometer_disable_manual(true);
     255            // Disable StayClassy
     256            olimometer_disable_stayclassy(true);
     257        }
     258        if ($progress_type == 2) {
     259            // Enable StayClassy
     260            olimometer_disable_stayclassy(false);
     261            // Disable PayPal
     262            olimometer_disable_paypal(true);
     263            // Disable Manual
     264            olimometer_disable_manual(true);
     265        }
     266    }
     267
     268    function olimometer_disable_manual($tof) {
     269        document.olimometer_form1.olimometer_progress_value.readOnly = $tof;
     270    }
     271
     272    function olimometer_disable_paypal($tof) {
     273        document.olimometer_form1.olimometer_paypal_username.readOnly = $tof;
     274        document.olimometer_form1.olimometer_paypal_password.readOnly = $tof;
     275        document.olimometer_form1.olimometer_paypal_signature.readOnly = $tof;
     276        document.olimometer_form1.olimometer_paypal_extra_value.readOnly = $tof;
     277    }
     278
     279    function olimometer_disable_stayclassy($tof) {
     280        document.olimometer_form1.olimometer_stayclassypid.readOnly = $tof;
     281    }
    235282
    236283    function olimometer_overlay_disable() {
     
    408455    <table class="form-table">
    409456        <tr class="form-required">
    410             <th scope="row" valign="top"><label for="name">Manual or PayPal Link?</label></th>
     457            <th scope="row" valign="top"><label for="name">Manual or Automatic Progress Tracking?</label></th>
    411458            <td><input name="olimometer_use_paypal" id="olimometer_use_paypal" type="radio" value="0"<?php
    412459if($current_olimometer->olimometer_use_paypal == 0) {
     
    414461}
    415462
    416 ?> onClick="olimometer_progress_enable();"> Manual<br />
     463?> onClick="olimometer_progress(0);"> Manual<br />
    417464                <input name="olimometer_use_paypal" id="olimometer_use_paypal" type="radio" value="1"<?php
    418465if($current_olimometer->olimometer_use_paypal == 1) {
     
    420467}
    421468
    422 ?> onClick="olimometer_progress_disable();"> PayPal
    423 
    424             <p><span class="description">Do you want to update the progress (current amount raised) manually or automatically by linking to a PayPal account?</span></p></td>
     469?> onClick="olimometer_progress(1);"> PayPal<br />
     470                <input name="olimometer_use_paypal" id="olimometer_use_paypal" type="radio" value="2"<?php
     471if($current_olimometer->olimometer_use_paypal == 2) {
     472    echo " checked";
     473}
     474
     475?> onClick="olimometer_progress(2);"> StayClassy
     476
     477            <p><span class="description">Do you want to update the progress (current amount raised) manually or automatically by linking to a PayPal or StayClassy account?</span></p></td>
    425478
    426479        </tr>
     
    491544        </tr>
    492545       
     546        <tr class="form-field form-required">
     547            <th scope="row" valign="top"><label for="name">StayClassy PID</label></th>
     548            <td><input name="olimometer_stayclassypid" id="olimometer_stayclassypid" type="text" value="<?php
     549                echo $current_olimometer->olimometer_stayclassypid;
     550           
     551            ?>" size="40" aria-required="true" />
     552            <p><span class="description">Please enter your unique StayClassy.org project ID for which you would like to track the total.</span></p></td>
     553        </tr>
    493554
    494555
     
    820881if(document.olimometer_form1.olimometer_use_paypal[0].checked)
    821882{
    822 olimometer_progress_enable();
    823 }
    824 else
     883olimometer_progress(0);
     884}
     885if(document.olimometer_form1.olimometer_use_paypal[1].checked)
    825886{
    826 olimometer_progress_disable();
     887olimometer_progress(1);
     888}
     889if(document.olimometer_form1.olimometer_use_paypal[2].checked)
     890{
     891olimometer_progress(2);
    827892}
    828893
     
    10671132************************/
    10681133global $olimometer_db_version;
    1069 $olimometer_db_version = "2.40";
     1134$olimometer_db_version = "2.41";
    10701135
    10711136function olimometer_install() {
     
    11031168  olimometer_overlay_x int,
    11041169  olimometer_overlay_y int,
     1170  olimometer_stayclassypid int,
    11051171  UNIQUE KEY olimometer_id (olimometer_id)
    11061172    );";
     
    11291195        // Yes it has!
    11301196        // If currently installed database version is less than current version required for this plugin, then we need to upgrade
    1131         $required_db_version = 2.40;
     1197        $required_db_version = 2.41;
    11321198        $installed_db_version = get_option("olimometer_db_version");
    11331199        if($installed_db_version < $required_db_version) {
     
    12831349}
    12841350
     1351
     1352
     1353   
     1354
     1355
    12851356?>
  • olimometer/trunk/readme.txt

    r608691 r613541  
    77Stable tag: trunk
    88
    9 A fully customisable fundraising thermometer with PayPal integration, custom skins and support for multiple vertical and horizontal thermometers.
     9A fully customisable fundraising thermometer with PayPal and StayClassy integration, custom skins and support for multiple vertical and horizontal thermometers.
    1010
    1111== Description ==
    1212
    13 A fully customisable fundraising thermometer with PayPal integration and custom skin support.
     13A fully customisable fundraising thermometer with PayPal and StayClassy integration and custom skin support.
    1414
    1515Multiple thermometers can be configured and displayed separately on different pages or posts. Each thermometer supports individual customisation, targets, currencies and progress tracking.
     
    105105== Changelog ==
    106106
     107= 2.41 =
     108* Added support for tracking StayClassy.org fundraising totals
     109
    107110= 2.40 =
    108111* Added the ability to overlay a custom image over the top of the Olimometer. This feature can be found at the bottom of the Appearance and Layout section of the admin page.
     
    226229== Upgrade Notice ==
    227230
     231= 2.41 =
     232* Added support for tracking StayClassy.org fundraising totals
     233
    228234= 2.40 =
    229235* Added the ability to overlay a custom image over the top of the Olimometer. This feature can be found at the bottom of the Appearance and Layout section of the admin page.
Note: See TracChangeset for help on using the changeset viewer.