function delete($SourceId = NULL, $EventId = NULL)
 {
     if (is_numeric($SourceId)) {
         if (FALSE !== $this->input->post('caldel_confirm')) {
             // User has confirmed deletion
             static $mapping = array('accept' => TRUE, 'decline' => FALSE, 'maybe' => NULL);
             // Now determine what protocol to use
             $this->load->library('calendar_backend');
             $this->load->library('calendar_source_my_calendar');
             $my_calendar = new CalendarSourceMyCalendar();
             $messages = $my_calendar->DeleteEvent((int) $SourceId, $EventId);
             if (!array_key_exists('error', $messages)) {
                 $this->messages->AddMessage('success', 'The event was successfully deleted.');
             }
             $this->messages->AddMessages($messages);
             // shift 2 arguments and redirect
             $args = array_shift(array_shift(func_get_args()));
             redirect(implode('/', $args));
         } else {
             // User has not yet confirmed deleting
             $data = array('Event' => NULL, 'Occurrences' => array());
             $this->main_frame->SetContentSimple('calendar/event_delete', $data);
             $this->main_frame->Load();
         }
     } else {
         return show_404();
     }
 }
Пример #2
0
 /**
  * @return array(Todays events view, Todo view).
  */
 private function _GetMiniCalendars()
 {
     $this->load->library('academic_calendar');
     $this->load->library('calendar_backend');
     $this->load->library('calendar_source_my_calendar');
     $this->load->library('calendar_frontend');
     $this->load->library('calendar_view_upcoming');
     $this->load->library('calendar_view_todo_list');
     $now = new Academic_time(time());
     $start = $now;
     $end = $now->Midnight()->Adjust('+2day');
     $sources = new CalendarSourceMyCalendar();
     // lets be explicit just in case:
     $sources->EnableGroup('owned');
     $sources->EnableGroup('subscribed');
     $sources->EnableGroup('private');
     $sources->EnableGroup('active');
     $sources->DisableGroup('inactive');
     $sources->SetRange($start->Timestamp(), $end->Timestamp());
     $sources->SetTodoRange(time(), time());
     $calendar_data = new CalendarData();
     $this->messages->AddMessages($calendar_data->FetchEventsFromSources($sources));
     // Display data
     $this->load->library('calendar_view_days');
     $EventsView = new CalendarViewUpcoming();
     $EventsView->SetMiniMode();
     $EventsView->SetCalendarData($calendar_data);
     //$EventsView->SetStartEnd($start->Timestamp(), $end->Timestamp());
     $TodoView = NULL;
     // 		$TodoView = new CalendarViewTodoList();
     // 		$TodoView->SetCalendarData($calendar_data);
     return array($EventsView, $TodoView);
 }
 function GetEvent($SourceId = NULL, $EventId = NULL, $OccurrenceId = NULL)
 {
     if (is_numeric($SourceId)) {
         $SourceId = (int) $SourceId;
         $CI =& get_instance();
         // Get the specific event
         $CI->load->helper('uri_tail');
         $CI->load->library('calendar_backend');
         $CI->load->library('calendar_source_my_calendar');
         $sources = new CalendarSourceMyCalendar();
         $calendar_data = new CalendarData();
         $sources->FetchEvent($calendar_data, $SourceId, $EventId);
         $events = $calendar_data->GetEvents();
         if (array_key_exists(0, $events)) {
             $event = $events[0];
             // Find the occurrence
             $found_occurrence = NULL;
             foreach ($event->Occurrences as $key => $occurrence) {
                 if ($occurrence->SourceOccurrenceId == $OccurrenceId) {
                     $found_occurrence =& $event->Occurrences[$key];
                     break;
                 }
             }
             if (NULL === $found_occurrence) {
                 return show_404();
             }
             if ($CI->input->post('evview_return')) {
                 // REDIRECT
                 $CI->load->helper('uri_tail');
                 RedirectUriTail(5);
             } else {
                 $data = array('Event' => &$event, 'Occurrence' => &$found_occurrence, 'ReadOnly' => $this->mReadOnly, 'Attendees' => $sources->GetOccurrenceAttendanceList($SourceId, $OccurrenceId), 'FailRedirect' => '/' . GetUriTail(5), 'Path' => $this->mPaths);
                 $CI->main_frame->SetTitleParameters(array('event' => $event->Name));
                 $this->SetupTabs('', $found_occurrence->StartTime);
                 return new FramesView('calendar/event', $data);
             }
         } else {
             $CI->messages->AddMessage('error', 'The event coud not be found');
             RedirectUriTail(5);
         }
     } else {
         show_404();
     }
 }
