Plugin Directory

Changeset 698522


Ignore:
Timestamp:
04/16/2013 01:35:22 PM (13 years ago)
Author:
oshingler
Message:

Added StayClassy support for Events

Location:
olimometer
Files:
65 added
3 edited

Legend:

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

    r675314 r698522  
    3838    public $olimometer_overlay_y = 0;
    3939    public $olimometer_stayclassypid = 0;
     40    public $olimometer_stayclassyeid = 0;
    4041   
    4142    private $olimometer_default_link = "http://www.olivershingler.co.uk/oliblog/olimometer/";
     
    7879        $this->olimometer_overlay_y = $query_results['olimometer_overlay_y'];
    7980        $this->olimometer_stayclassypid = $query_results['olimometer_stayclassypid'];
     81        $this->olimometer_stayclassyeid = $query_results['olimometer_stayclassyeid'];
    8082       
    8183        if($query_results['olimometer_link'] == "" || $query_results['olimometer_link'] == null) {
     
    164166                                                                'olimometer_overlay_x' => $this->olimometer_overlay_x,
    165167                                                                'olimometer_overlay_y' => $this->olimometer_overlay_y,
    166                                                                 'olimometer_stayclassypid' => $this->olimometer_stayclassypid
     168                                                                'olimometer_stayclassypid' => $this->olimometer_stayclassypid,
     169                                                                'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid
    167170                                                                 ) );
    168171           
     
    199202                                'olimometer_overlay_x' => $this->olimometer_overlay_x,
    200203                                'olimometer_overlay_y' => $this->olimometer_overlay_y,
    201                                 'olimometer_stayclassypid' => $this->olimometer_stayclassypid
     204                                'olimometer_stayclassypid' => $this->olimometer_stayclassypid,
     205                                'olimometer_stayclassyeid' => $this->olimometer_stayclassyeid
    202206                        ),
    203207                        array( 'olimometer_id' => $this->olimometer_id )
     
    260264        }
    261265
    262         // If StayClassy integration is configured, get the current balance and save it
     266        // If StayClassy PROJECT ID integration is configured, get the current balance and save it
    263267        if($this->olimometer_use_paypal == 2) {
    264268            $olimometer_stayclassy_balance = $this->getStayClassy($this->olimometer_stayclassypid);
     
    278282            }
    279283        }
     284
     285        // If StayClassy EVENT ID integration is configured, get the current balance and save it
     286        if($this->olimometer_use_paypal == 3) {
     287            $olimometer_stayclassy_balance = $this->getStayClassyEvent($this->olimometer_stayclassyeid);
     288            if($olimometer_stayclassy_balance == false) {
     289                // If PayPal link is broken, set balance to 0
     290                $olimometer_stayclassy_balance = 0;
     291            }
     292            else {
     293                    if($this->olimometer_progress_value == ($olimometer_stayclassy_balance) ) {
     294                        // PayPal balance hasn't changed since we last checked so don't do anything
     295                    }
     296                    else {
     297                        // It has changed, so save it
     298                        $this->olimometer_progress_value = $olimometer_stayclassy_balance;
     299                        $this->save();
     300                    }
     301            }
     302        }
    280303   
    281304   
     
    289312            $the_olimometer_text = $the_olimometer_text." class='".$css_class."'";
    290313        }
    291         $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.45'></a>";
     314        $the_olimometer_text = $the_olimometer_text." alt='Olimometer 2.46'></a>";
    292315       
    293316        return $the_olimometer_text;
     
    319342    }
    320343   
     344        // Gets the total_raised value from StayClassy.org for a given EID.
     345    function getStayClassyEvent($EID) {
     346        $json = file_get_contents("http://www.stayclassy.org/api/event-info?eid=$EID");
     347
     348        $jsonIterator = new RecursiveIteratorIterator(
     349        new RecursiveArrayIterator(json_decode($json, TRUE)),
     350        RecursiveIteratorIterator::SELF_FIRST);
     351   
     352        $return_value = 0;
     353
     354            foreach ($jsonIterator as $key => $val) {
     355                if(is_array($val)) {
     356                    //$return_text = $return_text . "$key:\n";
     357                } else {
     358                    if($key == "total_raised") {
     359                        $return_value = $val;
     360                    }
     361                    //$return_text = $return_text . "$key => $val\n";
     362                }
     363            }
     364
     365        return $return_value;
     366    }
     367
    321368    // The following function is for PayPal balance retrieval
    322369    function PPHttpPost($methodName_, $nvpStr_) {
  • olimometer/trunk/olimometer.php

    r675314 r698522  
    66Author: Oliver Shingler
    77Author URI: http://www.olivershingler.co.uk
    8 Version: 2.45
     8Version: 2.46
    99*/
    1010
     
    151151    $an_olimometer->olimometer_overlay_y = $_REQUEST['olimometer_overlay_y'];
    152152    $an_olimometer->olimometer_stayclassypid = $_REQUEST['olimometer_stayclassypid'];
     153    $an_olimometer->olimometer_stayclassyeid = $_REQUEST['olimometer_stayclassyeid'];
    153154   
    154155    // Save it
     
    219220<script language="javascript">
    220221
    221     /*
    222     function olimometer_progress_disable() {
    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;
    228     }
    229 
    230     function olimometer_progress_enable() {
    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     }*/
    237222
    238223    function olimometer_progress($progress_type) {
    239224        // 0 = Manual
    240225        // 1 = PayPal
    241         // 2 = StayClassy
     226        // 2 = StayClassy Project
     227        // 3 = StayClassy Event
    242228        if ($progress_type == 0) {
    243229            // Enable manual
     
    247233            // Disable StayClassy
    248234            olimometer_disable_stayclassy(true);
     235            // Disable StayClassy Event
     236            olimometer_disable_stayclassyevent(true);
    249237        }
    250238        if ($progress_type == 1) {
     
    255243            // Disable StayClassy
    256244            olimometer_disable_stayclassy(true);
     245            // Disable StayClassy Event
     246            olimometer_disable_stayclassyevent(true);
    257247        }
    258248        if ($progress_type == 2) {
     
    263253            // Disable Manual
    264254            olimometer_disable_manual(true);
     255            // Disable StayClassy Event
     256            olimometer_disable_stayclassyevent(true);
     257        }
     258        if ($progress_type == 3) {
     259            // Disable StayClassy
     260            olimometer_disable_stayclassy(true);
     261            // Disable PayPal
     262            olimometer_disable_paypal(true);
     263            // Disable Manual
     264            olimometer_disable_manual(true);
     265            // Enable StayClassy Event
     266            olimometer_disable_stayclassyevent(false);
    265267        }
    266268    }
     
    279281    function olimometer_disable_stayclassy($tof) {
    280282        document.olimometer_form1.olimometer_stayclassypid.readOnly = $tof;
     283    }
     284
     285    function olimometer_disable_stayclassyevent($tof) {
     286        document.olimometer_form1.olimometer_stayclassyeid.readOnly = $tof;
    281287    }
    282288
     
    473479}
    474480
    475 ?> onClick="olimometer_progress(2);"> StayClassy
     481?> onClick="olimometer_progress(2);"> StayClassy Project<br />
     482                <input name="olimometer_use_paypal" id="olimometer_use_paypal" type="radio" value="3"<?php
     483if($current_olimometer->olimometer_use_paypal == 3) {
     484    echo " checked";
     485}
     486
     487?> onClick="olimometer_progress(3);"> StayClassy Event
    476488
    477489            <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>
     
    553565        </tr>
    554566
     567        <tr class="form-field form-required">
     568            <th scope="row" valign="top"><label for="name">StayClassy EID</label></th>
     569            <td><input name="olimometer_stayclassyeid" id="olimometer_stayclassyeid" type="text" value="<?php
     570                echo $current_olimometer->olimometer_stayclassyeid;
     571           
     572            ?>" size="40" aria-required="true" />
     573            <p><span class="description">Please enter your unique StayClassy.org event ID for which you would like to track the total.</span></p></td>
     574        </tr>
    555575
    556576    </table>
     
    847867
    848868            <p><strong>Want to say thank you?</strong></p>
    849             <p>You can visit the my site for more information or to make a donation: <a href='http://www.olivershingler.co.uk/oliblog/olimometer'>http://www.olivershingler.co.uk/oliblog/olimometer</a>.</p>
     869            <p>You can visit my site for more information or to make a donation: <a href='http://www.olivershingler.co.uk/oliblog/olimometer'>http://www.olivershingler.co.uk/oliblog/olimometer</a>.</p>
    850870
    851871
     
    892912{
    893913olimometer_progress(2);
     914}
     915if(document.olimometer_form1.olimometer_use_paypal[3].checked)
     916{
     917olimometer_progress(3);
    894918}
    895919
     
    12231247************************/
    12241248global $olimometer_db_version;
    1225 $olimometer_db_version = "2.41";
     1249$olimometer_db_version = "2.46";
    12261250
    12271251function olimometer_install() {
     
    12601284  olimometer_overlay_y int,
    12611285  olimometer_stayclassypid int,
     1286  olimometer_stayclassyeid int,
    12621287  UNIQUE KEY olimometer_id (olimometer_id)
    12631288    );";
  • olimometer/trunk/readme.txt

    r675314 r698522  
    109109== Changelog ==
    110110
     111= 2.46 =
     112* Added support for StayClassy Events in addition to Projects
     113
    111114= 2.45 =
    112115* Added Swiss Francs (CHF) as a currency option
     
    245248== Upgrade Notice ==
    246249
     250= 2.46 =
     251* Added support for StayClassy Events in addition to Projects
     252
    247253= 2.45 =
    248254* Added Swiss Francs (CHF) as a currency option
Note: See TracChangeset for help on using the changeset viewer.