function publish($EventId = NULL) { if (!CheckPermissions('vip+pr')) { return; } if (is_numeric($EventId)) { $EventId = (int) $EventId; // Get the specific event $this->load->library('calendar_backend'); $this->load->library('calendar_source_yorker'); $source_yorker = new CalendarSourceYorker(0); $calendar_data = new CalendarData(); $source_yorker->FetchEvent($calendar_data, $EventId); $events = $calendar_data->GetEvents(); if (array_key_exists(0, $events)) { $event = $events[0]; if ($this->input->post('evpub_cancel')) { // REDIRECT $this->messages->AddMessage('information', 'Event publication was cancelled.'); $this->load->helper('uri_tail'); RedirectUriTail(3); } elseif ($this->input->post('evpub_confirm')) { // PUBLISH $result = $this->events_model->OccurrenceDraftPublish($EventId, FALSE); if ($result > 0) { $this->messages->AddMessage('success', $result . ' occurrences were altered'); } else { print_r($this->db->last_query()); exit; $this->messages->AddMessage('error', 'No occurrences were altered'); } $this->load->helper('uri_tail'); RedirectUriTail(3); } else { $data = array('Event' => $event); $this->main_frame->SetContentSimple('calendar/publish', $data); $this->main_frame->Load(); } } else { $this->messages->AddMessage('error', 'The event coud not be found'); $this->load->helper('uri_tail'); RedirectUriTail(3); } } else { show_404(); } }
function calendar($organisation, $DateRange = NULL, $Filter = NULL) { $this->load->model('subcontrollers/calendar_subcontroller'); if (!CheckPermissions('public')) { return; } // Set up the filter $data = $this->organisations->_GetOrgData($organisation); if (!empty($data)) { $this->_SetupOrganisationFrame($organisation); $this->main_frame->SetPage('calendar', 'directory'); $this->calendar_subcontroller->SetRangePageCode('directory_calendar'); // restrict to this organisation $this->calendar_subcontroller->UseStreams(array((int) $data['organisation']['id'] => array('subscribed' => isset($data['organisation']['subscription']) && $data['organisation']['subscription']['calendar'], 'name' => $data['organisation']['name'], 'short_name' => $organisation))); // disable cancelled events $sources =& $this->calendar_subcontroller->GetSources(); $sources->DisableGroup('inactive'); $args = func_get_args(); array_shift($args); $this->calendar_subcontroller->_map($args); } else { $this->load->library('custom_pages'); $this->main_frame->SetContent(new CustomPageView('directory_notfound', 'error')); $this->main_frame->Load(); } return; $this->pages_model->SetPageCode('directory_calendar'); $data = $this->organisations->_GetOrgData($organisation); if (!empty($data)) { $this->_SetupOrganisationFrame($organisation); $this->load->library('my_calendar'); $this->load->library('calendar_source_yorker'); $this->my_calendar->SetUrlPrefix('/directory/' . $organisation . '/calendar/'); //$this->My_calendar->SetAgenda(vip_url('calendar/agenda').'/'); $yorker_source = new CalendarSourceYorker(0); // Only those events of the organisation $yorker_source->DisableGroup('subscribed'); $yorker_source->DisableGroup('owned'); $yorker_source->DisableGroup('private'); $yorker_source->EnableGroup('active'); $yorker_source->DisableGroup('inactive'); $yorker_source->EnableGroup('hide'); $yorker_source->EnableGroup('show'); $yorker_source->EnableGroup('rsvp'); $yorker_source->IncludeStream((int) $data['organisation']['id'], TRUE); $now = new Academic_time(time()); $this->my_calendar->SetTabs(FALSE); $this->my_calendar->SetDefaultRange($now->AcademicYear() . '-' . $now->AcademicTermNameUnique()); $this->my_calendar->SetPath('edit', site_url('calendar/event')); $calendar_view = $this->my_calendar->GetMyCalendar($yorker_source, $DateRange, $Filter); if (FALSE) { $this->load->model('calendar/events_model'); $this->load->library('view_calendar_select_week'); $this->load->library('view_calendar_list'); $this->load->library('date_uri'); $use_default_range = FALSE; if (empty($DateRange)) { // $DateRange Empty $use_default_range = TRUE; } else { $uri_result = $this->date_uri->ReadUri($DateRange); if ($uri_result['valid']) { // valid $start_time = $uri_result['start']; $end_time = $uri_result['end']; $format = $uri_result['format']; $range_description = $uri_result['description']; } else { // invalid $this->main_frame->AddMessage('error', 'Unrecognised date range: "' . $DateRange . '"'); $use_default_range = TRUE; } } if ($use_default_range) { // Default to this week $start_time = Academic_time::NewToday(); $start_time = $start_time->BackToMonday(); $end_time = $start_time->Adjust('1week'); $format = 'ac'; //$range_description = 'from today for 1 week'; $range_description = 'this week'; } // Use the start time, end time, and format to set up views //$weeks_start = $start_time->Adjust('-2week')->BackToMonday(); $weeks_start = $this->academic_calendar->AcademicDayOfTerm($start_time->AcademicYear(), $start_time->AcademicTerm(), 1, 0, 0, 0); /*if ($weeks_start->Timestamp() < $monday->Timestamp()) { $weeks_start = $monday; }*/ /*$weeks_end = $end_time->Adjust('5week')->BackToMonday(); if ($weeks_end->Timestamp() < $monday->Timestamp()) { $weeks_end = $monday->Adjust('5week'); }*/ // Set up the week select view $week_select = new ViewCalendarSelectWeek(); $week_select->SetUriBase('directory/' . $organisation . '/calendar/'); $week_select->SetUriFormat($format); //$week_select->SetRange($weeks_start, $weeks_end); $week_select->SetAcademicTerm($weeks_start->AcademicYear(), $weeks_start->AcademicTerm()); $week_select->SetSelectedWeek($start_time, $end_time); $week_select->Retrieve(); $occurrence_filter = new EventOccurrenceFilter(); $occurrence_filter->EnableSource('all'); $occurrence_filter->SetSpecialCondition('organisations.organisation_directory_entry_name = ' . $this->db->escape($organisation)); // Set up the events list $events_list = new ViewCalendarList(); $events_list->SetUriBase('directory/' . $organisation . '/calendar/'); $events_list->SetUriFormat($format); $events_list->SetRange($start_time, $end_time); $events_list->SetOccurrenceFilter($occurrence_filter); $events_list->Retrieve(); // Set up the directory events view to contain the week select and // events list $directory_events = new FramesFrame('directory/directory_view_events', $data); $directory_events->SetContent($week_select, 'week_select'); $directory_events->SetContent($events_list, 'events_list'); $directory_events->SetData('date_range_description', $range_description); } // Set up the directory frame to use the messages frame $this->main_frame->SetPage('calendar', 'directory'); $this->frame_directory->SetOrganisation($data['organisation']); $this->frame_directory->SetContent($calendar_view); // Set up the public frame to use the directory frame $this->main_frame->SetTitleParameters(array('organisation' => $data['organisation']['name'])); $this->main_frame->SetContent($this->frame_directory); } else { $this->load->library('custom_pages'); $this->main_frame->SetContent(new CustomPageView('directory_notfound', 'error')); } // Load the public frame view $this->main_frame->Load(); }
function GetOrganisationScoresCalender($dir_entry_name) { //get calender head $calendar['head']['name'] = 'Calender'; //calender - events // Event statistics $this->CI->load->library('calendar_backend'); $this->CI->load->library('calendar_source_yorker'); $yorker_source = new CalendarSourceYorker(0); // Only those events of the organisation $yorker_source->DisableGroup('subscribed'); $yorker_source->DisableGroup('owned'); $yorker_source->DisableGroup('private'); $yorker_source->EnableGroup('active'); $yorker_source->DisableGroup('inactive'); $yorker_source->EnableGroup('show'); $yorker_source->EnableGroup('rsvp'); $yorker_source->IncludeStream((int) $this->CI->pr_model->GetOrganisationID($dir_entry_name), TRUE); //times for the next 2 weeks $last_monday = strtotime("last Monday"); $next_monday = strtotime("next Monday"); $week_monday = strtotime("+1 week", $next_monday); //set time to this week $yorker_source->SetRange($last_monday, $next_monday); $this_result = $yorker_source->MainQuery('COUNT(*)', $yorker_source->ProduceWhereClause()); //set time to this week $yorker_source->SetRange($next_monday, $week_monday); $next_result = $yorker_source->MainQuery('COUNT(*)', $yorker_source->ProduceWhereClause()); //$this->CI->messages->AddDumpMessage('this_result', $this_result); //$this->CI->messages->AddDumpMessage('next_result', $next_result); //result = $yorker_source->MainQuery( 'COUNT(event_occurrences.event_occurrence_id)', $yorker_source->ProduceWhereClause().' GROUP BY organisations.organisation_entity_id' ); $score_item['name'] = 'Events - This Week'; $score_item['link'] = '#'; $score_item['score_current'] = $this_result[0]['COUNT(*)']; $score_item['score_possible'] = 1; $calendar['body'][] = $score_item; $score_item['name'] = 'Events - Next Week'; $score_item['link'] = '#'; $score_item['score_current'] = $next_result[0]['COUNT(*)']; $score_item['score_possible'] = 1; $calendar['body'][] = $score_item; return $calendar; }