예제 #1
0
 public function getUsers($like)
 {
     $this->connection->real_escape_string($like);
     $query = "SELECT name, steamID, charity_ID FROM Users WHERE name LIKE '%" . $like . "%' LIMIT 10";
     $result = $this->connection->query($query);
     $JGAPI = new JustGivingAPI();
     $results_array = array();
     while ($row = $result->fetch_assoc()) {
         $charityInfo = $JGAPI->getCharityByID($row['charity_ID']);
         $row['charity_name'] = $charityInfo['name'];
         $results_array[] = $row;
     }
     return $results_array;
 }
예제 #2
0
 /**
  * Updates this events money raised value.
  * @return void
  */
 public function updateMoneyRaised()
 {
     $total = 0;
     //get the event and look through all its pages.
     foreach ($this->JustGivingEvent as $jgEvent) {
         $pages = Doctrine_Core::getTable('Page')->findByJustGivingEventId($jgEvent->id);
         //get and save the amount raised for each page.
         foreach ($pages as $page) {
             $resp = JustGivingAPI::retrievePage($page->short_name);
             $moneyRaised = (string) $resp->grandTotalRaisedExcludingGiftAid;
             $page->money_raised = $moneyRaised;
             $page->save();
             if ($moneyRaised > 0) {
                 $total += $moneyRaised;
             }
         }
     }
     //save the events total.
     $this->total_money = $total;
     $this->save();
 }
예제 #3
0
<?php

require_once dirname(__FILE__) . '/../bootstrap/unit.php';
$t = new lime_test(20, new lime_output_color());
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'test', true);
$t->comment('->donationRecieveStatus()');
// List of Fundraising Pages by Email
// <-- Returns internal server error!
$response = JustGivingAPI::donationRecieveStatus(1);
$t->isnt($response, null, 'Works');
// Account Create
$response = JustGivingAPI::accountCreate($country = "UK", $county_or_state = "London", $line1 = "Flat 3", $line2 = "176 Shoreditch High Street", $postcode_or_zipcode = "E1 6AX", $town_or_city = "London", $email = "*****@*****.**", $first_name = "Justen", $last_name = "Doherty", $password = "******", $reference = "CharityHack 2010", $title = "Mr");
$t->isnt($response, null, 'Works');
// List of Fundraising Pages by Email
$response = JustGivingAPI::listAllFundRaisingPagesByEmail("*****@*****.**");
$t->isnt($response, null, 'Works');
// List Fundraising Pages by Auth User
$response = JustGivingAPI::listAllFundRaisingPagesForUser();
$t->isnt($response, null, 'Works');
// Charity Search
$response = JustGivingAPI::charitySearch($term = "Cancer", $page = 1, $page_size = 4);
$t->isnt($response, null, 'Works');
// Retrieve Page Donations
$response = JustGivingAPI::retrievePageDonations();
$t->isnt($response, null, 'Works');
// Create a Page
$response = JustGivingAPI::createPage($charity_funded = "false", $charity_id = 2367, $charity_opt_in = "false", $event_id = 9999, $event_name = "TEST EVENT 2", $just_giving_opt_in = "false", $page_short_name = "TEST EVENT 2", $page_title = "PAGE TITLE 2", $activity_type_id = "InMemory", $target_amount = 2000);
$t->isnt($response, null, 'Works');
<?php

