Exemplo n.º 1
0
 function getEvents(&$params)
 {
     //simplepie has many strict standards errors, since they are not minievents errors they have been suppressed
     jimport('simplepie.simplepie');
     $id = $params->get('google_gid', '');
     $orderby = $params->get('google_orderby', 'starttime');
     $query = '?singleevents=true&orderby=' . $orderby . '&sortorder=a&max-results=' . $params->get('google_maxresults', 25);
     if ($params->get('time_range') != 'time_span' && $params->get('rangespan') == 'all_events') {
         if ($params->get('google_past')) {
             $query .= '&futureevents=false';
         } else {
             $query .= '&futureevents=true';
         }
     } else {
         $startMin = $params->get('startmin');
         $query .= "&start-min=" . $startMin;
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $query .= "&start-max=" . $startMax;
         }
     }
     $query = 'http://www.google.com/calendar/feeds/' . $id . '/public/full' . $query;
     $rss = @new SimplePie($query, JPATH_CACHE, $params->get('google_gcache', 3600));
     @$rss->enable_order_by_date(false);
     if ($rss->error) {
         return $events['error'] = $rss->error;
     }
     $items = @$rss->get_items();
     $events = array();
     if (empty($items)) {
         return $events;
     }
     foreach ($items as $item) {
         $when = @$item->get_item_tags('http://schemas.google.com/g/2005', 'when');
         $link = $params->get('google_links') != 'link_no' ? array('internal' => $params->get('google_links') == 'link_internal' ? true : false, 'link' => @$item->get_link()) : false;
         //date_default_timezone_set('UTC');
         $startdatetime = str_split($when[0]['attribs']['']['startTime'], 19);
         $enddatetime = str_split($when[0]['attribs']['']['endTime'], 19);
         $startdate = str_replace('T', ' ', $startdatetime[0]);
         $enddate = str_replace('T', ' ', $enddatetime[0]);
         $time_diff = (int) $enddate - (int) $startdate;
         $event = new RokMiniEvents3_Event($startdate, $enddate, @$item->get_title(), @$item->get_content(), $link);
         if ($startdate == $enddate || $time_diff <= 86401 && $time_diff >= 86399) {
             $event->setAllDay(true);
         }
         $events[] = $event;
     }
     return $events;
 }
Exemplo n.º 2
0
 function getEvents(&$params)
 {
     include_once REDEVENT_PATH_SITE . '/classes/output.class.php';
     include_once REDEVENT_PATH_SITE . '/helpers/route.php';
     include_once REDEVENT_PATH_SITE . '/helpers/helper.php';
     include_once REDEVENT_PATH_SITE . '/classes/useracl.class.php';
     include_once 'redevent/model.php';
     // load language file
     $language = JFactory::getLanguage();
     $language->load('com_redevent', JPATH_ROOT);
     $model = new RokMiniEvents3SourceRedEventModel($params);
     $rows = $model->getData();
     $total_count = 1;
     $total_max = $params->get('redevent_total', 10);
     $events = array();
     if (empty($rows)) {
         return $events;
     }
     foreach ($rows as $row) {
         if ($params->get('redevent_links') != 'link_no') {
             $link = array('internal' => $params->get('redevent_links') == 'link_internal' ? true : false, 'link' => JRoute::_(REdeventHelperRoute::getDetailsRoute($row->slug, $row->xslug)));
         } else {
             $link = false;
         }
         date_default_timezone_set('UTC');
         $offset = 0;
         if ($params->get('redevent_dates_format', 'utc') == 'joomla') {
             $conf = JFactory::getConfig();
             $timezone = $conf->get('offset');
             $offset = $timezone * 3600 * -1;
         }
         $startdate = strtotime($row->dates . ' ' . $row->times) + $offset;
         $enddate = $row->enddates ? strtotime($row->enddates . ' ' . $row->endtimes) + $offset : strtotime($row->dates . ' ' . $row->endtimes) + $offset;
         $event = new RokMiniEvents3_Event($startdate, $enddate, $row->title, $row->summary, $link);
         if ($startdate === $enddate) {
             $event->setAllDay(true);
         }
         if (!$row->enddates && !$row->endtimes) {
             $event->setNoEndTime(true);
         }
         $events[] = $event;
         $total_count++;
         if ($total_count > $total_max) {
             break;
         }
     }
     return $events;
 }
