Beispiel #1
0
 /**
  * Return array of rss-feed compatible data
  */
 function getFEED($maxEntry = 20, $userid = null)
 {
     $events = array();
     CFactory::load('helpers', 'owner');
     CFactory::load('models', 'events');
     $model = new CommunityModelEvents();
     $eventObjs = $model->getEvents(null, $userid);
     if ($eventObjs) {
         foreach ($eventObjs as $row) {
             $event =& JTable::getInstance('Event', 'CTable');
             $event->load($row->id);
             $events[] = $event;
         }
         unset($eventObjs);
     }
     return $events;
 }
Beispiel #2
0
 function getEvents(&$params)
 {
     require_once JPATH_ROOT . '/components/com_community/libraries/core.php';
     require_once JPATH_ROOT . '/administrator/components/com_community/tables/configuration.php';
     require_once JPATH_ROOT . '/components/com_community/models/events.php';
     $cfactory = new CFactory();
     $cfactory->load('helpers', 'event');
     $cfactory->load('helpers', 'string');
     $cfactory->load('helpers', 'time');
     // Reuse existing language file from JomSocial
     $language = JFactory::getLanguage();
     $language->load('com_community', JPATH_ROOT);
     //$model = $cfactory->getModel('Events');
     $model = new CommunityModelEvents();
     $user_id = null;
     //if ((bool) $params->get( 'jomsocial_user' , false )){
     //    $user = JFactory::getUser();
     //    $user_id = $user->id;
     //}
     $advanced = null;
     if ($params->get('time_range') == 'time_span' || $params->get('rangespan') != 'all_events') {
         $advanced = array();
         $advanced['startdate'] = $params->get('startmin');
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $advanced['enddate'] = $startMax;
         }
     }
     $cat = $params->get('jomsocial_category', 0);
     //if all cats is selected return 0 for cats
     if (is_array($cat) && in_array(0, $cat)) {
         $cat = 0;
     }
     $rows = $model->getEvents($cat, $user_id, null, null, (bool) $params->get('jomsocial_past', false), false, null, $advanced, $params->get('jomsocial_type', CEventHelper::ALL_TYPES), 0, $params->get('jomsocial_total', 10));
     $events = array();
     if (empty($rows)) {
         return $events;
     }
     foreach ($rows as $row) {
         $table = JTable::getInstance('Event', 'CTable');
         $table->bind($row);
         $handler = CEventHelper::getHandler($table);
         if ($params->get('jomsocial_links') != 'link_no') {
             $link = array('internal' => $params->get('jomsocial_links') == 'link_internal' ? true : false, 'link' => $handler->getFormattedLink('index.php?option=com_community&view=events&task=viewevent&eventid=' . $table->id));
         } else {
             $link = false;
         }
         $conf = JFactory::getConfig();
         $tz = $conf->get('offset');
         $tz_offset = RokMiniEvents3::_get_timezone_offset($tz, false);
         $db_offset = $row->offset != 0 ? $row->offset * 3600 * -1 : 0;
         $startdate = strtotime($row->startdate) - (int) $tz_offset + (int) $db_offset;
         $enddate = strtotime($row->enddate) - (int) $tz_offset + (int) $db_offset;
         $time_diff = (int) $enddate - (int) $startdate;
         $event = new RokMiniEvents3_Event($startdate, $enddate, $row->title, $row->description, $link);
         if ($startdate == $enddate || $time_diff <= 86401 && $time_diff >= 86399 || $row->allday) {
             $event->setAllDay(true);
         }
         $events[] = $event;
     }
     return $events;
 }