function checkRepeatOverlaps($repeat, &$returnData, $eventid, $requestObject) { $params =& JComponentHelper::getParams("com_jevents"); $db = JFactory::getDBO(); $overlaps = array(); if ($params->get("noclashes", 0)) { $sql = "SELECT * FROM #__jevents_repetition as rpt "; $sql .= " LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id=rpt.eventdetail_id "; $sql .= " WHERE rpt.rp_id<>" . intval($repeat->rp_id) . " AND rpt.startrepeat<" . $db->Quote($repeat->endrepeat) . " AND rpt.endrepeat>" . $db->Quote($repeat->startrepeat); $sql .= " LIMIT 100"; $db->setQuery($sql); $conflicts = $db->loadObjectList(); if ($conflicts && count($conflicts) > 0) { foreach ($conflicts as &$conflict) { $conflict->conflictCause = JText::_("JEV_GENERAL_OVERLAP"); } unset($conflict); $overlaps = array_merge($overlaps, $conflicts); } } else { if ($params->get("checkclashes", 0)) { $dataModel = new JEventsDataModel(); $dbModel = new JEventsDBModel($dataModel); $skipCatTest = false; $catinfo = $dbModel->getCategoryInfo(array($repeat->event->catid())); if ($catinfo && count($catinfo) == 1) { $catinfo = current($catinfo); if (JVersion::isCompatible("1.6.0")) { $catparams = json_decode($catinfo->params); if (!$catparams->overlaps) { $skipCatTest = true; } } else { if (!$catinfo->overlaps) { $skipCatTest = true; } } } if (!$skipCatTest) { $sql = "SELECT * FROM #__jevents_repetition as rpt "; $sql .= " LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id=rpt.eventdetail_id "; $sql .= " LEFT JOIN #__jevents_vevent as evt ON evt.ev_id=rpt.eventid "; $sql .= " WHERE rpt.rp_id<>" . intval($repeat->rp_id) . " AND rpt.startrepeat<" . $db->Quote($repeat->endrepeat) . " AND rpt.endrepeat>" . $db->Quote($repeat->startrepeat); //$sql .= " AND (evt.catid=".$repeat->event->catid()." OR evt.icsid=".$repeat->event->icsid().") GROUP BY rpt.rp_id"; $sql .= " AND (evt.catid=" . $repeat->event->catid() . ") GROUP BY rpt.rp_id"; $sql .= " LIMIT 100"; $db->setQuery($sql); $conflicts = $db->loadObjectList(); if ($conflicts && count($conflicts) > 0) { foreach ($conflicts as &$conflict) { $conflict->conflictCause = JText::sprintf("JEV_CATEGORY_CLASH", $repeat->event->getCategoryName()); } unset($conflict); $overlaps = array_merge($overlaps, $conflicts); } } } } $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger('onCheckRepeatOverlaps', array(&$repeat, &$overlaps, $eventid, $requestObject)); return $overlaps; }
function checkRepeatOverlaps($repeat, &$returnData, $eventid, $requestObject) { $params = JComponentHelper::getParams("com_jevents"); $db = JFactory::getDBO(); $overlaps = array(); if ($params->get("noclashes", 0)) { $sql = "SELECT *, ev.state FROM #__jevents_repetition as rpt "; $sql .= " LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id=rpt.eventdetail_id "; $sql .= " LEFT JOIN #__jevents_vevent as ev ON ev.ev_id=rpt.eventid "; $sql .= " WHERE rpt.rp_id<>" . intval($repeat->rp_id) . " AND rpt.startrepeat<" . $db->Quote($repeat->endrepeat) . " AND rpt.endrepeat>" . $db->Quote($repeat->startrepeat); $sql .= " AND ev.state=1"; $sql .= " LIMIT 100"; $db->setQuery($sql); $conflicts = $db->loadObjectList(); if ($conflicts && count($conflicts) > 0) { foreach ($conflicts as &$conflict) { $conflict->conflictCause = JText::_("JEV_GENERAL_OVERLAP"); } unset($conflict); $overlaps = array_merge($overlaps, $conflicts); } } else { if ($params->get("checkclashes", 0)) { $dataModel = new JEventsDataModel(); $dbModel = new JEventsDBModel($dataModel); $catids = $repeat->event->catids(); if (!$catids) { $catids = array($repeat->event->catid()); } $skipCatTest = false; $catinfo = $dbModel->getCategoryInfo($catids); if ($catinfo && count($catinfo) > 0) { for ($c = 0; $c < count($catids); $c++) { if (isset($catinfo[$catids[$c]])) { $cinfo = $catinfo[$catids[$c]]; $catparams = json_decode($cinfo->params); if (!$catparams->overlaps) { unset($catids[$c]); } } } if (count($catids) == 0) { $skipCatTest = true; } } else { $skipCatTest = true; } if (!$skipCatTest) { $sql = "SELECT *, evt.catid, evt.state "; if ($params->get("multicategory", 0)) { $sql .= ", GROUP_CONCAT(DISTINCT catmap.catid SEPARATOR ',') as catids"; } $sql .= " FROM #__jevents_repetition as rpt "; $sql .= " LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id=rpt.eventdetail_id "; $sql .= " LEFT JOIN #__jevents_vevent as evt ON evt.ev_id=rpt.eventid "; if ($params->get("multicategory", 0)) { $sql .= " LEFT JOIN #__jevents_catmap as catmap ON catmap.evid = rpt.eventid"; $sql .= " LEFT JOIN #__categories AS catmapcat ON catmap.catid = catmapcat.id"; } $sql .= " WHERE rpt.rp_id<>" . intval($repeat->rp_id) . " AND rpt.startrepeat<" . $db->Quote($repeat->endrepeat) . " AND rpt.endrepeat>" . $db->Quote($repeat->startrepeat); $sql .= " AND evt.state=1"; if ($params->get("multicategory", 0)) { $sql .= " AND catmap.catid IN(" . implode(",", $catids) . ") GROUP BY rpt.rp_id"; } else { $sql .= " AND (evt.catid=" . $repeat->event->catid() . ") GROUP BY rpt.rp_id"; } $sql .= " LIMIT 100"; $db->setQuery($sql); $conflicts = $db->loadObjectList(); if ($conflicts && count($conflicts) > 0) { foreach ($conflicts as &$conflict) { $conflictCats = isset($conflict->catids) ? explode(",", $conflict->catids) : array($conflict->catid); $catname = array(); foreach ($conflictCats as $cc) { if (isset($catinfo[$cc])) { $catname[] = $catinfo[$cc]->title; } } $cat = count($catname) > 0 ? implode(", ", $catname) : $testevent->getCategoryName(); $conflict->conflictCause = JText::sprintf("JEV_CATEGORY_CLASH", $cat); } unset($conflict); $overlaps = array_merge($overlaps, $conflicts); } } } } $dispatcher = JDispatcher::getInstance(); $dispatcher->trigger('onCheckRepeatOverlaps', array(&$repeat, &$overlaps, $eventid, $requestObject)); return $overlaps; }