Exemplo n.º 3
0
 /**
  * @param $params
  * @return array
  */
 function getEvents(&$params)
 {
     if (!class_exists('rseventsproHelper')) {
         require_once JPATH_SITE . '/components/com_rseventspro/helpers/rseventspro.php';
     }
     if (!class_exists('RSEvent')) {
         require_once JPATH_SITE . '/components/com_rseventspro/helpers/events.php';
     }
     if (!class_exists('RseventsproHelperRoute')) {
         require_once JPATH_SITE . '/components/com_rseventspro/helpers/route.php';
     }
     // Reuse existing language file from JomSocial
     $language = JFactory::getLanguage();
     $language->load('com_rseventspro', JPATH_ROOT);
     $query_start_date = null;
     $query_end_date = null;
     if ($params->get('time_range') == 'time_span' || $params->get('rangespan') != 'all_events') {
         $query_start_date = $params->get('startmin', null);
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $query_end_date = $startMax;
         }
     }
     $db = JFactory::getDBO();
     $query = $db->getQuery(true);
     $nullDate = $db->getNullDate();
     $now = JFactory::getDate()->toSql();
     $query->select('e.id, e.name as title ,e.description, e.start as startdate, e.end as enddate, e.allday');
     $query->select('CONCAT_WS(",", t.id) AS category_ids');
     $query->from('#__rseventspro_events AS e');
     $query->join('left', '#__rseventspro_taxonomy AS t ON (t.ide = e.id AND t.type = "category")');
     $query->where('e.published = 1');
     $query->group('e.id');
     $query->order('e.start ASC');
     $catids = $params->get('rsevents_category', array());
     if (isset($catids) && !empty($catids) && !in_array('0', $catids)) {
         foreach ($catids as $catid) {
             $query->where($catid . ' IN (' . 'CONCAT_WS(",", t.id)' . ')');
         }
     }
     $locationids = $params->get('rsevents_venue', array());
     if (!is_array($locationids)) {
         $locationids = array($locationids);
     }
     if (isset($locationids) && !empty($locationids) && !in_array('0', $locationids)) {
         $query->where('e.location IN (' . implode(",", $locationids) . ')');
     }
     if (!empty($query_start_date) && !is_null($query_start_date)) {
         $rstartdate = $query_start_date;
         if ($params->get('rsevents_past', 0) == 0 && $rstartdate < $now) {
             $rstartdate = $now;
         }
         $query->where('e.start >= ' . $db->quote($rstartdate));
     } else {
         if ($params->get('rsevents_past', 0) == 0) {
             $rstartdate = $now;
             $query->where('((e.end >= ' . $db->quote($rstartdate) . ') OR (e.start >= ' . $db->quote($rstartdate) . ' AND e.allday = 1))');
         }
     }
     if (!empty($query_end_date) && !is_null($query_end_date)) {
         $renddate = $query_end_date;
         $query->where('e.start <= ' . $db->quote($renddate));
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $events = array();
     if (empty($rows)) {
         return $events;
     }
     $total_count = 1;
     $total_max = $params->get('rsevents_total', 10);
     foreach ($rows as $row) {
         if ($params->get('rsevents_links') != 'link_no') {
             $link = array('internal' => $params->get('rsevents_links') == 'link_internal' ? true : false, 'link' => 'index.php?option=com_rseventspro&layout=show&id=' . rseventsproHelper::sef($row->id, $row->title));
         } else {
             $link = false;
         }
         $event = new RokMiniEvents3_Event($row->startdate, $row->enddate, $row->title, $row->description, $link);
         if ($row->allday) {
             $event->setAllDay(true);
         }
         $events[] = $event;
         $total_count++;
         if ($total_count > $total_max) {
             break;
         }
     }
     //$events = array();
     return $events;
 }
