/** * @param array $data * @return ISummit */ public function createSummit(array $data) { $this_var = $this; $repository = $this->summit_repository; $factory = $this->summit_factory; return $this->tx_manager->transaction(function () use($this_var, $factory, $data, $repository) { $summit = new Summit(); $summit->registerMainInfo($factory->buildMainInfo($data)); if ($repository->isDuplicated($summit)) { throw new EntityAlreadyExistsException('Summit', sprintf('Name %s', $summit->getName())); } $repository->add($summit); return $summit; }); }
/** * Check for auth tokens * @return mixed */ public function init() { parent::init(); if (!Summit::get_active()->isInDB()) { return $this->httpError(404, 'There is no active summit'); } /** * On the existing tokenauthentication system, this is a fairly trivialmatter, and I'm not so sure it's anything to navigate right now. * Thiswas implemented to provide the video upload people a simple API foradding videos. It's a very specific use c * ase, and general users shouldnot be using it. If they can and they are, then that needs to bechanged. */ $result = $this->checkAuthenticationToken(); if (!$result && !Member::currentUser()) { //check if speaker registration token is present.. $speaker_registration_token = $this->request->getVar(SpeakerRegistrationRequest::ConfirmationTokenParamName); if (!is_null($speaker_registration_token)) { $request = $this->speaker_registration_request_repository->getByConfirmationToken($speaker_registration_token); if (is_null($request) || $request->alreadyConfirmed()) { return SummitSecurity::permission_failure($this); } // redirect to register member speaker $url = Controller::join_links(Director::baseURL(), 'summit-login', 'registration'); return $this->redirect($url . '?BackURL=' . urlencode($this->request->getURL()) . '&' . SpeakerRegistrationRequest::ConfirmationTokenParamName . '=' . $speaker_registration_token); } return SummitSecurity::permission_failure($this); } $speaker = Member::currentUser()->getSpeakerProfile(); if (!$speaker) { $speaker = PresentationSpeaker::create(array('MemberID' => Member::currentUserID(), 'FirstName' => Member::currentUser()->FirstName, 'LastName' => Member::currentUser()->Surname)); $speaker->write(); } }
public function getCMSFields() { $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : Summit::ActiveSummitID(); Requirements::javascript('summit/javascript/SummitPushNotification.js'); $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main'))); $f->addFieldToTab('Root.Main', $txt = new TextareaField('Message', 'Message')); $txt->setAttribute('required', 'true'); $f->addFieldToTab('Root.Main', $ddl_channel = new DropdownField('Channel', 'Channel', singleton('SummitPushNotification')->dbObject('Channel')->enumValues())); $f->addFieldToTab('Root.Main', $ddl_events = new DropdownField('EventID', 'Event', SummitEvent::get()->filter(['Published' => 1, 'SummitID' => $summit_id])->sort('Title', 'ASC')->Map('ID', 'FormattedTitle'))); $f->addFieldToTab('Root.Main', $ddl_groups = new DropdownField('GroupID', 'Group', Group::get()->sort('Title', 'ASC')->Map('ID', 'Title'))); $f->addFieldToTab('Root.Main', new HiddenField('SummitID', 'SummitID')); $ddl_channel->setEmptyString('--SELECT A CHANNEL--'); $ddl_channel->setAttribute('required', 'true'); $ddl_events->setEmptyString('--SELECT AN EVENT--'); $ddl_events->addExtraClass('hidden'); $ddl_groups->setEmptyString('--SELECT A GROUP--'); $ddl_groups->addExtraClass('hidden'); $config = GridFieldConfig_RelationEditor::create(50); $config->removeComponentsByType('GridFieldAddExistingAutocompleter'); $config->removeComponentsByType('GridFieldAddNewButton'); $config->addComponent($auto_completer = new CustomGridFieldAddExistingAutocompleter('buttons-before-right')); $auto_completer->setResultsFormat('$Title ($Email)'); $recipients = new GridField('Recipients', 'Member Recipients', $this->Recipients(), $config); $f->addFieldToTab('Root.Main', $recipients); return $f; }
/** * @param IPresentationSpeaker $speaker * @return PresentationSpeakerAcceptedAnnouncementEmailSender * @throws Exception */ public function build(IPresentationSpeaker $speaker) { $summit = Summit::get_active(); $has_approved = $speaker->hasApprovedPresentations($summit->ID); $has_rejected = $speaker->hasRejectedPresentations($summit->ID); $has_alternate = $speaker->hasAlternatePresentations($summit->ID); if ($has_approved && !$has_rejected && !$has_alternate) { return new PresentationSpeakerAcceptedAnnouncementEmailSender(); } if (!$has_approved && !$has_rejected && $has_alternate) { return new PresentationSpeakerAlternateAnnouncementEmailSender(); } if (!$has_approved && $has_rejected && !$has_alternate) { return new PresentationSpeakerRejectedAnnouncementEmailSender(); } if ($has_approved && !$has_rejected && $has_alternate) { return new PresentationSpeakerAcceptedAlternateAnnouncementEmailSender(); } if ($has_approved && $has_rejected && !$has_alternate) { return new PresentationSpeakerAcceptedRejectedAnnouncementEmailSender(); } if (!$has_approved && $has_rejected && $has_alternate) { return new PresentationSpeakerAlternateRejectedAnnouncementEmailSender(); } if ($has_approved && $has_rejected && $has_alternate) { return new PresentationSpeakerAcceptedAlternateAnnouncementEmailSender(); } return null; }
/** * @param SS_HTTPRequest $r */ public function presentations(SS_HTTPRequest $r) { $data = []; $speaker = null; $key = $r->getVar('key'); if ($key) { $username = PresentationSpeaker::hash_to_username($key); $speaker = PresentationSpeaker::get()->filter('Member.Email', $username)->first(); } elseif ($speakerID = Session::get('UploadMedia.SpeakerID')) { $speaker = PresentationSpeaker::get()->byID($speakerID); } // Speaker not found if (!$speaker) { return $this->httpError(404, 'Sorry, that does not appear to be a valid token.'); } Session::set('UploadMedia.SpeakerID', $speaker->ID); $mostRecentSummit = Summit::get_most_recent(); $presentations = $speaker->PublishedPresentations($mostRecentSummit->ID); // No presentations if (!$presentations->exists()) { return $this->httpError(404, 'Sorry, it does not appear that you have any presentations.'); } // IF there's only one presentation with no media, go ahead and forward to it's page if ($presentations->count() == 1) { $slide = $presentations->first()->MaterialType('PresentationSlide'); if (!$slide) { $presentationID = $presentations->first()->ID; return $this->redirect(Controller::join_links($this->Link(), '/presentation/', $presentationID, 'upload')); } } $data['Speaker'] = $speaker; $data['Presentations'] = $presentations; return $this->customise($data); }
/** * @param string $promo_code_type * @param int $batch_size * @return ISpeakerSummitRegistrationPromoCode */ public function getNextAvailableByType($promo_code_type, $batch_size = 10) { switch ($promo_code_type) { case ISpeakerSummitRegistrationPromoCode::TypeAccepted: if (count($this->promo_code_speaker_session_pool) === 0) { $query = new QueryObject(new SpeakerSummitRegistrationPromoCode()); $query->addAndCondition(QueryCriteria::equal('Type', $promo_code_type)); $query->addAndCondition(QueryCriteria::equal('OwnerID', 0)); $query->addAndCondition(QueryCriteria::equal('SpeakerID', 0)); $query->addAndCondition(QueryCriteria::equal('SummitID', Summit::get_active()->ID)); $query->addOrder(QueryOrder::asc('ID')); list($this->promo_code_speaker_session_pool, $count) = $this->getAll($query, 0, $batch_size); } return array_shift($this->promo_code_speaker_session_pool); break; case ISpeakerSummitRegistrationPromoCode::TypeAlternate: if (count($this->promo_code_alternate_speaker_session_pool) === 0) { $query = new QueryObject(new SpeakerSummitRegistrationPromoCode()); $query->addAndCondition(QueryCriteria::equal('Type', $promo_code_type)); $query->addAndCondition(QueryCriteria::equal('OwnerID', 0)); $query->addAndCondition(QueryCriteria::equal('SpeakerID', 0)); $query->addAndCondition(QueryCriteria::equal('SummitID', Summit::get_active()->ID)); $query->addOrder(QueryOrder::asc('ID')); list($this->promo_code_alternate_speaker_session_pool, $count) = $this->getAll($query, 0, $batch_size); } return array_shift($this->promo_code_alternate_speaker_session_pool); break; } return null; }
public function handleGetAllPresentations(SS_HTTPRequest $r) { $limit = $r->getVar('limit') ?: 50; if ($limit > 50) { $limit = 50; } $start = $r->getVar('page') ?: 0; $presentations = Member::currentUser() ? Member::currentUser()->getRandomisedPresentations() : Presentation::get()->filter(array('SummitEvent.SummitID' => Summit::get_active()->ID)); if ($r->getVar('category')) { $presentations = $presentations->filter('CategoryID', (int) $r->getVar('category')); } if ($r->getVar('keyword')) { $k = $r->getVar('keyword'); $presentations = $presentations->filterAny(array('Title:PartialMatch' => $k, 'Description:PartialMatch' => $k, 'Speakers.FirstName:PartialMatch' => $k, 'Speakers.LastName:PartialMatch' => $k)); } if ($r->getVar('voted') == "true") { $presentations = $presentations->leftJoin("PresentationVote", "PresentationVote.PresentationID = Presentation.ID")->where("IFNULL(PresentationVote.MemberID,0) = " . Member::currentUserID()); } if ($r->getVar('voted') == "false") { $presentations = $presentations->leftJoin("PresentationVote", "PresentationVote.PresentationID = Presentation.ID")->where("IFNULL(PresentationVote.MemberID,0) != " . Member::currentUserID()); } $count = $presentations->count(); $presentations = $presentations->limit($limit, $start * $limit); $data = array('results' => array(), 'has_more' => $count > $limit * ($start + 1), 'total' => $count, 'remaining' => $count - $limit * ($start + 1)); foreach ($presentations as $p) { $data['results'][] = array('id' => $p->ID, 'title' => $p->Title, 'user_vote' => $p->getUserVote() ? $p->getUserVote()->Vote : null); } return (new SS_HTTPResponse(Convert::array2json($data), 200))->addHeader('Content-Type', 'application/json'); }
/** * @return void */ public function run() { try { $batch_size = 100; $init_time = time(); $summit = null; if (isset($_GET['batch_size'])) { $batch_size = intval(trim(Convert::raw2sql($_GET['batch_size']))); echo sprintf('batch_size set to %s', $batch_size) . PHP_EOL; } if (isset($_GET['summit_id'])) { $summit = Summit::get()->byID(intval($_GET['summit_id'])); } if (is_null($summit)) { throw new Exception('summit_id is not valid!'); } $manager = Injector::inst()->get('SpeakerSecondBreakoutAnnouncementSenderManager'); if (!$manager instanceof ISpeakerSecondBreakoutAnnouncementSenderManager) { return; } $processed = $manager->send($summit, $batch_size); $finish_time = time() - $init_time; echo 'processed records ' . $processed . ' - time elapsed : ' . $finish_time . ' seconds.'; } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); } }
/** * @return void */ public function run() { try { $init_time = time(); $processed_events = 0; $events = array(); $current_summit = Summit::get_active(); if ($current_summit) { $events = $current_summit->getSchedule(); } foreach ($events as $event) { $processed_events++; $rate_sum = 0; $rate_count = 0; foreach ($event->Feedback as $feedback) { $rate_count++; $rate_sum = $rate_sum + $feedback->Rate; } $rate_avg = $rate_count > 0 ? $rate_sum / $rate_count : 0; try { $event->setAvgRate(round($rate_avg, 2)); $event->write(true); } catch (Exception $ex) { SS_Log::log($ex, SS_Log::ERR); echo $ex->getMessage(); } } $finish_time = time() - $init_time; echo 'processed events ' . $processed_events . ' - time elapsed : ' . $finish_time . ' seconds.'; } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); } }
protected function getPresentationFields() { $categorySource = Summit::ActiveSummit()->Categories()->map('ID', 'FormattedTitleAndDescription')->toArray(); $categorySource['other'] = '<h4 class="category-label">Other topic...</h4>'; $fields = FieldList::create()->text('Title', 'Proposed Presentation Title')->configure()->setAttribute('autofocus', 'TRUE')->end()->dropdown('Level', 'Please select the level of your presentation content')->configure()->setEmptyString('-- Select one --')->setSource(Presentation::create()->dbObject('Level')->enumValues())->end()->literal('AbstractHelp', '<hr/><p>YouTube and other services limit the length of your presentation\'s description. We will take the first 100 characters of your abstract to display in the YouTube description.</p>')->tinyMCEEditor('ShortDescription', 'Abstract (1000 chars)')->configure()->setRows(20)->setColumns(8)->setMaxCharLimit(1000)->setRequired(true)->end()->tinyMCEEditor('ProblemAddressed', 'What is the problem or use case you’re addressing in this session? (1000 chars)')->configure()->setRows(20)->setColumns(8)->setMaxCharLimit(1000)->setRequired(true)->end()->tinyMCEEditor('AttendeesExpectedLearnt', 'What should attendees expect to learn? (1000 chars)')->configure()->setRows(20)->setColumns(8)->setMaxCharLimit(1000)->setRequired(true)->end()->tinyMCEEditor('SelectionMotive', 'Why should this session be selected? (1000 chars)')->configure()->setRows(20)->setColumns(8)->setMaxCharLimit(1000)->setRequired(true)->end()->literal('PresentationMaterialsTitle', '<h3>Please provide any relevant links to additional information, such as code repositories, case studies, papers, blog posts etc. (Up to 5 links)</h3>')->text('PresentationLink[1]', '#1')->text('PresentationLink[2]', '#2')->text('PresentationLink[3]', '#3')->text('PresentationLink[4]', '#4')->text('PresentationLink[5]', '#5')->literal('HR', '<hr/>')->optionset('CategoryID', 'What is the general topic of the presentation?')->configure()->setSource($categorySource)->end()->text('OtherTopic', 'Other topic (if one above does not match)')->configure()->displayIf('CategoryID')->isEqualTo('other')->end()->end()->hidden('ID', 'ID'); return $fields; }
public function handleAddDefaultEventTypes($grid, $request, $data = null) { $summit_id = intval($request->param('ID')); if ($summit_id > 0 && ($summit = Summit::get()->byID($summit_id))) { Summit::seedBasicEventTypes($summit_id); } }
/** * @return ISummitAttendee|null */ public function getUpcomingSummitAttendee() { $upcoming_summit = Summit::ActiveSummit(); if ($upcoming_summit) { return $this->getSummitAttendee($upcoming_summit->ID); } return null; }
public function CurrentSummit() { $current_summit = Summit::CurrentSummit(); if (is_null($current_summit)) { $current_summit = $this->UpcomingSummit(); } return $current_summit; }
function up() { echo "Starting Migration Proc ...<BR>"; //check if migration already had ran ... $migration = Migration::get()->filter('Name', $this->title)->first(); $promo_code_type = isset($_REQUEST['promo_code_type']) ? intval($_REQUEST['promo_code_type']) : null; $promo_code_file = isset($_REQUEST['promo_code_file']) ? $_REQUEST['promo_code_file'] : null; if (is_null($promo_code_type)) { echo 'ERROR - promo_code_type param missing!'; exit; } if (is_null($promo_code_file)) { echo 'ERROR - promo_code_file param missing!'; exit; } $base_path = ASSETS_PATH; $file_path = $base_path . '/' . $promo_code_file; $type = explode(".", $file_path); if (!strtolower(end($type)) == 'csv') { echo 'ERROR - file hast not a csv extension!'; exit; } if (!file_exists($file_path)) { echo sprintf('ERROR - %s file does not exists!', $file_path); exit; } $reader = new CSVReader($file_path); $row = 0; do { $line = $reader->getLine(); if ($line) { ++$row; if ($row === 1) { continue; } // skip header ... switch ($promo_code_type) { case 1: $type = 'ACCEPTED'; break; case 2: $type = 'ALTERNATE'; break; } $code = new SpeakerSummitRegistrationPromoCode(); $code->Code = $line[0]; $code->Type = $type; $code->SummitID = Summit::get_active()->ID; try { $code->write(); } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); } } } while ($line); echo "Ending Migration Proc ...<BR>"; }
/** * @param $subject * @throws InvalidArgumentException * @return void */ public function send($subject) { $email_template = PermamailTemplate::get_by_identifier(SUMMIT_ATTENDEE_CREATE_MEMBERSHIP_INVITATION_EMAIL_TEMPLATE); if (is_null($email_template)) { return; } $email = EmailFactory::getInstance()->buildEmail(null, $subject); $email->setUserTemplate('summit-attendee-create-membership-invitation')->populateTemplate(array('Email' => $subject, 'Summit' => Summit::get_active()))->send(); }
protected function getPresentationFields() { $categorySource = Summit::get_active()->Categories()->map('ID', 'FormattedTitleAndDescription')->toArray(); $categorySource['other'] = '<h4 class="category-label">Other topic...</h4>'; $fields = FieldList::create()->text('Title', 'Proposed Presentation Title')->configure()->setAttribute('autofocus', 'TRUE')->end()->dropdown('Level', 'Please select the level of your presentation content')->configure()->setEmptyString('-- Select one --')->setSource(Presentation::create()->dbObject('Level')->enumValues())->end()->tinyMCEEditor('Description', 'Abstract')->configure()->setRows(20)->end()->literal('ShortDescriptionHelp', '<hr/><p>YouTube and other services limit the length of your presentation\'s description. Please provide a shorter, YouTube-friendly summary below.</p>')->literal('ShortDescriptionWordCount', '<p id="word-count"></p>')->tinyMCEEditor('ShortDescription', 'Short Description (450 Word Max)')->configure()->setRows(7)->setWordCount(450)->end()->literal('HR', '<hr/>')->optionset('CategoryID', 'What is the general topic of the presentation?')->configure()->setSource($categorySource)->end()->text('OtherTopic', 'Other topic (if one above does not match)')->configure()->displayIf('CategoryID')->isEqualTo('other')->end()->end()->literal('TagHelp', '<p>You can optionally add tags help attendees find presentations that interest them. Examples: <i>nova, ubuntu, ldap.</i></p>')->bootstrapTag('Tags', 'Presentation Tags (Optional)')->configure()->setLabelField('Tag')->setSource(Tag::get())->setPrefetch(Tag::get()->leftJoin('Presentation_Tags', 'TagID = Tag.ID')->sort('COUNT(Tag.ID)', 'DESC')->limit(10)->alterDataQuery(function ($query) { $query->groupby('Tag.ID'); }))->setFreeInput(true)->end(); return $fields; }
/** * @param IEntity $subject * @throws InvalidArgumentException * @return void */ public function send(IEntity $subject) { if (!$subject instanceof IPresentationSpeaker) { return; } $subject->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailAlternate); $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $subject->getEmail()); $email->setUserTemplate('presentation-speaker-alternate-only')->populateTemplate(array('Speaker' => $subject, 'ConfirmationLink' => $subject->getSpeakerConfirmationLink(), 'ScheduleMainPageLink' => Summit::get_active()->SchedUrl, 'PromoCode' => $subject->getSummitPromoCode()->getCode()))->send(); }
/** * @param mixed $subject * @throws InvalidArgumentException * @return void */ public function send($subject) { if (!$subject instanceof IPresentationSpeaker) { return; } $summit = Summit::get_active(); $subject->registerAnnouncementEmailTypeSent(IPresentationSpeaker::AnnouncementEmailRejected, $summit->ID); $email = EmailFactory::getInstance()->buildEmail('*****@*****.**', $subject->getEmail()); $email->setUserTemplate('presentation-speaker-rejected-only')->populateTemplate(array('Speaker' => $subject))->send(); }
function trackChairCheck() { $member = Member::currentUser(); $chair = new SummitTrackChair(); if ($member) { $chair = SummitTrackChair::get()->filter(array('MemberID' => $member->ID, 'SummitID' => Summit::get_active()->ID)); } if ($chair->exists() || Permission::check('ADMIN')) { return true; } }
/** * @param $subject * @throws InvalidArgumentException * @return void */ public function send($subject) { if (!$subject instanceof ISummitAttendee) { return; } $email_template = PermamailTemplate::get_by_identifier(SUMMIT_ATTENDEE_CREATED_EMAIL_TEMPLATE); if (is_null($email_template)) { return; } $email = EmailFactory::getInstance()->buildEmail(null, $subject->getMember()->getEmail()); $email->setUserTemplate('summit-attendee-created')->populateTemplate(array('Attendee' => $subject, 'Summit' => Summit::get_active()))->send(); }
function __construct($controller, $name, $speakerHash) { $activeSummit = Summit::get_active(); $PhoneField = new TextField('OnSitePhoneNumber', 'Your Onsite Phone Number for ' . $activeSummit->Title . ':'); $RegisteredField = new CheckboxField('RegisteredForSummit', 'I have registered for the summit using the confirmation code sent in the email.'); // Speaker Hash Field $SpeakerHashField = new HiddenField('speakerHash', "speakerHash", $speakerHash); $fields = new FieldList($PhoneField, $RegisteredField, $SpeakerHashField); $submitButton = new FormAction('doSavePhoneNumber', 'Save'); $actions = new FieldList($submitButton); $validator = new RequiredFields('OnSitePhoneNumber'); parent::__construct($controller, $name, $fields, $actions, $validator); }
/** * */ public function run() { SapphireTransactionManager::getInstance()->transaction(function () { $unprocessedVideos = PresentationVideo::get()->filter(['Processed' => false])->limit(50); if (!$unprocessedVideos->exists()) { return; } $summit = Summit::get_active(); $dateUTC = $summit->convertDateFromTimeZone2UTC(SS_DateTime::now()->Rfc2822()); $dateUTCTimestamp = strtotime($dateUTC); $maxAge = SummitVideoApp::config()->abandon_unprocessed_videos_after; $ids = []; foreach ($unprocessedVideos as $video) { $age = $dateUTCTimestamp - strtotime($video->DateUploaded); if ($age > $maxAge) { SS_Log::log("Video {$video->Title} has been unprocessed for a long time. ({$age} seconds). It should be deleted.", SS_Log::WARN); continue; } $ids[] = $video->YouTubeID; } try { $response = $this->api->getVideoStatusById($ids); } catch (\Exception $e) { SS_Log::log("YouTube check for status failed" . $e->getMessage(), SS_Log::ERR); return; } $body = $response->getBody()->getContents(); $data = Convert::json2array($body); $items = $data['items']; if (empty($items)) { echo "No videos are marked as processing. Exiting.\n"; return; } foreach ($items as $item) { $currentStatus = $item['status']['uploadStatus']; if ($currentStatus == 'processed') { $video = PresentationVideo::get()->filter(['YouTubeID' => $item['id']])->first(); if (!$video) { SS_Log::log("Tried to update processing status for " . $item['id'] . " but no PresentationVideo with that YouTubeID was found.", SS_Log::WARN); continue; } $video->Processed = true; $video->write(); $this->videosUpdated++; } } echo "{$this->videosUpdated} videos updated.\n"; }); }
public function handleDeleteAllSummitEntityEventsAction($gridField, $request) { $summit_id = intval($request->param("ID")); $controller = $gridField->getForm()->Controller(); $this->gridField = $gridField; $summit = Summit::get()->byID($summit_id); $status = 404; if (!is_null($summit)) { $status = 200; DB::query("DELETE FROM SummitEntityEvent WHERE SummitID = {$summit_id} ;"); } $response = new SS_HTTPResponse(); $response->setStatusCode($status); return $response; }
/** * Implement this method in the task subclass to * execute via the TaskRunner */ public function run($request) { set_time_limit(0); $summit_id = intval($request->getVar('summit_id')); if (empty($summit_id)) { throw new InvalidArgumentException('missing summit_id param!'); } $summit_external_id = intval($request->getVar('summit_external_id')); if (empty($summit_external_id)) { throw new InvalidArgumentException('missing summit_external_id param!'); } // get ticket types ... $summit = Summit::get()->byID($summit_id); if (is_null($summit)) { throw new InvalidArgumentException("non existent summit!"); } $summit->ExternalEventId = $summit_external_id; $summit->write(); Summit::seedBasicEventTypes($summit_id); Summit::seedSummitTypes($summit_id); $client = new GuzzleHttp\Client(); $query = array('token' => EVENTBRITE_PERSONAL_OAUTH2_TOKEN); $response = $client->get(sprintf("https://www.eventbriteapi.com/v3/events/%s/ticket_classes/", $summit_external_id), array('query' => $query)); if ($response->getStatusCode() !== 200) { throw new Exception('invalid status code!'); } $content_type = $response->getHeader('content-type'); if (empty($content_type)) { throw new Exception('invalid content type!'); } if ($content_type !== 'application/json') { throw new Exception('invalid content type!'); } $json = $response->getBody()->getContents(); $ticket_types = json_decode($json, true); $ticket_types = $ticket_types['ticket_classes']; foreach ($ticket_types as $t) { $new_ticket = new SummitTicketType(); $new_ticket->ExternalId = $t["id"]; if (SummitTicketType::get()->filter(array('SummitID' => $summit_id, 'ExternalId' => $new_ticket->ExternalId))->count() > 0) { continue; } $new_ticket->Name = $t["name"]; $new_ticket->Description = $t["description"]; $new_ticket->SummitID = $summit_id; $new_ticket->write(); } }
function getCMSFields() { $fields = parent::getCMSFields(); $summits = Summit::get(); $SummitDropDownField = new DropdownField("SummitID", "Summit", $summits->map("ID", "Name")); $fields->addFieldToTab('Root.Main', $SummitDropDownField); //google analitycs tracking params $fields->addFieldToTab("Root.GoogleAnalitycs", new TextField("GAConversionId", "Conversion Id", "994798451")); $fields->addFieldToTab("Root.GoogleAnalitycs", new TextField("GAConversionLanguage", "Conversion Language", "en")); $fields->addFieldToTab("Root.GoogleAnalitycs", new TextField("GAConversionFormat", "Conversion Format", "3")); $fields->addFieldToTab("Root.GoogleAnalitycs", new ColorField("GAConversionColor", "Conversion Color", "ffffff")); $fields->addFieldToTab("Root.GoogleAnalitycs", new TextField("GAConversionLabel", "Conversion Label", "IuM5CK3OzQYQ89at2gM")); $fields->addFieldToTab("Root.GoogleAnalitycs", new TextField("GAConversionValue", "Conversion Value", "0")); $fields->addFieldToTab("Root.GoogleAnalitycs", new CheckboxField("GARemarketingOnly", "Remarketing Only")); return $fields; }
/** * @return string[] */ public function toSQL() { $primary_id = $this->primary_id; $dupe_id = $this->dupe_id; $primary = Member::get()->byID($primary_id); $dupe = Member::get()->byID($dupe_id); $queries = array(); $summits = Summit::get(); foreach ($summits as $summit) { if ($dupe->isAttendee($summit->ID) && !$primary->isAttendee($summit->ID)) { // move array_push($queries, "UPDATE SummitAttendee SET MemberID = {$primary_id} WHERE MemberID = {$dupe_id} AND SummitID = {$summit->ID};"); } } return $queries; }
public function getCMSFields() { $f = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Main'))); $f->addFieldToTab('Root.Main', new HiddenField('OwnerID', 'OwnerID')); $f->addFieldsToTab('Root.Main', new TextField('ExternalOrderId', '#Order')); $f->addFieldsToTab('Root.Main', new TextField('ExternalAttendeeId', '#Attendee')); $f->addFieldsToTab('Root.Main', $date = new DatetimeField('TicketBoughtDate', 'Bought Date')); $date->getDateField()->setConfig('showcalendar', true); $f->addFieldsToTab('Root.Main', $date = new DatetimeField('TicketChangedDate', 'Changed Date')); $date->getDateField()->setConfig('showcalendar', true); $summit_id = $_REQUEST['SummitID']; if (empty($summit_id)) { $summit_id = $this->Owner()->exists() ? $this->Owner()->SummitID : Summit::get_active()->ID; } $f->addFieldsToTab('Root.Main', $ddl = new DropdownField('TicketTypeID', 'Ticket Type', SummitTicketType::get()->filter('SummitID', $summit_id)->map("ID", "Name"))); return $f; }
protected function validate() { $valid = parent::validate(); if (!$valid->valid()) { return $valid; } $summit_id = isset($_REQUEST['SummitID']) ? $_REQUEST['SummitID'] : $this->SummitID; $summit = Summit::get()->byID($summit_id); if (!$summit) { return $valid->error('Invalid Summit!'); } $count = intval(SummitTicketType::get()->filter(array('SummitID' => $summit->ID, 'Name' => trim($this->Name), 'ID:ExactMatch:not' => $this->ID))->count()); if ($count > 0) { return $valid->error(sprintf('Summit Ticket Type "%s" already exists!. please set another one', $this->Name)); } return $valid; }
/** * @return void */ public function run() { try { $init_time = time(); $summit_id = Summit::ActiveSummitID(); if (isset($_GET['summit_id'])) { $summit_id = intval(trim(Convert::raw2sql($_GET['summit_id']))); echo sprintf('summit_id set to %s', $summit_id) . PHP_EOL; } $manager = Injector::inst()->get('SummitVenueRoomMetricsManager'); $manager->ingest($summit_id); $finish_time = time() - $init_time; echo 'time elapsed : ' . $finish_time . ' seconds.' . PHP_EOL; } catch (Exception $ex) { SS_Log::log($ex->getMessage(), SS_Log::ERR); } }
public function ExportNoticeEmails() { $speakers = Summit::get_active()->Speakers(); $filepath = $_SERVER['DOCUMENT_ROOT'] . '/assets/speaker-notifications.csv'; $fp = fopen($filepath, 'w'); $fields = array('First_Name', 'Last_Name', 'Speaker_ID', 'Member_ID', 'Email', 'Presentation_List'); fputcsv($fp, $fields); foreach ($speakers as $speaker) { $this->AssembleEmail($speaker, $fp); } fclose($fp); header("Cache-control: private"); header("Content-type: application/force-download"); header("Content-transfer-encoding: binary\n"); header("Content-disposition: attachment; filename=\"speaker-notifications.csv\""); header("Content-Length: " . filesize($filepath)); readfile($filepath); }