Beispiel #1
0
 public function onRaidCreate($aRaidId)
 {
     if ($this->authenticate()) {
         // Query the given raid, make sure we include canceled and closed
         // raids
         $Parameters = array('raid' => $aRaidId, 'canceled' => true, 'closed' => true);
         $RaidResult = Api::queryRaid($Parameters);
         if (count($RaidResult) > 0) {
             // As we specified a specific raid id, we are only
             // interested in the first (and only) raid.
             // Cache and set UTC timezone just to be sure.
             $Raid = $RaidResult[0];
             $LocationName = $this->mLocations[$Raid['LocationId']];
             $Url = getBaseURL() . 'index.php#raid,' . $aRaidId;
             $Timezone = date_default_timezone_get();
             try {
                 date_default_timezone_set('UTC');
                 $Start = new Google_Service_Calendar_EventDateTime();
                 $Start->setDateTime(date($this->mDateFormat, intval($Raid['Start'])));
                 $Start->setTimeZone('UTC');
                 $End = new Google_Service_Calendar_EventDateTime();
                 $End->setDateTime(date($this->mDateFormat, intval($Raid['End'])));
                 $End->setTimeZone('UTC');
                 $Properties = new Google_Service_Calendar_EventExtendedProperties();
                 $Properties->setShared(array('RaidId' => $aRaidId));
                 $Source = new Google_Service_Calendar_EventSource();
                 $Source->setTitle('Raidplaner link');
                 $Source->setUrl($Url);
                 $Event = new Google_Service_Calendar_Event();
                 $Event->setSummary($LocationName . ' (' . $Raid['Size'] . ')');
                 $Event->setLocation($LocationName);
                 $Event->setDescription($Raid['Description']);
                 $Event->setOriginalStartTime($Start);
                 $Event->setStart($Start);
                 $Event->setEnd($End);
                 $Event->setExtendedProperties($Properties);
                 $Event->setSource($Source);
                 $this->mCalService->events->insert(GOOGLE_CAL_ID, $Event);
             } catch (Exception $Ex) {
                 $Out = Out::getInstance();
                 $Out->pushError($Ex->getMessage());
             }
             date_default_timezone_set($Timezone);
         }
     }
 }