Example #1
0
 static function createEvent($eventType, $team, $station, $points, $data = "")
 {
     if (is_array($data)) {
         $data = json_encode($data);
     }
     // if data is an array assume its json and convert it to text
     $o = new Event();
     $o->set('eventType', $eventType);
     $o->set('teamId', $team->get('OID'));
     $o->set('stationId', $station->get('OID'));
     $o->set('points', $points);
     $o->set('data', $data);
     return $o->create();
 }
Example #2
0
function sendMailForNewEvent()
{
    $reponse['statut'] = 'ok';
    $idEvent = $_REQUEST['idEvent'];
    $arch = new Archiviste();
    $event = new Event();
    $event->set('id', $idEvent);
    $events = $arch->restituer($event);
    $nom = $events[0]->get('nom');
    $time = $events[0]->get('date');
    mailCreation($nom, $time, $idEvent);
    return $reponse;
}
Example #3
0
 public function getDealDetails(&$deal)
 {
     $closed_stages = DealHelper::getClosedStages();
     $deal->closed = in_array($deal->stage_id, $closed_stages) ? TRUE : FALSE;
     $deal_id = $deal->id;
     /** ------------------------------------------
      *  Join contacts
      */
     $peopleModel = new People();
     $peopleModel->set('deal_id', $deal_id);
     $people = $peopleModel->getContacts();
     //assign results to company
     $deal->people = $people;
     /** ------------------------------------------
      *  Join conversations
      */
     $convoModel = new Conversation();
     $convoModel->set('deal_id', $deal_id);
     $conversations = $convoModel->getConversations();
     $deal->conversations = $conversations;
     /** ------------------------------------------
      *  Join notes
      */
     $notesModel = new Note();
     $deal->notes = $notesModel->getNotes($deal_id, 'deal');
     /** ------------------------------------------
      *  Join documents
      */
     $docModel = new Document();
     $docModel->set('deal_id', $deal_id);
     $deal->documents = $docModel->getDocuments();
     /** ------------------------------------------
      *  Join tasks & events
      */
     $eventModel = new Event();
     $eventModel->set('deal_id', $deal_id);
     $events = $eventModel->getEvents();
     $deal->events = $events;
 }