Exemplo n.º 4
0
 function getEvents(&$params)
 {
     // Reuse existing language file from JomSocial
     $language = JFactory::getLanguage();
     $language->load('com_eventlist', JPATH_ROOT);
     $query_start_date = null;
     $query_end_date = null;
     if ($params->get('time_range') == 'time_span' || $params->get('rangespan') != 'all_events') {
         $query_start_date = $params->get('startmin');
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $query_end_date = $startMax;
         }
     }
     $app = JFactory::getApplication();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $user_gid = (int) $user->get('aid');
     $catid = trim($params->get('eventlist_category', 0));
     $venid = trim($params->get('eventlist_venue', 0));
     $categories = '';
     if ($catid != 0) {
         $categories = ' AND catsid = ' . $catid;
     }
     $venues = '';
     if ($venid != 0) {
         $venues = ' AND locid = ' . $venid;
     }
     $dates_start = '';
     if (!empty($query_start_date)) {
         $dates_start = ' AND a.dates >= ' . $db->Quote($query_start_date);
     }
     $dates_end = '';
     if (!empty($query_end_date)) {
         $dates_end = ' AND a.enddates <= ' . $db->Quote($query_end_date);
     }
     $query = 'SELECT a.*,' . ' CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(\':\', a.id, a.alias) ELSE a.id END as slug' . ' FROM #__eventlist_events AS a' . ' WHERE a.published = 1 ' . $categories . $venues . $dates_start . $dates_end . ' ORDER BY a.dates ASC, a.times ASC';
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     $total_count = 1;
     $total_max = $params->get('eventlist_total', 10);
     $events = array();
     if (empty($rows)) {
         return $events;
     }
     foreach ($rows as $row) {
         if ($params->get('eventlist_links') != 'link_no') {
             $link = array('internal' => $params->get('eventlist_links') == 'link_internal' ? true : false, 'link' => JRoute::_(self::getRoute($row->slug)));
         } else {
             $link = false;
         }
         if (!ini_get('date.timezone')) {
             date_default_timezone_set('UTC');
         }
         $offset = 0;
         if ($params->get('eventlist_dates_format', 'utc') == 'joomla') {
             $conf = JFactory::getConfig();
             $timezone = $conf->get('offset');
             $offset = $timezone * 3600 * -1;
         }
         $startdate = strtotime($row->dates . ' ' . $row->times) + $offset;
         $enddate = $row->enddates ? strtotime($row->enddates . ' ' . $row->endtimes) + $offset : strtotime($row->dates . ' ' . $row->endtimes) + $offset;
         $event = new RokMiniEvents3_Event($startdate, $enddate, $row->title, $row->datdescription, $link);
         if ($startdate === $enddate) {
             $event->setAllDay(true);
         }
         if (!$row->enddates && !$row->endtimes) {
             $event->setNoEndTime(true);
         }
         $events[] = $event;
         $total_count++;
         if ($total_count > $total_max) {
             break;
         }
     }
     //$events = array();
     return $events;
 }
Exemplo n.º 5
0
 function getEvents(&$params)
 {
     // Reuse existing language file from JomSocial
     $language = JFactory::getLanguage();
     $language->load('com_jevents', JPATH_ROOT);
     $query_start_date = null;
     $query_end_date = null;
     if ($params->get('time_range') == 'time_span' || $params->get('rangespan') != 'all_events') {
         $query_start_date = $params->get('startmin');
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $query_end_date = $startMax;
         }
     }
     // setup for all required function and classes
     $file = JPATH_SITE . '/components/com_jevents/mod.defines.php';
     if (file_exists($file)) {
         include_once $file;
         include_once JEV_LIBS . "/modfunctions.php";
     } else {
         die("JEvents Calendar\n<br />This module needs the JEvents component");
     }
     $eventHelper = @new JEVHelper();
     // load language constants
     @$eventHelper->loadLanguage('modlatest');
     $datamodel = @new JEventsDataModel();
     $showrepeats = $params->get('jevents_norepeats', 0) == 0 ? true : false;
     $catids = $params->get('jevents_category', array());
     if (!empty($catids) && !in_array('0', $catids)) {
         $params->set('catidnew', $catids);
     }
     $myItemid = @$datamodel->setupModuleCatids($params);
     $catout = @$datamodel->getCatidsOutLink(true);
     $reg = @JevRegistry::getInstance("jevents");
     $reg->setReference("jevents.datamodel", $datamodel);
     if (!empty($query_start_date)) {
         $rstartdate = new RokMiniEvents3_Date($query_start_date);
         if ($params->get('jevents_past', 0) == 0 && $rstartdate->toUnix() < time()) {
             $rstartdate = new RokMiniEvents3_Date(time());
         }
         $dates_start = $rstartdate->toISO8601();
     } else {
         if ($params->get('jevents_past', 0) == 0) {
             $rstartdate = new RokMiniEvents3_Date(time());
             $dates_start = $rstartdate->toISO8601();
         } else {
             $dates_start = date('Y-m-d\\T23:59:59', strtotime("-1 month"));
         }
     }
     if (empty($query_end_date)) {
         $dates_end = date('Y-m-d\\T23:59:59', strtotime("+1 year"));
     } else {
         $dates_end = $query_end_date;
     }
     $rows = @$datamodel->queryModel->listIcalEventsByRange($dates_start, $dates_end, 0, 20, $showrepeats);
     $events = array();
     if (empty($rows)) {
         return $events;
     }
     $total_count = 1;
     $total_max = $params->get('jevents_total', 10);
     foreach ($rows as $row) {
         if ($params->get('jevents_links') != 'link_no') {
             $title = JFilterOutput::stringURLSafe($row->_title);
             $itemId = @$eventHelper->getItemid();
             if ($params->get('jevents_links') == 'link_internal_event' || $params->get('jevents_links') == 'link_external_event') {
                 $link = array('internal' => $params->get('jevents_links') == 'link_internal_event' ? true : false, 'link' => JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalrepeat.detail&rp_id=' . $row->_eventid . '&rp_id=' . $row->_rp_id . '&Itemid=' . $itemId . '&year=' . $row->_yup . '&month=' . $row->_mup . '&day=' . $row->_dup . 'title=' . $title));
             } else {
                 $link = array('internal' => $params->get('jevents_links') == 'link_internal' ? true : false, 'link' => JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=month.calendar&year' . $row->_yup . '&month=' . $row->_mup . '&day=' . $row->_dup . '&Itemid=' . $itemId));
             }
         } else {
             $link = false;
         }
         $event = new RokMiniEvents3_Event($row->_unixstarttime, $row->_unixendtime, $row->_title, $row->_content, $link);
         $event->setAllDay($row->_alldayevent ? true : false);
         if ($row->_noendtime == "1") {
             $event->setNoEndTime(true);
         }
         $events[] = $event;
         $total_count++;
         if ($total_count > $total_max) {
             break;
         }
     }
     return $events;
 }
Exemplo n.º 6
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;
 }