Пример #4
0
 function eventsearch($search = '')
 {
     if (!CheckPermissions('public')) {
         return;
     }
     if (array_key_exists('search', $_GET)) {
         redirect('test/james/eventsearch/' . urlencode($_GET['search']));
     }
     // Load the libraries
     $this->load->library('calendar_backend');
     $this->load->library('calendar_source_my_calendar');
     $this->load->library('facebook');
     $data = array('target' => $this->uri->uri_string(), 'search' => $search);
     if (!empty($search)) {
         $source = new CalendarSourceMyCalendar();
         // Use the search phrase
         $source->SetSearchPhrase($search);
         // Set the groups to get events from
         /*
         	groups:
         	'owned'      => TRUE,
         	'subscribed' => TRUE,
         	'all'        => FALSE,
         	
         	'private'    => TRUE,
         	'active'     => TRUE,
         	'inactive'   => TRUE,
         	
         	'hide'       => FALSE,
         	'show'       => TRUE,
         	'rsvp'       => TRUE,
         	
         	'event'      => TRUE,
         	'todo'       => FALSE,
         */
         $source->EnableGroup('all');
         $source->DisableGroup('subscribed');
         // (subset of all)
         $source->DisableGroup('owned');
         // (subset of all)
         $source->EnableGroup('hide');
         // Show events hidden by user
         $source->EnableGroup('todo');
         // Enable todo items
         // Set the date range if applicable
         //$source->SetRange(strtotime('-1month'), NULL))
         //$source->SetTodoRange(strtotime('-1month'), NULL))
         // Get the actual events from the sources
         $calendar_data = new CalendarData();
         $source->FetchEvents($calendar_data);
         // Do whatever with the data
         // $calendar_data->GetEvents() are the events
         // theres a couple of others for occurrences + organisations
         $data['results'] = $calendar_data->GetEvents();
     }
     $this->main_frame->SetContentSimple('test/james-eventsearch', $data);
     $this->main_frame->Load();
 }
    /**
     * @brief Do a small search, reply with max 16 results
     * @param $string string Search string entered.
     */
    function ajax($string)
    {
        $result = array();
        $sql = <<<QUERY
\t\tSELECT articles.article_id AS id,
\t\t\tarticle_content_heading AS title
\t\t\tUNIX_TIMESTAMP(articles.article_publish_date) AS date,
\t\t\tcontent_types.content_type_codename AS type_codename,
\t\t\tparent_type.content_type_codename AS parent_codename,
\t\t\tIF (content_types.content_type_parent_content_type_id IS NOT NULL,
\t\t\t\tparent_type.content_type_name,
\t\t\t\tcontent_types.content_type_name) AS category,
\t\t\tMATCH(article_content_heading, article_content_subheading, article_contents.article_content_blurb,article_content_wikitext_cache)
\t\t\t\tAGAINST(?) as score
\t\tFROM articles, article_contents, content_types
\t\tLEFT JOIN content_types AS parent_type
\t\t\tON content_types.content_type_parent_content_type_id = parent_type.content_type_id
\t\tWHERE
\t\t\tarticles.article_content_type_id = content_types.content_type_id
\t\t\tAND articles.article_pulled = 0 AND articles.article_publish_date < CURRENT_TIMESTAMP()
\t\t\tAND articles.article_deleted = 0 AND articles.article_live_content_id IS NOT NULL
\t\t\tAND articles.article_live_content_id = article_contents.article_content_id
\t\t\tAND articles.article_id = article_contents.article_content_article_id
\t\t\tAND content_types.content_type_archive = 1
\t\t\tAND MATCH(article_content_heading, article_content_subheading, article_contents.article_content_blurb,article_content_wikitext_cache)
\t\tAGAINST(?)
\t\tAND (category = 'uninews'
\t\t\tOR category = 'features'
\t\t\tOR category = 'lifestyle'
\t\t\tOR category = 'food'
\t\t\tOR category = 'drink'
\t\t\tOR category = 'arts'
\t\t\tOR category = 'sport'
\t\t\tOR category = 'blogs'
\t\tORDER BY score DESC LIMIT 4
QUERY;
        $result['articles'] = $this->db->query($sql, array($string, $string));
        curl_init('http://yorkipedia.theyorker.co.uk/api.php?action=opensearch&search=' . urlencode(utf8_decode($filter)));
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 0.2);
        //possibly not valid, manual says integer only, but we wil try...
        $wikiResult = curl_exec($curl);
        $result['wiki'] = array();
        if ($wikiResult or $wikiResult != 1) {
            //example result ["Tet",["Tet","Tet-off","Tet-on","TetR","Tet 1969","Tet Corporation"]]
            preg_match_all("/[^.|\"\\[\\]]*/", $wikiResult, $wikiResult);
            foreach ($wikiResult as $page) {
                if (!empty($page) & $page != ',') {
                    $result['wiki'][] = $page;
                }
            }
        }
        // This query is possibly even slower than the one above, because It has to match against
        // two separate indexes!
        $sql = <<<QUERY
\t\t\tSELECT
\t\t\t\torganisations.organisation_name AS title,
\t\t\t\torganisations.organisation_directory_entry_name AS link,
\t\t\t\tUNIX_TIMESTAMP(organisation_timestamp) AS date,
\t\t\t\t((MATCH(organisations.organisation_name) AGAINST(?))+
\t\t\t\t\t(MATCH(organisation_contents.organisation_content_description) AGAINST(?))) AS score
\t\t\tFROM organisations
\t\t\tINNER JOIN organisation_types
\t\t\tON organisations.organisation_organisation_type_id=organisation_types.organisation_type_id
\t\t\tLEFT JOIN organisation_contents
\t\t\tON organisations.organisation_live_content_id = organisation_contents.organisation_content_id
\t\t\tINNER JOIN entities
\t\t\tON entities.entity_id = organisations.organisation_entity_id
\t\t\tAND entities.entity_deleted = 0
\t\t\tWHERE organisations.organisation_directory_entry_name IS NOT NULL
\t\t\t\tAND organisation_types.organisation_type_directory=1
\t\t\t\tAND organisations.organisation_show_in_directory=1
\t\t\t\tAND organisations.organisation_needs_approval=0
\t\t\t\tAND (MATCH (organisations.organisation_name) AGAINST (?)
\t\t\t\t OR MATCH (organisation_contents.organisation_content_description) AGAINST (?))
\t\t\tORDER BY score DESC LIMIT 4
QUERY;
        $result['directory'] = $this->db->query($sql, array($string, $string, $string, $string));
        $this->load->library('calendar_backend');
        $this->load->library('calendar_source_my_calendar');
        $this->load->library('facebook');
        $source = new CalendarSourceMyCalendar();
        // Use the search phrase
        $source->SetSearchPhrase($string);
        $source->EnableGroup('all');
        $calendar_data = new CalendarData();
        $source->FetchEvents($calendar_data);
        $result['events'] = $calendar_data->GetEvents();
        return $result;
    }