// Expecting a donation ID from Just Giving to this page
// This is a callback
if (isset($_GET['jgDonationId'])) {
    $donationID = $_GET['jgDonationId'];
    include_once 'JustGivingAPI.class.php';
    $jg = new JustGivingAPI();
    // Get donation info with the API
    $donationInfo = $jg->getDonationInfo($donationID);
    echo '<pre>';
    print_r($donationInfo);
    echo '</pre>';
} else {
    echo 'No Donation Provided';
}
예제 #5
0
 /**
  * A form to create a page on JustGiving that will be tracked by the system.
  *
  * @param sfRequest $request A request object
  */
 public function executeForm(sfWebRequest $request)
 {
     $this->charityName = '';
     $this->charityCodeArray = array();
     //find the Just Giving Event Id.
     $eventCode = $request->getParameter('event_code');
     $this->event = Doctrine_Core::getTable('Event')->findOneByCode($eventCode);
     $firstJGEvent = $this->event->JustGivingEvent[0];
     $firstJGEventId = $firstJGEvent->id;
     $this->eventCode = $request->getParameter('event_code');
     $this->form = new PageCreationForm();
     $this->error = '';
     $this->form->setDefault('just_giving_event_id', $firstJGEventId);
     //$this->form->setDefault('charity_code', '2357');
     if ($request->isMethod(sfWebRequest::POST)) {
         $params = $request->getParameter($this->form->getName());
         $this->form->bind($params);
         if ($this->form->isValid()) {
             $existingShortPage = $params['existing_short_name'];
             if ($existingShortPage != '') {
                 $resp = JustGivingAPI::retrievePage($existingShortPage);
                 $title = (string) $resp->eventName;
                 if ($title != '') {
                     $page = new Page();
                     $page->title = $title;
                     $page->short_name = $existingShortPage;
                     $page->target_amount = (string) $resp->fundraisingTarget;
                     $page->charity_name = (string) $resp->charity->name;
                     $page->charity_code = (string) $resp->charity->registrationNumber;
                     $page->money_raised = (string) $resp->grandTotalRaisedExcludingGiftAid;
                     $page->user = (string) $resp->owner;
                     $page->just_giving_event_id = $firstJGEventId;
                     $page->save();
                     $this->getUser()->setFlash('message', 'The page with the title "' . $page->title . '" was found and added.');
                 } else {
                     $this->getUser()->setFlash('message', 'The page was not found.');
                 }
             } else {
                 $title = $params['title'];
                 $shortName = $params['short_name'];
                 $targetAmount = $params['target_amount'];
                 $charityCode = $params['charity_code'];
                 $charityName = $params['charity_name'];
                 $charitySearch = $params['charity_search'];
                 $jgEventId = $params['just_giving_event_id'];
                 //if searching for a charity, find it first.
                 if ($charitySearch != '' && $charityCode == '') {
                     $charityResp = JustGivingAPI::charitySearch($charitySearch);
                     if ($charityResp->error == '') {
                         $charityName = (string) $charityResp->charitySearchResults->charitySearchResult[0]->name;
                         $charityCode = (string) $charityResp->charitySearchResults->charitySearchResult[0]->charityId;
                         $this->form->setDefault('charity_code', $charityCode);
                         $this->charityName = $charityName;
                         $this->charityCodeArray = array('value' => $charityCode);
                         $this->form->setDefaults(array('charity_name' => $charityName));
                         $this->getUser()->setFlash('message', 'We have found a charity, click submit again to use this, or clear the charity id and try again.');
                         return;
                     } else {
                         $this->getUser()->setFlash('message', (string) $charityResp->error->desc);
                         return;
                     }
                 }
                 $response = JustGivingAPI::createPage('false', $charityCode, 'false', $jgEventId, $title, 'false', $shortName, $title, null, $targetAmount);
                 if (!is_null($response)) {
                     $uri = (string) $response->next->uri;
                     if ($uri != '') {
                         $page = Doctrine_Core::getTable('Page')->create(array('title' => $title, 'short_name' => $shortName, 'target_amount' => $targetAmount, 'charity_code' => $charityCode, 'charity_name' => $charityName, 'just_giving_event_id' => $jgEventId));
                         $page->save();
                         $this->redirect($uri);
                     } else {
                         $errors = '';
                         foreach ($response->error as $error) {
                             $errors .= ", " . (string) $error->desc;
                         }
                         $this->getUser()->setFlash('message', 'Not able to create this JustGiving page' . $errors);
                     }
                 }
             }
         } else {
             $this->getUser()->setFlash('message', "Form is invalid.");
         }
     }
 }
예제 #6
0
                <th>Game</th>
                <th>Achievement</th>
                <th>Challenged</th>
                <th>Bounty</th>
                <th>Done?</th>
                <th>Paid?</th>
              </tr>
            </thead>
            <tbody>
<?php 
include_once 'login/db.class.php';
include_once 'login/SteamAPI.class.php';
include_once 'login/JustGivingAPI.class.php';
$db = new DB();
$steamAPI = new SteamAPI();
$JGAPI = new JustGivingAPI();
foreach ($db->getChallengesMadeBy($_SESSION['steamID']) as $row) {
    echo '<tr>';
    echo '<td>' . $steamAPI->getGameName($row['appID']) . '</td>';
    echo '<td>' . $row['Achievement'] . '</td>';
    $toUser = $db->getUserDetails($row['toUser']);
    echo '<td>' . $toUser['name'] . '</td>';
    echo '<td>' . $row['amount'] . '</td>';
    if ($row['completed'] == 1) {
        echo '<td><a class="tick" href="javascript:void(0)"
                         title="Yes">
                      <i class="glyphicon glyphicon-ok"></i>
                  </a></td>';
    } else {
        echo '<td><a class="cross" href="javascript:void(0)"
                         title="No">
예제 #7
0
<?php

include_once 'JustGivingAPI.class.php';
$searchString = $_GET["typed"];
$jgAPI = new JustGivingAPI();
$charityNames = $jgAPI->searchCharities($searchString, 50);
echo json_encode($charityNames);