if ($cfg->get("show_webcal_google", 0) == 1) { echo $this->ExportGoogle($publiclink, $privatelink); } } if ($cfg->get("outlook2003icalexport", 0) == 0 && $cfg->get("show_ical_download", 1) == 0 && $cfg->get("show_webcal_url", 0) == 0 && $cfg->get("show_webcal_google", 0) && $cfg->get("outlook2003icalexport", 0)) { //If non are enabled we don't want to have user thinking the script is buggy as nothing is produced. echo "<div style='margin:15px;font-weight:bold;'>" . JText::_("JEV_ICAL_ALL_DISABLED") . "</div>"; } else { ?> <div class="export_form"> <form id="ical" name="ical" method="post" class="<?php isset($_POST['submit']) ? 'icalexportresults' : ''; ?> "> <?php $categories = JEV_CommonFunctions::getCategoryData(); ?> <div class='choosecat' style='float:left;width:300px;'> <?php echo "<h3>" . JText::_('JEV_EVENT_CHOOSE_CATEG') . "</h3>\n"; // All categories $cb = "<input name=\"categories[]\" value=\"0\" type=\"checkbox\" onclick='clearIcalCategories(this);' "; $checked = false; if (!JRequest::getVar('categories', 0, 'POST')) { $cb = $cb . " CHECKED"; $checked = true; } else { if (JRequest::getVar('categories', 0, 'POST') && in_array(0, JRequest::getVar('categories', '', 'POST'))) { $cb = $cb . " CHECKED"; $checked = true; }
function setColor($row) { $cfg =& JEVConfig::getInstance(); static $catData; if (!isset($catData)) { $catData = JEV_CommonFunctions::getCategoryData(); } if (is_object($row) && strtolower(get_class($row)) != "stdclass") { if ($cfg->get('com_calForceCatColorEventForm', 2) == '2') { $color = $row->catid() > 0 && isset($catData[$row->catid()]) ? $catData[$row->catid()]->color : '#333333'; } else { $color = $row->useCatColor() ? $row->catid() > 0 && isset($catData[$row->catid()]) ? $catData[$row->catid()]->color : '#333333' : $row->color_bar(); } } else { if ($cfg->get('com_calForceCatColorEventForm', 2) == '2') { $color = $row->catid > 0 && isset($catData[$row->catid()]) ? $catData[$row->catid]->color : '#333333'; } else { $color = $row->useCatColor ? $row->catid > 0 && isset($catData[$row->catid()]) ? $catData[$row->catid]->color : '#333333' : $row->color_bar; } } //$color = $row->useCatColor ? ( $row->catid > 0 ) ? $catData[$row->catid]->color : '#333333' : $row->color_bar; return $color; }
/** * List Icals * */ function overview() { // get the view $this->view =& $this->getView("icals", "html"); $this->_checkValidCategories(); $option = JEV_COM_COMPONENT; $db =& JFactory::getDBO(); $catid = intval(JFactory::getApplication()->getUserStateFromRequest("catid{$option}", 'catid', 0)); $limit = intval(JFactory::getApplication()->getUserStateFromRequest("viewlistlimit", 'limit', 10)); $limitstart = intval(JFactory::getApplication()->getUserStateFromRequest("view{$option}limitstart", 'limitstart', 0)); $search = JFactory::getApplication()->getUserStateFromRequest("search{$option}", 'search', ''); $search = $db->getEscaped(trim(strtolower($search))); $where = array(); if ($search) { $where[] = "LOWER(icsf.label) LIKE '%{$search}%'"; } if ($catid > 0) { $where[] = "catid = {$catid}"; } // get the total number of records $query = "SELECT count(*)" . "\n FROM #__jevents_icsfile AS icsf" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); $db->setQuery($query); $total = $db->loadResult(); echo $db->getErrorMsg(); if ($limitstart > $total) { $limitstart = 0; } if (JVersion::isCompatible("1.6.0")) { $query = "SELECT icsf.*, a.title as _groupname" . "\n FROM #__jevents_icsfile as icsf " . "\n LEFT JOIN #__viewlevels AS a ON a.id = icsf.access" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); } else { $query = "SELECT icsf.*, g.name AS _groupname" . "\n FROM #__jevents_icsfile as icsf " . "\n LEFT JOIN #__groups AS g ON g.id = icsf.access" . (count($where) ? "\n WHERE " . implode(' AND ', $where) : ''); } $query .= "\n ORDER BY icsf.isdefault DESC, icsf.label ASC"; if ($limit > 0) { $query .= "\n LIMIT {$limitstart}, {$limit}"; } $db->setQuery($query); $rows = $db->loadObjectList(); $catData = JEV_CommonFunctions::getCategoryData(); for ($s = 0; $s < count($rows); $s++) { $row =& $rows[$s]; if (array_key_exists($row->catid, $catData)) { $row->category = $catData[$row->catid]->name; } else { $row->category = "?"; } } if ($this->_debug) { echo '[DEBUG]<br />'; echo 'query:'; echo '<pre>'; echo $query; echo '-----------<br />'; echo 'option "' . $option . '"<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, true, false, 0, 'catid'); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); // Set the layout $this->view->setLayout('overview'); $this->view->assign('option', JEV_COM_COMPONENT); $this->view->assign('rows', $rows); $this->view->assign('clist', $clist); $this->view->assign('search', $search); $this->view->assign('pageNav', $pageNav); $this->view->display(); }
/** * 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(); }
public static function setColours($row) { $cfg = JEVConfig::getInstance(); if (!$cfg->get("multicategory", 0)) { return array(JEV_CommonFunctions::setColor($row)); } static $catData; if (!isset($catData)) { $catData = JEV_CommonFunctions::getCategoryData(); } $colours = array(); foreach ($row->catids() as $catid) { if (is_object($row) && strtolower(get_class($row)) != "stdclass") { if ($cfg->get('com_calForceCatColorEventForm', 2) == '2') { $colors[] = $catid > 0 && isset($catData[$catid]) ? $catData[$catid]->color : '#333333'; } else { $colors[] = $row->useCatColor() ? $catid > 0 && isset($catData[$catid]) ? $catData[$catid]->color : '#333333' : $row->color_bar(); } } else { if ($cfg->get('com_calForceCatColorEventForm', 2) == '2') { $colors[] = $row->catid > 0 && isset($catData[$catid]) ? $catData[$row->catid]->color : '#333333'; } else { $colors[] = $row->useCatColor ? $row->catid > 0 && isset($catData[$catid]) ? $catData[$row->catid]->color : '#333333' : $row->color_bar; } } } return $colors; }