function getAdjacentYear($year, $month, $day, $direction = 1) { $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction); $day = JevDate::strftime("%d", $d1); $year = JevDate::strftime("%Y", $d1); $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $cfg = JEVConfig::getInstance(); if (method_exists("JEVHelper", "getMinYear")) { $earliestyear = JEVHelper::getMinYear(); $latestyear = JEVHelper::getMaxYear(); } else { $earliestyear = $params->get("com_earliestyear", 1970); $latestyear = $params->get("com_latestyear", 2150); } if ($year > $latestyear || $year < $earliestyear) { return false; } $month = JevDate::strftime("%m", $d1); $task = JRequest::getString('jevtask'); $Itemid = JEVHelper::getItemid(); if (isset($Itemid)) { $item = "&Itemid={$Itemid}"; } else { $item = ""; } return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}"); }
function getAdjacentYear($year, $month, $day, $direction = 1) { $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction); $day = JevDate::strftime("%d", $d1); $year = JevDate::strftime("%Y", $d1); $cfg =& JEVConfig::getInstance(); $earliestyear = $cfg->get('com_earliestyear'); $latestyear = $cfg->get('com_latestyear'); if ($year > $latestyear || $year < $earliestyear) { return false; } $month = JevDate::strftime("%m", $d1); $task = JRequest::getString('jevtask'); $Itemid = JEVHelper::getItemid(); if (isset($Itemid)) { $item = "&Itemid={$Itemid}"; } else { $item = ""; } return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}"); }
static function getEventStringArray($row) { $urlString['title'] = urlencode($row->title()); $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $tz = $params->get("icaltimezonelive", ""); if ($tz) { $urlString['dates'] = JevDate::strftime("%Y%m%dT%H%M%S", $row->getUnixStartTime()) . "/" . JevDate::strftime("%Y%m%dT%H%M%S", $row->getUnixEndTime()) . "&ctz=" . $tz; } else { $urlString['dates'] = JevDate::strftime("%Y%m%dT%H%M%SZ", $row->getUnixStartTime()) . "/" . JevDate::strftime("%Y%m%dT%H%M%SZ", $row->getUnixEndTime()); } $urlString['st'] = JevDate::strftime("%Y%m%dT%H%M%SZ", $row->getUnixStartTime()); $urlString['et'] = JevDate::strftime("%Y%m%dT%H%M%SZ", $row->getUnixEndTime()); $urlString['duration'] = (int) $row->getUnixEndTime() - (int) $row->getUnixStartTime(); $urlString['location'] = urlencode(isset($row->_locationaddress) ? $row->_locationaddress : $row->location()); $urlString['sitename'] = urlencode(JFactory::getApplication()->get('sitename')); $urlString['siteurl'] = urlencode(JUri::root()); $urlString['rawdetails'] = urlencode($row->get('description')); $urlString['details'] = strip_tags($row->get('description')); if (JString::strlen($urlString['details']) > 100) { $urlString['details'] = JString::substr($urlString['details'], 0, 100) . ' ...'; } $urlString['details'] = urlencode($urlString['details']); return $urlString; }
function getTime($date, $h = -1, $m = -1) { $cfg =& JEVConfig::getInstance(); static $format_type; if (!isset($format_type)) { $cfg =& JEVConfig::getInstance(); $format_type = $cfg->get('com_dateformat'); } // if date format is from langauge file then do this first if ($format_type == 3) { if ($h >= 0 && $m >= 0) { $time = JevDate::mktime($h, $m); return JEV_CommonFunctions::jev_strftime(JText::_("TIME_FORMAT"), $time); } else { return JEV_CommonFunctions::jev_strftime(JText::_("TIME_FORMAT"), $date); } } if ($cfg->get('com_calUseStdTime') == '0') { if ($h >= 0 && $m >= 0) { return sprintf('%02d:%02d', $h, $m); } else { return JevDate::strftime("%H:%M", $date); } } else { if (JUtility::isWinOS()) { return JevDate::strftime("%#I:%M%p", $date); } else { return strtolower(JevDate::strftime("%I:%M%p", $date)); } } }
function simulateSaveRepeat($requestObject) { include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php"; if (!JEVHelper::isEventCreator()) { throwerror(JText::_('ALERTNOTAUTH')); } // Convert formdata to array $formdata = array(); foreach (get_object_vars($requestObject->formdata) as $k => $v) { $k = str_replace("[]", "", $k); $formdata[$k] = $v; } $array = JRequest::_cleanVar($formdata, JREQUEST_ALLOWHTML); if (!array_key_exists("rp_id", $array) || intval($array["rp_id"]) <= 0) { throwerror(JText::_("Not a repeat", true)); } $rp_id = intval($array["rp_id"]); $dataModel = new JEventsDataModel("JEventsAdminDBModel"); $queryModel = new JEventsDBModel($dataModel); // I should be able to do this in one operation but that can come later $event = $queryModel->listEventsById(intval($rp_id), 1, "icaldb"); if (!JEVHelper::canEditEvent($event)) { throwerror(JText::_('ALERTNOTAUTH')); } $db =& JFactory::getDBO(); $rpt = new iCalRepetition($db); $rpt->load($rp_id); $query = "SELECT detail_id FROM #__jevents_vevent WHERE ev_id={$rpt->eventid}"; $db->setQuery($query); $eventdetailid = $db->loadResult(); $data["UID"] = valueIfExists($array, "uid", md5(uniqid(rand(), true))); $data["X-EXTRAINFO"] = valueIfExists($array, "extra_info", ""); $data["LOCATION"] = valueIfExists($array, "location", ""); $data["allDayEvent"] = valueIfExists($array, "allDayEvent", "off"); $data["CONTACT"] = valueIfExists($array, "contact_info", ""); // allow raw HTML (mask =2) $data["DESCRIPTION"] = valueIfExists($array, "jevcontent", "", 'request', 'html', 2); $data["publish_down"] = valueIfExists($array, "publish_down", "2006-12-12"); $data["publish_up"] = valueIfExists($array, "publish_up", "2006-12-12"); $interval = valueIfExists($array, "rinterval", 1); $data["SUMMARY"] = valueIfExists($array, "title", ""); $data["MULTIDAY"] = intval(valueIfExists($array, "multiday", "1")); $data["NOENDTIME"] = intval(valueIfExists($array, "noendtime", 0)); $ics_id = valueIfExists($array, "ics_id", 0); if ($data["allDayEvent"] == "on") { $start_time = "00:00"; } else { $start_time = valueIfExists($array, "start_time", "08:00"); } $publishstart = $data["publish_up"] . ' ' . $start_time . ':00'; $data["DTSTART"] = JevDate::strtotime($publishstart); if ($data["allDayEvent"] == "on") { $end_time = "23:59"; $publishend = $data["publish_down"] . ' ' . $end_time . ':59'; } else { $end_time = valueIfExists($array, "end_time", "15:00"); $publishend = $data["publish_down"] . ' ' . $end_time . ':00'; } $data["DTEND"] = JevDate::strtotime($publishend); // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day list($h, $m, $s) = explode(":", $end_time . ':00'); if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) { $publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"] - 86400); $data["DTEND"] = JevDate::strtotime($publishend); } $data["X-COLOR"] = valueIfExists($array, "color", ""); // Add any custom fields into $data array foreach ($array as $key => $value) { if (strpos($key, "custom_") === 0) { $data[$key] = $value; } } // populate rpt with data $start = $data["DTSTART"]; $end = $data["DTEND"]; $rpt->startrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $start); $rpt->endrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $end); $rpt->duplicatecheck = md5($rpt->eventid . $start); $rpt->rp_id = $rp_id; $rpt->event = $event; return $rpt; }
/** * iCal spec represents date in ISO 8601 format followed by "T" then the time * a "Z at the end means the time is UTC and not local time zone * * TODO make sure if time is UTC we take account of system time offset properly * */ function unixTime($ical_date, $tz = false) { jimport("joomla.utilities.date"); static $offset = null; if (is_null($offset)) { $config =& JFactory::getConfig(); $offset = $config->getValue('config.offset', 0); } if (!is_numeric($ical_date)) { $t = JevDate::strtotime($ical_date); if (JString::strpos($ical_date, "Z") > 0) { if (is_callable("date_default_timezone_set")) { $timezone = date_default_timezone_get(); // See http://www.php.net/manual/en/timezones.php $params = JComponentHelper::getParams(JEV_COM_COMPONENT); // server offset tiemzone if ($params->get("icaltimezone", "") != "") { date_default_timezone_set($params->get("icaltimezone", "")); } // server offset PARAMS $serveroffset1 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; // server offset SERVER date_default_timezone_set($timezone); $serveroffset2 = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; $t = new JevDate($ical_date, $serveroffset1 - $serveroffset2); //$t = new JevDate($ical_date ); date_default_timezone_set($timezone); echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>"; } else { // Summer Time adjustment list($y, $m, $d, $h, $min, $s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S', $t)); $dst = (JevDate::mktime($h, $min, $s, $m, $d, $y, 0) - JevDate::mktime($h, $min, $s, $m, $d, $y, -1)) / 3600; // server offset including DST $serveroffset = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S', $t)) - JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ', $t))) / 3600; $serveroffset += $dst; $t = new JevDate($ical_date, -($serveroffset + $offset)); } /* echo "<h3>SET TIMEZONE</h3>"; $timezone= date_default_timezone_get(); date_default_timezone_set('America/New_York'); $tempIcal = "20091020T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal); echo $t->toMySQL()."<br><br/>"; $tempIcal = "20091029T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal ); echo $t->toMySQL()."<br><br/>"; $tempIcal = "20091103T163000Z"; echo $tempIcal."<br/>"; $temp = JevDate::strtotime($tempIcal); list($y,$m,$d,$h,$min,$s) = explode(":", JevDate::strftime('%Y:%m:%d:%H:%M:%S',$temp)); echo "$y,$m,$d,$h,$min,$s<br/>"; $dst = (JevDate::mktime($h,$min,$s,$m,$d,$y,0)-JevDate::mktime($h,$min,$s,$m,$d,$y,-1))/3600; $so = (JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%S',$temp))-JevDate::strtotime(JevDate::strftime('%Y%m%dT%H%M%SZ',$temp)))/3600; echo " dst=".$dst." serverforoffset=".$so."<br/>"; $so += $dst; $t = new JevDate($tempIcal); echo $t->toMySQL()."<br>"; */ } else { if ($tz != false && $tz != "") { // really should use the timezone of the inputted date $tz = new DateTimeZone($tz); $t = new JevDate($ical_date, $tz); echo "icaldate = " . $ical_date . " imported date=" . $t->toMySQL() . "<br/>"; } else { $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT); $jtz = $compparams->get("icaltimezonelive", ""); if ($jtz) { $t = new JevDate($ical_date, $jtz); } else { $t = new JevDate($ical_date); } } } //$result = $t->toMySQL(); $result = $t->toUnix(); return $result; } $isUTC = false; if (JString::strpos($ical_date, "Z") !== false) { $isUTC = true; } // strip "T" and "Z" from the string $ical_date = str_replace('T', '', $ical_date); $ical_date = str_replace('Z', '', $ical_date); // split it out intyo YYYY MM DD HH MM SS preg_match("#([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{0,2})([0-9]{0,2})([0-9]{0,2})#", $ical_date, $date); list($temp, $y, $m, $d, $h, $min, $s) = $date; if (!$min) { $min = 0; } if (!$h) { $h = 0; } if (!$d) { $d = 0; } if (!$s) { $s = 0; } // Trap unix dated beofre 1970 $y = max($y, 1970); if ($isUTC) { $t = gmJevDate::mktime($h, $min, $s, $m, $d, $y) + 3600 * $offset; $result = JevDate::strtotime(gmdate('Y-m-d H:i:s', $t)); } else { $result = JevDate::mktime($h, $min, $s, $m, $d, $y); } // double check!! //list($y1,$m1,$d1,$h1,$min1,$s1)=explode(":",JevDate::strftime('%Y:%m:%d:%H:%M:%S',$result)); return $result; }
function save($array, &$queryModel, $rrule, $dryrun = false) { $cfg =& JEVConfig::getInstance(); $db =& JFactory::getDBO(); $user = JFactory::getUser(); // Allow plugins to check data validity $dispatcher =& JDispatcher::getInstance(); JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onBeforeSaveEvent', array(&$array, &$rrule, $dryrun)); // TODO do error and hack checks here $ev_id = intval(JArrayHelper::getValue($array, "evid", 0)); $newevent = $ev_id == 0; $data = array(); // TODO add UID to edit form $data["UID"] = JArrayHelper::getValue($array, "uid", md5(uniqid(rand(), true))); $data["X-EXTRAINFO"] = JArrayHelper::getValue($array, "extra_info", ""); $data["LOCATION"] = JArrayHelper::getValue($array, "location", ""); $data["allDayEvent"] = JArrayHelper::getValue($array, "allDayEvent", "off"); $data["CONTACT"] = JArrayHelper::getValue($array, "contact_info", ""); $data["DESCRIPTION"] = JArrayHelper::getValue($array, "jevcontent", ""); $data["publish_down"] = JArrayHelper::getValue($array, "publish_down", "2006-12-12"); $data["publish_up"] = JArrayHelper::getValue($array, "publish_up", "2006-12-12"); $data["SUMMARY"] = JArrayHelper::getValue($array, "title", ""); $data["URL"] = JArrayHelper::getValue($array, "url", ""); // 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); if ($creatorid > 0) { if (JVersion::isCompatible("1.6.0")) { //$access = JAccess::check($user->id, "core.deleteall","com_jevents"); $access = $user->authorise('core.admin', 'com_jevents'); } else { // Get an ACL object $acl =& JFactory::getACL(); $grp = $acl->getAroGroup($user->get('id')); $access = $acl->is_group_child_of($grp->name, 'Public Backend'); } if ($jevuser && $jevuser->candeleteall || $access) { $data["X-CREATEDBY"] = $creatorid; } } $ics_id = JArrayHelper::getValue($array, "ics_id", 0); if ($data["allDayEvent"] == "on") { $start_time = "00:00"; } else { $start_time = JArrayHelper::getValue($array, "start_time", "08:00"); } $publishstart = $data["publish_up"] . ' ' . $start_time . ':00'; $data["DTSTART"] = JevDate::strtotime($publishstart); if ($data["allDayEvent"] == "on") { $end_time = "00:00"; } else { $end_time = JArrayHelper::getValue($array, "end_time", "15:00"); } $publishend = $data["publish_down"] . ' ' . $end_time . ':00'; if (isset($array["noendtime"]) && $array["noendtime"]) { $publishend = $data["publish_down"] . ' 23:59:59'; } $data["DTEND"] = JevDate::strtotime($publishend); // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day list($h, $m, $s) = explode(":", $end_time . ':00'); if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) { //if (($h+$m+$s)==0 && $data["allDayEvent"]=="on" && $data["DTEND"]>=$data["DTSTART"]) { //$publishend = JevDate::strftime('%Y-%m-%d 23:59:59',($data["DTEND"]-86400)); $publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"]); $data["DTEND"] = JevDate::strtotime($publishend); } $data["RRULE"] = $rrule; $data["MULTIDAY"] = JArrayHelper::getValue($array, "multiday", "1"); $data["NOENDTIME"] = JArrayHelper::getValue($array, "noendtime", "0"); $data["X-COLOR"] = JArrayHelper::getValue($array, "color", ""); $data["LOCKEVENT"] = JArrayHelper::getValue($array, "lockevent", "0"); // Add any custom fields into $data array foreach ($array as $key => $value) { if (strpos($key, "custom_") === 0) { $data[$key] = $value; } } $vevent = iCalEvent::iCalEventFromData($data); $vevent->catid = JArrayHelper::getValue($array, "catid", 0); if (is_array($vevent->catid)) { JArrayHelper::toInteger($vevent->catid); } // if catid is empty then use the catid of the ical calendar if (is_string($vevent->catid) && $vevent->catid <= 0 || is_array($vevent->catid) && count($vevent->catid) == 0) { $query = "SELECT catid FROM #__jevents_icsfile WHERE ics_id={$ics_id}"; $db->setQuery($query); $vevent->catid = $db->loadResult(); } $vevent->access = intval(JArrayHelper::getValue($array, "access", 0)); if (!JVersion::isCompatible("1.6.0")) { $vevent->access = $vevent->access > $user->aid ? $user->aid : $vevent->access; } $vevent->state = intval(JArrayHelper::getValue($array, "state", 0)); // Shouldn't really do this like this $vevent->_detail->priority = intval(JArrayHelper::getValue($array, "priority", 0)); // FRONT END AUTO PUBLISHING CODE $frontendPublish = JEVHelper::isEventPublisher(); if (!$frontendPublish) { $frontendPublish = JEVHelper::canPublishOwnEvents($ev_id); } // Always unpublish if no Publisher otherwise publish automatically (for new events) // Should we always notify of new events $notifyAdmin = $cfg->get("com_notifyallevents", 0); if (!JFactory::getApplication()->isAdmin()) { if ($frontendPublish && $ev_id == 0) { $vevent->state = 1; } else { if (!$frontendPublish) { $vevent->state = 0; // In this case we send a notification email to admin $notifyAdmin = true; } } } $vevent->icsid = $ics_id; if ($ev_id > 0) { $vevent->ev_id = $ev_id; } $rp_id = intval(JArrayHelper::getValue($array, "rp_id", 0)); if ($rp_id > 0) { // I should be able to do this in one operation but that can come later $testevent = $queryModel->listEventsById(intval($rp_id), 1, "icaldb"); if (!JEVHelper::canEditEvent($testevent)) { JError::raiseError(403, JText::_('ALERTNOTAUTH')); } } $db =& JFactory::getDBO(); $success = true; //echo "class = ".get_class($vevent); if (!$dryrun) { if (!$vevent->store()) { echo $db->getErrorMsg() . "<br/>"; $success = false; JError::raiseWarning(101, JText::_('COULD_NOT_SAVE_EVENT_')); } } else { // need a value for eventid to pretend we have saved the event so we can get the repetitions if (!isset($vevent->ev_id)) { $vevent->ev_id = 0; } $vevent->rrule->eventid = $vevent->ev_id; } // Only update the repetitions if the event edit says the reptitions will have changed or a new event if ($newevent || JRequest::getInt("updaterepeats", 1)) { $repetitions = $vevent->getRepetitions(true); if (!$dryrun) { if (!$vevent->storeRepetitions()) { echo $db->getErrorMsg() . "<br/>"; $success = false; JError::raiseWarning(101, JText::_('COULD_NOT_SAVE_REPETITIONS')); } } } $res = $dispatcher->trigger('onAfterSaveEvent', array(&$vevent, $dryrun)); if ($dryrun) { return $vevent; } // If not authorised to publish in the frontend then notify the administrator if (!$dryrun && $success && $notifyAdmin && !JFactory::getApplication()->isAdmin()) { JLoader::register('JEventsCategory', JEV_ADMINPATH . "/libraries/categoryClass.php"); $cat = new JEventsCategory($db); $cat->load($vevent->catid); $adminuser = $cat->getAdminUser(); $adminEmail = $adminuser->email; $config = new JConfig(); $sitename = $config->sitename; $subject = JText::_('JEV_MAIL_ADDED') . ' ' . $sitename; $subject = $vevent->state == '1' ? '[Info] ' . $subject : '[Approval] ' . $subject; $Itemid = JEVHelper::getItemid(); // reload the event to get the reptition ids $evid = intval($vevent->ev_id); $testevent = $queryModel->getEventById($evid, 1, "icaldb"); $rp_id = $testevent->rp_id(); list($year, $month, $day) = JEVHelper::getYMD(); //http://joomlacode1.5svn/index.php?option=com_jevents&task=icalevent.edit&evid=1&Itemid=68&rp_id=72&year=2008&month=09&day=10&lang=cy $uri =& JURI::getInstance(JURI::base()); $root = $uri->toString(array('scheme', 'host', 'port')); $modifylink = '<a href="' . $root . JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.edit&evid=' . $evid . '&rp_id=' . $rp_id . '&Itemid=' . $Itemid . "&year={$year}&month={$month}&day={$day}") . '"><b>' . JText::_('JEV_MODIFY') . '</b></a>' . "\n"; $viewlink = '<a href="' . $root . JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalrepeat.detail&evid=' . $rp_id . '&Itemid=' . $Itemid . "&year={$year}&month={$month}&day={$day}&login=1") . '"><b>' . JText::_('JEV_VIEW') . '</b></a>' . "\n"; $created_by = $user->name; if ($created_by == null) { $created_by = "Anonymous"; if (JRequest::getString("custom_anonusername", "") != "") { $created_by = JRequest::getString("custom_anonusername", "") . " (" . JRequest::getString("custom_anonemail", "") . ")"; } } JEV_CommonFunctions::sendAdminMail($sitename, $adminEmail, $subject, $testevent->title(), $testevent->content(), $created_by, JURI::root(), $modifylink, $viewlink); } if ($success) { return $vevent; } return $success; }
/** * Support all JevDate::strftime() parameter for Window systems * * @param string $format * @param int $timestamp * @return string formated string */ function jev_strftime($format = '', $timestamp = null) { if (!$timestamp) { $timestamp = time(); } // Replace names by own translation to get rid of improper os system library if (strpos($format, '%a') !== false) { $format = str_replace('%a', JEVHelper::getShortDayName(date('w', $timestamp)), $format); } if (strpos($format, '%A') !== false) { $format = str_replace('%A', JEVHelper::getDayName(date('w', $timestamp)), $format); } if (strpos($format, '%b') !== false) { $format = str_replace('%b', JEVHelper::getShortMonthName(date('n', $timestamp)), $format); } if (strpos($format, '%B') !== false) { $format = str_replace('%B', JEVHelper::getMonthName(date('n', $timestamp)), $format); } if (JUtility::isWinOS()) { if (!class_exists('JEV_CompatWin')) { require_once dirname(__FILE__) . '/compatwin.php'; } return JEV_CompatWin::win_strftime($format, $timestamp); } else { return JevDate::strftime($format, $timestamp); } }
function JEventsBuildRoute(&$query) { $cfg =& JEVConfig::getInstance(); $segments = array(); // sometimes the task is not set but view and layout are so tackle this! if (!isset($query['task']) && isset($query['view']) && isset($query['layout'])) { $query['task'] = $query['view'] . "." . $query['layout']; } // We don't need the view - its only used to manipulate parameters if (isset($query['view'])) { unset($query['view']); } if (isset($query['layout'])) { unset($query['layout']); } $task = false; $task = false; if (!isset($query['task'])) { if (isset($query["Itemid"])) { $menu =& JSite::getMenu(); $menuitem = $menu->getItem($query["Itemid"]); if (!is_null($menuitem) && isset($menuitem->query["task"])) { $task = $menuitem->query["task"]; return $segments; } else { if (!is_null($menuitem) && isset($menuitem->query["layout"]) && isset($menuitem->query["view"])) { $task = $menuitem->query["view"] . "." . $menuitem->query["layout"]; } } } if (!$task) { $task = 'month.calendar'; } } else { $task = $query['task']; unset($query['task']); } switch ($task) { case "year.listevents": case "month.calendar": case "week.listevents": case "day.listevents": case "cat.listevents": case "jevent.detail": case "icalevent.detail": case "icalrepeat.detail": case "search.form": case "search.results": case "admin.listevents": $segments[] = $task; $config =& JFactory::getConfig(); $t_datenow = JEVHelper::getNow(); // if no date in the query then use TODAY not the calendar date $nowyear = JevDate::strftime('%Y', $t_datenow->toUnix(true)); $nowmonth = JevDate::strftime('%m', $t_datenow->toUnix(true)); $nowday = JevDate::strftime('%d', $t_datenow->toUnix(true)); /* $year = intval( JRequest::getVar( 'year', $nowyear )); $month = intval( JRequest::getVar( 'month', $nowmonth )); $day = intval( JRequest::getVar( 'day', $nowday )); */ if (isset($query['year'])) { $segments[] = $query['year']; unset($query['year']); } else { // if no date in the query then use TODAY not the calendar date $segments[] = $nowyear; } if (isset($query['month'])) { $segments[] = $query['month']; unset($query['month']); } else { // if no date in the query then use TODAY not the calendar date $segments[] = $nowmonth; } if (isset($query['day'])) { $segments[] = $query['day']; unset($query['day']); } else { // if no date in the query then use TODAY not the calendar date $segments[] = $nowday; } switch ($task) { case "jevent.detail": case "icalevent.detail": case "icalrepeat.detail": if (isset($query['jevtype'])) { unset($query['jevtype']); } if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } /* // Can we drop the use of uid? if(isset($query['title'])) { $segments[] = JFilterOutput::stringURLSafe($query['title']); unset($query['title']); } else { $segments[] = "-"; } */ break; default: break; } if (isset($query['catids']) && strlen($query['catids']) > 0) { $segments[] = $query['catids']; unset($query['catids']); } else { $segments[] = "-"; } switch ($task) { case "icalrepeat.detail": if (isset($query['uid'])) { // Some remote UIDs have @ and other dodgy characters in them so encode them for safety //$segments[] = base64_encode($query['uid']); unset($query['uid']); } if (isset($query['title'])) { $segments[] = substr(JFilterOutput::stringURLSafe($query['title']), 0, 150); unset($query['title']); } else { $segments[] = "-"; } break; default: break; } break; case "jevent.edit": case "icalevent.edit": case "icalevent.publish": case "icalevent.unpublish": case "icalevent.editcopy": case "icalrepeat.edit": case "jevent.delete": case "icalevent.delete": case "icalrepeat.delete": case "icalrepeat.deletefuture": $segments[] = $task; if (isset($query['jevtype'])) { unset($query['jevtype']); } if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } break; case "modlatest.rss": $segments[] = $task; // assume implicit feed document //unset($query['format']); // feed type if (isset($query['type'])) { $segments[] = $query['type']; unset($query['type']); } else { $segments[] = 'rss'; } // modid if (isset($query['modid'])) { $segments[] = $query['modid']; unset($query['modid']); } else { $segments[] = "0"; } break; case "icalrepeat.vcal": case "icalevent.vcal": $segments[] = $task; if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } if (isset($query['catids'])) { $segments[] = $query['catids']; unset($query['catids']); } else { $segments[] = "0"; } break; default: $segments[] = $task; $segments[] = "-"; break; } return $segments; }
/** * Get week number according ISO 8601 * * @static * @param int $date date * @return int weeknumber */ function _getWeekNumberISO8601($date) { $thursday = JEV_CompatWin::_getThursdayOfWeek($date); $thursday_Y = JevDate::strftime('%Y', $thursday); $first_th = JEV_CompatWin::_getThursdayOfWeek(JevDate::strtotime($thursday_Y . '-01-04')); return (JevDate::strftime('%j', $thursday) - JevDate::strftime('%j', $first_th)) / 7 + 1; }
function countIcalEventsByCat($catids, $showrepeats = false) { $db =& JFactory::getDBO(); $user = JFactory::getUser(); // Use catid in accessibleCategoryList to pick up offsping too! $aid = null; $catidlist = implode(",", $catids); // process the new plugins // get extra data and conditionality from plugins $extrafields = ""; // must have comma prefix $extratables = ""; // must have comma prefix $extrawhere = array(); $extrajoin = array(); $needsgroup = false; if (!$this->cfg->getValue("showyearpast", 1)) { list($year, $month, $day) = JEVHelper::getYMD(); $startdate = JevDate::mktime(0, 0, 0, $month, $day, $year); $startdate = JevDate::strftime('%Y-%m-%d 00:00:00', $startdate); $extrawhere[] = "rpt.endrepeat >= '{$startdate}'"; } $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "search")); $filters->setWhereJoin($extrawhere, $extrajoin); $needsgroup = $filters->needsGroupBy(); $extrafields = ""; // must have comma prefix $extratables = ""; // must have comma prefix $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) : ''; // Get the count if ($showrepeats) { $query = "SELECT count(DISTINCT rpt.rp_id) as cnt" . "\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_rrule as rr ON rr.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" . $extrawhere; } else { // TODO fine a single query way of doing this !!! $query = "SELECT MIN(rpt.rp_id) as rp_id FROM #__jevents_repetition as rpt " . "\n LEFT JOIN #__jevents_vevent as ev ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.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 . $catwhere . $extrawhere . "\n AND icsf.state=1" . "\n GROUP BY ev.ev_id"; $db->setQuery($query); $rplist = $db->loadResultArray(); $rplist = implode(',', array_merge(array(-1), $rplist)); $query = "SELECT count(DISTINCT det.evdet_id) as cnt" . "\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 AND rpt.rp_id IN({$rplist})" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.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" . $extrawhere; } $db->setQuery($query); //echo $db->_sql; //echo $db->explain(); $total = intval($db->loadResult()); return $total; }
?> </span> </fieldset> </div> <div style="float:left;margin-left:20px!important;background-color:#dddddd;" id="cu_until"> <fieldset style="background-color:#dddddd"> <legend style="background-color:#dddddd"><input type="radio" name="countuntil" value="until" id="cuu" onclick="toggleCountUntil('cu_until');" /><?php echo JText::_('REPEAT_UNTIL'); ?> </legend> <?php $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $minyear = JEVHelper::getMinYear(); $maxyear = JEVHelper::getMaxYear(); $inputdateformat = $params->get("com_editdateformat", "d.m.Y"); JEVHelper::loadCalendar("until", "until", JevDate::strftime("%Y-%m-%d", $this->row->until()), $minyear, $maxyear, 'updateRepeatWarning();', "checkUntil();updateRepeatWarning();", $inputdateformat); ?> <input type="hidden" name="until2" id="until2" value="" /> </fieldset> </div> </div> <div style="clear:both;"> <div id="byyearday"> <fieldset><legend><input type="radio" name="whichby" id="jevbyd" value="byd" onclick="toggleWhichBy('byyearday');" /><?php echo JText::_('BY_YEAR_DAY'); ?> </legend> <div> <?php echo JText::_('COMMA_SEPARATED_LIST');
function getAdjacentDay($year, $month, $day, $direction = 1) { $d1 = JevDate::mktime(0, 0, 0, $month, $day + $direction, $year); $day = JevDate::strftime("%d", $d1); $year = JevDate::strftime("%Y", $d1); $cfg = JEVConfig::getInstance(); $earliestyear = JEVHelper::getMinYear(); $latestyear = JEVHelper::getMaxYear(); if ($year > $latestyear || $year < $earliestyear) { return false; } $month = JevDate::strftime("%m", $d1); $task = JRequest::getString('jevtask'); $Itemid = JEVHelper::getItemid(); if (isset($Itemid)) { $item = "&Itemid={$Itemid}"; } else { $item = ""; } // URL suffix to preserver catids! $cat = $this->getCatidsOutLink(); return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}" . $cat); }
for ($d = 0; $d < 7 && $dn < $datacount; $d++) { $currentDay = $this->data["dates"][$dn]; switch ($currentDay["monthType"]) { case "prior": case "following": ?> <td class="weekdayemptyclr" align="center" height="50" valign="middle"> <?php echo $currentDay["d"]; ?> </td> <?php break; case "current": //Current month $dayOfWeek = JevDate::strftime("%w", $currentDay["cellDate"]); $style = $dayOfWeek == 0 ? "sundayemptyclr" : "weekdayclr"; if ($currentDay['today']) { $style = "todayclr"; } ?> <td class="<?php echo $style; ?> " width="14%" align="center" height="50" valign="top"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr class="caldaydigits"> <td class="caldaydigits"> <strong><a href="<?php echo $currentDay["link"]; ?>
<?php $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $minyear = JEVHelper::getMinYear(); $maxyear = JEVHelper::getMaxYear(); $inputdateformat = $params->get("com_editdateformat", "d.m.Y"); $inputdateformat2 = str_replace(array("Y", "m", "d"), array("%Y", "%m", "%d"), $inputdateformat); JEVHelper::loadElectricCalendar("irregular", "irregular", "", $minyear, $maxyear, '', "selectIrregularDate();updateRepeatWarning();", $inputdateformat, array("style" => "display:none;")); ?> </div> <select id="irregularDates" name="irregularDates[]" multiple="multiple" size="5" onchange="updateRepeatWarning()"> <?php sort($this->row->_irregulardates); array_unique($this->row->_irregulardates); foreach ($this->row->_irregulardates as $irregulardate) { $irregulardateval = JevDate::strftime('%Y-%m-%d', $irregulardate); $irregulardatetext = JevDate::strftime($inputdateformat2, $irregulardate); ?> <option value="<?php echo $irregulardateval; ?> " selected="selected"><?php echo $irregulardatetext; ?> </option> <?php } ?> </select> <strong><?php echo JText::_("JEV_IRREGULAR_REPEATS_CANNOT_BE_EXPORTED_AT_PRESENT"); ?>
function JEventsBuildRouteNew(&$query, $task) { $transtask = translatetask($task); $params = JComponentHelper::getParams("com_jevents"); // get a menu item based on Itemid or currently active $app = JFactory::getApplication(); $menu = $app->getMenu(); // we need a menu item. Either the one specified in the query, or the current active one if none specified if (empty($query['Itemid'])) { $menuItem = $menu->getActive(); $menuItemGiven = false; } else { $menuItem = $menu->getItem($query['Itemid']); $menuItemGiven = true; } $cfg = JEVConfig::getInstance(); $segments = array(); if (count($query) == 2 && isset($query['Itemid']) && isset($query['option'])) { // special case where we do not need any information since its a menu item // as long as the task matches up! $menu = JFactory::getApplication()->getMenu(); $menuitem = $menu->getItem($query["Itemid"]); if (!is_null($menuitem) && (isset($menuitem->query["task"]) || isset($menuitem->query["view"]) && isset($menuitem->query["layout"]))) { if (isset($menuitem->query["task"]) && $task == $menuitem->query["task"]) { return $segments; } else { if (isset($menuitem->query["view"]) && isset($menuitem->query["layout"]) && $task == $menuitem->query["view"] . "." . $menuitem->query["layout"]) { return $segments; } else { $segments[] = $transtask; } } } } switch ($task) { case "year.listevents": case "month.calendar": case "week.listevents": case "day.listevents": case "cat.listevents": case "jevent.detail": case "icalevent.detail": case "icalrepeat.detail": case "search.form": case "search.results": case "admin.listevents": if (!in_array($transtask, $segments)) { $segments[] = $transtask; } $config = JFactory::getConfig(); $t_datenow = JEVHelper::getNow(); // if no date in the query then use TODAY not the calendar date $nowyear = JevDate::strftime('%Y', $t_datenow->toUnix(true)); $nowmonth = JevDate::strftime('%m', $t_datenow->toUnix(true)); $nowday = JevDate::strftime('%d', $t_datenow->toUnix(true)); if (isset($query['year'])) { $year = $query['year'] == "YYYYyyyy" ? "YYYYyyyy" : intval($query['year']); unset($query['year']); } else { $year = $nowyear; } if (isset($query['month'])) { $month = $query['month'] == "MMMMmmmm" ? "MMMMmmmm" : intval($query['month']); unset($query['month']); } else { $month = $nowmonth; } if (isset($query['day'])) { $day = intval($query['day']); unset($query['day']); } else { // if no date in the query then use TODAY not the calendar date $day = $nowday; } // for week data always go to the start of the week if ($task == "week.listevents" && is_int($month)) { $startday = $cfg->get('com_starday'); if (!$startday) { $startday = 0; } $date = mktime(5, 5, 5, $month, $day, $year); $currentday = strftime("%w", $date); if ($currentday > $startday) { $date -= ($currentday - $startday) * 86400; list($year, $month, $day) = explode("-", strftime("%Y-%m-%d", $date)); } else { if ($currentday < $startday) { $date -= (7 + $currentday - $startday) * 86400; list($year, $month, $day) = explode("-", strftime("%Y-%m-%d", $date)); } } } // only include the year in the date and list views if (in_array($task, array("year.listevents", "month.calendar", "week.listevents", "day.listevents"))) { $segments[] = $year; } // only include the month in the date and list views (excluding year) if (in_array($task, array("month.calendar", "week.listevents", "day.listevents"))) { $segments[] = $month; } // only include the day in the week and day views (excluding year and month) if (in_array($task, array("week.listevents", "day.listevents"))) { $segments[] = $day; } switch ($task) { case "jevent.detail": case "icalevent.detail": case "icalrepeat.detail": if (isset($query['jevtype'])) { unset($query['jevtype']); } if ($transtask != "") { if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } } break; default: break; } if (isset($query['catids']) && strlen($query['catids']) > 0) { $segments[] = $query['catids']; unset($query['catids']); } else { if ($transtask != "") { $segments[] = "-"; } } switch ($task) { case "icalrepeat.detail": if (isset($query['uid'])) { // Some remote UIDs have @ and other dodgy characters in them so encode them for safety //$segments[] = base64_encode($query['uid']); unset($query['uid']); } if (isset($query['title'])) { $segments[] = substr(JApplication::stringURLSafe($query['title']), 0, 150); unset($query['title']); } else { $segments[] = "-"; } if ($transtask == "") { if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } } break; default: break; } break; case "jevent.edit": case "icalevent.edit": case "icalevent.publish": case "icalevent.unpublish": case "icalevent.editcopy": case "icalrepeat.edit": case "jevent.delete": case "icalevent.delete": case "icalrepeat.delete": case "icalrepeat.deletefuture": $segments[] = $transtask; if (isset($query['jevtype'])) { unset($query['jevtype']); } if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } break; case "modlatest.rss": $segments[] = $transtask; // assume implicit feed document //unset($query['format']); // feed type if (isset($query['type'])) { $segments[] = $query['type']; unset($query['type']); } else { $segments[] = 'rss'; } // modid if (isset($query['modid'])) { $segments[] = $query['modid']; unset($query['modid']); } else { $segments[] = "0"; } break; case "icalrepeat.vcal": case "icalevent.vcal": $segments[] = $transtask; if (isset($query['evid'])) { $segments[] = $query['evid']; unset($query['evid']); } else { $segments[] = "0"; } if (isset($query['catids'])) { $segments[] = $query['catids']; unset($query['catids']); } else { $segments[] = "0"; } break; default: $segments[] = $transtask; $segments[] = "-"; break; } return $segments; }
protected function processMatch(&$content, $match, $dayEvent, $dateParm, $relDay) { $datenow = JEVHelper::getNow(); $dispatcher = JDispatcher::getInstance(); // get the title and start time $startDate = JevDate::strtotime($dayEvent->publish_up()); if ($relDay > 0) { $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " +{$relDay} days"); } else { $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $startDate) . " {$relDay} days"); } $endDate = JevDate::strtotime($dayEvent->publish_down()); list($st_year, $st_month, $st_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate)); list($ev_year, $ev_month, $ev_day) = explode('-', JevDate::strftime('%Y-%m-%d', $startDate)); $task_events = 'icalrepeat.detail'; switch ($match) { case 'endDate': case 'startDate': case 'eventDate': // Note we need to examine the date specifiers used to determine if language translation will be // necessary. Do this later when script is debugged. if (!$this->disableDateStyle) { $content .= '<span class="mod_events_latest_date">'; } if (!$dayEvent->alldayevent() && $match == "endDate" && ($dayEvent->noendtime() && $dayEvent->getUnixStartDate() == $dayEvent->getUnixEndDate() || $dayEvent->getUnixStartTime() == $dayEvent->getUnixEndTime())) { $time_fmt = ""; } else { if (!isset($dateParm) || $dateParm == '') { if ($this->com_calUseStdTime) { $time_fmt = $dayEvent->alldayevent() ? '' : IS_WIN ? ' @%I:%M%p' : ' @%l:%M%p'; } else { $time_fmt = $dayEvent->alldayevent() ? '' : ' @%H:%M'; } $dateFormat = $this->displayYear ? '%a %b %d, %Y' . $time_fmt : '%a %b %d' . $time_fmt; $jmatch = new JevDate(${$match}); $content .= $jmatch->toFormat($dateFormat); //$content .= JEV_CommonFunctions::jev_strftime($dateFormat, $$match); } else { // format endDate when midnight to show midnight! if ($match == "endDate" && $dayEvent->sdn() == 59) { $tempEndDate = $endDate + 1; if ($dayEvent->alldayevent()) { // if an all day event then we don't want to roll to the next day $tempEndDate -= 86400; } $match = "tempEndDate"; } // if a '%' sign detected in date format string, we assume JevDate::strftime() is to be used, if (preg_match("/\\%/", $dateParm)) { $jmatch = new JevDate(${$match}); $content .= $jmatch->toFormat($dateParm); } else { $content .= date($dateParm, ${$match}); } if ($match == "tempDndDate") { $match = "endDate"; } } } if (!$this->disableDateStyle) { $content .= "</span>"; } break; case 'title': $title = $dayEvent->title(); if (!empty($dateParm)) { $parts = explode("|", $dateParm); if (count($parts) > 0 && strlen($title) > intval($parts[0])) { $title = substr($title, 0, intval($parts[0])); if (count($parts) > 1) { $title .= $parts[1]; } } } if (!$this->disableTitleStyle) { $content .= '<span class="mod_events_latest_content">'; } if ($this->displayLinks) { $link = $dayEvent->viewDetailLink($ev_year, $ev_month, $ev_day, false, $this->myItemid); if ($this->modparams->get("ignorefiltermodule", 0)) { $link = JRoute::_($link . $this->datamodel->getCatidsOutLink() . "&filter_reset=1"); } else { $link = JRoute::_($link . $this->datamodel->getCatidsOutLink()); } $content .= $this->_htmlLinkCloaking($link, JEventsHTML::special($title)); } else { $content .= JEventsHTML::special($title); } if (!$this->disableTitleStyle) { $content .= '</span>'; } break; case 'category': $catobj = $dayEvent->getCategoryName(); $content .= JEventsHTML::special($catobj); break; case 'categoryimage': $catobj = $dayEvent->getCategoryImage(); $content .= $catobj; break; case 'calendar': $catobj = $dayEvent->getCalendarName(); $content .= JEventsHTML::special($catobj); break; case 'contact': // Also want to cloak contact details so $this->modparams->set("image", 1); $dayEvent->text = $dayEvent->contact_info(); $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent, &$this->modparams, 0)); $dayEvent->contact_info($dayEvent->text); $content .= $dayEvent->contact_info(); break; case 'content': // Added by Kaz McCoy 1-10-2004 $this->modparams->set("image", 1); $dayEvent->data->text = $dayEvent->content(); $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0)); if (!empty($dateParm)) { $parts = explode("|", $dateParm); if (count($parts) > 0 && strlen(strip_tags($dayEvent->data->text)) > intval($parts[0])) { $dayEvent->data->text = substr(strip_tags($dayEvent->data->text), 0, intval($parts[0])); if (count($parts) > 1) { $dayEvent->data->text .= $parts[1]; } } } $dayEvent->content($dayEvent->data->text); //$content .= substr($dayEvent->content, 0, 150); $content .= $dayEvent->content(); break; case 'addressInfo': case 'location': $this->modparams->set("image", 0); $dayEvent->data->text = $dayEvent->location(); $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0)); $dayEvent->location($dayEvent->data->text); $content .= $dayEvent->location(); break; case 'duration': $timedelta = $dayEvent->noendtime() || $dayEvent->alldayevent() ? "" : $dayEvent->getUnixEndTime() - $dayEvent->getUnixStartTime(); if ($timedelta == "") { break; } $fieldval = isset($dateParm) && $dateParm != '' ? $dateParm : 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("%wd", $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); } $content .= $fieldval; break; case 'extraInfo': $this->modparams->set("image", 0); $dayEvent->data->text = $dayEvent->extra_info(); $dispatcher->trigger('onContentPrepare', array('com_jevents', &$dayEvent->data, &$this->modparams, 0)); $dayEvent->extra_info($dayEvent->data->text); $content .= $dayEvent->extra_info(); break; case 'countdown': $timedelta = $dayEvent->getUnixStartTime() - JevDate::mktime(); $eventPassed = !($timedelta >= 0); $fieldval = $dateParm; $shownsign = false; if (stripos($fieldval, "%nopast") !== false) { if (!$eventPassed) { $fieldval = str_ireplace("%nopast", "", $fieldval); } else { $fieldval = JText::_('JEV_EVENT_FINISHED'); } } if (stripos($fieldval, "%d") !== false) { $days = intval($timedelta / (60 * 60 * 24)); $timedelta -= $days * 60 * 60 * 24; $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); } $content .= $fieldval; break; case 'createdByAlias': $content .= $dayEvent->created_by_alias(); break; case 'createdByUserName': $catobj = JEVHelper::getUser($dayEvent->created_by()); $content .= isset($catobj->username) ? $catobj->username : ""; break; case 'createdByUserEmail': // Note that users email address will NOT be available if they don't want to receive email $catobj = JEVHelper::getUser($dayEvent->created_by()); $content .= $catobj->sendEmail ? $catobj->email : ''; break; case 'createdByUserEmailLink': // Note that users email address will NOT be available if they don't want to receive email $content .= JRoute::_("index.php?option=" . $compname . "&task=" . $task_events . "&agid=" . $dayEvent->id() . "&year=" . $st_year . "&month=" . $st_month . "&day=" . $st_day . "&Itemid=" . $this->myItemid . $this->catout); break; case 'color': $content .= $dayEvent->bgcolor(); break; case 'eventDetailLink': $link = $dayEvent->viewDetailLink($st_year, $st_month, $st_day, false, $this->myItemid); $link = JRoute::_($link . $this->datamodel->getCatidsOutLink()); $content .= $link; /* $content .= JRoute::_("index.php?option=" . $compname . "&task=".$task_events . "&agid=".$dayEvent->id() . "&year=".$st_year . "&month=".$st_month . "&day=".$st_day . "&Itemid=".$this->myItemid . $this->catout); */ break; default: try { if (strpos($match, '${') !== false) { $parts = explode('${', $match); $tempstr = ""; foreach ($parts as $part) { if (strpos($part, "}") !== false) { // limit to 2 because we may be using joomla content plugins $subparts = explode("}", $part, 2); if (strpos($subparts[0], "#") > 0) { $formattedparts = explode("#", $subparts[0]); $subparts[0] = $formattedparts[0]; } else { $formattedparts = array($subparts[0], "%s", ""); } $subpart = "_" . $subparts[0]; if (isset($dayEvent->{$subpart})) { $temp = $dayEvent->{$subpart}; if ($temp != "") { $tempstr .= str_replace("%s", $temp, $formattedparts[1]); } else { if (isset($formattedparts[2])) { $tempstr .= str_replace("%s", $temp, $formattedparts[2]); } } } else { if (isset($dayEvent->customfields[$subparts[0]]['value'])) { $temp = $dayEvent->customfields[$subparts[0]]['value']; if ($temp != "") { $tempstr .= str_replace("%s", $temp, $formattedparts[1]); } else { if (isset($formattedparts[2])) { $tempstr .= str_replace("%s", $temp, $formattedparts[2]); } } } else { $matchedByPlugin = false; $layout = "list"; static $fieldNameArrays = array(); $jevplugins = JPluginHelper::getPlugin("jevents"); foreach ($jevplugins as $jevplugin) { $classname = "plgJevents" . ucfirst($jevplugin->name); if (is_callable(array($classname, "substitutefield"))) { if (!isset($fieldNameArrays[$classname])) { $fieldNameArrays[$classname] = call_user_func(array($classname, "fieldNameArray"), $layout); } if (isset($fieldNameArrays[$classname]["values"])) { if (in_array($subparts[0], $fieldNameArrays[$classname]["values"])) { $matchedByPlugin = true; // is the event detail hidden - if so then hide any custom fields too! if (!isset($event->_privateevent) || $event->_privateevent != 3) { $temp = call_user_func(array($classname, "substitutefield"), $dayEvent, $subparts[0]); if ($temp != "") { $tempstr .= str_replace("%s", $temp, $formattedparts[1]); } else { if (isset($formattedparts[2])) { $tempstr .= str_replace("%s", $temp, $formattedparts[2]); } } } } } } } if (!$matchedByPlugin) { // Layout editor code include_once JEV_PATH . "/views/default/helpers/defaultloadedfromtemplate.php"; ob_start(); // false at the end to stop it running through the plugins $part = "{{Dummy Label:" . implode("#", $formattedparts) . "}}"; DefaultLoadedFromTemplate(false, false, $dayEvent, 0, $part, false); $newpart = ob_get_clean(); if ($newpart != $part) { $tempstr .= $newpart; $matchedByPlugin = true; } } // none of the plugins has replaced the output so we now replace the blank formatted part! if (!$matchedByPlugin && isset($formattedparts[2])) { $tempstr .= str_replace("%s", "", $formattedparts[2]); } //$dispatcher->trigger( 'onLatestEventsField', array( &$dayEvent, $subparts[0], &$tempstr)); } } $tempstr .= $subparts[1]; } else { $tempstr .= $part; } } $content .= $tempstr; } else { if ($match) { $content .= $match; } } } catch (Exception $e) { if ($match) { $content .= $match; } } break; } // end of switch }
/** * function that adjusts instances in the repetitions table * */ function adjustRepetition($matchingEvent) { $eventid = $this->ev_id; $start = iCalImport::unixTime($this->recurrence_id); $duplicatecheck = md5($eventid . $start); // find the existing repetition in order to get the detailid $db =& JFactory::getDBO(); $sql = "SELECT * FROM #__jevents_repetition WHERE duplicatecheck='{$duplicatecheck}'"; $db->setQuery($sql); $matchingRepetition = $db->loadObject(); if (!isset($matchingRepetition)) { return false; } // I now create a new evdetail instance $newDetail = iCalEventDetail::iCalEventDetailFromData($this->data); if (isset($matchingRepetition) && isset($matchingRepetition->eventdetail_id)) { // This traps the first time through since the 'global id has not been overwritten if ($matchingEvent->detail_id != $matchingRepetition->eventdetail_id) { //$newDetail->evdet_id = $matchingRepetition->eventdetail_id; } } if (!$newDetail->store()) { return false; } // clumsy - add in the new version with the correct times (does not deal with modified descriptions and sequence) $start = JevDate::strftime('%Y-%m-%d %H:%M:%S', $newDetail->dtstart); if ($newDetail->dtend != 0) { $end = $newDetail->dtend; } else { $end = $start + $newDetail->duration; } // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day list($h, $m, $s) = explode(":", JevDate::strftime("%H:%M:%S", $end)); if ($h + $m + $s == 0) { $end = JevDate::strftime('%Y-%m-%d 23:59:59', $end - 86400); } else { $end = JevDate::strftime('%Y-%m-%d %H:%M:%S', $end); } $duplicatecheck = md5($eventid . $start); $db =& JFactory::getDBO(); $sql = "UPDATE #__jevents_repetition SET eventdetail_id=" . $newDetail->evdet_id . ", startrepeat='" . $start . "'" . ", endrepeat='" . $end . "'" . ", duplicatecheck='" . $duplicatecheck . "'" . " WHERE rp_id=" . $matchingRepetition->rp_id; $db->setQuery($sql); return $db->query(); }
private function vtimezone($icalEvents) { $params = JComponentHelper::getParams(JEV_COM_COMPONENT); $tzid = ""; if (is_callable("date_default_timezone_set")) { $current_timezone = date_default_timezone_get(); // Do the Timezone definition $tzid = ";TZID={$current_timezone}"; // find the earliest start date $firststart = false; foreach ($icalEvents as $a) { if (!$firststart || $a->getUnixStartTime() < $firststart) { $firststart = $a->getUnixStartTime(); } } // Subtract 1 leap year to make sure we have enough transitions $firststart -= 31622400; $timezone = new DateTimeZone($current_timezone); if (version_compare(PHP_VERSION, "5.3.0") >= 0) { $transitions = $timezone->getTransitions($firststart); } else { $transitions = $timezone->getTransitions(); } $tzindex = 0; while (JevDate::strtotime($transitions[$tzindex]['time']) < $firststart) { $tzindex++; } $transitions = array_slice($transitions, $tzindex); if (count($transitions) >= 2) { $lastyear = $params->get("com_latestyear", 2020); echo "BEGIN:VTIMEZONE\n"; echo "TZID:{$current_timezone}\n"; for ($t = 0; $t < count($transitions); $t++) { $transition = $transitions[$t]; if ($transition['isdst'] == 0) { if (JevDate::strftime("%Y", $transition['ts']) > $lastyear) { continue; } echo "BEGIN:STANDARD\n"; echo "DTSTART:" . JevDate::strftime("%Y%m%dT%H%M%S\n", $transition['ts']); if ($t < count($transitions) - 1) { echo "RDATE:" . JevDate::strftime("%Y%m%dT%H%M%S\n", $transitions[$t + 1]['ts']); } // if its the first transition then assume the old setting is the same as the next otherwise use the previous value $prev = $t; $prev += $t == 0 ? 1 : -1; $offset = $transitions[$prev]["offset"]; $sign = $offset >= 0 ? "+" : "-"; $offset = abs($offset); $offset = $sign . sprintf("%04s", floor($offset / 3600) * 100 + $offset % 60); echo "TZOFFSETFROM:{$offset}\n"; $offset = $transitions[$t]["offset"]; $sign = $offset >= 0 ? "" : "-"; $offset = abs($offset); $offset = $sign . sprintf("%04s", floor($offset / 3600) * 100 + $offset % 60); echo "TZOFFSETTO:{$offset}\n"; echo "TZNAME:{$current_timezone} " . $transitions[$t]["abbr"] . "\n"; echo "END:STANDARD\n"; } } for ($t = 0; $t < count($transitions); $t++) { $transition = $transitions[$t]; if ($transition['isdst'] == 1) { if (JevDate::strftime("%Y", $transition['ts']) > $lastyear) { continue; } echo "BEGIN:DAYLIGHT\n"; echo "DTSTART:" . JevDate::strftime("%Y%m%dT%H%M%S\n", $transition['ts']); if ($t < count($transitions) - 1) { echo "RDATE:" . JevDate::strftime("%Y%m%dT%H%M%S\n", $transitions[$t + 1]['ts']); } // if its the first transition then assume the old setting is the same as the next otherwise use the previous value $prev = $t; $prev += $t == 0 ? 1 : -1; $offset = $transitions[$prev]["offset"]; $sign = $offset >= 0 ? "+" : "-"; $offset = abs($offset); $offset = $sign . sprintf("%04s", floor($offset / 3600) * 100 + $offset % 60); echo "TZOFFSETFROM:{$offset}\n"; $offset = $transitions[$t]["offset"]; $sign = $offset >= 0 ? "" : "-"; $offset = abs($offset); $offset = $sign . sprintf("%04s", floor($offset / 3600) * 100 + $offset % 60); echo "TZOFFSETTO:{$offset}\n"; echo "TZNAME:{$current_timezone} " . $transitions[$t]["abbr"] . "\n"; echo "END:DAYLIGHT\n"; } } echo "END:VTIMEZONE\n"; } } return $tzid; }
/** * Generates repetition from vevent & rrule data from scratch * The result can then be saved to the database */ function getRepetitions($dtstart, $dtend, $duration, $recreate = false, $exdate = array()) { // put exdate into somewhere that I can get from _makerepeat $this->_exdate = $exdate; // TODO "getRepetitions doesnt yet deal with Short months and 31st or leap years/week 53<br/>"; if ($dtend == 0 && $duration > 0) { $dtend = $dtstart + $duration; } if (!$recreate && isset($this->_repetitions)) { return $this->_repetitions; } $this->_repetitions = array(); if (!isset($this->eventid)) { echo "no eventid set in generateRepetitions<br/>"; return $this->_repetitions; } if ($this->count == 1 && $this->freq != "IRREGULAR") { //echo "count=1 returing<br/>"; $this->_makeRepeat($dtstart, $dtend); return $this->_repetitions; } //list ($h,$min,$s,$d,$m,$y) = explode(":",JevDate::strftime("%H:%M:%S:%d:%m:%Y",$end)); list($startHour, $startMin, $startSecond, $startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("0%H:0%M:0%S:%d:%m:%Y:%w", $dtstart)); //echo "$startHour,$startMin,$startSecond,$startDay,$startMonth,$startYear,$startWD,$dtstart<br/>"; $dtstartMidnight = JevDate::mktime(0, 0, 0, $startMonth, $startDay, $startYear); list($endDay, $endMonth, $endYear, $endWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $dtend)); $duration = $dtend - $dtstart; static $weekdayMap = array("SU" => 0, "MO" => 1, "TU" => 2, "WE" => 3, "TH" => 4, "FR" => 5, "SA" => 6); static $weekdayReverseMap = array("SU", "MO", "TU", "WE", "TH", "FR", "SA"); static $dailySecs = 86400; static $weeklySecs = 604800; // TODO implement byyearday // TODO do full leap year audit e.g. YEARLY repeats //echo "freq = ".$this->freq."<br/>"; switch ($this->freq) { case "YEARLY": // TODO the code doesn't yet deal with multiple bymonths if ($this->bymonth == "") { $this->bymonth = $startMonth; } //if ($this->byday=="") $this->byday=$weekdayReverseMap[$startWD]; // If I have byday and bymonthday then the two considions must be met $weekdays = array(); if ($this->byday != "") { foreach (explode(",", $this->byday) as $bday) { if (array_key_exists($bday, $weekdayMap)) { $weekdays[] = $weekdayMap[$bday]; } } } if ($this->byyearday != "") { echo "byyearday <br/>"; $days = explode(",", $this->byyearday); $start = $dtstart; $end = $dtend; $countRepeats = 0; $currentYearStart = JevDate::mktime(0, 0, 0, 1, 1, $startYear); // do the current month first while ($countRepeats < $this->count && !$this->_afterUntil($currentYearStart)) { $currentYear = JevDate::strftime("%Y", $currentYearStart); $currentYearDays = date("L", $currentYearStart) ? 366 : 365; foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } // TODO I am assuming all + or all -ve $details = array(); preg_match("/(\\+|-?)(\\d*)/", $day, $details); list($temp, $plusminus, $daynumber) = $details; if (JString::strlen($plusminus) == 0) { $plusminus = "+"; } // do not go over year end if ($daynumber > $currentYearDays) { continue; } if ($plusminus == "+") { $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, 12, 31, $currentYear - 1); $targetStart = JevDate::strtotime("+{$daynumber} days", $targetStart); } else { $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, 1, 1, $currentYear + 1); $targetStart = JevDate::strtotime("-{$daynumber} days", $targetStart); } $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { // double check for byday constraints if ($this->byday != "") { if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) { continue; } } $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } // now ago to the start of next year if ($currentYear + $this->rinterval > 2099) { return $this->_repetitions; } $currentYearStart = JevDate::mktime(0, 0, 0, 1, 1, $currentYear + $this->rinterval); } } else { if ($this->bymonthday != "") { echo "bymonthday" . $this->bymonthday . " <br/>"; $days = explode(",", $this->bymonthday); $start = $dtstart; $end = $dtend; $countRepeats = 0; $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear); // do the current month first while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) { list($currentMonth, $currentYear) = explode(":", JevDate::strftime("%m:%Y", $currentMonthStart)); $currentMonthDays = date("t", $currentMonthStart); foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } // Assume no negative bymonthday values // TODO relax this assumption // do not go over month end if ($day > $currentMonthDays) { continue; } $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $day, $currentYear); $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { // double check for byday constraints if ($this->byday != "") { if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) { continue; } } $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } // now ago to the start of next month if ($currentYear + $this->rinterval > 2099) { return $this->_repetitions; } $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth, 1, $currentYear + $this->rinterval); } } else { if ($this->byday == "") { $start = $dtstart; $end = $dtend; $countRepeats = 0; while ($countRepeats < $this->count && !$this->_afterUntil($start)) { $countRepeats += $this->_makeRepeat($start, $end); $currentYear = JevDate::strftime("%Y", $start); list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start)); $maxyear = PHP_INT_SIZE === 8 ? 2999 : 2037; if ($currentYear + $this->rinterval >= $maxyear) { break; } $start = JevDate::strtotime("+" . $this->rinterval . " years", $start); $end = JevDate::strtotime("+" . $this->rinterval . " years", $end); } } else { $days = explode(",", $this->byday); // duplicate where necessary $extradays = array(); foreach ($days as $day) { if (strpos($day, "+") === false && strpos($day, "-") === false) { for ($i = 2; $i <= 52; $i++) { $extradays[] = "+" . $i . $day; } } } $days = array_merge($days, $extradays); $start = $dtstart; $end = $dtend; $countRepeats = 0; // do the current month first while ($countRepeats < $this->count && !$this->_afterUntil($start)) { $currentMonth = JevDate::strftime("%m", $start); foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } $details = array(); if (strpos($day, "+") === false && strpos($day, "-") === false) { $day = "+1" . $day; } preg_match("/(\\+|-?)(\\d+)(.{2})/", $day, $details); if (count($details) != 4) { echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>"; return $this->_repetitions; } else { list($temp, $plusminus, $weeknumber, $dayname) = $details; if (JString::strlen($plusminus) == 0) { $plusminus = "+"; } if (JString::strlen($weeknumber) == 0) { $weeknumber = 1; } // always check for dtstart (nothing is allowed earlier) if ($plusminus == "-") { //echo "count back $weeknumber weeks on $dayname<br/>"; list($startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $start)); $startLast = date("t", $start); $monthEnd = JevDate::mktime(0, 0, 0, $startMonth, $startLast, $startYear); $meWD = JevDate::strftime("%w", $monthEnd); $adjustment = $startLast - (7 + $meWD - $weekdayMap[$dayname]) % 7; $targetstartDay = $adjustment - ($weeknumber - 1) * 7; $targetendDay = $targetstartDay + $endDay - $startDay; list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start)); $testStart = JevDate::mktime($h, $min, $s, $m, $targetstartDay, $y); if ($currentMonth == JevDate::strftime("%m", $testStart)) { $targetStart = $testStart; $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } } else { //echo "count forward $weeknumber weeks on $dayname<br/>"; list($startDay, $startMonth, $startYear, $startWD) = explode(":", JevDate::strftime("%d:%m:%Y:%w", $start)); $monthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear); $msWD = JevDate::strftime("%w", $monthStart); if (!isset($weekdayMap[$dayname])) { $x = 1; } $adjustment = 1 + (7 + $weekdayMap[$dayname] - $msWD) % 7; $targetstartDay = $adjustment + ($weeknumber - 1) * 7; $targetendDay = $targetstartDay + $endDay - $startDay; list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start)); $testStart = JevDate::mktime($h, $min, $s, $m, $targetstartDay, $y); if ($currentMonth == JevDate::strftime("%m", $testStart)) { $targetStart = $testStart; $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } } } } // now ago to the start of the next month $start = $targetStart; $end = $targetEnd; list($h, $min, $s, $d, $m, $y) = explode(":", JevDate::strftime("%H:%M:%S:%d:%m:%Y", $start)); if ($y + $this->rinterval + $m / 12 > 2099) { return $this->_repetitions; } $start = JevDate::mktime($h, $min, $s, $m, 1, $y + $this->rinterval); $end = $start + $duration; } } } } return $this->_repetitions; break; case "MONTHLY": if ($this->bymonthday == "" && $this->byday == "") { $this->bymonthday = $startDay; } if ($this->bymonthday != "") { echo "bymonthday" . $this->bymonthday . " <br/>"; // if not byday then by monthday $days = explode(",", $this->bymonthday); // If I have byday and bymonthday then the two considions must be met $weekdays = array(); if ($this->byday != "") { foreach (explode(",", $this->byday) as $bday) { $weekdays[] = $weekdayMap[$bday]; } } $start = $dtstart; $end = $dtend; $countRepeats = 0; $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear); // do the current month first while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) { //echo $countRepeats ." ".$this->count." ".$currentMonthStart."<br/>"; list($currentMonth, $currentYear) = explode(":", JevDate::strftime("%m:%Y", $currentMonthStart)); $currentMonthDays = date("t", $currentMonthStart); foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } $details = array(); preg_match("/(\\+|-?)(\\d+)/", $day, $details); if (count($details) != 3) { echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>"; return $this->_repetitions; } else { list($temp, $plusminus, $daynumber) = $details; if (JString::strlen($plusminus) == 0) { $plusminus = "+"; } if (JString::strlen($daynumber) == 0) { $daynumber = $startDay; } // always check for dtstart (nothing is allowed earlier) if ($plusminus == "-") { // must not go before start of month etc. if ($daynumber > $currentMonthDays) { continue; } echo "I need to check negative bymonth days <br/>"; $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $currentMonthDays + 1 - $daynumber, $currentYear); $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } else { //echo "$daynumber $currentMonthDays bd=".$this->byday." <br/>"; // must not go over end month etc. if ($daynumber > $currentMonthDays) { continue; } //echo "$startHour,$startMin,$startSecond,$currentMonth,$daynumber,$currentYear<br/>"; $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $daynumber, $currentYear); $targetEnd = $targetStart + $duration; //echo "$targetStart $targetEnd $dtstartMidnight<br/>"; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { // double check for byday constraints if ($this->byday != "") { if (!in_array(JevDate::strftime("%w", $targetStart), $weekdays)) { continue; } } $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); //echo "countrepeats = $countRepeats<br/>"; } } } } // now ago to the start of next month if ($currentYear + ($currentMonth + $this->rinterval) / 12 > 2099) { return $this->_repetitions; } $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth + $this->rinterval, 1, $currentYear); } } else { $days = explode(",", $this->byday); // TODO I should also iterate over week number if this is used //$weeknumbers = explode(",",$this->byweekno); if ($this->bysetpos != "") { $newdays = array(); $setpositions = explode(",", $this->bysetpos); foreach ($setpositions as $setposition) { foreach ($days as $day) { if (strpos($setposition, "+") === false && strpos($setposition, "-") === false) { $setposition = "+" . $setposition; } $newdays[] = $setposition . $day; } } $days = $newdays; $this->byday = implode(",", $days); } $start = $dtstart; $end = $dtend; $countRepeats = 0; $currentMonthStart = JevDate::mktime(0, 0, 0, $startMonth, 1, $startYear); // do the current month first while ($countRepeats < $this->count && !$this->_afterUntil($currentMonthStart)) { list($currentMonth, $currentYear, $currentMonthStartWD) = explode(":", JevDate::strftime("%m:%Y:%w", $currentMonthStart)); $currentMonthDays = date("t", $currentMonthStart); $this->sortByDays($days, $currentMonthStart, $dtstart); foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } $details = array(); preg_match("/(\\+|-?)(\\d?)(.+)/", $day, $details); if (count($details) != 4) { echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>"; return $this->_repetitions; } else { list($temp, $plusminus, $weeknumber, $dayname) = $details; if (JString::strlen($plusminus) == 0) { $plusminus = "+"; } if (JString::strlen($weeknumber) == 0) { $weeknumber = 1; } $multiplier = $plusminus == "+" ? 1 : -1; // always check for dtstart (nothing is allowed earlier) if ($plusminus == "-") { //echo "count back $weeknumber weeks on $dayname<br/>"; $startLast = date("t", $currentMonthStart); $currentMonthEndWD = ($startLast - 1 + $currentMonthStartWD) % 7; $adjustment = $startLast - (7 + $currentMonthEndWD - $weekdayMap[$dayname]) % 7; $targetstartDay = $adjustment - ($weeknumber - 1) * 7; } else { //echo "count forward $weeknumber weeks on $dayname<br/>"; $adjustment = 1 + (7 + $weekdayMap[$dayname] - $currentMonthStartWD) % 7; $targetstartDay = $adjustment + ($weeknumber - 1) * 7; } $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $targetstartDay, $currentYear); if ($currentMonth == JevDate::strftime("%m", $targetStart)) { $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } } } // now go to the start of next month if ($currentYear + ($currentMonth + $this->rinterval) / 12 > 2099) { return $this->_repetitions; } $currentMonthStart = JevDate::mktime(0, 0, 0, $currentMonth + $this->rinterval, 1, $currentYear); } } return $this->_repetitions; break; case "WEEKLY": $days = explode(",", $this->byday); $start = $dtstart; $end = $dtend; $countRepeats = 0; $currentWeekDay = JevDate::strftime("%w", $start); // Go to the zero day of the first week (even if this is in the past) // this will be the base from which we count the weeks and weekdays $currentWeekStart = JevDate::strtotime("-{$currentWeekDay} days", $start); // no BYDAY specified if ($this->byday == "") { $daynames = array("SU", "MO", "TU", "WE", "TH", "FR", "SA", "SU"); $this->byday = "+" . $daynames[$currentWeekDay]; $days = array($this->byday); } while ($countRepeats < $this->count && !$this->_afterUntil($currentWeekStart)) { list($currentDay, $currentMonth, $currentYear) = explode(":", JevDate::strftime("%d:%m:%Y", $currentWeekStart)); foreach ($days as $day) { if ($countRepeats >= $this->count || $this->_afterUntil($start)) { return $this->_repetitions; } $details = array(); preg_match("/(\\+|-?)(\\d?)(.+)/", $day, $details); if (count($details) != 4) { continue; echo "<br/><br/><b>PROBLEMS with {$day}</b><br/><br/>"; return $this->_repetitions; } else { list($temp, $plusminus, $daynumber, $dayname) = $details; if (JString::strlen($plusminus) == 0) { $plusminus = "+"; } // this is not relevant for weekly recurrence ?!?!? //if (JString::strlen($daynumber)==0) $daynumber=1; $multiplier = $plusminus == "+" ? 1 : -1; if ($plusminus == "-") { // TODO find out if I ever have this situation? // It would seem meaningless } else { //echo "count forward $daynumber days on $dayname<br/>"; $targetstartDay = $currentDay + $weekdayMap[$dayname]; } $targetStart = JevDate::mktime($startHour, $startMin, $startSecond, $currentMonth, $targetstartDay, $currentYear); $targetEnd = $targetStart + $duration; if ($countRepeats >= $this->count) { return $this->_repetitions; } if ($targetStart >= $dtstartMidnight && !$this->_afterUntil($targetStart)) { $countRepeats += $this->_makeRepeat($targetStart, $targetEnd); } } } // now go to the start of next week if ($currentYear + $currentMonth / 12 > 2099) { return $this->_repetitions; } $currentWeekStart = JevDate::strtotime("+" . $this->rinterval . " weeks", $currentWeekStart); } return $this->_repetitions; break; case "DAILY": $start = $dtstart; $end = $dtend; $countRepeats = 0; $startYear = JevDate::strftime("%Y", $start); while ($startYear < 2027 && $countRepeats < $this->count && !$this->_afterUntil($start)) { //while ($startYear<5027 && $countRepeats < $this->count && !$this->_afterUntil($start)) { $countRepeats += $this->_makeRepeat($start, $end); $start = JevDate::strtotime("+" . $this->rinterval . " days", $start); $end = JevDate::strtotime("+" . $this->rinterval . " days", $end); $startYear = JevDate::strftime("%Y", $start); } return $this->_repetitions; break; case "IRREGULAR": $processedDates = array(); // current date is ALWAYS a repeat $processedDates[] = $dtstart; $this->_makeRepeat($dtstart, $dtend); if (is_string($this->irregulardates) && $this->irregulardates != "") { $this->irregulardates = @json_decode($this->irregulardates); } if (!is_array($this->irregulardates)) { $this->irregulardates = array(); } sort($this->irregulardates); foreach ($this->irregulardates as $irregulardate) { // avoid duplicate values if (in_array($irregulardate, $processedDates)) { continue; } $processedDates[] = $irregulardate; // find the start and end times of the initial event $irregulardate += $dtstart - $dtstartMidnight; $this->_makeRepeat($irregulardate, $irregulardate + $duration); } return $this->_repetitions; break; default: echo "UNKNOWN TYPE<br/>"; return $this->_repetitions; break; } }
// UTC! // Change timezone to UTC $current_timezone = date_default_timezone_get(); date_default_timezone_set("UTC"); // Do not use JevDate version since this sets timezone to config value! $chstart = strftime("%Y%m%dT%H%M%SZ", $chstart); $chend = strftime("%Y%m%dT%H%M%SZ", $chend); $stamptime = strftime("%Y%m%dT%H%M%SZ", time()); $originalstart = strftime("%Y%m%dT%H%M%SZ", $originalstart); // Change back date_default_timezone_set($current_timezone); } else { $chstart = JevDate::strftime("%Y%m%dT%H%M%S", $chstart); $chend = JevDate::strftime("%Y%m%dT%H%M%S", $chend); $stamptime = JevDate::strftime("%Y%m%dT%H%M%S", time()); $originalstart = JevDate::strftime("%Y%m%dT%H%M%S", $originalstart); } $html .= "DTSTAMP{$tzid}:" . $stamptime . "\r\n"; $html .= "DTSTART{$tzid}:" . $chstart . "\r\n"; $html .= "DTEND{$tzid}:" . $chend . "\r\n"; $html .= "RECURRENCE-ID{$tzid}:" . $originalstart . "\r\n"; $html .= "SEQUENCE:" . $a->_sequence . "\r\n"; $html .= "TRANSP:OPAQUE\r\n"; $html .= "END:VEVENT\r\n"; } } } } $html .= "END:VCALENDAR"; // clear out any rubbish @ob_end_clean();
$docimage->link = $this->info['imagelink']; $doc->image = $docimage; foreach ($this->eventsByRelDay as $relDay => $ebrd) { foreach ($ebrd as $row) { // title for particular item $item_title = htmlspecialchars($row->title()); $item_title = html_entity_decode($item_title); // url link to article $startDate = $row->publish_up(); //$eventDate = JevDate::mktime(JString::substr($startDate,11,2),JString::substr($startDate,14,2), JString::substr($startDate,17,2),$this->jeventCalObject->now_m,$this->jeventCalObject->now_d + $relDay,$this->jeventCalObject->now_Y); $eventDate = JevDate::strtotime($startDate); $datenow = JEVHelper::getNow(); if ($relDay > 0) { $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $eventDate) . " +{$relDay} days"); } else { $eventDate = JevDate::strtotime($datenow->toFormat('%Y-%m-%d ') . JevDate::strftime('%H:%M', $eventDate) . " {$relDay} days"); } $targetid = $this->modparams->get("target_itemid", 0); $link = $row->viewDetailLink(date("Y", $eventDate), date("m", $eventDate), date("d", $eventDate), false, $targetid); $link = str_replace("&tmpl=component", "", $link); $item_link = JRoute::_($link . $this->jeventCalObject->datamodel->getCatidsOutLink()); // removes all formating from the intro text for the description text $item_description = $row->content(); // remove dodgy border e.g. "diamond/question mark" $item_description = preg_replace('#border=[\\"\'][^0-9]*[\\"\']#i', '', $item_description); if ($this->info['limit_text']) { if ($this->info['text_length']) { $item_description = JFilterOutput::cleanText($item_description); // limits description text to x words $item_description_array = explode(' ', $item_description); $count = count($item_description_array);
function monthYearNavigation($cal_today, $adj, $symbol, $label, $action = "month.calendar") { $cfg =& JEVConfig::getInstance(); $jev_component_name = JEV_COM_COMPONENT; $adjDate = JevDate::strtotime($adj, $cal_today); list($year, $month) = explode(":", JevDate::strftime("%Y:%m", $adjDate)); $link = JRoute::_($this->linkpref . $action . "&day=1&month={$month}&year={$year}" . $this->cat); $content = ""; if (isset($this->_modid) && $this->_modid > 0) { $this->_navigationJS($this->_modid); $link = htmlentities("index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$month}&year={$year}&modid={$this->_modid}&tmpl=component" . $this->cat); $content = '<td>'; $link_image = ''; if ($symbol == "<") { $link_image = '<img src="/templates/ecc/images/month_prev.jpg" alt="Попередній місяць" />'; } else { if ($symbol == ">") { $link_image = '<img src="/templates/ecc/images/month_next.jpg" alt="Наступний місяць" />'; } } $content .= '<div class="mod_events_link" onmousedown="callNavigation(\'' . $link . '\');">' . $link_image . "</div>\n"; $content .= '</td>'; } return $content; }
function fixDtstart() { // must only ever do this once! if (isset($this->dtfixed) && $this->dtfixed) { return; } $this->dtfixed = 1; $db =& JFactory::getDBO(); // Now get the first repeat since dtstart may have been set in a different timezeone and since it is a unixdate it would then be wrong if (strtolower($this->freq()) == "none") { $repeat = $this->getFirstRepeat(); $this->dtstart($repeat->getUnixStartTime()); $this->dtend($repeat->getUnixEndTime()); } else { $repeat = $this->getFirstRepeat(); // Is this repeat an exception? $db->setQuery("SELECT * FROM #__jevents_exception WHERE rp_id=" . intval($repeat->rp_id())); $exception = $db->loadObject(); if (!$exception) { $this->dtstart($repeat->getUnixStartTime()); $this->dtend($repeat->getUnixEndTime()); } else { // This is the scenario where the first repeat is an exception so check to see if we need to be worried $jregistry =& JRegistry::getInstance("jevents"); // This is the server default timezone $jtimezone = $jregistry->getValue("jevents.timezone", false); if ($jtimezone) { // This is the JEvents set timezone $timezone = date_default_timezone_get(); // Only worry if the JEvents set timezone is different to the server timezone if ($timezone != $jtimezone) { // look for repeats that are not exceptions $repeat2 = $this->getFirstRepeat(false); // if we have none then use the first repeat and give a warning if (!$repeat2) { $this->dtstart($repeat->getUnixStartTime()); $this->dtend($repeat->getUnixEndTime()); JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT')); } else { // Calculate the time adjustment (if any) then check against the non-exceptional repeat // Convert dtstart using system timezone to date date_default_timezone_set($jtimezone); $truestarttime = JevDate::strftime("%H:%M:%S", $this->dtstart()); // if the system timezone version of dtstart is the same time as the first non-exceptional repeat // then we are safe to use this adjustment mechanism to dtstart. We use the real "date" and convert // back into unix time using the Jevents timezone if ($truestarttime == JevDate::strftime("%H:%M:%S", JevDate::mktime($repeat2->hup(), $repeat2->minup(), $repeat2->sup(), 0, 0, 0))) { $truedtstart = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtstart()); $truedtend = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtend()); // switch timezone back to Jevents timezone date_default_timezone_set($timezone); $this->dtstart(JevDate::strtotime($truedtstart)); $this->dtend(JevDate::strtotime($truedtend)); } else { // In this scenario we have no idea what the time should be unfortunately JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT')); // switch timezone back date_default_timezone_set($timezone); } } } } } } }
/** * Gets the date in a specific format * * Returns a string formatted according to the given format. Month and weekday names and * other language dependent strings respect the current locale * * @deprecated Deprecated since 1.6, use JDate::format() instead. * * @param string The date format specification string (see {@link PHP_MANUAL#JevDate::strftime}) * @param boolean True to return the date string in the local time zone, false to return it in GMT. * @return string The date as a formatted string. * @since 1.5 */ public function toFormat($format = '%Y-%m-%d %H:%M:%S', $local = false) { // do not reset the timezone !! - this is needed for the weekdays // Set time zone to GMT as JevDate::strftime formats according locale setting. // date_default_timezone_set('GMT'); // Generate the timestamp. $time = (int) parent::format('U', true); // this requires php 5.3! //$time = $this->getTimeStamp(); // If the returned time should be local add the GMT offset. if ($local) { $time += $this->getOffsetFromGMT(); } // Manually modify the month and day strings in the format. if (strpos($format, '%a') !== false) { $format = str_replace('%a', $this->dayToString(date('w', $time), true), $format); } if (strpos($format, '%A') !== false) { $format = str_replace('%A', $this->dayToString(date('w', $time)), $format); } if (strpos($format, '%b') !== false) { $format = str_replace('%b', $this->monthToString(date('n', $time), true), $format); } if (strpos($format, '%B') !== false) { $format = str_replace('%B', $this->monthToString(date('n', $time)), $format); } // Generate the formatted string. $date = JevDate::strftime($format, $time); // reset the timezone !! date_default_timezone_set(self::$stz->getName()); return $date; }
function DefaultViewHelperShowNavTableBar($view) { // this, previous and next date handling $cfg =& JEVConfig::getInstance(); // Optionally display no nav bar if ($cfg->get('com_calUseIconic', 1) == -1) { return ""; } $t_datenow = JEVHelper::getNow(); $datetime = JevDate::strftime('%Y-%m-%d %H:%M:%S', $t_datenow->toUnix(true)); preg_match("#([0-9]{4})-([0-9]{2})-([0-9]{2})[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})#", $datetime, $regs); $this_date = new JEventDate(); $this_date->setDate($view->year, $view->month, $view->day); $today_date = clone $this_date; $today_date->setDate($regs[1], $regs[2], $regs[3]); $task = JRequest::getString("jevtask"); $view->loadModules("jevpretoolbar"); $view->loadModules("jevpretoolbar_" . $task); $prev_year = clone $this_date; $prev_year->addMonths(-12); $next_year = clone $this_date; $next_year->addMonths(+12); $prev_month = clone $this_date; $prev_month->addMonths(-1); $next_month = clone $this_date; $next_month->addMonths(+1); $prev_week = clone $this_date; $prev_week->addDays(-7); $next_week = clone $this_date; $next_week->addDays(+7); $prev_day = clone $this_date; $prev_day->addDays(-1); $next_day = clone $this_date; $next_day->addDays(+1); switch ($task) { case 'year.listevents': $dates['prev2'] = $prev_year; $dates['prev1'] = $prev_year; $dates['next1'] = $next_year; $dates['next2'] = $next_year; $alts['prev2'] = JText::_('JEV_PREVIOUSYEAR'); $alts['prev1'] = JText::_('JEV_PREVIOUSYEAR'); $alts['next1'] = JText::_('JEV_NEXTYEAR'); $alts['next2'] = JText::_('JEV_NEXTYEAR'); // Show if ($cfg->get('com_calUseIconic', 1) == 1 || $cfg->get('com_calUseIconic', 1) == 2) { $view->viewNavTableBarIconic($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } else { $view->viewNavTableBar($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } break; case 'month.calendar': $dates['prev2'] = $prev_year; $dates['prev1'] = $prev_month; $dates['next1'] = $next_month; $dates['next2'] = $next_year; $alts['prev2'] = JText::_('JEV_PREVIOUSYEAR'); $alts['prev1'] = JText::_('JEV_PREVIOUSMONTH'); $alts['next1'] = JText::_('JEV_NEXTMONTH'); $alts['next2'] = JText::_('JEV_NEXTYEAR'); // Show if ($cfg->get('com_calUseIconic', 1) == 1 || $cfg->get('com_calUseIconic', 1) == 2) { $view->viewNavTableBarIconic($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } else { $view->viewNavTableBar($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } break; case 'week.listevents': $dates['prev2'] = $prev_month; $dates['prev1'] = $prev_week; $dates['next1'] = $next_week; $dates['next2'] = $next_month; $alts['prev2'] = JText::_('JEV_PREVIOUSMONTH'); $alts['prev1'] = JText::_('JEV_PREVIOUSWEEK'); $alts['next1'] = JText::_('JEV_NEXTWEEK'); $alts['next2'] = JText::_('JEV_NEXTMONTH'); // Show if ($cfg->get('com_calUseIconic', 1) == 1 || $cfg->get('com_calUseIconic', 1) == 2) { $view->viewNavTableBarIconic($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } else { $view->viewNavTableBar($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } break; case 'day.listevents': default: $dates['prev2'] = $prev_month; $dates['prev1'] = $prev_day; $dates['next1'] = $next_day; $dates['next2'] = $next_month; $alts['prev2'] = JText::_('JEV_PREVIOUSMONTH'); $alts['prev1'] = JText::_('JEV_PREVIOUSDAY'); $alts['next1'] = JText::_('JEV_NEXTDAY'); $alts['next2'] = JText::_('JEV_NEXTMONTH'); // Show if ($cfg->get('com_calUseIconic', 1) == 1 || $cfg->get('com_calUseIconic', 1) == 2) { $view->viewNavTableBarIconic($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, $task, $view->Itemid); } else { $view->viewNavTableBar($today_date, $this_date, $dates, $alts, JEV_COM_COMPONENT, "day.listevents", $view->Itemid); } break; } $view->loadModules("jevposttoolbar"); $view->loadModules("jevposttoolbar_" . $task); }
private function doSave(&$msg) { if (!JEVHelper::isEventCreator()) { throw new Exception(JText::_('ALERTNOTAUTH'), 403); return false; } // clean out the cache $cache = JFactory::getCache('com_jevents'); $cache->clean(JEV_COM_COMPONENT); $option = JEV_COM_COMPONENT; $rp_id = intval(JRequest::getVar("rp_id", "0")); $cid = JRequest::getVar("cid", array()); if (count($cid) > 0 && $rp_id == 0) { $rp_id = intval($cid[0]); } if ($rp_id == 0) { $this->setRedirect('index.php?option=' . $option . '&task=icalrepeat.list&cid[]=' . $rp_id, "1Cal rpt NOT SAVED"); $this->redirect(); } // I should be able to do this in one operation but that can come later $event = $this->queryModel->listEventsById(intval($rp_id), 1, "icaldb"); if (!JEVHelper::canEditEvent($event)) { throw new Exception(JText::_('ALERTNOTAUTH'), 403); return false; } $db = JFactory::getDBO(); $rpt = new iCalRepetition($db); $rpt->load($rp_id); $query = "SELECT detail_id FROM #__jevents_vevent WHERE ev_id={$rpt->eventid}"; $db->setQuery($query); $eventdetailid = $db->loadResult(); $data["UID"] = JRequest::getVar("uid", md5(uniqid(rand(), true))); $data["X-EXTRAINFO"] = JRequest::getVar("extra_info", ""); $data["LOCATION"] = JRequest::getVar("location", ""); $data["allDayEvent"] = JRequest::getVar("allDayEvent", "off"); $data["CONTACT"] = JRequest::getVar("contact_info", ""); // allow raw HTML (mask =2) $data["DESCRIPTION"] = JRequest::getVar("jevcontent", "", 'request', 'html', 2); $data["publish_down"] = JRequest::getVar("publish_down", "2006-12-12"); $data["publish_up"] = JRequest::getVar("publish_up", "2006-12-12"); // Alternative date format handling if (JRequest::getVar("publish_up2", false)) { $data["publish_up"] = JRequest::getVar("publish_up2", $data["publish_up"]); } if (JRequest::getVar("publish_down2", false)) { $data["publish_down"] = JRequest::getVar("publish_down2", $data["publish_down"]); } $interval = JRequest::getVar("rinterval", 1); $data["SUMMARY"] = JRequest::getVar("title", ""); $data["MULTIDAY"] = JRequest::getInt("multiday", "1"); $data["NOENDTIME"] = JRequest::getInt("noendtime", 0); $ics_id = JRequest::getVar("ics_id", 0); if ($data["allDayEvent"] == "on") { $start_time = "00:00"; } else { $start_time = JRequest::getVar("start_time", "08:00"); } $publishstart = $data["publish_up"] . ' ' . $start_time . ':00'; $data["DTSTART"] = JevDate::strtotime($publishstart); if ($data["allDayEvent"] == "on") { $end_time = "23:59"; $publishend = $data["publish_down"] . ' ' . $end_time . ':59'; } else { $end_time = JRequest::getVar("end_time", "15:00"); $publishend = $data["publish_down"] . ' ' . $end_time . ':00'; } $data["DTEND"] = JevDate::strtotime($publishend); // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day list($h, $m, $s) = explode(":", $end_time . ':00'); if ($h + $m + $s == 0 && $data["allDayEvent"] == "on" && $data["DTEND"] > $data["DTSTART"]) { $publishend = JevDate::strftime('%Y-%m-%d 23:59:59', $data["DTEND"] - 86400); $data["DTEND"] = JevDate::strtotime($publishend); } $data["X-COLOR"] = JRequest::getVar("color", ""); // Add any custom fields into $data array - allowing HTML (which can be cleaned up later by plugins) $array = JRequest::get("post", 2); foreach ($array as $key => $value) { if (strpos($key, "custom_") === 0) { $data[$key] = $value; } // convert jform data to data format used before if (strpos($key, "jform") === 0 && is_array($value)) { foreach ($value as $cfkey => $cfvalue) { $data["custom_" . $cfkey] = $cfvalue; } } } $detail = iCalEventDetail::iCalEventDetailFromData($data); // if we already havea unique event detail then edit this one! if ($eventdetailid != $rpt->eventdetail_id) { $detail->evdet_id = $rpt->eventdetail_id; } $detail->priority = intval(JArrayHelper::getValue($array, "priority", 0)); $detail->store(); // KEEP THE ORIGINAL START REPEAT FOR THE EXCEPTION HANDLING $original_start = $rpt->startrepeat; // populate rpt with data //$start = JevDate::strtotime($data["publish_up"] . ' ' . $start_time . ':00'); //$end = JevDate::strtotime($data["publish_down"] . ' ' . $end_time . ':00'); $start = $data["DTSTART"]; $end = $data["DTEND"]; $rpt->startrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $start); $rpt->endrepeat = JevDate::strftime('%Y-%m-%d %H:%M:%S', $end); $rpt->duplicatecheck = md5($rpt->eventid . $start); $rpt->eventdetail_id = $detail->evdet_id; $rpt->rp_id = $rp_id; $rpt->store(); // I may also need to process repeat changes $dispatcher = JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onStoreCustomRepeat', array(&$rpt)); $exception = iCalException::loadByRepeatId($rp_id); if (!$exception) { $exception = new iCalException($db); $exception->bind(get_object_vars($rpt)); // ONLY set the old start repeat when first creating the exception $exception->oldstartrepeat = $original_start; } $exception->exception_type = 1; // modified $exception->store(); return $rpt; }
function monthYearNavigation($cal_today, $adj, $symbol, $label, $action = "month.calendar") { $cfg =& JEVConfig::getInstance(); $jev_component_name = JEV_COM_COMPONENT; $adjDate = JevDate::strtotime($adj, $cal_today); list($year, $month) = explode(":", JevDate::strftime("%Y:%m", $adjDate)); $link = JRoute::_($this->linkpref . $action . "&day=1&month={$month}&year={$year}" . $this->cat); $content = ""; if (isset($this->_modid) && $this->_modid > 0) { $this->_navigationJS($this->_modid); $link = htmlentities("index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$month}&year={$year}&modid={$this->_modid}&tmpl=component" . $this->cat); $content = '<td>'; $content .= '<div class="mod_events_link" onmousedown="callNavigation(\'' . $link . '\');">' . $symbol . "</div>\n"; $content .= '</td>'; } return $content; }
function checkRepeatDay($this_currentdate) { list($y, $m, $d) = explode(":", JevDate::strftime("%Y:%m:%d", $this_currentdate)); $dayEndSecond = JevDate::mktime(23, 59, 59, $m, $d, $y); $this->eventDaysDay = $this->getRepeatArray($this_currentdate, $this_currentdate, $dayEndSecond); return array_key_exists($this_currentdate, $this->eventDaysDay); /* * do net keep result set, next call is for different day if (!isset($this->eventDaysDay)){ $this->eventDaysDay = array(); if(is_null($this_currentdate)) { return false; } list($y,$m,$d) = explode(":",JevDate::strftime("%Y:%m:%d",$this_currentdate)); $dayEndSecond = JevDate::mktime( 23,59,59, $m, $d , $y); $this->eventDaysDay = $this->getRepeatArray($this_currentdate, $this_currentdate, $dayEndSecond); } return (array_key_exists($this_currentdate,$this->eventDaysDay)); */ }
function _displayCalendarMod($time, $startday, $linkString, &$day_name, $monthMustHaveEvent = false, $basedate = false) { $db = JFactory::getDBO(); $cfg = JEVConfig::getInstance(); $compname = JEV_COM_COMPONENT; $cal_day = date("d", $time); //$cal_year=date("Y",$time); //$cal_month=date("m",$time); //list($cal_year,$cal_month,$cal_day) = JEVHelper::getYMD(); if (!$basedate) { $basedate = $time; } $base_year = date("Y", $basedate); $base_month = date("m", $basedate); $basefirst_of_month = JevDate::mktime(0, 0, 0, $base_month, 1, $base_year); $requestYear = JRequest::getInt("year", 0); $requestMonth = JRequest::getInt("month", 0); // special case when site link set the dates for the mini-calendar in the URL but not in the ajax request if ($requestMonth && $requestYear && JRequest::getString("task", "") != "modcal.ajax" && $this->modparams->get("minical_usedate", 0)) { $requestDay = JRequest::getInt("day", 1); $requestTime = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear); if ($time - $basedate > 100000) { $requestTime = JevDate::strtotime("+1 month", $requestTime); } else { if ($time - $basedate < -100000) { $requestTime = JevDate::strtotime("-1 month", $requestTime); } } $cal_year = date("Y", $requestTime); $cal_month = date("m", $requestTime); $base_year = $requestYear; $base_month = $requestMonth; $basefirst_of_month = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear); } else { $cal_year = date("Y", $time); $cal_month = date("m", $time); } $base_prev_month = $base_month - 1; $base_next_month = $base_month + 1; $base_next_month_year = $base_year; $base_prev_month_year = $base_year; if ($base_prev_month == 0) { $base_prev_month = 12; $base_prev_month_year -= 1; } if ($base_next_month == 13) { $base_next_month = 1; $base_next_month_year += 1; } $reg = JFactory::getConfig(); $reg->set("jev.modparams", $this->modparams); if ($this->modparams->get("showtooltips", 0)) { $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, false, false); $this->hasTooltips = true; } else { $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, true, $this->modparams->get("noeventcheck", 0)); } $reg->set("jev.modparams", false); $width = $this->modparams->get("mod_cal_width", "135px"); $height = $this->modparams->get("mod_cal_height", "auto"); $rowheight = $this->modparams->get("mod_cal_rowheight", "auto"); $month_name = JEVHelper::getMonthName($cal_month); $to_day = date("Y-m-d", $this->timeWithOffset); $today = JevDate::mktime(0, 0, 0, $cal_month, $cal_day, $cal_year); $cal_prev_month = $cal_month - 1; $cal_next_month = $cal_month + 1; $cal_next_month_year = $cal_year; $cal_prev_month_year = $cal_year; // additional EBS if ($cal_prev_month == 0) { $cal_prev_month = 12; $cal_prev_month_year -= 1; } if ($cal_next_month == 13) { $cal_next_month = 1; $cal_next_month_year += 1; } $viewname = $this->getTheme(); $viewpath = JURI::root(true) . "/components/{$compname}/views/" . $viewname . "/assets"; $viewimages = $viewpath . "/images"; $linkpref = "index.php?option={$compname}&Itemid=" . $this->myItemid . $this->cat . "&task="; /* $linkprevious = $linkpref."month.calendar&day=$cal_day&month=$cal_prev_month&year=$cal_prev_month_year"; $linkprevious = JRoute::_($linkprevious); $linkprevious = $this->htmlLinkCloaking($linkprevious, '<img border="0" title="' . JText::_("JEV_PREVIOUSMONTH") . '" alt="' . JText::_("JEV_PREVIOUSMONTH") . '" src="'.$viewimages.'/mini_arrowleft.gif"/>' ); */ $jev_component_name = JEV_COM_COMPONENT; $this->_navigationJS($this->_modid); $scriptlinks = ""; if ($this->minical_prevmonth) { $linkprevious = htmlentities(JURI::base() . "index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$base_prev_month}&year={$base_prev_month_year}&modid={$this->_modid}&tmpl=component" . $this->cat); $scriptlinks .= "linkprevious = '" . $linkprevious . "';\n"; $linkprevious = '<img border="0" title="' . JText::_("JEV_PREVIOUSMONTH") . '" alt="' . JText::_("JEV_LAST_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowleft.gif" onmousedown="callNavigation(\'' . $linkprevious . '\');" />'; } else { $linkprevious = ""; } if ($this->minical_actmonth == 1) { $linkcurrent = $linkpref . "month.calendar&day={$cal_day}&month={$cal_month}&year={$cal_year}"; $linkcurrent = JRoute::_($linkcurrent); $linkcurrent = $this->htmlLinkCloaking($linkcurrent, $month_name . " " . $cal_year, array("style" => "text-decoration:none;color:inherit;")); } elseif ($this->minical_actmonth == 2) { $linkcurrent = $month_name . " " . $cal_year; } else { $linkcurrent = ""; } /* $linknext = $linkpref."month.calendar&day=$cal_day&month=$cal_next_month&year=$cal_next_month_year"; $linknext = JRoute::_($linknext); $linknext = $this->htmlLinkCloaking($linknext, '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" src="'.$viewimages.'/mini_arrowright.gif"/>' ); */ $this->_navigationJS($this->_modid); if ($this->minical_nextmonth) { $linknext = htmlentities(JURI::base() . "index.php?option={$jev_component_name}&task=modcal.ajax&day=1&month={$base_next_month}&year={$base_next_month_year}&modid={$this->_modid}&tmpl=component" . $this->cat); $scriptlinks .= "linknext = '" . $linknext . "';\n"; $linknext = '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowright.gif" onmousedown="callNavigation(\'' . $linknext . '\');" />'; } else { $linknext = ""; } $content = <<<START <div id="extcal_minical"> \t<table cellspacing="1" cellpadding="0" style="width:{$width}; text-align:center;border: 1px solid rgb(190, 194, 195); background-color: rgb(255, 255, 255);"> \t\t<tr> \t\t\t<td style="vertical-align: top;"> START; if ($this->minical_showlink) { $content .= <<<START \t\t\t\t<table style="width:{$width};" cellspacing="0" cellpadding="2" border="0" class="extcal_navbar"> \t\t\t\t\t<tr> \t\t\t\t\t\t<td valign="middle" height="18" align="center"> \t\t\t\t\t\t\t{$linkprevious} \t\t</td> \t\t <td width="98%" valign="middle" nowrap="nowrap" height="18" align="center" class="extcal_month_label"> \t\t\t\t\t\t\t{$linkcurrent} \t\t </td> \t\t\t\t\t\t<td valign="middle" height="18" align="center" style="margin: 0 auto; min-width: 4px;"> \t\t {$linknext} \t\t</td> \t\t\t\t\t</tr> \t\t\t\t</table> START; } $content .= <<<START \t\t\t\t<table style="width:{$width};height:{$height}; " class="extcal_weekdays"> START; $lf = "\n"; // Days name rows - with blank week no. $content .= "<tr>\n<td/>\n"; for ($i = 0; $i < 7; $i++) { $content .= "<td class='extcal_weekdays'>" . $day_name[($i + $startday) % 7] . "</td>" . $lf; } $content .= "</tr>\n"; $datacount = count($data["dates"]); $dn = 0; for ($w = 0; $w < 6 && $dn < $datacount; $w++) { $content .= "<tr style='height:{$rowheight};'>\n"; // the week column list($week, $link) = each($data['weeks']); $content .= '<td class="extcal_weekcell">'; $content .= $this->htmlLinkCloaking($link, "<img width='5' height='20' border='0' alt='week " . $week . "' src='" . $viewimages . "/icon-mini-week.gif'/>"); $content .= "</td>\n"; for ($d = 0; $d < 7 && $dn < $datacount; $d++) { $currentDay = $data["dates"][$dn]; switch ($currentDay["monthType"]) { case "prior": case "following": $content .= "<td class='extcal_othermonth'/>\n"; break; case "current": $dayOfWeek = JevDate::strftime("%w", $currentDay["cellDate"]); $class = $currentDay["today"] ? "extcal_todaycell" : "extcal_daycell"; $linkclass = "extcal_daylink"; if ($dayOfWeek == 0 && !$currentDay["today"]) { $class = "extcal_sundaycell"; $linkclass = "extcal_sundaylink"; } if ($currentDay["events"] || $this->modparams->get("noeventcheck", 0)) { $linkclass = "extcal_busylink"; } $content .= "<td class='" . $class . "'>\n"; $tooltip = $this->getTooltip($currentDay, array('class' => $linkclass)); if ($tooltip) { $content .= $tooltip; } else { if ($this->modparams->get("emptydaylinks", 1) || $currentDay["events"] || $this->modparams->get("noeventcheck", 0)) { $content .= $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], array('class' => $linkclass, 'title' => JText::_('JEV_CLICK_TOSWITCH_DAY'))); } else { $content .= $currentDay['d']; } } $content .= "</td>\n"; break; } $dn++; } $content .= "</tr>\n"; } $content .= "</table>\n"; $content .= "</td></tr></table></div>\n"; if ($scriptlinks != "") { $content .= "<script style='text/javascript'>xyz=1;" . $scriptlinks . "zyx=1;</script>"; } // Now check to see if this month needs to have at least 1 event in order to display // if (!$monthMustHaveEvent || $monthHasEvent) return $content; // else return ''; return $content; }