function getIcalByIcsid($icsid) { $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $query = "SELECT *" . "\n FROM #__jevents_icsfile as ical" . "\n WHERE ical.ics_id = {$icsid}" . "\n AND ical.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $db->setQuery($query); $row = $db->loadObject(); return $row; }
function monthEvents() { $modid = intval(JRequest::getVar('modid', 0)); $user = JFactory::getUser(); $query = "SELECT id, params" . "\n FROM #__modules AS m" . "\n WHERE m.published = 1" . "\n AND m.id = " . $modid . "\n AND m.access IN (" . JEVHelper::getAid($user, 'string') . ")" . "\n AND m.client_id != 1"; $db = JFactory::getDBO(); $db->setQuery($query); $modules = $db->loadObjectList(); if (count($modules) <= 0) { if (!$modid <= 0) { return new JResponseJson(array()); } } $params = new JRegistry(isset($modules[0]->params) ? $modules[0]->params : null); $reg = JFactory::getConfig(); $reg->set("jev.modparams", $params); $this->datamodel = new JEventsDataModel(); $myItemid = $this->datamodel->setupModuleCatids($params); $year = JRequest::getVar('jev_current_year', 0); $month = JRequest::getVar('jev_current_month', 0); if ($year == 0) { $year = date("Y"); } if ($month == 0) { $month = date("m"); } $data = $this->datamodel->getCalendarData($year, $month, 1, false, 0); $events = array(); foreach ($data['dates'] as $day_index) { foreach ($day_index['events'] as $event) { $eventArray['date'] = $day_index['year'] . "-" . $day_index['month'] . "-" . $day_index['d0'] . " " . date("H:i", $event->getUnixStartTime()); $eventArray['title'] = $event->title(); $link = $event->viewDetailLink($day_index['year'], $day_index['month'], $day_index['d0'], false, $myItemid); $eventArray['link'] = JRoute::_($link . $this->datamodel->getCatidsOutLink()); $events[] = $eventArray; } } $result = new JResponseJson($events); echo $result; }
function select() { JRequest::checkToken('default') or jexit('Invalid Token'); $db = JFactory::getDBO(); $publishedOnly = true; $id = JRequest::getInt('evid', 0); $limit = intval(JFactory::getApplication()->getUserStateFromRequest("viewlistlimit", 'limit', 10)); $limitstart = intval(JFactory::getApplication()->getUserStateFromRequest("view{" . JEV_COM_COMPONENT . "}limitstart", 'limitstart', 0)); $user = JFactory::getUser(); $where[] = "\n ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $where[] = "\n icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $query = "SELECT count( DISTINCT rpt.rp_id)" . "\n 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" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n WHERE ev.ev_id=" . $id . "\n AND icsf.state=1" . (count($where) ? "\n AND " . implode(' AND ', $where) : '') . ($publishedOnly ? "\n AND ev.state=1" : ""); $db->setQuery($query); $total = $db->loadResult(); if ($limit > $total) { $limitstart = 0; } $query = "SELECT ev.*, rpt.*, rr.*, det.*" . "\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_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" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n WHERE ev.ev_id=" . $id . "\n AND icsf.state=1" . ($publishedOnly ? "\n AND ev.state=1" : "") . (count($where) ? "\n AND " . implode(' AND ', $where) : '') . "\n GROUP BY rpt.rp_id" . "\n ORDER BY rpt.startrepeat"; if ($limit > 0) { $query .= "\n LIMIT {$limitstart}, {$limit}"; } $db->setQuery($query); $icalrows = $db->loadObjectList(); $icalcount = count($icalrows); for ($i = 0; $i < $icalcount; $i++) { // convert rows to jIcalEvents $icalrows[$i] = new jIcalEventRepeat($icalrows[$i]); } $menulist = $this->targetMenu(JRequest::getInt("Itemid"), "Itemid"); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); // get the view $this->view = $this->getView("icalrepeat", "html"); // Set the layout $this->view->setLayout('select'); $this->view->assign('menulist', $menulist); $this->view->assign('icalrows', $icalrows); $this->view->assign('pageNav', $pageNav); $this->view->assign('evid', $id); $this->view->display(); }
function export() { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $years = JRequest::getVar('years', 'NONE'); $cats = JRequest::getVar('catids', 'NONE'); // validate the key $icalkey = $params->get("icalkey", "secret phrase"); $outlook2003icalexport = JRequest::getInt("outlook2003", 0) && $params->get("outlook2003icalexport", 0); if ($outlook2003icalexport) { JRequest::setVar("icf", 1); } $privatecalendar = false; $k = JRequest::getString("k", "NONE"); $pk = JRequest::getString("pk", "NONE"); $userid = JRequest::getInt("i", 0); if ($pk != "NONE") { if (!$userid) { throw new Exception(JText::_('JEV_ERROR'), 403); return false; } $privatecalendar = true; $puser = JUser::getInstance($userid); $key = md5($icalkey . $cats . $years . $puser->password . $puser->username . $puser->id); if ($key != $pk) { throw new Exception(JText::_('JEV_ERROR'), 403); return false; } // ensure "user" can access non-public categories etc. $this->dataModel->aid = JEVHelper::getAid($puser); $this->dataModel->accessuser = $puser->get('id'); $registry = JRegistry::getInstance("jevents"); $registry->set("jevents.icaluser", $puser); } else { if ($k != "NONE") { if ($params->get("disableicalexport", 0)) { throw new Exception(JText::_('ALERTNOTAUTH'), 403); return false; } $key = md5($icalkey . $cats . $years); if ($key != $k) { throw new Exception(JText::_('JEV_ERROR'), 403); return false; } } else { throw new Exception(JText::_('JEV_ERROR'), 403); return false; } } // Fix the cats $cats = explode(',', $cats); // hardening! JEVHelper::forceIntegerArray($cats, false); if ($cats != array(0)) { JRequest::setVar("catids", implode("|", $cats)); } else { JRequest::setVar("catids", ''); } //Parsing variables from URL //Year // All years if ($years == 0) { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $years = array(); for ($y = JEVHelper::getMinYear(); $y <= JEVHelper::getMaxYear(); $y++) { if (!in_array($y, $years)) { $years[] = $y; } } JArrayHelper::toInteger($years); } else { if ($years != "NONE") { $years = explode(",", JRequest::getVar('years')); if (!is_array($years) || count($years) == 0) { list($y, $m, $d) = JEVHelper::getYMD(); $years = array($y); } JArrayHelper::toInteger($years); } else { list($y, $m, $d) = JEVHelper::getYMD(); $years = array($y); } } // Lockin hte categories from the URL $Itemid = JRequest::getInt("Itemid", 0); if (!$Itemid) { JRequest::setVar("Itemid", 1); } $this->dataModel->setupComponentCatids(); $dispatcher = JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); //And then the real work // Force all only the one repeat $cfg = JEVConfig::getInstance(); $cfg->set('com_showrepeats', 0); $icalEvents = array(); foreach ($years as $year) { $startdate = $year . "-01-01"; $enddate = $year . "-12-31"; $rows = $this->dataModel->getRangeData($startdate, $enddate, 0, 0); if (!isset($rows["rows"])) { continue; } foreach ($rows["rows"] as $row) { if (!array_key_exists($row->ev_id(), $icalEvents)) { $dispatcher->trigger('onExportRow', array(&$row)); $icalEvents[$row->ev_id()] = $row; } } unset($rows); } if ($userid) { $user = JUser::getInstance($userid); } $mainframe = JFactory::getApplication(); // get the view $this->view = $this->getView("icals", "html"); $this->view->setLayout("export"); $this->view->assign("dataModel", $this->dataModel); $this->view->assign("outlook2003icalexport", $outlook2003icalexport); $this->view->assign("icalEvents", $icalEvents); $this->view->assign("withrepeats", true); $this->view->export(); return; }
/** * Returns contact details or user details as fall back * * @param int id key of user * @param string attrib Requested attribute of the user object * @return mixed row Attribute or row object */ public static function getContact($id, $attrib = 'Object') { $db = JFactory::getDBO(); static $rows = array(); if ($id <= 0) { return null; } if (!isset($rows[$id])) { $user = JFactory::getUser(); $rows[$id] = null; $query = "SELECT ju.id, ju.name, ju.username, ju.sendEmail, ju.email, cd.name as contactname, " . ' CASE WHEN CHAR_LENGTH(cd.alias) THEN CONCAT_WS(\':\', cd.id, cd.alias) ELSE cd.id END as slug, ' . ' CASE WHEN CHAR_LENGTH(cat.alias) THEN CONCAT_WS(\':\', cat.id, cat.alias) ELSE cat.id END AS catslug ' . " \n FROM #__users AS ju" . "\n LEFT JOIN #__contact_details AS cd ON cd.user_id = ju.id " . "\n LEFT JOIN #__categories AS cat ON cat.id = cd.catid " . "\n WHERE block ='0'" . "\n AND cd.published =1 " . "\n AND cd.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND cat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND ju.id = " . $id; $db->setQuery($query); $rows[$id] = $db->loadObject(); if (is_null($rows[$id])) { // if the user has been deleted then try to suppress the warning // this causes a problem in Joomla 2.5.1 on some servers if (version_compare(JVERSION, '2.5', '>=')) { $rows[$id] = JEVHelper::getUser($id); } else { $handlers = JError::getErrorHandling(2); JError::setErrorHandling(2, "ignore"); $rows[$id] = JEVHelper::getUser($id); foreach ($handlers as $handler) { if (!is_array($handler)) { JError::setErrorHandling(2, $handler); } } if ($rows[$id]) { $error = JError::getError(true); } } } } if ($attrib == 'Object') { return $rows[$id]; } elseif (isset($rows[$id]->{$attrib})) { return $rows[$id]->{$attrib}; } else { return null; } }
function getCatData($catids, $showRepeats = true, $limit = 0, $limitstart = 0, $order = "rpt.startrepeat asc, rpt.endrepeat ASC, det.summary ASC") { $data = array(); $Itemid = JEVHelper::getItemid(); $db =& JFactory::getDBO(); include_once JPATH_ADMINISTRATOR . "/components/" . JEV_COM_COMPONENT . "/libraries/colorMap.php"; $cfg =& JEVConfig::getInstance(); $counter = $this->queryModel->countEventsByCat($catids); $total = $this->queryModel->countIcalEventsByCat($catids, $showRepeats); $counter += $total; $data['total'] = $counter; //$limit = $limit ? $limit : $cfg->get('com_calEventListRowsPpg'); if ($data['total'] <= $limit || $limitstart > $data['total']) { $limitstart = 0; } $data['limit'] = $limit; $data['limitstart'] = $limitstart; $rows = $this->queryModel->listEventsByCat($catids, $limitstart, $limit); $icalrows = $this->queryModel->listIcalEventsByCat($catids, $showRepeats, $total, $limitstart, $limit, $order); $rows = array_merge($icalrows, $rows); $num_events = count($rows); if (count($catids) == 0 || count($catids) == 1 && $catids[0] == "") { // We are using the filter instead $tempcat = JRequest::getVar("category_fv", 0); $catids = array(); $catids[] = $tempcat; } else { // Override multiple categories using the filter instead $tempcat = JFactory::getApplication()->getUserStateFromRequest('category_fv_ses', 'category_fv', 0); if ($tempcat > 0) { $catids = array(); $catids[] = $tempcat; } } $catdesc = ""; $catname = ""; if (count($catids) > 1) { $catname = JText::_('JEV_EVENT_CHOOSE_CATEG'); } if ($num_events > 0) { if (count($catids) == 1 && $catids[0] != 0) { $catname = $rows[0]->getCategoryName(); $catdesc = $rows[0]->getCategoryDescription(); foreach ($rows as $row) { if ($row->getCategoryName() != $catname) { $catname = JText::_('JEV_EVENT_CHOOSE_CATEG'); break; } } } else { $catname = ""; $catdesc = ""; } } else { if (count($catids) == 0) { $catname = JText::_('JEV_EVENT_CHOOSE_CATEG'); } else { if (count($catids) == 1 && $catids[0] != 0) { // get the cat name from the database $db =& JFactory::getDBO(); $user =& JFactory::getUser(); $catsql = 'SELECT c.title, c.description FROM #__categories AS c' . ' WHERE c.access ' . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . ' AND c.' . (JVersion::isCompatible("1.6.0") ? 'extension' : 'section') . ' = ' . $db->Quote(JEV_COM_COMPONENT) . ' AND c.id = ' . $db->Quote($catids[0]); $db->setQuery($catsql); $catdata = $db->loadObject(); if ($catdata) { $catname = $catdata->title; $catdesc = $catdata->description; } else { $catname = JText::_('JEV_EVENT_ALLCAT'); } } } } $data['catname'] = $catname; $data['catdesc'] = $catdesc; $data['catids'] = $catids; if ($num_events > 0) { for ($r = 0; $r < $num_events; $r++) { $row =& $rows[$r]; if ($row->catname() == "") { $row->catname($catname); // for completeness of dataset } } } $data['rows'] = $rows; return $data; }
/** * Pseudo Constructor * */ function setup(&$params, $modid) { $this->modid = $modid; $user = JFactory::getUser(); $cfg = JEVConfig::getInstance(); $db = JFactory::getDBO(); $this->datamodel = new JEventsDataModel(); // component config object $jevents_config = JEVConfig::getInstance(); $this->modparams =& $params; $this->aid = JEVHelper::getAid($user, 'string'); // RSH modified getAid to handle different return types 10/26/10 $tmplang = JFactory::getLanguage(); // get params exclusive to module $this->inc_ec_css = $this->modparams->get('inc_ec_css', 0); $this->minical_showlink = $this->modparams->get('minical_showlink', 1); $this->minical_prevyear = $this->modparams->get('minical_prevyear', 1); $this->minical_prevmonth = $this->modparams->get('minical_prevmonth', 1); $this->minical_actmonth = $this->modparams->get('minical_actmonth', 1); $this->minical_actmonth = $this->modparams->get('minical_actmonth', 1); $this->minical_actyear = $this->modparams->get('minical_actyear', 1); $this->minical_nextmonth = $this->modparams->get('minical_nextmonth', 1); $this->minical_nextyear = $this->modparams->get('minical_nextyear', 1); // get params exclusive to component $this->com_starday = intval($jevents_config->get('com_starday', 0)); // make config object (module or component) current if (intval($this->modparams->get('modcal_useLocalParam', 0)) == 1) { $myparam =& $this->modparams; } else { $myparam =& $jevents_config; } // get com_event config parameters for this module $this->displayLastMonth = $myparam->get('modcal_DispLastMonth', 'NO'); $this->disp_lastMonthDays = $myparam->get('modcal_DispLastMonthDays', 0); $this->linkCloaking = $myparam->get('modcal_LinkCloaking', 0); $t_datenow = JEVHelper::getNow(); $this->timeWithOffset = $t_datenow->toUnix(true); switch ($this->displayLastMonth) { case 'YES_stop': $this->disp_lastMonth = 1; break; case 'YES_stop_events': $this->disp_lastMonth = 2; break; case 'ALWAYS': $this->disp_lastMonthDays = 0; $this->disp_lastMonth = 1; break; case 'ALWAYS_events': $this->disp_lastMonthDays = 0; $this->disp_lastMonth = 2; break; case 'NO': default: $this->disp_lastMonthDays = 0; $this->disp_lastMonth = 0; break; } $this->displayNextMonth = $myparam->get('modcal_DispNextMonth', 'NO'); $this->disp_nextMonthDays = $myparam->get('modcal_DispNextMonthDays', 0); switch ($this->displayNextMonth) { case 'YES_stop': $this->disp_nextMonth = 1; break; case 'YES_stop_events': $this->disp_nextMonth = 2; break; case 'ALWAYS': $this->disp_nextMonthDays = 0; $this->disp_nextMonth = 1; break; case 'ALWAYS_events': $this->disp_nextMonthDays = 0; $this->disp_nextMonth = 2; break; case 'NO': default: $this->disp_nextMonthDays = 0; $this->disp_nextMonth = 0; break; } // find appropriate Itemid and setup catids for datamodel $this->myItemid = $this->datamodel->setupModuleCatids($this->modparams); $this->cat = $this->datamodel->getCatidsOutLink(true); $this->linkpref = 'index.php?option=' . JEV_COM_COMPONENT . '&Itemid=' . $this->myItemid . $this->cat . '&task='; }
protected function getCategoryHierarchy($catidList, $catidsGPList) { $db = JFactory::getDBO(); $aid = $this->datamodel->aid; $user = JFactory::getUser(); // Get all the categories $sql = "SELECT c.* FROM #__categories as c WHERE extension='" . JEV_COM_COMPONENT . "'" . " AND c.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND c.language in (" . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')' . " AND c.published = 1" . "\n ORDER BY c.lft"; $db->setQuery($sql); $catlist = $db->loadObjectList('id'); foreach ($catlist as &$cat) { $cat->name = $cat->title; $params = new JRegistry($cat->params); $cat->color = $params->get("catcolour", ""); $cat->overlaps = $params->get("overlaps", 0); } unset($cat); // any plugin based resitrictions $dispatcher = JDispatcher::getInstance(); // remember NOT to reindex the list $dispatcher->trigger('onGetAccessibleCategories', array(&$catlist, false)); // Copy the array $clonedCatList = unserialize(serialize($catlist)); $validcats = array(); if (JString::strlen($catidsGPList) > 0) { $validcats = array_merge($validcats, explode(",", $catidsGPList)); } // convert to a tree $cattree = $this->mapTree($catlist, $validcats); // constrain tree by component or module paramaters if (JString::strlen($catidList) > 0) { $validcats = array(); $validcats = array_merge($validcats, explode(",", $catidList)); if (count($validcats) > 0) { $cattree2 = $this->mapTree($clonedCatList, $validcats); $combinedCatTree = $this->constrainTree($cattree, $cattree2); } } return $cattree; }
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 export() { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); if ($params->get("disableicalexport", 0)) { JError::raiseError(403, JText::_('ALERTNOTAUTH')); } $years = JRequest::getVar('years', 'NONE'); $cats = JRequest::getVar('catids', 'NONE'); // validate the key $icalkey = $params->get("icalkey", "secret phrase"); $outlook2003icalexport = JRequest::getInt("outlook2003", 0) && $params->get("outlook2003icalexport", 0); if ($outlook2003icalexport) { JRequest::setVar("icf", 1); } $privatecalendar = false; $k = JRequest::getString("k", "NONE"); $pk = JRequest::getString("pk", "NONE"); $userid = JRequest::getInt("i", 0); if ($pk != "NONE") { if (!$userid) { JError::raiseError(403, "JEV_ERROR"); } $privatecalendar = true; $puser = JUser::getInstance($userid); $key = md5($icalkey . $cats . $years . $puser->password . $puser->username . $puser->id); if ($key != $pk) { JError::raiseError(403, "JEV_ERROR"); } if (JVersion::isCompatible("1.6.0")) { // ensure "user" can access non-public categories etc. $this->dataModel->aid = JEVHelper::getAid($puser); $this->dataModel->accessuser = $puser->get('id'); } else { // Get an ACL object $acl =& JFactory::getACL(); // Get the user group from the ACL $grp = $acl->getAroGroup($puser->get('id')); //Mark the user as logged in $puser->set('guest', 0); $puser->set('aid', 1); // Fudge Authors, Editors, Publishers and Super Administrators into the special access group if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) { $puser->set('aid', 2); } // ensure "user" can access non-public categories etc. $this->dataModel->aid = $puser->aid; $this->dataModel->accessuser = $puser->get('id'); } $registry =& JRegistry::getInstance("jevents"); $registry->setValue("jevents.icaluser", $puser); } else { if ($k != "NONE") { $key = md5($icalkey . $cats . $years); if ($key != $k) { JError::raiseError(403, "JEV_ERROR"); } } else { JError::raiseError(403, "JEV_ERROR"); } } // Fix the cats $cats = explode(',', $cats); // hardening! JEVHelper::forceIntegerArray($cats, false); if ($cats != array(0)) { JRequest::setVar("catids", implode("|", $cats)); } else { JRequest::setVar("catids", ''); } //Parsing variables from URL //Year // All years if ($years == 0) { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $years = array(); for ($y = $params->get("com_earliestyear", date('Y')); $y <= $params->get("com_latestyear", date('Y')); $y++) { if (!in_array($y, $years)) { $years[] = $y; } } JArrayHelper::toInteger($years); } else { if ($years != "NONE") { $years = explode(",", JRequest::getVar('years')); if (!is_array($years) || count($years) == 0) { list($y, $m, $d) = JEVHelper::getYMD(); $years = array($y); } JArrayHelper::toInteger($years); } else { list($y, $m, $d) = JEVHelper::getYMD(); $years = array($y); } } // Lockin hte categories from the URL $this->dataModel->setupComponentCatids(); $dispatcher =& JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); //And then the real work // Force all only the one repeat $cfg =& JEVConfig::getInstance(); $cfg->set('com_showrepeats', 0); $icalEvents = array(); foreach ($years as $year) { $startdate = $year . "-01-01"; $enddate = $year . "-12-31"; $rows = $this->dataModel->getRangeData($startdate, $enddate, 0, 0); if (!isset($rows["rows"])) { continue; } foreach ($rows["rows"] as $row) { if (!array_key_exists($row->ev_id(), $icalEvents)) { $dispatcher->trigger('onExportRow', array(&$row)); $icalEvents[$row->ev_id()] = $row; } } unset($rows); } if ($userid) { $user = JUser::getInstance($userid); } $mainframe = JFactory::getApplication(); // get the view $this->view =& $this->getView("icals", "html"); $this->view->setLayout("export"); $this->view->assign("dataModel", $this->dataModel); $this->view->assign("outlook2003icalexport", $outlook2003icalexport); $this->view->assign("icalEvents", $icalEvents); $this->view->export(); return; }
function findAppropriateMenuID(&$catidsOut, &$modcatids, &$catidList, $modparams, &$showall) { // Itemid, search for menuid with lowest access rights $user = JFactory::getUser(); $db = JFactory::getDBO(); // Do we ignore category filters? $ignorecatfilter = 0; if (isset($modparams->ignorecatfilter) && $modparams->ignorecatfilter) { $ignorecatfilter = $modparams->ignorecatfilter; JRequest::setVar("category_fv", 0); } $menu = JFactory::getApplication()->getMenu(); $menuitems = $menu->getItems("component", JEV_COM_COMPONENT); // restrict this list to those accessible by the user if (!is_null($menuitems)) { foreach ($menuitems as $index => $menuitem) { if (version_compare(JVERSION, '1.6.0', '>=') ? !in_array($menuitem->access, JEVHelper::getAid($user, 'array')) : JEVHelper::getAid($user) < $menuitem->access) { unset($menuitems[$index]); } else { if (array_key_exists("task", $menuitem->query) && strpos($menuitem->query['task'], 'admin') === 0) { unset($menuitems[$index]); } } } } else { $menuitems = array(); } $activeMenu = $menu->getActive(); if (isset($modparams->target_itemid) && $modparams->target_itemid != '' && intval($modparams->target_itemid) > 0) { $targetid = intval($modparams->target_itemid); $myItemid = 0; foreach ($menuitems as $item) { if ($targetid == $item->id) { $myItemid = $targetid; break; } } } else { if ($activeMenu && $activeMenu->component == JEV_COM_COMPONENT) { // use result by reference $myItemid = $activeMenu->id; } else { if (count($menuitems) > 0) { reset($menuitems); $myItemid = current($menuitems); $myItemid = $myItemid->id; } else { // if no menu pointing the JEvents use itemid of home page and set empty menu array $myItemid = 1; $menuitems = array(); } } } // put the best guess first for checking category selections if ($myItemid > 0) { $newmenuitems = array(); foreach ($menuitems as $item) { if ($myItemid == $item->id) { array_unshift($newmenuitems, $item); } else { array_push($newmenuitems, $item); } } $menuitems = $newmenuitems; } //Finds the first enclosing setof catids from menu item if it exists ! // // First of all get the module paramaters $c = 0; $modcatids = array(); $catidList = ""; // New system $newcats = isset($modparams->catidnew) ? $modparams->catidnew : false; if ($newcats && is_array($newcats)) { foreach ($newcats as $newcat) { if (!in_array($newcat, $modcatids)) { $modcatids[] = $newcat; $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $newcat; } } } else { for ($c = 0; $c < 999; $c++) { $nextCID = "catid{$c}"; // stop looking for more catids when you reach the last one! if (!isset($modparams->{$nextCID})) { break; } if ($modparams->{$nextCID} > 0 && !in_array($modparams->{$nextCID}, $modcatids)) { $modcatids[] = $modparams->{$nextCID}; $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $modparams->{$nextCID}; } } } if (count($modcatids) == 0) { $showall = true; } $catidsOut = str_replace(",", "|", $catidList); $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $separator = $params->get("catseparator", "|"); $catidsOut = str_replace("|", $separator, $catidsOut); // Now check the catids from the URL $catidsin = JRequest::getString("catids", ""); // if ignoring catid filter then force to blank if ($ignorecatfilter) { $catidsin = ""; } if (JString::strlen($catidsin) > 0) { $catidsin = explode("|", $catidsin); JArrayHelper::toInteger($catidsin); } else { // if no catids from the URL then stick to the module catids $catidsin = $modcatids; } // if we have no modcatids then the enclosing set MUST be all categories and catids must therefore also be empty! if (count($modcatids) == 0) { if (count($catidsin) > 0) { $modcatids = $catidsin; } //return $myItemid; } else { foreach ($modcatids as $key => $modcatid) { if (!in_array($modcatid, $catidsin)) { unset($modcatids[$key]); } } // if we have no categories left then we have to force the result set to be empty so add a -1 category // since accessibleCategoryList uses a count of zero catids to allow them all! if (count($modcatids) == 0) { $modcatids[] = -1; } } $catidsOut = implode("|", $modcatids); $catidList = implode(",", $modcatids); $catidsOut = str_replace("|", $separator, $catidsOut); if ($myItemid == 0) { // User has specified a non JEvents menu so catid filters won't work $myItemid = intval($modparams->target_itemid); return $myItemid; } // if we are not inside a real module i.e. in the legend beneath the calendar we just use the Itemid we are currently on if ((!isset($modparams->target_itemid) || $modparams->target_itemid == "") && $activeMenu && $activeMenu->component == JEV_COM_COMPONENT) { return $activeMenu->id; } // now find an appropriate enclosing set and associated menu item $possibleset = array(); foreach ($menuitems as $testparms) { $test = new JRegistry($testparms->params); $c = 0; $catids = array(); // New system $newcats = $test->get("catidnew", false); if ($newcats && is_array($newcats)) { foreach ($newcats as $newcat) { if (!in_array($newcat, $catids)) { $catids[] = $newcat; } } } else { while ($nextCatId = $test->get("catid{$c}", null)) { if (!in_array($nextCatId, $catids)) { $catids[] = $nextCatId; } $c++; } } // Now check if its an enclosing set of catids so we use this one if the targetid has not been explicitly set if (count($catids) == 0 && !isset($targetid) && !($activeMenu && $activeMenu->component == JEV_COM_COMPONENT)) { $Itemid = JEVHelper::getItemid(); $myItemid = intval($testparms->id); return $myItemid; break; } else { // if we have no modcatids then the enclosing set MUST be all categories and catids must therefore also be empty! if (count($modcatids) > 0) { $enclosed = true; foreach ($modcatids as $cid) { if (!in_array($cid, $catids)) { $enclosed = false; } } // if enclosed or menu item is not constrained if ($enclosed) { $possibleset[] = intval($testparms->id); break; } else { if (count($catids) == 0) { $possibleset[] = intval($testparms->id); } } } } } if (in_array($myItemid, $possibleset)) { return $myItemid; } else { if (count($possibleset) > 0) { return $possibleset[0]; } } return $myItemid; }
function rss($tpl = null) { $modid = intval(JRequest::getVar('modid', 0)); if ($modid < 0) { $modid = 0; } $cfg =& JEVConfig::getInstance(); $db =& JFactory::getDBO(); // setup for all required function and classes $file = JPATH_SITE . '/components/com_jevents/mod.defines.php'; include_once $file; // load language constants JEVHelper::loadLanguage('modlatest'); // Check document type $doc =& JFactory::getDocument(); if ($doc->getType() != 'feed') { JError::raiseError('E999', 'Fatal error, document type: "' . $doc->getType() . '" not supported.'); } if ($modid > 0) { $user = JFactory::getUser(); $query = "SELECT id, params" . "\n FROM #__modules AS m" . "\n WHERE m.published = 1" . "\n AND m.id = " . $modid . "\n AND m.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user, 'string') . ')' : ' <= ' . JEVHelper::getAid($user)) . "\n AND m.client_id != 1"; $db =& JFactory::getDBO(); $db->setQuery($query); $modules = $db->loadObjectList(); if (count($modules) <= 0) { // fake module parameter $params = new JParameter(''); } else { $params = new JParameter($modules[0]->params); } } else { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); } // parameter intialization $info['link'] = str_replace('&', '&', JURI::root(true)); $info['imagelink'] = str_replace('&', '&', JURI::root()); $info['base'] = str_replace('&', '&', JURI::root()); $info['cache'] = $cfg->get('com_rss_cache', 1); $info['cache_time'] = $cfg->get('com_rss_cache_time', 3600); $info['count'] = $cfg->get('com_rss_count', 5); $info['title'] = $cfg->get('com_rss_title', 'Powered by JEvents!'); $info['description'] = $cfg->get('com_rss_description', 'JEvents Syndication for Joomla'); // get rss title from module param if requested and defined $t_title = $params->get('modlatest_rss_title', null); if ($params->get('modlatest_useLocalParam', 0) == 1 && !empty($t_title)) { $info['title'] = $t_title; } // get rss description from module param if requested and defined $t_description = $params->get('modlatest_rss_description', null); if ($params->get('modlatest_useLocalParam', 0) == 1 && !empty($t_description)) { $info['description'] = $t_description; } $info['image_url'] = htmlspecialchars($cfg->get('com_rss_logo', JURI::root() . 'administrator/components/' . JEV_COM_COMPONENT . '/assets/images/logo.gif')); if ($info['image_url'] == "") { $info['image_url'] = htmlspecialchars(JURI::root() . 'administrator/components/' . JEV_COM_COMPONENT . '/assets/images/logo.gif'); } $info['image_alt'] = $info['title']; $info['limit_text'] = $cfg->get('com_rss_limit_text', 1); $info['text_length'] = $cfg->get('com_rss_text_length', 20); // include the appropraite VIEW - this should be based on config and/or URL? $cfg =& JEVConfig::getInstance(); $theme = JEV_CommonFunctions::getJEventsViewName(); $viewclass = ucfirst($theme) . "ModLatestView"; jimport('joomla.application.module.helper'); require_once JModuleHelper::getLayoutPath('mod_jevents_latest', $theme . DS . "latest"); $jeventCalObject = new $viewclass($params, $modid); $jeventCalObject->getLatestEventsData($info["count"]); $this->set("eventsByRelDay", $jeventCalObject->eventsByRelDay); $this->set("info", $info); $this->set("modparams", $params); $this->set("jeventCalObject", $jeventCalObject); parent::displaytemplate($tpl); }
function select() { JRequest::checkToken('default') or jexit('Invalid Token'); // get the view $this->view =& $this->getView("icalevent", "html"); $this->_checkValidCategories(); $showUnpublishedICS = false; $showUnpublishedCategories = false; $db =& JFactory::getDBO(); $icsFile = intval(JFactory::getApplication()->getUserStateFromRequest("icsFile", "icsFile", 0)); $catid = intval(JFactory::getApplication()->getUserStateFromRequest("catidIcalEvents", 'catid', 0)); $catidtop = $catid; $state = 1; $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}%'"; } $user = JFactory::getUser(); // keep this incase we use filters in category lists $catwhere = "\n ev.catid IN(" . $this->queryModel->accessibleCategoryList() . ")"; $params = JComponentHelper::getParams(JRequest::getCmd("option")); if ($params->get("multicategory", 0)) { $join[] = "\n #__jevents_catmap as catmap ON catmap.evid = rpt.eventid"; $join[] = "\n #__categories AS catmapcat ON catmap.catid = catmapcat.id"; $where[] = " catmapcat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $where[] = " catmap.catid IN(" . $this->queryModel->accessibleCategoryList() . ")"; $needsgroup = true; $catwhere = " 1"; } $where[] = $catwhere; if ($catid > 0) { if ($params->get("multicategory", 0)) { $where[] = "catmap.catid='{$catid}'"; } else { $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 = ""; } } $user = JFactory::getUser(); $where[] = "\n ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $where[] = "\n icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); $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"; } } // 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); $menulist = $this->targetMenu(0, "Itemid"); $catData = JEV_CommonFunctions::getCategoryData(); jimport('joomla.html.pagination'); $pageNav = new JPagination($total, $limitstart, $limit); // Set the layout $this->view->setLayout('select'); $this->view->assign('rows', $rows); $this->view->assign('userlist', $userlist); $this->view->assign('menulist', $menulist); $this->view->assign('clist', $clist); $this->view->assign('plist', $plist); $this->view->assign('search', $search); $this->view->assign('icsList', $icslist); $this->view->assign('pageNav', $pageNav); $this->view->display(); }
function viewDetailLink($year, $month, $day, $sef = true, $Itemid = 0) { $Itemid = $Itemid > 0 ? $Itemid : JEVHelper::getItemid($this); static $menuitems = false; if (!$menuitems) { $menu = JFactory::getApplication()->getMenu(); $menuitems = $menu->getItems("component", JEV_COM_COMPONENT); $user = JFactory::getUser(); // restrict this list to those accessible by the user if (!is_null($menuitems)) { $lang = JFactory::getLanguage(); foreach ($menuitems as $index => $menuitem) { if (!in_array($menuitem->access, JEVHelper::getAid($user, 'array'))) { unset($menuitems[$index]); } else { if (array_key_exists("task", $menuitem->query) && strpos($menuitem->query['task'], 'admin') === 0) { unset($menuitems[$index]); } else { if ($menuitem->language != "*" && $menuitem->language != $lang->getTag()) { unset($menuitems[$index]); } else { if (!(array_key_exists("layout", $menuitem->query) && array_key_exists("view", $menuitem->query) && $menuitem->query['view'] . "." . $menuitem->query['layout'] == 'icalrepeat.detail')) { unset($menuitems[$index]); } } } } } } else { $menuitems = array(); } } // Is there a specific menu item for this ONE event - this overrides everything (if in the same language!) foreach ($menuitems as $index => $menuitem) { if (array_key_exists("layout", $menuitem->query) && array_key_exists("view", $menuitem->query) && $menuitem->query['view'] . "." . $menuitem->query['layout'] == 'icalrepeat.detail') { if (isset($menuitem->query["evid"]) && $menuitem->query["evid"] == $this->ev_id()) { $Itemid = $menuitem->id; break; } } } // uid = event series unique id i.e. the actual event $title = JApplication::stringURLSafe($this->title()); $link = "index.php?option=" . JEV_COM_COMPONENT . "&task=" . $this->detailTask() . "&evid=" . $this->rp_id() . '&Itemid=' . $Itemid . "&year={$year}&month={$month}&day={$day}&title=" . $title . "&uid=" . urlencode($this->uid()); if (JRequest::getCmd("tmpl", "") == "component" && JRequest::getCmd('task', 'selectfunction') != 'icalevent.select' && JRequest::getCmd("option", "") != "com_acymailing" && JRequest::getCmd("option", "") != "com_jnews" && JRequest::getCmd("option", "") != "com_search" && JRequest::getCmd("jevtask", "") != "crawler.listevents") { $link .= "&tmpl=component"; } // SEF is applied later $link = $sef ? JRoute::_($link, true) : $link; return $link; }
// New custom fields if (isset($this->location->customfields)) { $customfields = $this->location->customfields; } else { $customfields = array(); } $plugin = JPluginHelper::getPlugin('jevents', 'jevcustomfields'); $pluginparams = new JRegistry($plugin->params); $templatetop = $pluginparams->get("templatetop", "<table border='0'>"); $templaterow = $pluginparams->get("templatebody", "<tr><td class='label'>{LABEL}</td><td>{VALUE}</td>"); $templatebottom = $pluginparams->get("templatebottom", "</table>"); $html = $templatetop; $user = JFactory::getUser(); foreach ($customfields as $customfield) { if (version_compare(JVERSION, '1.6.0', '>=')) { if (!in_array(intval($customfield["access"]), JEVHelper::getAid($user, 'array'))) { continue; } } else { if ($user->aid < intval($customfield["access"])) { continue; } } if (!is_null($customfield["hiddenvalue"]) && trim($customfield["value"]) == $customfield["hiddenvalue"]) { continue; } $outrow = str_replace("{LABEL}", $customfield["label"], $templaterow); $outrow = str_replace("{VALUE}", nl2br($customfield["value"]), $outrow); $html .= $outrow; } $html .= $templatebottom;
/** * Build HTML selection list of categories * * @param int $catid Selected catid * @param string $args Additional HTML attributes for the <select> tag * @param string $catidList Restriction list of categories * @param boolean $with_unpublished Set true to build list with unpublished categories * @param boolean $require_sel First entry: true = Choose one category, false = All categories * @param int $catidtop Top level category ancestor */ function buildCategorySelect($catid, $args, $catidList = null, $with_unpublished = false, $require_sel = false, $catidtop = 0, $fieldname = "catid", $sectionname = JEV_COM_COMPONENT, $excludeid = false, $order = "ordering", $eventediting = false) { if (JVersion::isCompatible("1.6.0")) { // need to declare this because of bug in Joomla JHtml::_('select.options', on content pages - it loade the WRONG CLASS! include_once JPATH_SITE . "/libraries/joomla/html/html/category.php"; ob_start(); $t_first_entry = $require_sel ? JText::_('JEV_EVENT_CHOOSE_CATEG') : JText::_('JEV_EVENT_ALLCAT'); $options = JHtml::_('category.options', $sectionname); if ($catidList != null) { $cats = explode(',', $catidList); $count = count($options); for ($o = 0; $o < $count; $o++) { if (!in_array($options[$o]->value, $cats)) { unset($options[$o]); } } $options = array_values($options); } // Thanks to ssobada // when editing events we restrict the available list! $jevtask = JRequest::getString("jevtask"); if (strpos($jevtask, "icalevent.edit") !== false || strpos($jevtask, "icalrepeat.edit") !== false) { $user = JFactory::getUser(); $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $authorisedonly = $params->get("authorisedonly", 0); if ($authorisedonly) { $jevuser = JEVHelper::getAuthorisedUser(); if ($jevuser) { if ($jevuser->categories == "all") { $cats = array(); foreach ($options as $opt) { $cats[] = $opt->value; } } else { if ($jevuser->categories != "") { $cats = explode("|", $jevuser->categories); } else { if (JRequest::getInt("evid", 0) > 0) { // TODO - this should check the creator of the event $action = 'core.edit'; $cats = $user->getAuthorisedCategories('com_jevents', $action); $action = 'core.edit.own'; $cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action)); } else { $action = 'core.create'; $cats = $user->getAuthorisedCategories('com_jevents', $action); } } } } else { if (JRequest::getInt("evid", 0) > 0) { // TODO - this should check the creator of the event $action = 'core.edit'; $cats = $user->getAuthorisedCategories('com_jevents', $action); $action = 'core.edit.own'; $cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action)); } else { $action = 'core.create'; $cats = $user->getAuthorisedCategories('com_jevents', $action); } } } else { if (JRequest::getInt("evid", 0) > 0) { // TODO - this should check the creator of the event $action = 'core.edit'; $cats = $user->getAuthorisedCategories('com_jevents', $action); $action = 'core.edit.own'; $cats = array_merge($cats, $user->getAuthorisedCategories('com_jevents', $action)); } else { $action = 'core.create'; $cats = $user->getAuthorisedCategories('com_jevents', $action); } } $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onGetAccessibleCategoriesForEditing', array(&$cats)); // allow anon-user event creation through if (isset($user->id)) { $count = count($options); for ($o = 0; $o < $count; $o++) { if (!in_array($options[$o]->value, $cats)) { unset($options[$o]); } } $options = array_values($options); } } else { } // if only one category then preselect it if (count($options) == 1) { $catid = current($options)->value; } // should we offer multi-choice categories? // do not use jev_com_component incase we call this from locations etc. $params = JComponentHelper::getParams(JRequest::getCmd("option")); if ($eventediting && $params->get("multicategory", 0)) { $size = count($options) > 6 ? 6 : count($options) + 1; ?> <select name="<?php echo $fieldname; ?> []" <?php echo $args; ?> multiple="multiple" size="<?php echo $size; ?> "> <?php } else { ?> <select name="<?php echo $fieldname; ?> " <?php echo $args; ?> > <option value="0"><?php echo $t_first_entry; ?> </option> <?php } ?> <?php echo JHtml::_('select.options', $options, 'value', 'text', $catid); ?> </select> <?php return ob_get_clean(); } $user = JFactory::getUser(); $db = JFactory::getDBO(); $catsql = 'SELECT c.id, c.published, c.title as ctitle,p.title as ptitle, gp.title as gptitle, ggp.title as ggptitle ' . (JVersion::isCompatible("1.6.0") ? ", c.lft as ordering " : ", c.ordering as ordering") . ' , p.id as pid, gp.id as gpid, ggp.id as ggpid ' . ' FROM #__categories AS c' . ' LEFT JOIN #__categories AS p ON p.id=c.parent_id' . ' LEFT JOIN #__categories AS gp ON gp.id=p.parent_id ' . ' LEFT JOIN #__categories AS ggp ON ggp.id=gp.parent_id ' . "WHERE c.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <= ' . JEVHelper::getAid($user)); if (JVersion::isCompatible("1.6.0")) { $catsql .= ' AND c.extension = ' . $db->Quote($sectionname); } else { $catsql .= ' AND c.section = ' . $db->Quote($sectionname); } if ($with_unpublished) { $catsql .= ' AND c.published >= 0'; } else { $catsql .= ' AND c.published = 1'; } if ($excludeid) { $catsql .= ' AND c.id NOT IN (' . $excludeid . ')'; } if (is_string($catidList) && strlen(trim($catidList))) { $catsql .= ' AND c.id IN (' . trim($catidList) . ')'; } if (JVersion::isCompatible("1.6.0")) { $catsql .= " ORDER BY c.lft"; } else { $catsql .= " ORDER BY c.ordering"; } $db->setQuery($catsql); //echo $db->_sql; $rows = $db->loadObjectList('id'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onGetCategoryData', array(&$rows)); foreach ($rows as $key => $option) { if (JVersion::isCompatible("1.6.0") && $option->pid == 1) { $option->pid = 0; $option->ptitle = null; } $title = $option->ctitle; if (!is_null($option->ptitle)) { // this doesn't; work in Joomfish //$title = $option->ptitle."=>".$title; if (array_key_exists($option->pid, $rows)) { $title = $rows[$option->pid]->ctitle . "=>" . $title; } else { $title = $option->ptitle . "=>" . $title; } } if (!is_null($option->gptitle)) { // this doesn't; work in Joomfish //$title = $option->gptitle."=>".$title; if (array_key_exists($option->gpid, $rows)) { $title = $rows[$option->gpid]->ctitle . "=>" . $title; } else { $title = $option->gptitle . "=>" . $title; } } if (!is_null($option->ggptitle)) { // this doesn't; work in Joomfish //$title = $option->ggptitle."=>".$title; if (array_key_exists($option->ggpid, $rows)) { $title = $rows[$option->ggpid]->ctitle . "=>" . $title; } else { $title = $option->ggptitle . "=>" . $title; } } /* if (!is_null($option->gggptitle)){ $title = $option->gggptitle."=>".$title; } */ $rows[$key]->name = $title; } JArrayHelper::sortObjects($rows, $order); $t_first_entry = $require_sel ? JText::_('JEV_EVENT_CHOOSE_CATEG') : JText::_('JEV_EVENT_ALLCAT'); //$categories[] = JHTML::_('select.option', '0', JText::_('JEV_EVENT_CHOOSE_CATEG'), 'id', 'name' ); $categories[] = JHTML::_('select.option', '0', $t_first_entry, 'id', 'name'); if ($with_unpublished) { for ($i = 0; $i < count($rows); $i++) { if ($rows[$i]->published == 0) { $rows[$i]->name = $rows[$i]->name . '(' . JText::_('JEV_NOT_PUBLISHED') . ')'; } } } $categories = array_merge($categories, $rows); // if only one category then preselect it if (count($categories) == 2) { $catid = $categories[1]->id; } $clist = JHTML::_('select.genericlist', $categories, $fieldname, $args, 'id', 'name', $catid); return $clist; }