Example #4
0
function changerEtatinscrit(&$vueAgenda, $estModerateur, $idUser)
{
    $idEvent = false;
    $idInscrit = false;
    if (isset($_GET['id'])) {
        $idEvent = $_GET['id'];
    }
    if (isset($_GET['idInscrit'])) {
        $idInscrit = $_GET['idInscrit'];
    }
    if ($idEvent !== false && $idInscrit !== false) {
        $arch = new Archiviste();
        $event = new Event();
        $event->set('id', $idEvent);
        $events = $arch->restituer($event);
        if (count($events) == 1) {
            $event = $events[0];
            if ($estModerateur || $idUser == $event->get('idUser')) {
                $inscription = new EventInscrit();
                $inscription->set('idUser', $idInscrit);
                $inscription->set('idEvent', $idEvent);
                $inscritsTrouves = $arch->restituer($inscription);
                if (count($inscritsTrouves) == 1) {
                    $inscrit = $inscritsTrouves[0];
                    $inscriptionModif = new EventInscrit();
                    if ($inscrit->get('etat') == 'd') {
                        $inscriptionModif->set('etat', 'v');
                    } else {
                        if ($inscrit->get('etat') == 'v') {
                            $inscriptionModif->set('etat', 'r');
                        } else {
                            if ($inscrit->get('etat') == 'r') {
                                $inscriptionModif->set('etat', 'd');
                            }
                        }
                    }
                    $arch->modifier($inscription, $inscriptionModif);
                    voirEvent($vueAgenda, $estModerateur, $idUser);
                }
            }
        }
    }
}
Example #5
0
 /**
  * Refresh a Specific Group Calendar
  *
  * @param  bool  $force  Force refresh calendar?
  */
 public function refresh($force = false)
 {
     // only refresh subscriptions
     if (!$this->isSubscription()) {
         $this->setError($this->get('title'));
         return false;
     }
     // get refresh interval
     $interval = \Plugin::params('calendar', 'groups')->get('import_subscription_interval', 60);
     // get datetimes needed to refresh
     $now = Date::of('now');
     $lastRefreshed = Date::of($this->get('last_fetched_attempt'));
     $refreshInterval = new DateInterval("PT{$interval}M");
     // add refresh interval to last refreshed
     $lastRefreshed->add($refreshInterval);
     // if we havent passed our need to refresh date stop
     if ($now < $lastRefreshed && !$force) {
         return false;
     }
     // get current events
     $currentEvents = $this->events('list', array('scope' => $this->get('scope'), 'scope_id' => $this->get('scope_id'), 'calendar_id' => $this->get('id'), 'state' => array(1)));
     //build calendar url
     $calendarUrl = str_replace('webcal', 'http', $this->get('url'));
     //test to see if this calendar is valid
     $calendarHeaders = get_headers($calendarUrl, 1);
     $statusCode = isset($calendarHeaders[0]) ? $calendarHeaders[0] : '';
     // if we got a 301, lets update the location
     if (stristr($statusCode, '301 Moved Permanently')) {
         if (isset($calendarHeaders['Location'])) {
             $this->set('url', $calendarHeaders['Location']);
             $this->store(true);
             $this->refresh();
         }
     }
     //make sure the calendar url is valid
     if (!strstr($statusCode, '200 OK')) {
         $this->set('failed_attempts', $this->failed_attempts + 1);
         $this->set('last_fetched_attempt', Date::toSql());
         $this->store(true);
         $this->setError($this->get('title'));
         return false;
     }
     //read calendar file
     $icalparser = new \icalparser($calendarUrl);
     $incomingEvents = $icalparser->getEvents();
     // check to make sure we have events
     if (count($incomingEvents) < 1) {
         $this->setError($this->get('title'));
         return false;
     }
     //make uid keys for array
     //makes it easier to diff later on
     foreach ($incomingEvents as $k => $incomingEvent) {
         //get old and new key
         $oldKey = $k;
         $newKey = isset($incomingEvent['UID']) ? $incomingEvent['UID'] : '';
         //set keys to be the uid
         if ($newKey != '') {
             $incomingEvents[$newKey] = $incomingEvent;
             unset($incomingEvents[$oldKey]);
         }
     }
     //get events we need to delete
     $eventsToDelete = array_diff($currentEvents->lists('ical_uid'), array_keys($incomingEvents));
     //delete each event we dont have in the incoming events
     foreach ($eventsToDelete as $eventDelete) {
         $e = $currentEvents->fetch('ical_uid', $eventDelete);
         $e->delete();
     }
     //create new events for each event we pull
     foreach ($incomingEvents as $uid => $incomingEvent) {
         // fetch event from our current events by uid
         $event = $currentEvents->fetch('ical_uid', $uid);
         // create blank event if we dont have one
         if (!$event) {
             $event = new Event();
         }
         // set the timezone
         $tz = new DateTimezone(Config::get('offset'));
         // start already datetime objects
         $start = $incomingEvent['DTSTART'];
         $start->setTimezone($tz);
         // set publish up/down
         $publish_up = $start->toSql();
         $publish_down = '0000-00-00 00:00:00';
         $allday = isset($incomingEvent['ALLDAY']) && $incomingEvent['ALLDAY'] == 1 ? 1 : 0;
         $rrule = null;
         // handle end
         if (isset($incomingEvent['DTEND'])) {
             $end = $incomingEvent['DTEND'];
             $end->setTimezone($tz);
             $publish_down = $end->toSql();
         }
         // handle rrule
         if (isset($incomingEvent['RRULE'])) {
             // add frequency
             $rrule = 'FREQ=' . $incomingEvent['RRULE']['FREQ'];
             // add interval
             if (!isset($incomingEvent['RRULE']['INTERVAL'])) {
                 $incomingEvent['RRULE']['INTERVAL'] = 1;
             }
             $rrule .= ';INTERVAL=' . $incomingEvent['RRULE']['INTERVAL'];
             // count
             if (isset($incomingEvent['RRULE']['COUNT'])) {
                 $rrule .= ';COUNT=' . $incomingEvent['RRULE']['COUNT'];
             }
             // until
             if (isset($incomingEvent['RRULE']['UNTIL'])) {
                 if (strlen($incomingEvent['RRULE']['UNTIL']) == 8) {
                     $incomingEvent['RRULE']['UNTIL'] .= 'T000000Z';
                 }
                 $until = Date::of($incomingEvent['RRULE']['UNTIL']);
                 $rrule .= ';UNTIL=' . $until->format('Ymd\\THis\\Z');
             }
             //by day
             if (isset($incomingEvent['RRULE']['BYDAY'])) {
                 $rrule .= ';BYDAY=' . $incomingEvent['RRULE']['BYDAY'];
             }
         }
         // handle all day events
         if ($start->add(new DateInterval('P1D')) == $end) {
             $publish_down = '0000-00-00 00:00:00';
         }
         // set event details
         $event->set('title', isset($incomingEvent['SUMMARY']) ? $incomingEvent['SUMMARY'] : '');
         $event->set('content', isset($incomingEvent['DESCRIPTION']) ? $incomingEvent['DESCRIPTION'] : '');
         $event->set('content', stripslashes(str_replace('\\n', "\n", $event->get('content'))));
         $event->set('adresse_info', isset($incomingEvent['LOCATION']) ? $incomingEvent['LOCATION'] : '');
         $event->set('extra_info', isset($incomingEvent['URL']) ? $incomingEvent['URL'] : '');
         $event->set('modified', Date::toSql());
         $event->set('modified_by', User::get('id'));
         $event->set('publish_up', $publish_up);
         $event->set('publish_down', $publish_down);
         $event->set('allday', $allday);
         $event->set('repeating_rule', $rrule);
         // new event
         if (!$event->get('id')) {
             $event->set('catid', -1);
             $event->set('calendar_id', $this->get('id'));
             $event->set('ical_uid', isset($incomingEvent['UID']) ? $incomingEvent['UID'] : '');
             $event->set('scope', $this->get('scope'));
             $event->set('scope_id', $this->get('scope_id'));
             $event->set('state', 1);
             $event->set('created', Date::toSql());
             $event->set('created_by', User::get('id'));
             $event->set('time_zone', -5);
             $event->set('registerby', '0000-00-00 00:00:00');
             $event->set('params', '');
         }
         // save event
         $event->store(true);
     }
     // mark as fetched
     // clear failed attempts
     $this->set('last_fetched', Date::toSql());
     $this->set('last_fetched_attempt', Date::toSql());
     $this->set('failed_attempts', 0);
     $this->store(true);
     return true;
 }
