示例#1
0
 /**
  * Computes the total number of events.
  *
  * @return int Event count
  */
 function _compute_events_count_total()
 {
     // Get the pre-filtered QB
     $qb = fi_kilonkipinat_events_viewer::prepare_event_qb($this->_request_data, $this->_config);
     return $qb->count_unchecked();
 }
示例#2
0
 /**
  * Prepare event listing query builder that takes all configured filters into account
  *
  * @access static
  */
 static function prepare_event_qb(&$data, &$config)
 {
     // Load filters
     $filters = fi_kilonkipinat_events_viewer::prepare_filters($config);
     $qb = fi_kilonkipinat_events_event_dba::new_query_builder();
     if (!$_MIDGARD['user']) {
         $qb->add_constraint('visibility', '=', FI_KILONKIPINAT_EVENTS_EVENT_VISIBILITY_PUBLIC);
     }
     // Add node or root event constraints
     if ($config->get('list_from_master')) {
         // List under an event tree by up field
         $qb->add_constraint('up', 'INTREE', $data['master_event']);
     } else {
         $list_from_folders = $config->get('list_from_folders');
         if ($list_from_folders) {
             // We have specific folders to list from, therefore list from them and current node
             $guids = explode('|', $config->get('list_from_folders'));
             $guids_array = array();
             $guids_array[] = $data['content_topic']->guid;
             foreach ($guids as $guid) {
                 if (!$guid || !mgd_is_guid($guid)) {
                     // Skip empty and broken guids
                     continue;
                 }
                 $guids_array[] = $guid;
             }
             /**
              * Ref #1776, expands GUIDs before adding them as constraints, should save query time
              */
             $topic_ids = array();
             $topic_ids[] = $data['content_topic']->id;
             if (!empty($guids_array)) {
                 $mc = midcom_db_topic::new_collector('sitegroup', $_MIDGARD['sitegroup']);
                 $mc->add_constraint('guid', 'IN', $guids_array);
                 $mc->add_value_property('id');
                 $mc->execute();
                 $keys = $mc->list_keys();
                 foreach ($keys as $guid => $dummy) {
                     $topic_ids[] = $mc->get_subkey($guid, 'id');
                 }
                 unset($mc, $keys, $guid, $dummy);
             }
             $qb->add_constraint('topic', 'IN', $topic_ids);
         } else {
             // List from current node only
             $qb->add_constraint('topic', '=', $data['content_topic']->id);
         }
     }
     // Add filtering constraint
     if (isset($filters['type_filter'])) {
         $qb->add_constraint('type', '=', (int) $filters['type_filter']);
     }
     if (isset($filters['other'])) {
         // Handle other direct field mapping constraints
         foreach ($filters['other'] as $field => $filter) {
             $qb->add_constraint($field, '=', $filter);
         }
     }
     // Handle category filter
     if (isset($filters['category_filter'])) {
         $qb->add_constraint('category', 'LIKE', "%|{$filters['category_filter']}|%");
     }
     return $qb;
 }
示例#3
0
 /**
  * Shows the autoindex list. Nothing to do in the handle phase except setting last modified
  * dates.
  *
  * @param mixed $handler_id The ID of the handler.
  * @param Array $args The argument list.
  * @param Array &$data The local request data.
  * @return boolean Indicating success.
  */
 function _handler_ical($handler_id, $args, &$data)
 {
     $_MIDCOM->cache->content->content_type("text/calendar; charset=UTF-8");
     // FIXME: There should be some lifetime specification for the cache engine
     $_MIDCOM->cache->content->uncached();
     $_MIDCOM->header("Content-type: text/calendar; charset=UTF-8");
     $_MIDCOM->skip_page_style = true;
     if (strstr($handler_id, 'user')) {
         $_MIDCOM->auth->require_valid_user('basic');
     }
     // Prepare control structures
     $this->_datamanager = new midcom_helper_datamanager2_datamanager($data['schemadb']);
     // Get the pre-filtered QB
     $qb = fi_kilonkipinat_events_viewer::prepare_event_qb($this->_request_data, $this->_config);
     if (strstr($handler_id, 'meetings')) {
         $qb->add_constraint('type', '>=', FI_KILONKIPINAT_EVENTS_EVENT_TYPE_MEETING_GENERIC);
         $qb->add_constraint('type', '<=', FI_KILONKIPINAT_EVENTS_EVENT_TYPE_MEETING_ANNUAL);
     } elseif (strstr($handler_id, 'trips')) {
         $qb->add_constraint('type', '>=', FI_KILONKIPINAT_EVENTS_EVENT_TYPE_GENERIC);
         $qb->add_constraint('type', '<', FI_KILONKIPINAT_EVENTS_EVENT_TYPE_MEETING_GENERIC);
     }
     $kisa_config = $this->_config->get('kisa');
     if ($kisa_config == 0) {
         $qb->add_constraint('kisa', '<=', FI_KILONKIPINAT_EVENTS_EVENT_KISA_BOTH);
     } elseif ($kisa_config == 1) {
         $qb->add_constraint('kisa', '<', FI_KILONKIPINAT_EVENTS_EVENT_KISA_BOTH);
     } elseif ($kisa_config == 2) {
         $qb->add_constraint('kisa', '>=', FI_KILONKIPINAT_EVENTS_EVENT_KISA_BOTH);
     } elseif ($kisa_config == 3) {
         $qb->add_constraint('kisa', '>', FI_KILONKIPINAT_EVENTS_EVENT_KISA_BOTH);
     }
     // Show only events that haven't ended
     $qb->add_constraint('end', '>', date('Y-m-d H:i:s'));
     $sorts = $this->_config->get('ical_sort_rules');
     if (!is_array($sorts)) {
         $sorts = array('start' => 'ASC');
     }
     foreach ($sorts as $prop => $rule) {
         $qb->add_order($prop, $rule);
     }
     $qb->set_limit($this->_config->get('ical_count'));
     $this->_events = $qb->execute();
     return true;
 }