Exemplo n.º 7
0
 function getEvents(&$params)
 {
     //simplepie has many strict standards errors, since they are not minievents errors they have been suppressed
     jimport('simplepie.simplepie');
     require 'google' . DS . 'api-php-client' . DS . 'autoload.php';
     $events = array();
     $id = $params->get('google_gid', '');
     $orderby = $params->get('google_orderby', 'startTime');
     $options = array('singleEvents' => true, 'orderBy' => $orderby, 'maxResults' => $params->get('google_maxresults', 25));
     // P12 approach
     $cemail = $params->get('google_p12_email', '');
     $p12 = JPATH_ROOT . DS . ltrim($params->get('google_p12_p12', ''), DS);
     if (!$p12 || !JFile::exists($p12) || !($p12 = file_get_contents($p12))) {
         return $events['error'] = "The P12 key has not been found at the location specified.";
     }
     $client = new Google_Client();
     $client->setApplicationName('RokMiniEvents3-' . uniqid());
     $service = new Google_Service_Calendar($client);
     $credentials = new Google_Auth_AssertionCredentials($cemail, array('https://www.googleapis.com/auth/calendar.readonly'), $p12);
     $client->setAssertionCredentials($credentials);
     if ($client->getAuth()->isAccessTokenExpired()) {
         try {
             $client->getAuth()->refreshTokenWithAssertion($credentials);
         } catch (Exception $error) {
             return $events['error'] = $error->getMessage();
         }
     }
     if ($params->get('time_range') != 'time_span' && $params->get('rangespan') == 'all_events') {
         if (!$params->get('google_past', false)) {
             $options['timeMin'] = date('Y-m-d\\T00:00:00\\Z', time());
         }
         // deprecated
     } else {
         $startMin = $params->get('startmin');
         $options['timeMin'] = $startMin . 'Z';
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $options['timeMax'] = $startMax . 'Z';
         }
     }
     try {
         $items = $service->events->listEvents($id, $options);
     } catch (Exception $error) {
         return $events['error'] = $error->getMessage();
     }
     if (empty($items)) {
         return $events;
     }
     foreach ($items as $item) {
         $link = $params->get('google_links') != 'link_no' ? array('internal' => $params->get('google_links') == 'link_internal' ? true : false, 'link' => $item->getHtmlLink()) : false;
         $start = $item->getStart();
         $end = $item->getEnd();
         $startdatetime = $start->dateTime ?: $start->date;
         $enddatetime = $end->dateTime ?: $end->date;
         $startdate = str_replace('T', ' ', $startdatetime);
         $enddate = str_replace('T', ' ', $enddatetime);
         $time_diff = (int) $enddate - (int) $startdate;
         $event = new RokMiniEvents3_Event($startdate, $enddate, $item->getSummary(), $item->getDescription(), $link);
         if ($startdate == $enddate || $time_diff <= 86401 && $time_diff >= 86399) {
             $event->setAllDay(true);
         }
         $events[] = $event;
     }
     return $events;
 }