Example #6
0
<?php

spl_autoload_register(function ($class_name) {
    include "../inc/" . $class_name . '.php';
});
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : PinnacleClient::SOCCER_ID;
$fixture = new Fixture($id);
$pinnacle_client = new PinnacleClient();
$json = $pinnacle_client->query("https://api.pinnaclesports.com/v1/fixtures?sportid=" . $id . "&since=" . $fixture->get('last'));
$fixture->set('last', $json->last);
foreach ($json->league as $l) {
    $league = new League($l->id);
    $league->set('sportId', $id);
    foreach ($l->events as $e) {
        $event = new Event($e->id);
        $event->set('leagueId', $l->id);
        $event->set('starts', $e->starts);
        $event->set('home', $e->home);
        $event->set('away', $e->away);
        $event->set('rotNum', $e->rotNum);
        if (isset($e->homePitcher)) {
            $event->set('homePitcher', $e->homePitcher);
        }
        if (isset($e->awayPitcher)) {
            $event->set('awayPitcher', $e->awayPitcher);
        }
    }
}
Example #7
0
 public function testParseEvent()
 {
     $eventTag = new Event();
     $eventTag->set("Some Ordinary Event");
     $unparsedTag = '[Event "Some Ordinary Event"]';
     $errors = null;
     $parsed = Tag::parse($unparsedTag, $errors);
     echo "errors: ";
     var_dump($errors);
     $this->assertInstanceof('pgn\\tags\\Event', $parsed);
     $this->assertSame($eventTag->get(), $parsed->get());
     $this->assertNotNull($errors);
     $this->assertEquals(0, count($errors));
 }