/** * override store function to force rrule to save too! * * @param unknown_type $updateNulls */ function store($updateNulls = false) { $date = JevDate::getDate(); $this->modified = $date->toMySQL(); if (parent::store($updateNulls)) { // I also need to store custom data $dispatcher = JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onStoreCustomDetails', array(&$this)); } else { JError::raiseError(321, "Problem saving event " . $this->_db->getErrorMsg()); } return $this->evdet_id; }
/** * List Ical Events * */ function overview() { // get the view $this->view =& $this->getView("icalevent", "html"); $this->_checkValidCategories(); $showUnpublishedICS = true; $showUnpublishedCategories = true; $db =& JFactory::getDBO(); $icsFile = intval(JFactory::getApplication()->getUserStateFromRequest("icsFile", "icsFile", 0)); $catid = intval(JFactory::getApplication()->getUserStateFromRequest("catidIcalEvents", 'catid', 0)); $catidtop = $catid; $state = intval(JFactory::getApplication()->getUserStateFromRequest("stateIcalEvents", 'state', 0)); $limit = intval(JFactory::getApplication()->getUserStateFromRequest("viewlistlimit", 'limit', 10)); $limitstart = intval(JFactory::getApplication()->getUserStateFromRequest("view{" . JEV_COM_COMPONENT . "}limitstart", 'limitstart', 0)); $search = JFactory::getApplication()->getUserStateFromRequest("search{" . JEV_COM_COMPONENT . "}", 'search', ''); $search = $db->getEscaped(trim(strtolower($search))); $created_by = JFactory::getApplication()->getUserStateFromRequest("createdbyIcalEvents", 'created_by', 0); // Is this a large dataset ? $query = "SELECT count(rpt.rp_id) from #__jevents_repetition as rpt "; $db->setQuery($query); $totalrepeats = $db->loadResult(); $this->_largeDataSet = 0; $cfg =& JEVConfig::getInstance(); if ($totalrepeats > $cfg->get('largeDataSetLimit', 100000)) { $this->_largeDataSet = 1; } $cfg =& JEVConfig::getInstance(); $cfg->set('largeDataSet', $this->_largeDataSet); $where = array(); $join = array(); if ($search) { $where[] = "LOWER(detail.summary) LIKE '%{$search}%'"; } if (JVersion::isCompatible("1.6.0")) { $user =& JFactory::getUser(); $params =& JComponentHelper::getParams(JEV_COM_COMPONENT); $authorisedonly = $params->get("authorisedonly", 0); $cats = $user->getAuthorisedCategories('com_jevents', 'core.create'); if (isset($user->id) && !$user->authorise('core.create', 'com_jevents') && !$authorisedonly) { if ($cats > 0 && $catid < 1) { for ($i = 0; $i < count($cats); $i++) { $whereCats[$i] = "ev.catid='{$cats[$i]}'"; } $where[] = '(' . implode(" OR ", $whereCats) . ')'; } else { if ($cats > 0 && $catid > 0 && in_array($catid, $cats)) { $where[] = "ev.catid='{$catid}'"; } else { $where[] = "ev.catid=''"; } } } else { if ($catid > 0) { $where[] = "ev.catid='{$catid}'"; } } } else { if ($catid > 0) { $where[] = "ev.catid='{$catid}'"; } } if ($created_by === "") { $where[] = "ev.created_by=0"; } else { $created_by = intval($created_by); if ($created_by > 0) { $where[] = "ev.created_by=" . $db->Quote($created_by); } } if ($icsFile > 0) { $join[] = " #__jevents_icsfile as icsf ON icsf.ics_id = ev.icsid"; $where[] = "\n icsf.ics_id = {$icsFile}"; if (!$showUnpublishedICS) { $where[] = "\n icsf.state=1"; } } else { if (!$showUnpublishedICS) { $join[] = " #__jevents_icsfile as icsf ON icsf.ics_id = ev.icsid"; $where[] = "\n icsf.state=1"; } else { $icsFrom = ""; } } $hidepast = intval(JFactory::getApplication()->getUserStateFromRequest("hidepast", "hidepast", 1)); if ($hidepast) { $datenow =& JevDate::getDate("-1 day"); if (!$this->_largeDataSet) { $where[] = "\n rpt.endrepeat>'" . $datenow->toMysql() . "'"; } } if ($state == 1) { $where[] = "\n ev.state=1"; } else { if ($state == 2) { $where[] = "\n ev.state=0"; } } // keep this incase we use filters in category lists $where[] = "\n ev.catid IN(" . $this->queryModel->accessibleCategoryList() . ")"; // get the total number of records $query = "SELECT count(distinct rpt.eventid)" . "\n FROM #__jevents_vevent AS ev " . "\n LEFT JOIN #__jevents_vevdetail as detail ON ev.detail_id=detail.evdet_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . (count($join) ? "\n LEFT JOIN " . implode(' LEFT JOIN ', $join) : '') . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); $db->setQuery($query); //echo $db->_sql; $total = $db->loadResult(); echo $db->getErrorMsg(); if ($limit > $total) { $limitstart = 0; } // if anon user plugin enabled then include this information $anonfields = ""; $anonjoin = ""; if (JPluginHelper::importPlugin("jevents", "jevanonuser")) { $anonfields = ", ac.name as anonname, ac.email as anonemail"; $anonjoin = "\n LEFT JOIN #__jev_anoncreator as ac on ac.ev_id = ev.ev_id"; } $orderdir = JRequest::getCmd("filter_order_Dir", 'asc'); $order = JRequest::getCmd("filter_order", 'start'); $dir = $orderdir == "asc" ? "asc" : "desc"; if ($order == 'start' || $order == 'starttime') { $order = $this->_largeDataSet ? "\n ORDER BY detail.dtstart {$dir}" : "\n GROUP BY ev.ev_id ORDER BY rpt.startrepeat {$dir}"; } else { if ($order == 'created') { $order = $this->_largeDataSet ? "\n ORDER BY ev.created {$dir}" : "\n GROUP BY ev.ev_id ORDER BY ev.created {$dir}"; } else { $order = $this->_largeDataSet ? "\n ORDER BY detail.summary {$dir}" : "\n GROUP BY ev.ev_id ORDER BY detail.summary {$dir}"; } } if (JVersion::isCompatible("1.6.0")) { $query = "SELECT ev.*, ev.state as evstate, detail.*, ev.created as created, a.title as _groupname " . $anonfields . "\n , rr.rr_id, rr.freq,rr.rinterval" . ($this->_largeDataSet ? "" : "\n ,MAX(rpt.endrepeat) as endrepeat ,MIN(rpt.startrepeat) as startrepeat" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat ) as ydn, MONTH(rpt.endrepeat ) as mdn, DAYOFMONTH(rpt.endrepeat ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat ) as hdn, MINUTE(rpt.endrepeat ) as mindn, SECOND(rpt.endrepeat ) as sdn") . "\n FROM #__jevents_vevent as ev " . ($this->_largeDataSet ? "" : "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id") . $anonjoin . "\n LEFT JOIN #__jevents_vevdetail as detail ON ev.detail_id=detail.evdet_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__viewlevels AS a ON a.id = ev.access" . (count($join) ? "\n LEFT JOIN " . implode(' LEFT JOIN ', $join) : '') . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . $order; } else { $query = "SELECT ev.*, ev.state as evstate, detail.*, ev.created as created, g.name AS _groupname " . $anonfields . "\n , rr.rr_id, rr.freq,rr.rinterval" . ($this->_largeDataSet ? "" : "\n ,MAX(rpt.endrepeat) as endrepeat ,MIN(rpt.startrepeat) as startrepeat" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat ) as ydn, MONTH(rpt.endrepeat ) as mdn, DAYOFMONTH(rpt.endrepeat ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat ) as hdn, MINUTE(rpt.endrepeat ) as mindn, SECOND(rpt.endrepeat ) as sdn") . "\n FROM #__jevents_vevent as ev " . ($this->_largeDataSet ? "" : "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id") . $anonjoin . "\n LEFT JOIN #__jevents_vevdetail as detail ON ev.detail_id=detail.evdet_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__groups AS g ON g.id = ev.access" . (count($join) ? "\n LEFT JOIN " . implode(' LEFT JOIN ', $join) : '') . (count($where) ? "\n WHERE " . implode(' AND ', $where) : '') . $order; } if ($limit > 0) { $query .= "\n LIMIT {$limitstart}, {$limit}"; } $db->setQuery($query); //echo $db->explain(); $rows = $db->loadObjectList(); foreach ($rows as $key => $val) { // set state variable to the event value not the event detail value $rows[$key]->state = $rows[$key]->evstate; if (JVersion::isCompatible("1.6.0")) { $groupname = $rows[$key]->_groupname; $rows[$key] = new jIcalEventRepeat($rows[$key]); $rows[$key]->_groupname = $groupname; } else { $groupname = $rows[$key]->_groupname; $rows[$key] = new jIcalEventRepeat($rows[$key]); $rows[$key]->_groupname = $groupname; } } if ($this->_debug) { echo '[DEBUG]<br />'; echo 'query:'; echo '<pre>'; echo $query; echo '-----------<br />'; echo 'option "' . JEV_COM_COMPONENT . '"<br />'; echo '</pre>'; //die( 'userbreak - mic ' ); } if ($db->getErrorNum()) { echo $db->stderr(); return false; } // get list of categories $attribs = 'class="inputbox" size="1" onchange="document.adminForm.submit();"'; $clist = JEventsHTML::buildCategorySelect($catid, $attribs, null, $showUnpublishedCategories, false, $catidtop, "catid"); // get list of ics Files $icsfiles = array(); //$icsfiles[] = JHTML::_('select.option', '0', "Choose ICS FILE" ); $icsfiles[] = JHTML::_('select.option', '-1', JText::_('ALL_ICS_FILES')); $query = "SELECT ics.ics_id as value, ics.label as text FROM #__jevents_icsfile as ics "; if (!$showUnpublishedICS) { $query .= " WHERE ics.state=1"; } $query .= " ORDER BY ics.isdefault DESC, ics.label ASC"; $db->setQuery($query); $result = $db->loadObjectList(); $icsfiles = array_merge($icsfiles, $result); $icslist = JHTML::_('select.genericlist', $icsfiles, 'icsFile', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $icsFile); // get list of creators $sql = "SELECT distinct u.id, u.* FROM #__jevents_vevent as jev LEFT JOIN #__users as u on u.id=jev.created_by order by u.name "; $db =& JFactory::getDBO(); $db->setQuery($sql); $users = $db->loadObjectList(); $userOptions = array(); $userOptions[] = JHTML::_('select.option', 0, JText::_("JEV_EVENT_CREATOR")); foreach ($users as $user) { $userOptions[] = JHTML::_('select.option', $user->id, $user->name . " ({$user->username})"); } $userlist = JHTML::_('select.genericlist', $userOptions, 'created_by', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $created_by); $options[] = JHTML::_('select.option', '0', JText::_('JEV_NO')); $options[] = JHTML::_('select.option', '1', JText::_('JEV_YES')); $plist = JHTML::_('select.genericlist', $options, 'hidepast', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $hidepast); $options = array(); $options[] = JHTML::_('select.option', '0', JText::_('ALL_EVENTS')); $options[] = JHTML::_('select.option', '1', JText::_('PUBLISHED')); $options[] = JHTML::_('select.option', '2', JText::_('UNPUBLISHED')); $statelist = JHTML::_('select.genericlist', $options, 'state', 'class="inputbox" size="1" onchange="document.adminForm.submit();"', 'value', 'text', $state); $catData = JEV_CommonFunctions::getCategoryData(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); // Set the layout $this->view->setLayout('overview'); $this->view->assign('rows', $rows); $this->view->assign('userlist', $userlist); $this->view->assign('clist', $clist); $this->view->assign('plist', $plist); $this->view->assign('statelist', $statelist); $this->view->assign('search', $search); $this->view->assign('icsList', $icslist); $this->view->assign('pageNav', $pageNav); $this->view->display(); }
/** * Get JevDate object of current time * * @return object JevDate */ public static function getNow() { /* JevDate object of current time */ static $datenow = null; if (!isset($datenow)) { include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php"; $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT); $tz = $compparams->get("icaltimezonelive", ""); // Now in the set timezone! $datenow = JevDate::getDate("+0 seconds"); } return $datenow; }
/** * override store function to force rrule to save too! * * @param unknown_type $updateNulls */ function store($updateNulls = false, $overwriteCreator = false) { $user =& JFactory::getUser(); if ($this->ev_id == 0) { $date =& JevDate::getDate(); $this->created = $date->toMySQL(); } if (!isset($this->created_by) || is_null($this->created_by) || $this->created_by == 0) { $this->created_by = $user->id; } $this->modified_by = $user->id; if (!isset($this->created_by_alias) || is_null($this->created_by_alias) || $this->created_by_alias == "") { $this->created_by_alias = ""; } // make sure I update existing detail $matchingDetail = $this->matchingEventDetails(); if (isset($matchingDetail) && isset($matchingDetail->evdet_id)) { $this->_detail->evdet_id = $matchingDetail->evdet_id; } // if existing row preserve created by - unless being overwritten by authorised user // If user is jevents can deleteall or has backend access then allow them to specify the creator $jevuser = JEVHelper::getAuthorisedUser(); $creatorid = JRequest::getInt("jev_creatorid", 0); $access = false; if ($user->get('id') > 0) { if (JVersion::isCompatible("1.6.0")) { //$access = JAccess::check($user->id, "core.deleteall","com_jevents"); $access = $user->authorise('core.deleteall', 'com_jevents'); } else { // does this logged in have backend access // Get an ACL object $acl =& JFactory::getACL(); $grp = $acl->getAroGroup($user->get('id')); // if no valid group (e.g. anon user) then skip this. if (!$grp) { return; } $access = $acl->is_group_child_of($grp->name, 'Public Backend'); } } if (!($jevuser && $jevuser->candeleteall || $access) || $creatorid == 0) { if (!is_null($this->ev_id) || $this->ev_id > 0) { // we can overwrite the creator if refreshing/saving an ical with specified creator if (isset($matchingDetail) && $matchingDetail->created_by > 0 && !$overwriteCreator) { $this->created_by = $matchingDetail->created_by; } } } $db =& JFactory::getDBO(); $detailid = $this->_detail->store($updateNulls); if (!$detailid) { JError::raiseError(104, JText::_('PROBLEMS_STORING_EVENT_DETAIL')); echo $db->getErroMsg() . "<br/>"; return false; } $this->detail_id = $detailid; if (!parent::store($updateNulls)) { JError::raiseError(105, JText::_('PROBLEMS_STORING_EVENT')); echo $db->getErrorMsg() . "<br/>"; return false; } // I also need to store custom data - when we need the event itself and not just the detail $dispatcher =& JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onStoreCustomEvent', array(&$this)); if (isset($this->rrule)) { $this->rrule->eventid = $this->ev_id; if ($id = $this->rrule->isDuplicate()) { $this->rrule->rr_id = $id; } $this->rrule->store($updateNulls); echo $db->getErrorMsg() . "<br/>"; } return true; }
function listEventsByKeyword($keyword, $order, &$limit, &$limitstart, &$total, $useRegX = false) { $user = JFactory::getUser(); $adminuser = JEVHelper::isAdminUser($user); $db = JFactory::getDBO(); $rows_per_page = $limit; if (empty($limitstart) || !$limitstart) { $limitstart = 0; } $limitstring = ""; if ($rows_per_page > 0) { $limitstring = "LIMIT {$limitstart}, {$rows_per_page}"; } $where = ""; $having = ""; if (!JRequest::getInt('showpast', 0)) { $datenow =& JevDate::getDate("-12 hours"); $having = " AND rpt.endrepeat>'" . $datenow->toMysql() . "'"; } if (!$order) { $order = 'publish_up'; } $order = preg_replace("/[\t ]+/", '', $order); $orders = explode(",", $order); // this function adds #__events. to the beginning of each ordering field function app_db($strng) { return '#__events.' . $strng; } $order = implode(',', array_map('app_db', $orders)); $total = 0; // process the new plugins // get extra data and conditionality from plugins $extrawhere = array(); $extrajoin = array(); $extrafields = ""; // must have comma prefix $needsgroup = false; $filterarray = array("published"); // If there are extra filters from the module then apply them now $reg =& JFactory::getConfig(); $modparams = $reg->getValue("jev.modparams", false); if ($modparams && $modparams->getValue("extrafilters", false)) { $filterarray = array_merge($filterarray, explode(",", $modparams->getValue("extrafilters", false))); } $filters = jevFilterProcessing::getInstance($filterarray); $filters->setWhereJoin($extrawhere, $extrajoin); $needsgroup = $filters->needsGroupBy(); JPluginHelper::importPlugin('jevents'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup)); $catwhere = "\n WHERE ev.catid IN(" . $this->accessibleCategoryList() . ")"; $params = JComponentHelper::getParams("com_jevents"); if ($params->get("multicategory", 0)) { $extrajoin[] = "\n #__jevents_catmap as catmap ON catmap.evid = rpt.eventid"; $extrajoin[] = "\n #__categories AS catmapcat ON catmap.catid = catmapcat.id"; $extrafields .= ", GROUP_CONCAT(DISTINCT catmap.catid SEPARATOR ',') as catids"; $extrawhere[] = " catmapcat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $extrawhere[] = " catmap.catid IN(" . $this->accessibleCategoryList() . ")"; $needsgroup = true; $catwhere = "\n WHERE 1 "; } $extrajoin = count($extrajoin) ? " \n LEFT JOIN " . implode(" \n LEFT JOIN ", $extrajoin) : ''; $extrawhere = count($extrawhere) ? ' AND ' . implode(' AND ', $extrawhere) : ''; $extrasearchfields = array(); $dispatcher->trigger('onSearchEvents', array(&$extrasearchfields, &$extrajoin, &$needsgroup)); if (count($extrasearchfields) > 0) { $extraor = implode(" OR ", $extrasearchfields); $extraor = " OR " . $extraor; // replace the ### placeholder with the keyword $extraor = str_replace("###", $keyword, $extraor); $searchpart = $useRegX ? "(det.summary RLIKE '{$keyword}' OR det.description RLIKE '{$keyword}' OR det.extra_info RLIKE '{$keyword}' {$extraor})\n" : " (MATCH (det.summary, det.description, det.extra_info) AGAINST ('{$keyword}' IN BOOLEAN MODE) {$extraor})\n"; } else { $searchpart = $useRegX ? "(det.summary RLIKE '{$keyword}' OR det.description RLIKE '{$keyword}' OR det.extra_info RLIKE '{$keyword}')\n" : "MATCH (det.summary, det.description, det.extra_info) AGAINST ('{$keyword}' IN BOOLEAN MODE)\n"; } // Now Search Icals $query = "SELECT count( distinct det.evdet_id) FROM #__jevents_vevent as ev" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . "\n AND icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND "; $query .= $searchpart; $query .= $extrawhere; $query .= $having; $db->setQuery($query); //echo $db->explain(); $total += intval($db->loadResult()); if ($total < $limitstart) { $limitstart = 0; } $rows = array(); if ($total == 0) { return $rows; } // Now Search Icals // New version $query = "SELECT DISTINCT det.evdet_id FROM #__jevents_vevdetail as det" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventdetail_id = det.evdet_id" . "\n LEFT JOIN #__jevents_vevent as ev ON ev.ev_id = rpt.eventid" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . $extrajoin . $catwhere . "\n AND icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $query .= " AND "; $query .= $searchpart; $query .= $extrawhere; $query .= $having; $query .= "\n ORDER BY rpt.startrepeat ASC "; $query .= "\n {$limitstring}"; $db->setQuery($query); if ($adminuser) { //echo $db->_sql; //echo $db->explain(); } //echo $db->explain(); $details = $db->loadResultArray(); $icalrows = array(); foreach ($details as $detid) { $query2 = "SELECT ev.*, rpt.*, det.* {$extrafields}" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat ) as ydn, MONTH(rpt.endrepeat ) as mdn, DAYOFMONTH(rpt.endrepeat ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat ) as hdn, MINUTE(rpt.endrepeat ) as mindn, SECOND(rpt.endrepeat ) as sdn" . "\n FROM #__jevents_vevent as ev" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . $extrajoin . "\n WHERE rpt.eventdetail_id = {$detid}" . $extrawhere . $having . "\n ORDER BY rpt.startrepeat ASC limit 1"; $db->setQuery($query2); //echo $db->explain(); $data = $db->loadObject(); // belts and braces - some servers have a MYSQLK bug on the user of DISTINCT! if (!$data->ev_id) { continue; } $icalrows[] = $data; } $num_events = count($icalrows); for ($i = 0; $i < $num_events; $i++) { // convert rows to jevents $icalrows[$i] = new jIcalEventRepeat($icalrows[$i]); } $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onDisplayCustomFieldsMultiRow', array(&$icalrows)); $dispatcher->trigger('onDisplayCustomFieldsMultiRowUncached', array(&$icalrows)); return $icalrows; }
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask, $template_value = false) { $db = JFactory::getDBO(); // find published template static $templates; static $fieldNameArray; if (!isset($templates)) { $templates = array(); $fieldNameArray = array(); $rawtemplates = array(); } $specialmodules = false; if (!$template_value) { if (!array_key_exists($template_name, $templates)) { $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name) . " AND " . 'language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')'); $rawtemplates = $db->loadObjectList(); $templates[$template_name] = array(); if ($rawtemplates) { foreach ($rawtemplates as $rt) { if (!isset($templates[$template_name][$rt->language])) { $templates[$template_name][$rt->language] = array(); } $templates[$template_name][$rt->language][$rt->catid] = $rt; } } if (count($templates[$template_name]) == 0) { $templates[$template_name] = null; return false; } if (isset($templates[$template_name][JFactory::getLanguage()->getTag()])) { $templateArray = $templates[$template_name][JFactory::getLanguage()->getTag()]; // We have the most specific by language now fill in the gaps if (isset($templates[$template_name]["*"])) { foreach ($templates[$template_name]["*"] as $cat => $cattemplates) { if (!isset($templateArray[$cat])) { $templateArray[$cat] = $cattemplates; } } } $templates[$template_name] = $templateArray; } else { if (isset($templates[$template_name]["*"])) { $templates[$template_name] = $templates[$template_name]["*"]; } else { if (is_array($templates[$template_name]) && count($templates[$template_name]) == 0) { $templates[$template_name] = null; } else { if (is_array($templates[$template_name]) && count($templates[$template_name]) > 0) { $templates[$template_name] = current($templates[$template_name]); } else { $templates[$template_name] = null; } } } } $matched = false; foreach (array_keys($templates[$template_name]) as $catid) { if ($templates[$template_name][$catid]->value != "") { if (isset($templates[$template_name][$catid]->params)) { $templates[$template_name][$catid]->params = new JRegistry($templates[$template_name][$catid]->params); $specialmodules = $templates[$template_name][$catid]->params; } // Adjust template_value to include dynamic module output then strip it out afterwards if ($specialmodules) { $modids = $specialmodules->get("modid", array()); if (count($modids) > 0) { $modvals = $specialmodules->get("modval", array()); // not sure how this can arise :( if (is_object($modvals)) { $modvals = get_object_vars($modvals); } for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) { $templates[$template_name][$catid]->value .= "{{module start:MODULESTART#" . $modids[$count] . "}}"; // cleaned later! //$templates[$template_name][$catid]->value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]); $templates[$template_name][$catid]->value .= $modvals[$count]; $templates[$template_name][$catid]->value .= "{{module end:MODULEEND}}"; } } } // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field $templates[$template_name][$catid]->value = str_replace("\r", '', $templates[$template_name][$catid]->value); $templates[$template_name][$catid]->value = str_replace("\n", '', $templates[$template_name][$catid]->value); // non greedy replacement - because of the ? $templates[$template_name][$catid]->value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $templates[$template_name][$catid]->value); $matchesarray = array(); preg_match_all('|{{.*?}}|', $templates[$template_name][$catid]->value, $matchesarray); $templates[$template_name][$catid]->matchesarray = $matchesarray; } } } if (is_null($templates[$template_name])) { return false; } $catids = $event->catids() && count($event->catids()) ? $event->catids() : array($event->catid()); $catids[] = 0; // find the overlap $catids = array_intersect($catids, array_keys($templates[$template_name])); // At present must be an EXACT category match - no inheriting allowed! if (count($catids) == 0) { if (!isset($templates[$template_name][0]) || $templates[$template_name][0]->value == "") { return false; } } $template = false; foreach ($catids as $catid) { // use the first matching non-empty layout if ($templates[$template_name][$catid]->value != "") { $template = $templates[$template_name][$catid]; break; } } if (!$template) { return false; } $template_value = $template->value; $specialmodules = $template->params; $matchesarray = $template->matchesarray; } else { // This is a special scenario where we call this function externally e.g. from RSVP Pro messages // In this scenario we have not gone through the displaycustomfields plugin static $pluginscalled = array(); if (!isset($pluginscalled[$event->rp_id()])) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin("jevents"); $customresults = $dispatcher->trigger('onDisplayCustomFields', array(&$event)); $pluginscalled[$event->rp_id()] = $event; } else { $event = $pluginscalled[$event->rp_id()]; } // Adjust template_value to include dynamic module output then strip it out afterwards if ($specialmodules) { $modids = $specialmodules->get("modid", array()); if (count($modids) > 0) { $modvals = $specialmodules->get("modval", array()); // not sure how this can arise :( if (is_object($modvals)) { $modvals = get_object_vars($modvals); } for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) { $template_value .= "{{module start:MODULESTART#" . $modids[$count] . "}}"; // cleaned later! //$template_value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]); $template_value .= $modvals[$count]; $template_value .= "{{module end:MODULEEND}}"; } } } // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field $template_value = str_replace("\r", '', $template_value); $template_value = str_replace("\n", '', $template_value); // non greedy replacement - because of the ? $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value); $matchesarray = array(); preg_match_all('|{{.*?}}|', $template_value, $matchesarray); } if ($template_value == "") { return; } if (count($matchesarray) == 0) { return; } // now replace the fields $search = array(); $replace = array(); $blank = array(); $rawreplace = array(); $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT); for ($i = 0; $i < count($matchesarray[0]); $i++) { $strippedmatch = preg_replace('/(#|:|;)+[^}]*/', '', $matchesarray[0][$i]); if (in_array($strippedmatch, $search)) { continue; } // translation string if (strpos($strippedmatch, "{{_") === 0 && strpos($strippedmatch, " ") === false) { $search[] = $strippedmatch; $strippedmatch = substr($strippedmatch, 3, strlen($strippedmatch) - 5); $replace[] = JText::_($strippedmatch); $blank[] = ""; continue; } // Built in fields switch ($strippedmatch) { case "{{TITLE}}": $search[] = "{{TITLE}}"; $replace[] = $event->title(); $blank[] = ""; break; case "{{PRIORITY}}": $search[] = "{{PRIORITY}}"; $replace[] = $event->priority(); $blank[] = ""; break; case "{{LINK}}": case "{{LINKSTART}}": case "{{LINKEND}}": case "{{TITLE_LINK}}": if ($view) { // Title link $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false); $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink()); ob_start(); ?> <a class="ev_link_row" href="<?php echo $rowlink; ?> " title="<?php echo JEventsHTML::special($event->title()); ?> "> <?php $linkstart = ob_get_clean(); } else { $rowlink = $linkstart = ""; } $search[] = "{{LINK}}"; $replace[] = $rowlink; $blank[] = ""; $search[] = "{{LINKSTART}}"; $replace[] = $linkstart; $blank[] = ""; $search[] = "{{LINKEND}}"; $replace[] = "</a>"; $blank[] = ""; $fulllink = $linkstart . $event->title() . '</a>'; $search[] = "{{TITLE_LINK}}"; $replace[] = $fulllink; $blank[] = ""; break; case "{{TRUNCTITLE}}": // for month calendar cell only if (isset($event->truncatedtitle)) { $search[] = "{{TRUNCTITLE}}"; $replace[] = $event->truncatedtitle; $blank[] = ""; } else { $search[] = "{{TRUNCTITLE}}"; $replace[] = $event->title(); $blank[] = ""; } break; case "{{URL}}": $search[] = "{{URL}}"; $replace[] = $event->url(); $blank[] = ""; break; case "{{TRUNCATED_DESC}}": $search[] = "{{TRUNCATED_DESC:.*?}}"; $replace[] = $event->content(); $blank[] = ""; // $search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content(); break; case "{{DESCRIPTION}}": $search[] = "{{DESCRIPTION}}"; $replace[] = $event->content(); $blank[] = ""; break; case "{{MANAGEMENT}}": $search[] = "{{MANAGEMENT}}"; if ($view) { ob_start(); $view->_viewNavAdminPanel(); $replace[] = ob_get_clean(); } else { $replace[] = ""; } $blank[] = ""; break; case "{{CATEGORY}}": $search[] = "{{CATEGORY}}"; $replace[] = $event->catname(); $blank[] = ""; break; case "{{ALLCATEGORIES}}": $search[] = "{{ALLCATEGORIES}}"; static $allcat_catids; if (!isset($allcat_catids)) { $db = JFactory::getDBO(); $arr_catids = array(); $catsql = "SELECT cat.id, cat.title as name FROM #__categories as cat WHERE cat.extension='com_jevents' "; $db->setQuery($catsql); $allcat_catids = $db->loadObjectList('id'); } $db = JFactory::getDbo(); $db->setQuery("Select catid from #__jevents_catmap WHERE evid = " . $event->ev_id()); $allcat_eventcats = $db->loadColumn(); $allcats = array(); foreach ($allcat_eventcats as $catid) { if (isset($allcat_catids[$catid])) { $allcats[] = $allcat_catids[$catid]->name; } } $replace[] = implode(", ", $allcats); $blank[] = ""; break; case "{{CALENDAR}}": $search[] = "{{CALENDAR}}"; $replace[] = $event->getCalendarName(); $blank[] = ""; break; case "{{COLOUR}}": case "{{colour}}": $bgcolor = $event->bgcolor(); $search[] = $strippedmatch; $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor; $blank[] = ""; break; case "{{FGCOLOUR}}": $search[] = "{{FGCOLOUR}}"; $replace[] = $event->fgcolor(); $blank[] = ""; break; case "{{TTTIME}}": $search[] = "{{TTTIME}}"; $replace[] = "[[TTTIME]]"; $blank[] = ""; break; case "{{EVTTIME}}": $search[] = "{{EVTTIME}}"; $replace[] = "[[EVTTIME]]"; $blank[] = ""; break; case "{{TOOLTIP}}": $search[] = "{{TOOLTIP}}"; $replace[] = "[[TOOLTIP]]"; $blank[] = ""; break; case "{{CATEGORYLNK}}": $router = JRouter::getInstance("site"); $catlinks = array(); if ($jevparams->get("multicategory", 0)) { $catids = $event->catids(); $catdata = $event->getCategoryData(); } else { $catids = array($event->catid()); $catdata = array($event->getCategoryData()); } $vars = $router->getVars(); foreach ($catids as $cat) { $vars["catids"] = $cat; $catname = "xxx"; foreach ($catdata as $cg) { if ($cat == $cg->id) { $catname = $cg->name; break; } } $eventlink = "index.php?"; foreach ($vars as $key => $val) { // this is only used in the latest events module so do not perpetuate it here if ($key == "filter_reset") { continue; } if ($key == "task" && ($val == "icalrepeat.detail" || $val == "icalevent.detail")) { $val = "week.listevents"; } $eventlink .= $key . "=" . $val . "&"; } $eventlink = substr($eventlink, 0, strlen($eventlink) - 1); $eventlink = JRoute::_($eventlink); $catlinks[] = '<a class="ev_link_cat" href="' . $eventlink . '" title="' . JEventsHTML::special($catname) . '">' . $catname . '</a>'; } $search[] = "{{CATEGORYLNK}}"; $replace[] = implode(", ", $catlinks); $blank[] = ""; break; case "{{CATEGORYIMG}}": $search[] = "{{CATEGORYIMG}}"; $replace[] = $event->getCategoryImage(); $blank[] = ""; break; case "{{CATEGORYIMGS}}": $search[] = "{{CATEGORYIMGS}}"; $replace[] = $event->getCategoryImage(true); $blank[] = ""; break; case "{{CATDESC}}": $search[] = "{{CATDESC}}"; $replace[] = $event->getCategoryDescription(); $blank[] = ""; break; case "{{CATID}}": $search[] = "{{CATID}}"; $replace[] = $event->catid(); $blank[] = ""; break; case "{{PARENT_CATEGORY}}": $search[] = "{{PARENT_CATEGORY}}"; $replace[] = $event->getParentCategory(); $blank[] = ""; break; case "{{ICALDIALOG}}": case "{{ICALBUTTON}}": case "{{EDITDIALOG}}": case "{{EDITBUTTON}}": static $styledone = false; if (!$styledone) { $document = JFactory::getDocument(); $document->addStyleDeclaration("div.jevdialogs {position:relative;margin-top:35px;text-align:left;}\n div.jevdialogs img{float:none!important;margin:0px}"); $styledone = true; } if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) { JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/"); $cssloaded = true; ob_start(); ?> <a href="javascript:void(0)" onclick='clickIcalButton()' title="<?php echo JText::_('JEV_SAVEICAL'); ?> "> <img src="<?php echo JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images/jevents_event_sml.png'; ?> " name="image" alt="<?php echo JText::_('JEV_SAVEICAL'); ?> " class="jev_ev_sml nothumb"/> </a> <div class="jevdialogs"> <?php $search[] = "{{ICALDIALOG}}"; if ($view) { ob_start(); $view->eventIcalDialog($event, $mask); $dialog = ob_get_clean(); $replace[] = $dialog; } else { $replace[] = ""; } $blank[] = ""; echo $dialog; ?> </div> <?php $search[] = "{{ICALBUTTON}}"; $replace[] = ob_get_clean(); $blank[] = ""; } else { $search[] = "{{ICALBUTTON}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{ICALDIALOG}}"; $replace[] = ""; $blank[] = ""; } if (JEVHelper::canEditEvent($event) || JEVHelper::canPublishEvent($event) || JEVHelper::canDeleteEvent($event)) { JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/"); ob_start(); ?> <a href="javascript:void(0)" onclick='clickEditButton()' title="<?php echo JText::_('JEV_E_EDIT'); ?> "> <?php echo JEVHelper::imagesite('edit.png', JText::_('JEV_E_EDIT')); ?> </a> <div class="jevdialogs"> <?php $search[] = "{{EDITDIALOG}}"; if ($view) { ob_start(); $view->eventManagementDialog($event, $mask); $dialog = ob_get_clean(); $replace[] = $dialog; } else { $replace[] = ""; } $blank[] = ""; echo $dialog; ?> </div> <?php $search[] = "{{EDITBUTTON}}"; $replace[] = ob_get_clean(); $blank[] = ""; } else { $search[] = "{{EDITBUTTON}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{EDITDIALOG}}"; $replace[] = ""; $blank[] = ""; } break; case "{{CREATED}}": $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT); $jtz = $compparams->get("icaltimezonelive", ""); if ($jtz == "") { $jtz = null; } $created = JevDate::getDate($event->created(), $jtz); $search[] = "{{CREATED}}"; $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED")); $blank[] = ""; break; case "{{ACCESS}}": $search[] = "{{ACCESS}}"; $replace[] = $event->getAccessName(); $blank[] = ""; break; case "{{REPEATSUMMARY}}": case "{{STARTDATE}}": case "{{ENDDATE}}": case "{{STARTTIME}}": case "{{ENDTIME}}": case "{{STARTTZ}}": case "{{ENDTZ}}": case "{{ISOSTART}}": case "{{ISOEND}}": case "{{DURATION}}": case "{{MULTIENDDATE}}": if ($template_name == "icalevent.detail_body") { $search[] = "{{REPEATSUMMARY}}"; $repeatsummary = $view->repeatSummary($event); if (!$repeatsummary) { $repeatsummary = $event->repeatSummary(); } $replace[] = $repeatsummary; //$replace[] = $event->repeatSummary(); $blank[] = ""; $row = $event; $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0); $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup()); $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0); $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn()); $stop_time_midnightFix = $stop_time; $stop_date_midnightFix = $stop_date; if ($row->sdn() == 59 && $row->mindn() == 59) { $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0); $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0); } $search[] = "{{STARTDATE}}"; $replace[] = $start_date; $blank[] = ""; $search[] = "{{ENDDATE}}"; $replace[] = $stop_date; $blank[] = ""; $search[] = "{{STARTTIME}}"; $replace[] = $row->alldayevent() ? "" : $start_time; $blank[] = ""; $search[] = "{{ENDTIME}}"; $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix; $blank[] = ""; $search[] = "{{STARTTZ}}"; $replace[] = $row->alldayevent() ? "" : $start_time; $blank[] = ""; $search[] = "{{ENDTZ}}"; $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix; $blank[] = ""; $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate(); $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate(); $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime(); $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime(); $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup(); $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn(); $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $stop_date : ""; $search[] = "{{ISOSTART}}"; $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup()); $blank[] = ""; $search[] = "{{ISOEND}}"; $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn()); $blank[] = ""; $search[] = "{{MULTIENDDATE}}"; $replace[] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : ""; $blank[] = ""; } else { $row = $event; $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0); $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup()); $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0); $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn()); $stop_time_midnightFix = $stop_time; $stop_date_midnightFix = $stop_date; if ($row->sdn() == 59 && $row->mindn() == 59) { $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0); $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0); } $search[] = "{{STARTDATE}}"; $replace[] = $start_date; $blank[] = ""; $search[] = "{{ENDDATE}}"; $replace[] = $stop_date; $blank[] = ""; $search[] = "{{STARTTIME}}"; $replace[] = $row->alldayevent() ? "" : $start_time; $blank[] = ""; $search[] = "{{ENDTIME}}"; $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix; $blank[] = ""; $search[] = "{{MULTIENDDATE}}"; $replace[] = $row->endDate() > $row->startDate() ? $stop_date : ""; $blank[] = ""; $search[] = "{{STARTTZ}}"; $replace[] = $row->alldayevent() ? "" : $start_time; $blank[] = ""; $search[] = "{{ENDTZ}}"; $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix; $blank[] = ""; $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate(); $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate(); $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime(); $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime(); $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup(); $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn(); $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : ""; if (strpos($template_value, "{{ISOSTART}}") !== false || strpos($template_value, "{{ISOEND}}") !== false) { $search[] = "{{ISOSTART}}"; $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup()); $blank[] = ""; $search[] = "{{ISOEND}}"; $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn()); $blank[] = ""; } // these would slow things down if not needed in the list $dorepeatsummary = strpos($template_value, "{{REPEATSUMMARY}}") !== false; if ($dorepeatsummary) { $cfg = JEVConfig::getInstance(); $jevtask = JRequest::getString("jevtask"); $jevtask = str_replace(".listevents", "", $jevtask); $showyeardate = $cfg->get("showyeardate", 0); $row = $event; $times = ""; if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "month.calendar" || $jevtask == "cat" || $jevtask == "range") { $start_publish = $row->getUnixStartDate(); $stop_publish = $row->getUnixEndDate(); if ($stop_publish == $start_publish) { if ($row->noendtime()) { $times = $start_time; } else { if ($row->alldayevent()) { $times = ""; } else { if ($start_time != $stop_time) { $times = $start_time . ' - ' . $stop_time_midnightFix; } else { $times = $start_time; } } } $times = $start_date . " " . $times . "<br/>"; } else { if ($row->noendtime()) { $times = $start_time; } else { if ($row->alldayevent()) { $times = ""; } else { if ($start_time != $stop_time && !$row->alldayevent()) { $times = $start_time . ' - ' . $stop_time_midnightFix; } } } $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>"; } } else { if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) { if ($row->noendtime()) { if ($showyeardate && $jevtask == "year") { $times = $start_time . ' - ' . $stop_time_midnightFix . ' '; } else { $times = $start_time . ' '; } } else { if ($row->alldayevent()) { $times = ""; } else { $times = $start_time . ' - ' . $stop_time_midnightFix . ' '; } } } } $search[] = "{{REPEATSUMMARY}}"; $replace[] = $times; $blank[] = ""; } } $search[] = "{{DURATION}}"; $timedelta = $row->noendtime() ? "" : $row->getUnixEndTime() - $row->getUnixStartTime(); if ($row->alldayevent()) { $timedelta = $row->getUnixEndDate() - $row->getUnixStartDate() + 60 * 60 * 24; } $fieldval = JText::_("JEV_DURATION_FORMAT"); $shownsign = false; // whole days! if (stripos($fieldval, "%wd") !== false) { $days = intval($timedelta / (60 * 60 * 24)); $timedelta -= $days * 60 * 60 * 24; if ($timedelta > 3610) { //if more than 1 hour and 10 seconds over a day then round up the day output $days += 1; } $fieldval = str_ireplace("%d", $days, $fieldval); $shownsign = true; } if (stripos($fieldval, "%d") !== false) { $days = intval($timedelta / (60 * 60 * 24)); $timedelta -= $days * 60 * 60 * 24; /* if ($timedelta>3610){ //if more than 1 hour and 10 seconds over a day then round up the day output $days +=1; } */ $fieldval = str_ireplace("%d", $days, $fieldval); $shownsign = true; } if (stripos($fieldval, "%h") !== false) { $hours = intval($timedelta / (60 * 60)); $timedelta -= $hours * 60 * 60; if ($shownsign) { $hours = abs($hours); } $hours = sprintf("%02d", $hours); $fieldval = str_ireplace("%h", $hours, $fieldval); $shownsign = true; } if (stripos($fieldval, "%m") !== false) { $mins = intval($timedelta / 60); $timedelta -= $hours * 60; if ($mins) { $mins = abs($mins); } $mins = sprintf("%02d", $mins); $fieldval = str_ireplace("%m", $mins, $fieldval); } $replace[] = $fieldval; $blank[] = ""; break; case "{{PREVIOUSNEXT}}": static $doprevnext; if (!isset($doprevnext)) { $doprevnext = strpos($template_value, "{{PREVIOUSNEXT}}") !== false; } if ($doprevnext) { $search[] = "{{PREVIOUSNEXT}}"; $replace[] = $event->previousnextLinks(); $blank[] = ""; } break; case "{{PREVIOUSNEXTEVENT}}": static $doprevnextevent; if (!isset($doprevnextevent)) { $doprevnextevent = strpos($template_value, "{{PREVIOUSNEXTEVENT}}") !== false; } if ($doprevnextevent) { $search[] = "{{PREVIOUSNEXTEVENT}}"; $replace[] = $event->previousnextEventLinks(); $blank[] = ""; } break; case "{{FIRSTREPEAT}}": case "{{FIRSTREPEATSTART}}": static $dofirstrepeat; if (!isset($dofirstrepeat)) { $dofirstrepeat = strpos($template_value, "{{FIRSTREPEAT}}") !== false || strpos($template_value, "{{FIRSTREPEATSTART}}") !== false; } if ($dofirstrepeat) { $search[] = "{{FIRSTREPEAT}}"; $firstrepeat = $event->getFirstRepeat(); if ($firstrepeat->rp_id() == $event->rp_id()) { $replace[] = ""; } else { $replace[] = "<a class='ev_firstrepeat' href='" . $firstrepeat->viewDetailLink($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), true) . "' title='" . JText::_('JEV_FIRSTREPEAT') . "' >" . JText::_('JEV_FIRSTREPEAT') . "</a>"; } $blank[] = ""; $search[] = "{{FIRSTREPEATSTART}}"; if ($firstrepeat->rp_id() == $event->rp_id()) { $replace[] = ""; } else { $replace[] = JEventsHTML::getDateFormat($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), 0); $rawreplace[] = $firstrepeat->yup() . "-" . $firstrepeat->mup() . "-" . $firstrepeat->dup() . " " . $firstrepeat->hup() . ":" . $firstrepeat->minup() . ":" . $firstrepeat->sup(); } $blank[] = ""; } break; case "{{LASTREPEAT}}": case "{{LASTREPEATEND}}": static $dolastrepeat; if (!isset($dolastrepeat)) { $dolastrepeat = strpos($template_value, "{{LASTREPEAT}}") !== false || strpos($template_value, "{{LASTREPEATEND}}") !== false; } if ($dolastrepeat) { $search[] = "{{LASTREPEAT}}"; $lastrepeat = $event->getLastRepeat(); if ($lastrepeat->rp_id() == $event->rp_id()) { $replace[] = ""; } else { $replace[] = "<a class='ev_lastrepeat' href='" . $lastrepeat->viewDetailLink($lastrepeat->yup(), $lastrepeat->mup(), $lastrepeat->dup(), true) . "' title='" . JText::_('JEV_LASTREPEAT') . "' >" . JText::_('JEV_LASTREPEAT') . "</a>"; } $blank[] = ""; $search[] = "{{LASTREPEATEND}}"; if ($lastrepeat->rp_id() != $event->rp_id()) { $replace[] = JEventsHTML::getDateFormat($lastrepeat->ydn(), $lastrepeat->mdn(), $lastrepeat->ddn(), 0); $rawreplace[] = $lastrepeat->ydn() . "-" . $lastrepeat->mdn() . "-" . $lastrepeat->ddn() . " " . $lastrepeat->hdn() . ":" . $lastrepeat->mindn() . ":" . $lastrepeat->sdn(); } else { $replace[] = ""; } $blank[] = ""; } break; case "{{CREATOR_LABEL}}": $search[] = "{{CREATOR_LABEL}}"; $replace[] = JText::_('JEV_BY'); $blank[] = ""; break; case "{{CREATOR}}": $search[] = "{{CREATOR}}"; $replace[] = $event->contactlink(); $blank[] = ""; break; case "{{HITS}}": $search[] = "{{HITS}}"; $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits(); $blank[] = ""; break; case "{{LOCATION_LABEL}}": case "{{LOCATION}}": if ($event->hasLocation()) { $search[] = "{{LOCATION_LABEL}}"; $replace[] = JText::_('JEV_EVENT_ADRESSE') . " "; $blank[] = ""; $search[] = "{{LOCATION}}"; $replace[] = $event->location(); $blank[] = ""; } else { $search[] = "{{LOCATION_LABEL}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{LOCATION}}"; $replace[] = ""; $blank[] = ""; } break; case "{{CONTACT_LABEL}}": case "{{CONTACT}}": if ($event->hasContactInfo()) { if (strpos($event->contact_info(), '<script') === false) { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); //Contact $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/]'; if (strpos($event->contact_info(), '<a href=') === false && $event->contact_info() != "") { $event->contact_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->contact_info())); } // NO need to call conContentPrepate since its called on the template value below here } $search[] = "{{CONTACT_LABEL}}"; $replace[] = JText::_('JEV_EVENT_CONTACT') . " "; $blank[] = ""; $search[] = "{{CONTACT}}"; $replace[] = $event->contact_info(); $blank[] = ""; } else { $search[] = "{{CONTACT_LABEL}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{CONTACT}}"; $replace[] = ""; $blank[] = ""; } break; case "{{EXTRAINFO}}": //Extra if (strpos($event->extra_info(), '<script') === false && $event->extra_info() != "") { $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/#]'; if (strpos($event->extra_info(), '<a href=') === false) { $event->extra_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->extra_info())); } //$row->extra_info(eregi_replace('[^(href=|href="|href=\')](((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $row->extra_info())); // NO need to call conContentPrepate since its called on the template value below here } $search[] = "{{EXTRAINFO}}"; $replace[] = $event->extra_info(); $blank[] = ""; break; case "{{RPID}}": $search[] = "{{RPID}}"; $replace[] = $event->rp_id(); $blank[] = ""; break; default: $strippedmatch = str_replace(array("{", "}"), "", $strippedmatch); if (is_callable(array($event, $strippedmatch))) { $search[] = "{{" . $strippedmatch . "}}"; $replace[] = $event->{$strippedmatch}(); $blank[] = ""; } break; } } // Now do the plugins // get list of enabled plugins $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail"; $jevplugins = JPluginHelper::getPlugin("jevents"); foreach ($jevplugins as $jevplugin) { $classname = "plgJevents" . ucfirst($jevplugin->name); if (is_callable(array($classname, "substitutefield"))) { if (!isset($fieldNameArray[$classname])) { $fieldNameArray[$classname] = array(); } if (!isset($fieldNameArray[$classname][$layout])) { //list($usec, $sec) = explode(" ", microtime()); //$starttime = (float) $usec + (float) $sec; $fieldNameArray[$classname][$layout] = call_user_func(array($classname, "fieldNameArray"), $layout); //list ($usec, $sec) = explode(" ", microtime()); //$time_end = (float) $usec + (float) $sec; //echo "$classname::fieldNameArray = ".round($time_end - $starttime, 4)."<br/>"; } if (isset($fieldNameArray[$classname][$layout]["values"])) { foreach ($fieldNameArray[$classname][$layout]["values"] as $fieldname) { if (!strpos($template_value, $fieldname) !== false) { continue; } $search[] = "{{" . $fieldname . "}}"; // is the event detail hidden - if so then hide any custom fields too! if (!isset($event->_privateevent) || $event->_privateevent != 3) { $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname); if (is_callable(array($classname, "blankfield"))) { $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname); } else { $blank[] = ""; } } else { $blank[] = ""; $replace[] = ""; } } } } } // word counts etc. for ($s = 0; $s < count($search); $s++) { if (strpos($search[$s], "TRUNCATED_DESC:") > 0) { global $tempreplace, $tempevent, $tempsearch; $tempreplace = $replace[$s]; $tempsearch = $search[$s]; $tempevent = $event; $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value); } } // Date/time formats etc. for ($s = 0; $s < count($search); $s++) { if (strpos($search[$s], "STARTDATE") > 0 || strpos($search[$s], "STARTTIME") > 0 || strpos($search[$s], "ENDDATE") > 0 || strpos($search[$s], "ENDTIME") > 0 || strpos($search[$s], "ENDTZ") > 0 || strpos($search[$s], "STARTTZ") > 0 || strpos($search[$s], "MULTIENDDATE") > 0 || strpos($search[$s], "FIRSTREPEATSTART") > 0 || strpos($search[$s], "LASTREPEATEND") > 0) { if (!isset($rawreplace[$search[$s]]) || !$rawreplace[$search[$s]]) { continue; } global $tempreplace, $tempevent, $tempsearch; $tempreplace = $rawreplace[$search[$s]]; $tempsearch = str_replace("}}", ";.*?}}", $search[$s]); $tempevent = $event; $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialDateFormatting', $template_value); } } for ($s = 0; $s < count($search); $s++) { global $tempreplace, $tempevent, $tempsearch, $tempblank; $tempreplace = $replace[$s]; $tempblank = $blank[$s]; $tempsearch = str_replace("}}", "#", $search[$s]); $tempevent = $event; $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value); } $template_value = str_replace($search, $replace, $template_value); if ($specialmodules) { $reg = JRegistry::getInstance("com_jevents"); $parts = explode("{{MODULESTART#", $template_value); $dynamicmodules = array(); foreach ($parts as $part) { $currentdynamicmodules = $reg->get("dynamicmodules", false); if (strpos($part, "{{MODULEEND}}") === false) { // strip out BAD HTML tags left by WYSIWYG editors if (substr($part, strlen($part) - 3) == "<p>") { $template_value = substr($part, 0, strlen($part) - 3); } else { $template_value = $part; } continue; } // start with module name $modname = substr($part, 0, strpos($part, "}}")); $modulecontent = substr($part, strpos($part, "}}") + 2); $modulecontent = substr($modulecontent, 0, strpos($modulecontent, "{{MODULEEND}}")); // strip out BAD HTML tags left by WYSIWYG editors if (strpos($modulecontent, "</p>") === 0) { $modulecontent = "<p>x@#" . $modulecontent; } if (substr($modulecontent, strlen($modulecontent) - 3) == "<p>") { $modulecontent .= "x@#</p>"; } $modulecontent = str_replace("<p>x@#</p>", "", $modulecontent); if (isset($currentdynamicmodules[$modname])) { if (!is_array($currentdynamicmodules[$modname])) { $currentdynamicmodules[$modname] = array($currentdynamicmodules[$modname]); } $currentdynamicmodules[$modname][] = $modulecontent; $dynamicmodules[$modname] = $currentdynamicmodules[$modname]; } else { $dynamicmodules[$modname] = $modulecontent; } } $reg->set("dynamicmodules", $dynamicmodules); } // non greedy replacement - because of the ? $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value); // replace [[ with { to that other content plugins can work ok - but not for calendar cell or tooltip since we use [[ there already! if ($template_name != "month.calendar_cell" && $template_name != "month.calendar_tip") { $template_value = str_replace(array("[[", "]]"), array("{", "}"), $template_value); } //We add new line characters again to avoid being marked as SPAM when using tempalte in emails // do this before content plugins incase they insert javascript etc. $template_value = preg_replace("@(<\\s*(br)*\\s*\\/\\s*(p|td|tr|table|div|ul|li|ol|dd|dl|dt)*\\s*>)+?@i", "\$1\n", $template_value); // Call content plugins - BUT because emailcloak doesn't identify emails in input fields to a text substitution $template_value = str_replace("@", "@£@", $template_value); $params = new JRegistry(null); $tmprow = new stdClass(); $tmprow->text = $template_value; $tmprow->event = $event; $dispatcher = JDispatcher::getInstance(); JPluginHelper::importPlugin('content'); $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0)); $template_value = $tmprow->text; $template_value = str_replace("@£@", "@", $template_value); echo $template_value; return true; }
/** * override store function to force rrule to save too! * * @param unknown_type $updateNulls */ function store($updateNulls = false, $overwriteCreator = false) { $user = JFactory::getUser(); if ($this->ev_id == 0) { $date = JevDate::getDate("+0 seconds"); $this->created = $date->toMySQL(); } if (!isset($this->created_by) || is_null($this->created_by) || $this->created_by == 0) { $this->created_by = $user->id; } $this->modified_by = $user->id; if (!isset($this->created_by_alias) || is_null($this->created_by_alias) || $this->created_by_alias == "") { $this->created_by_alias = ""; } // make sure I update existing detail $matchingDetail = $this->matchingEventDetails(); if (isset($matchingDetail) && isset($matchingDetail->evdet_id)) { $this->_detail->evdet_id = $matchingDetail->evdet_id; } // if existing row preserve created by - unless being overwritten by authorised user // If user is jevents can deleteall or has backend access then allow them to specify the creator $jevuser = JEVHelper::getAuthorisedUser(); $creatorid = JRequest::getInt("jev_creatorid", 0); $access = false; if ($user->get('id') > 0) { //$access = JAccess::check($user->id, "core.deleteall","com_jevents"); $access = $user->authorise('core.deleteall', 'com_jevents'); } if (!($jevuser && $jevuser->candeleteall || $access) || $creatorid == 0) { if (!is_null($this->ev_id) || $this->ev_id > 0) { // we can overwrite the creator if refreshing/saving an ical with specified creator if (isset($matchingDetail) && $matchingDetail->created_by > 0 && !$overwriteCreator) { $this->created_by = $matchingDetail->created_by; } } } // place private reference to created_by in event detail in case needed by plugins $this->_detail->_created_by = $this->created_by; $db = JFactory::getDBO(); $detailid = $this->_detail->store($updateNulls); if (!$detailid) { JError::raiseError(104, JText::_('PROBLEMS_STORING_EVENT_DETAIL')); echo $db->getErrorMsg() . "<br/>"; return false; } $this->detail_id = $detailid; // Keep the multiple catids for storing after this $catids = false; if (is_array($this->catid)) { $catids = $this->catid; $this->catid = $this->catid[0]; } if (!parent::store($updateNulls)) { JError::raiseError(105, JText::_('PROBLEMS_STORING_EVENT')); echo $db->getErrorMsg() . "<br/>"; return false; } if ($catids) { $pairs = array(); $order = 0; foreach ($catids as $catid) { if ($catid == "") { $catid = -1; } else { $pairs[] = "({$this->ev_id},{$catid}, {$order})"; $order++; } } $db->setQuery("DELETE FROM #__jevents_catmap where evid = " . $this->ev_id . " AND catid NOT IN (" . implode(",", $catids) . ")"); $sql = $db->getQuery(); $success = $db->query(); if (count($pairs) > 0) { $db->setQuery("Replace into #__jevents_catmap (evid, catid, ordering) VALUES " . implode(",", $pairs)); $sql = $db->getQuery(); $success = $db->query(); } } // I also need to store custom data - when we need the event itself and not just the detail $dispatcher = JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onStoreCustomEvent', array(&$this)); if (isset($this->rrule)) { $this->rrule->eventid = $this->ev_id; if ($id = $this->rrule->isDuplicate()) { $this->rrule->rr_id = $id; } $this->rrule->store($updateNulls); echo $db->getErrorMsg() . "<br/>"; } return true; }
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask) { $db = JFactory::getDBO(); // find published template static $templates; if (!isset($templates)) { $templates = array(); } if (!array_key_exists($template_name, $templates)) { $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name)); $templates[$template_name] = $db->loadObject(); } if (is_null($templates[$template_name]) || $templates[$template_name]->value == "") { return false; } $template = $templates[$template_name]; // now replace the fields $search = array(); $replace = array(); $blank = array(); $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT); // Built in fields $search[] = "{{TITLE}}"; $replace[] = $event->title(); $blank[] = ""; // Title link $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false); $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink()); ob_start(); ?> <a class="ev_link_row" href="<?php echo $rowlink; ?> " style="font-weight:bold;" title="<?php echo JEventsHTML::special($event->title()); ?> "> <?php $linkstart = ob_get_clean(); $search[] = "{{LINK}}"; $replace[] = $rowlink; $blank[] = ""; $search[] = "{{LINKSTART}}"; $replace[] = $linkstart; $blank[] = ""; $search[] = "{{LINKEND}}"; $replace[] = "</a>"; $blank[] = ""; $fulllink = $linkstart . $event->title() . '</a>'; $search[] = "{{TITLE_LINK}}"; $replace[] = $fulllink; $blank[] = ""; $search[] = "{{URL}}"; $replace[] = $event->url(); $blank[] = ""; $search[] = "{{TRUNCATED_DESC:.*}}"; $replace[] = $event->content(); $blank[] = ""; // $search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content(); $search[] = "{{DESCRIPTION}}"; $replace[] = $event->content(); $blank[] = ""; $search[] = "{{MANAGEMENT}}"; ob_start(); $view->_viewNavAdminPanel(); $replace[] = ob_get_clean(); $blank[] = ""; $search[] = "{{CATEGORY}}"; $replace[] = $event->catname(); $blank[] = ""; $bgcolor = $event->bgcolor(); $search[] = "{{COLOUR}}"; $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor; $blank[] = ""; $search[] = "{{FGCOLOUR}}"; $replace[] = $event->fgcolor(); $blank[] = ""; $search[] = "{{TTTIME}}"; $replace[] = "[[TTTIME]]"; $blank[] = ""; $search[] = "{{EVTTIME}}"; $replace[] = "[[EVTTIME]]"; $blank[] = ""; $search[] = "{{TOOLTIP}}"; $replace[] = "[[TOOLTIP]]"; $blank[] = ""; $router = JRouter::getInstance("site"); $vars = $router->getVars(); $vars["catids"] = $event->catid(); $eventlink = "index.php?"; foreach ($vars as $key => $val) { $eventlink .= $key . "=" . $val . "&"; } $eventlink = substr($eventlink, 0, strlen($eventlink) - 1); $eventlink = JRoute::_($eventlink); $catlink = '<a class="ev_link_cat" href="' . $eventlink . '" title="' . JEventsHTML::special($event->catname()) . '">' . $event->catname() . '</a>'; $search[] = "{{CATEGORYLNK}}"; $replace[] = $catlink; $blank[] = ""; $search[] = "{{CATEGORYIMG}}"; $replace[] = $event->getCategoryImage(); $blank[] = ""; static $styledone = false; if (!$styledone) { $document = JFactory::getDocument(); $document->addStyleDeclaration("div.jevdialogs {position:relative;margin-top:35px;text-align:left;}\n div.jevdialogs img{float:none!important;margin:0px}"); $styledone = true; } if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) { JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/"); $cssloaded = true; ob_start(); ?> <a href="javascript:void(0)" onclick='clickIcalButton()' title="<?php echo JText::_('JEV_SAVEICAL'); ?> "> <img src="<?php echo JURI::root() . 'administrator/components/' . JEV_COM_COMPONENT . '/assets/images/jevents_event_sml.png'; ?> " align="middle" name="image" alt="<?php echo JText::_('JEV_SAVEICAL'); ?> " style="height:24px;"/> </a> <div class="jevdialogs"> <?php $search[] = "{{ICALDIALOG}}"; ob_start(); $view->eventIcalDialog($event, $mask); $dialog = ob_get_clean(); $replace[] = $dialog; $blank[] = ""; echo $dialog; ?> </div> <?php $search[] = "{{ICALBUTTON}}"; $replace[] = ob_get_clean(); $blank[] = ""; } else { $search[] = "{{ICALBUTTON}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{ICALDIALOG}}"; $replace[] = ""; $blank[] = ""; } if ((JEVHelper::canEditEvent($event) || JEVHelper::canPublishEvent($event) || JEVHelper::canDeleteEvent($event)) && !($mask & MASK_POPUP)) { JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/"); ob_start(); ?> <a href="javascript:void(0)" onclick='clickEditButton()' title="<?php echo JText::_('JEV_E_EDIT'); ?> "> <?php echo JEVHelper::imagesite('edit.png', JText::_('JEV_E_EDIT')); ?> </a> <div class="jevdialogs"> <?php $search[] = "{{EDITDIALOG}}"; ob_start(); $view->eventManagementDialog($event, $mask); $dialog = ob_get_clean(); $replace[] = $dialog; $blank[] = ""; echo $dialog; ?> </div> <?php $search[] = "{{EDITBUTTON}}"; $replace[] = ob_get_clean(); $blank[] = ""; } else { $search[] = "{{EDITBUTTON}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{EDITDIALOG}}"; $replace[] = ""; $blank[] = ""; } $created = JevDate::getDate($event->created()); $search[] = "{{CREATED}}"; $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED")); $blank[] = ""; if ($template_name == "icalevent.detail_body") { $search[] = "{{REPEATSUMMARY}}"; $replace[] = $event->repeatSummary(); $blank[] = ""; $row = $event; $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0); $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup()); $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0); $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn()); $stop_time_midnightFix = $stop_time; $stop_date_midnightFix = $stop_date; if ($row->sdn() == 59 && $row->mindn() == 59) { $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0); $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0); } $search[] = "{{STARTDATE}}"; $replace[] = $start_date; $blank[] = ""; $search[] = "{{ENDDATE}}"; $replace[] = $stop_date; $blank[] = ""; $search[] = "{{STARTTIME}}"; $replace[] = $start_time; $blank[] = ""; $search[] = "{{ENDTIME}}"; $replace[] = $stop_time_midnightFix; $blank[] = ""; } else { $row = $event; $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0); $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup()); $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0); $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn()); $stop_time_midnightFix = $stop_time; $stop_date_midnightFix = $stop_date; if ($row->sdn() == 59 && $row->mindn() == 59) { $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0); $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0); } $search[] = "{{STARTDATE}}"; $replace[] = $start_date; $blank[] = ""; $search[] = "{{ENDDATE}}"; $replace[] = $stop_date; $blank[] = ""; $search[] = "{{STARTTIME}}"; $replace[] = $start_time; $blank[] = ""; $search[] = "{{ENDTIME}}"; $replace[] = $stop_time_midnightFix; $blank[] = ""; // these would slow things down if not needed in the list static $dorepeatsummary; if (!isset($dorepeatsummary)) { $dorepeatsummary = strpos($template->value, ":REPEATSUMMARY}}") !== false; } if ($dorepeatsummary) { $cfg =& JEVConfig::getInstance(); $jevtask = JRequest::getString("jevtask"); $jevtask = str_replace(".listevents", "", $jevtask); $showyeardate = $cfg->get("showyeardate", 0); $row = $event; $times = ""; if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "cat" || $jevtask == "range") { $start_publish = $row->getUnixStartDate(); $stop_publish = $row->getUnixEndDate(); if ($stop_publish == $start_publish) { if ($row->noendtime()) { $times = $start_time; } else { if ($row->alldayevent()) { $times = ""; } else { if ($start_time != $stop_time) { $times = $start_time . ' - ' . $stop_time_midnightFix; } else { $times = $start_time; } } } $times = $start_date . " " . $times . "<br/>"; } else { if ($row->noendtime()) { $times = $start_time; } else { if ($start_time != $stop_time && !$row->alldayevent()) { $times = $start_time . ' - ' . $stop_time_midnightFix; } } $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>"; } } else { if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) { if ($row->noendtime()) { if ($showyeardate && $jevtask == "year") { $times = $start_time . ' - ' . $stop_time_midnightFix . ' '; } else { $times = $start_time . ' '; } } else { $times = $start_time . ' - ' . $stop_time_midnightFix . ' '; } } } $search[] = "{{REPEATSUMMARY}}"; $replace[] = $times; $blank[] = ""; } } static $doprevnext; if (!isset($doprevnext)) { $doprevnext = strpos($template->value, ":PREVIOUSNEXT}}") !== false; } if ($doprevnext) { $search[] = "{{PREVIOUSNEXT}}"; $replace[] = $event->previousnextLinks(); $blank[] = ""; } $search[] = "{{CREATOR_LABEL}}"; $replace[] = JText::_('JEV_BY'); $blank[] = ""; $search[] = "{{CREATOR}}"; $replace[] = $event->contactlink(); $blank[] = ""; $search[] = "{{HITS}}"; $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits(); $blank[] = ""; if ($event->hasLocation()) { $search[] = "{{LOCATION_LABEL}}"; $replace[] = JText::_('JEV_EVENT_ADRESSE') . " "; $blank[] = ""; $search[] = "{{LOCATION}}"; $replace[] = $event->location(); $blank[] = ""; } else { $search[] = "{{LOCATION_LABEL}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{LOCATION}}"; $replace[] = ""; $blank[] = ""; } if ($event->hasContactInfo()) { $search[] = "{{CONTACT_LABEL}}"; $replace[] = JText::_('JEV_EVENT_CONTACT') . " "; $blank[] = ""; $search[] = "{{CONTACT}}"; $replace[] = $event->contact_info(); $blank[] = ""; } else { $search[] = "{{CONTACT_LABEL}}"; $replace[] = ""; $blank[] = ""; $search[] = "{{CONTACT}}"; $replace[] = ""; $blank[] = ""; } $search[] = "{{EXTRAINFO}}"; $replace[] = $event->extra_info(); $blank[] = ""; // Now do the plugins // get list of enabled plugins $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail"; $jevplugins = JPluginHelper::getPlugin("jevents"); foreach ($jevplugins as $jevplugin) { $classname = "plgJevents" . ucfirst($jevplugin->name); if (is_callable(array($classname, "substitutefield"))) { $fieldNameArray = call_user_func(array($classname, "fieldNameArray"), $layout); if (isset($fieldNameArray["values"])) { foreach ($fieldNameArray["values"] as $fieldname) { $search[] = "{{" . $fieldname . "}}"; // is the event detail hidden - if so then hide any custom fields too! if (!isset($event->_privateevent) || $event->_privateevent != 3) { $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname); if (is_callable(array($classname, "blankfield"))) { $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname); } else { $blank[] = ""; } } else { $blank[] = ""; $replace[] = ""; } } } } } $template_value = $template->value; // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field $template_value = str_replace("\r", '', $template_value); $template_value = str_replace("\n", '', $template_value); // non greedy replacement - because of the ? $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value); // word counts etc. for ($s = 0; $s < count($search); $s++) { if (strpos($search[$s], "TRUNCATED_DESC:") > 0) { global $tempreplace, $tempevent, $tempsearch; $tempreplace = $replace[$s]; $tempsearch = $search[$s]; $tempevent = $event; $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value); } } for ($s = 0; $s < count($search); $s++) { global $tempreplace, $tempevent, $tempsearch, $tempblank; $tempreplace = $replace[$s]; $tempblank = $blank[$s]; $tempsearch = str_replace("}}", "#", $search[$s]); $tempevent = $event; $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value); } $template_value = str_replace($search, $replace, $template_value); // non greedy replacement - because of the ? $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value); echo $template_value; return true; }