Exemplo n.º 1
0
 function canUserEdit()
 {
     $is_event_creator = JEVHelper::isEventCreator();
     $user = JFactory::getUser();
     // are we authorised to do anything with this category or calendar
     $jevuser = JEVHelper::getAuthorisedUser();
     if ($this->_icsid > 0 && $jevuser && $jevuser->calendars != "" && $jevuser->calendars != "all") {
         $allowedcals = explode("|", $jevuser->calendars);
         if (!in_array($this->_icsid, $allowedcals)) {
             return false;
         }
     }
     if ($this->_catid > 0 && $jevuser && $jevuser->categories != "" && $jevuser->categories != "all") {
         $allowedcats = explode("|", $jevuser->categories);
         if (!in_array($this->_catid, $allowedcats)) {
             return false;
         }
     }
     // if can create events and this was created by this user then can edit (not valid for anon users)
     if ($is_event_creator && $this->isEditable() && $this->created_by() == $user->id && $user->id > 0) {
         return true;
     }
     // if "event publisher" or "event editor" can always edit event
     if (JEVHelper::canEditEvent($this)) {
         return true;
     }
     if (JEVHelper::canPublishEvent($this)) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 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 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;
}
Exemplo n.º 4
0
 private function doSave(&$msg)
 {
     if (!JEVHelper::isEventCreator()) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     // clean out the cache
     $cache =& JFactory::getCache('com_jevents');
     $cache->clean(JEV_COM_COMPONENT);
     // JREQUEST_ALLOWHTML requires at least Joomla 1.5 svn9979 (past 1.5 stable)
     $array = JRequest::get('request', JREQUEST_ALLOWHTML);
     // Should we allow raw content through unfiltered
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     if ($params->get("allowraw", 0)) {
         $array['jevcontent'] = JRequest::getString("jevcontent", "", "POST", JREQUEST_ALLOWRAW);
     }
     if (!JEVHelper::canCreateEvent($array)) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     $rrule = SaveIcalEvent::generateRRule($array);
     // ensure authorised
     if (isset($array["evid"]) && $array["evid"] > 0) {
         $event = $this->queryModel->getEventById(intval($array["evid"]), 1, "icaldb");
         if (!$event || !JEVHelper::canEditEvent($event)) {
             JError::raiseError(403, JText::_('ALERTNOTAUTH'));
         }
     }
     $clearout = false;
     // remove all exceptions since they are no longer needed
     if (isset($array["evid"]) && $array["evid"] > 0) {
         $clearout = true;
     }
     if ($event = SaveIcalEvent::save($array, $this->queryModel, $rrule)) {
         $row = new jIcalEventDB($event);
         if (JEVHelper::canPublishEvent($row)) {
             $msg = JText::_("Event_Saved", true);
         } else {
             $msg = JText::_("EVENT_SAVED_UNDER_REVIEW", true);
         }
         if ($clearout) {
             $db = JFactory::getDBO();
             $query = "DELETE FROM #__jevents_exception WHERE eventid = " . $array["evid"];
             $db->setQuery($query);
             $db->query();
             // TODO clear out old exception details
         }
     } else {
         $msg = JText::_("Event Not Saved", true);
     }
     return $row;
 }
Exemplo n.º 5
0
 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;
 }
/**
 * Creates mini event dialog for view detail page etc.
 * note this must be contained in a position:relative block element in order to work
 *
 * @param Jevent or descendent $row
 */
function DefaultEventManagementDialog($view, $row, $mask, $bootstrap = false)
{
    JevHtmlBootstrap::modal("action_dialogJQ" . $row->rp_id());
    $user = JFactory::getUser();
    if ($user->get("id") == 0) {
        return "";
    }
    if (JEVHelper::canEditEvent($row) || JEVHelper::canPublishEvent($row) || JEVHelper::canDeleteEvent($row)) {
        $popup = false;
        $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
        if ($params->get("editpopup", 0) && JEVHelper::isEventCreator()) {
            JevHtmlBootstrap::modal();
            JEVHelper::script('editpopupJQ.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
            $popup = true;
            $popupw = $params->get("popupw", 800);
            $popuph = $params->get("popuph", 600);
        }
        if (JRequest::getInt("pop", 0)) {
            // do not call the modal scripts if already in a popup window!
            $popup = false;
        }
        $hasrepeat = false;
        $pathIMG = JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images';
        $editImg = JHtml::image('com_jevents/icons-32/edit.png', JText::_("EDIT_EVENT"), null, true);
        $editLink = $row->editLink();
        $editLink = $popup ? "javascript:jevEditPopupNoHeader('" . $editLink . "');" : $editLink;
        $editCopyImg = JHtml::image('com_jevents/icons-32/copy.png', JText::_("COPY_AND_EDIT_EVENT"), null, true);
        $editCopyLink = $row->editCopyLink();
        $editCopyLink = $popup ? "javascript:jevEditPopupNoHeader('" . $editCopyLink . "');" : $editCopyLink;
        $deleteImg = JHtml::image('com_jevents/icons-32/discard.png', JText::_("DELETE_EVENT"), null, true);
        $deleteLink = $row->deleteLink();
        if ($row->until() != $row->dtstart() || $row->count() > 1) {
            $hasrepeat = true;
            $editRepeatImg = JHtml::image('com_jevents/icons-32/edit.png', JText::_("EDIT_REPEAT"), null, true);
            $editRepeatLink = $row->editRepeatLink();
            $editRepeatLink = $popup ? "javascript:jevEditPopupNoHeader('" . $editRepeatLink . "');" : $editRepeatLink;
            $deleteRepeatImg = JHtml::image('com_jevents/icons-32/discard.png', JText::_("DELETE_THIS_REPEAT"), null, true);
            $deleteRepeatLink = $row->deleteRepeatLink();
            $deleteFutureImg = JHtml::image('com_jevents/icons-32/discards.png', JText::_("JEV_DELETE_FUTURE_REPEATS"), null, true);
            $deleteFutureLink = $row->deleteFutureLink();
            $deleteImg = JHtml::image('com_jevents/icons-32/discards.png', JText::_("DELETE_ALL_REPEATS"), null, true);
        } else {
            $editRepeatLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        if (!JEVHelper::canEditEvent($row)) {
            $editLink = "";
            $editRepeatLink = "";
            $editCopyLink = "";
        }
        if (!JEVHelper::canDeleteEvent($row)) {
            $deleteLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        $publishLink = "";
        if (JEVHelper::canPublishEvent($row)) {
            if ($row->published() > 0) {
                $publishImg = JHtml::image('com_jevents/icons-32/cancel.png', JText::_("UNPUBLISH_EVENT"), null, true);
                $publishLink = $row->unpublishLink();
                $publishText = JText::_('UNPUBLISH_EVENT');
            } else {
                $publishImg = JHtml::image('com_jevents/icons-32/accept.png', JText::_("PUBLISH_EVENT"), null, true);
                $publishLink = $row->publishLink();
                $publishText = JText::_('PUBLISH_EVENT');
            }
        }
        if ($publishLink . $editRepeatLink . $editLink . $deleteRepeatLink . $deleteLink . $deleteFutureLink == "") {
            return false;
        }
        ?>
		<div id="action_dialogJQ<?php 
        echo $row->rp_id();
        ?>
" class="action_dialogJQ modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog modal-sm">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title" id="myModalLabel"><?php 
        echo JText::_("JEV_MANAGE_EVENT");
        ?>
</h4>
					</div>
					<div class="modal-body">
						<?php 
        if ($publishLink != "") {
            ?>
						<a href="<?php 
            echo $publishLink;
            ?>
" id="publish_reccur"  title="<?php 
            echo $publishText;
            ?>
" ><?php 
            echo $publishImg;
            echo $publishText;
            ?>
</a><br/>
						<?php 
        }
        ?>
						<?php 
        if ($editRepeatLink != "") {
            ?>
						<a href="<?php 
            echo $editRepeatLink;
            ?>
" id="edit_reccur"  title="edit event" ><?php 
            echo $editRepeatImg;
            echo JText::_('EDIT_REPEAT');
            ?>
</a><br/>
						<?php 
        }
        if ($editLink != "") {
            ?>
					   <a href="<?php 
            echo $editLink;
            ?>
"  id="edit_event" title="edit event" ><?php 
            echo $editImg;
            echo JText::_('EDIT_EVENT');
            ?>
</a><br/>
					   <a href="<?php 
            echo $editCopyLink;
            ?>
" id="edit_eventcopy" title="edit event" ><?php 
            echo $editCopyImg;
            echo JText::_('COPY_AND_EDIT_EVENT');
            ?>
</a><br/>
						<?php 
        }
        if ($deleteRepeatLink != "") {
            ?>
						<a href="<?php 
            echo $deleteRepeatLink;
            ?>
"  onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_RECURRENCE', true);
            ?>
')" id="delete_repeat"  title="delete repeat" ><?php 
            echo $deleteRepeatImg;
            echo JText::_('DELETE_THIS_REPEAT');
            ?>
</a><br/>
						<?php 
        }
        if ($deleteLink != "") {
            ?>
						<a href="<?php 
            echo $deleteLink;
            ?>
"  onclick="return confirm('<?php 
            echo JText::_($hasrepeat ? 'ARE_YOU_SURE_YOU_WISH_TO_DELETE_THIS_EVENT_AND_ALL_ITS_REPEAT' : 'ARE_YOU_SURE_YOU_WISH_TO_DELETE_THIS_EVENT', true);
            ?>
')" id="delete_event"  title="delete event" ><?php 
            echo $deleteImg;
            echo JText::_($hasrepeat ? "DELETE_ALL_REPEATS" : "DELETE_EVENT");
            ?>
</a><br/>
					   <?php 
        }
        if ($deleteFutureLink != "") {
            ?>
						<a href="<?php 
            echo $deleteFutureLink;
            ?>
"  onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WITH_TO_DELETE_THIS_EVENT_AND_ALL_FUTURE_REPEATS', true);
            ?>
')" id="delete_eventfuture"  title="delete event" ><?php 
            echo $deleteFutureImg;
            echo JText::_('JEV_DELETE_FUTURE_REPEATS');
            ?>
</a><br/>
				   <?php 
        }
        ?>
					</div>
					<div class="modal-footer">
						 <button type="button" class="btn btn-default" data-dismiss="modal"><?php 
        echo JText::_("JEV_CLOSE");
        ?>
</button>
					</div>
				</div>
			</div>
		</div>

	        <?php 
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 7
0
 function edit($tpl = null)
 {
     $document = JFactory::getDocument();
     include JEV_ADMINLIBS . "/editStrings.php";
     $document->addScriptDeclaration($editStrings);
     JEVHelper::script('editicalJQ.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
     JEVHelper::script('JevStdRequiredFieldsJQ.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
     if ($this->row->title() <= "") {
         // Set toolbar items for the page
         JToolBarHelper::title(JText::_('CREATE_ICAL_EVENT'), 'jevents');
         $document->setTitle(JText::_('CREATE_ICAL_EVENT'));
     } else {
         // Set toolbar items for the page
         JToolBarHelper::title(JText::_('EDIT_ICAL_EVENT'), 'jevents');
         $document->setTitle(JText::_('EDIT_ICAL_EVENT'));
     }
     $bar = JToolBar::getInstance('toolbar');
     if ($this->id > 0) {
         if ($this->editCopy) {
             if (JEVHelper::isEventEditor() || JEVHelper::canEditEvent($this->row)) {
                 $this->toolbarConfirmButton("icalevent.apply", JText::_("JEV_SAVE_COPY_WARNING"), 'apply', 'apply', 'JEV_SAVE', false);
             }
             //$this->toolbarConfirmButton("icalevent.savenew", JText::_("JEV_SAVE_COPY_WARNING"), 'save', 'save', 'JEV_SAVE_NEW', false);
             $this->toolbarConfirmButton("icalevent.save", JText::_("JEV_SAVE_COPY_WARNING"), 'save', 'save', 'JEV_SAVE_CLOSE', false);
         } else {
             if (JEVHelper::isEventEditor() || JEVHelper::canEditEvent($this->row)) {
                 $this->toolbarConfirmButton("icalevent.apply", JText::_("JEV_SAVE_ICALEVENT_WARNING"), 'apply', 'apply', 'JEV_SAVE', false);
             }
             //$this->toolbarConfirmButton("icalevent.savenew", JText::_("JEV_SAVE_ICALEVENT_WARNING"), 'save', 'save', 'JEV_SAVE_NEW', false);
             $this->toolbarConfirmButton("icalevent.save", JText::_("JEV_SAVE_ICALEVENT_WARNING"), 'save', 'save', 'JEV_SAVE_CLOSE', false);
         }
     } else {
         $canEditOwn = false;
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         if (!$params->get("authorisedonly", 0)) {
             $juser = JFactory::getUser();
             $canEditOwn = $juser->authorise('core.edit.own', 'com_jevents');
         }
         if (JEVHelper::isEventEditor() || $canEditOwn) {
             $this->toolbarButton("icalevent.apply", 'apply', 'apply', 'JEV_SAVE', false);
         }
         //JToolBarHelper::save('icalevent.savenew', "JEV_Save_New");
         $this->toolbarButton("icalevent.save", 'save', 'save', 'JEV_SAVE_CLOSE', false);
     }
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $evedrd = $params->get("editreturnto", "day.listevents");
     if ($params->get("editpopup", 0)) {
         $document->addStyleDeclaration("div#toolbar-box{margin:10px 10px 0px 10px;} div#jevents {margin:0px 10px 10px 10px;} ");
         $this->toolbarButton("icalevent.close", 'cancel', 'cancel', 'Cancel', false);
         JRequest::setVar('tmpl', 'component');
         //force the component template
     } else {
         if ($this->id > 0) {
             $this->toolbarButton("icalrepeat.detail", 'cancel', 'cancel', 'Cancel', false);
         } else {
             $this->toolbarButton($evedrd, 'cancel', 'cancel', 'Cancel', false);
         }
     }
     // I pass in the rp_id so that I can return to the repeat I was viewing before editing
     $this->assign("rp_id", JRequest::getInt("rp_id", 0));
     $this->_adminStart();
     // load Joomla javascript classes
     JHTML::_('behavior.core');
     $this->setLayout("edit");
     JEVHelper::componentStylesheet($this, "editextra.css");
     jimport('joomla.filesystem.file');
     // Lets check if we have editted before! if not... rename the custom file.
     if (JFile::exists(JPATH_SITE . "/components/com_jevents/assets/css/jevcustom.css")) {
         // It is definitely now created, lets load it!
         JEVHelper::stylesheet('jevcustom.css', 'components/' . JEV_COM_COMPONENT . '/assets/css/');
     }
     $this->setupEditForm();
     parent::displaytemplate($tpl);
     $this->_adminEnd();
 }
Exemplo n.º 8
0
 function getEventData($rpid, $jevtype, $year, $month, $day, $uid = "")
 {
     $data = array();
     $pop = intval(JRequest::getVar('pop', 0));
     $Itemid = JEVHelper::getItemid();
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $cfg = JEVConfig::getInstance();
     $row = $this->queryModel->listEventsById($rpid, 1, $jevtype);
     // include unpublished events for publishers and above
     // if the event is not published then make sure the user can edit or publish it or created it before allowing it to be seen!
     if ($row && $row->published() != 1) {
         if ($user->id != $row->created_by() && !JEVHelper::canEditEvent($row) && !JEVHelper::canPublishEvent($row) && !JEVHelper::isAdminUser($user)) {
             $row = null;
         }
     }
     $num_row = count($row);
     // No matching rows - use uid as alternative
     if ($num_row == 0 && JString::strlen($uid) > 0) {
         $rpid = $this->queryModel->findMatchingRepeat($uid, $year, $month, $day);
         if (isset($rpid) && $rpid > 0) {
             $row = $this->queryModel->listEventsById($rpid, 1, $jevtype);
             // include unpublished events for publishers and above
             if ($row && !$row->published()) {
                 if ($user->id != $row->created_by() && !JEVHelper::canEditEvent($row) && !JEVHelper::canPublishEvent($row) && !JEVHelper::isAdminUser($user)) {
                     $row = null;
                 }
             }
             $num_row = count($row);
         }
     }
     if ($num_row) {
         // process the new plugins
         $dispatcher = JEventDispatcher::getInstance();
         $dispatcher->trigger('onGetEventData', array(&$row));
         $params = new JRegistry(null);
         $row->contactlink = JEventsHTML::getUserMailtoLink($row->id(), $row->created_by(), false, $row);
         $event_up = new JEventDate($row->publish_up());
         $row->start_date = JEventsHTML::getDateFormat($event_up->year, $event_up->month, $event_up->day, 0);
         $row->start_time = JEVHelper::getTime($row->getUnixStartTime());
         $event_down = new JEventDate($row->publish_down());
         $row->stop_date = JEventsHTML::getDateFormat($event_down->year, $event_down->month, $event_down->day, 0);
         $row->stop_time = JEVHelper::getTime($row->getUnixEndTime());
         $row->stop_time_midnightFix = $row->stop_time;
         $row->stop_date_midnightFix = $row->stop_date;
         if ($event_down->second == 59) {
             $row->stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1);
             $row->stop_date_midnightFix = JEventsHTML::getDateFormat($event_down->year, $event_down->month, $event_down->day + 1, 0);
         }
         // *******************
         // ** This cloaking should be done by mambot/Joomla function
         // *******************
         // Parse http and  wrap in <a> tag
         // trigger content plugin
         JPluginHelper::importPlugin('content');
         $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/]';
         // Addresse
         if (!is_numeric($row->location())) {
             // don't convert address that already has a link tag
             if (strpos($row->location(), '<a href=') === false) {
                 $row->location(preg_replace('#(http://)(' . $pattern . '*)#i', '<a href="\\1\\2">\\1\\2</a>', $row->location()));
             }
             $tmprow = new stdClass();
             $tmprow->text = $row->location();
             $dispatcher = JEventDispatcher::getInstance();
             $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
             $row->location($tmprow->text);
         }
         //Contact
         if (strpos($row->contact_info(), '<a href=') === false) {
             $row->contact_info(preg_replace('#(http://)(' . $pattern . '*)#i', '<a href="\\1\\2">\\1\\2</a>', $row->contact_info()));
         }
         $tmprow = new stdClass();
         $tmprow->text = $row->contact_info();
         $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
         $row->contact_info($tmprow->text);
         //Extra
         if (strpos($row->extra_info(), '<a href=') === false) {
             $row->extra_info(preg_replace('#(http://)(' . $pattern . '*)#i', '<a href="\\1\\2">\\1\\2</a>', $row->extra_info()));
         }
         //$row->extra_info(eregi_replace('[^(href=|href="|href=\')](((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $row->extra_info()));
         $tmprow = new stdClass();
         $tmprow->text = $row->extra_info();
         $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
         $row->extra_info($tmprow->text);
         $mask = JFactory::getApplication()->getCfg('hideAuthor') ? MASK_HIDEAUTHOR : 0;
         $mask |= JFactory::getApplication()->getCfg('hideCreateDate') ? MASK_HIDECREATEDATE : 0;
         $mask |= JFactory::getApplication()->getCfg('hideModifyDate') ? MASK_HIDEMODIFYDATE : 0;
         $mask |= JFactory::getApplication()->getCfg('hidePdf') ? MASK_HIDEPDF : 0;
         $mask |= JFactory::getApplication()->getCfg('hidePrint') ? MASK_HIDEPRINT : 0;
         $mask |= JFactory::getApplication()->getCfg('hideEmail') ? MASK_HIDEEMAIL : 0;
         //$mask |= JFactory::getApplication()->getCfg( 'vote' ) ? MASK_VOTES : 0;
         $mask |= JFactory::getApplication()->getCfg('vote') ? MASK_VOTES | MASK_VOTEFORM : 0;
         $mask |= $pop ? MASK_POPUP | MASK_IMAGES | MASK_BACKTOLIST : 0;
         // Do main mambot processing here
         // process bots
         //$row->text      = $row->content;
         $params->set("image", 1);
         $row->text = $row->content();
         $dispatcher->trigger('onContentPrepare', array('com_jevents', &$row, &$params, 0));
         $row->content($row->text);
         $data['row'] = $row;
         $data['mask'] = $mask;
         $row->updateHits();
         return $data;
     } else {
         // Do we have to be logged in to see this event?
         // If we set the access user for ical export (as an example) then use this user id for access checks!
         $user = isset($this->accessuser) ? JEVHelper::getUser($this->accessuser) : JFactory::getUser();
         if ($user->id == 0) {
             $db = JFactory::getDBO();
             $query = "SELECT ev.*" . "\n FROM #__jevents_vevent as ev " . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n WHERE rpt.rp_id = '{$rpid}'";
             $db->setQuery($query);
             $row2 = $db->loadObject();
             // need to be logged in to see this event?
             if ($row2 && (version_compare(JVERSION, '1.6.0', '>=') ? !in_array($row2->access, JEVHelper::getAid($user, 'array')) : JEVHelper::getAid($user) < $row2->access)) {
                 $uri = JURI::getInstance();
                 $link = $uri->toString();
                 $comuser = version_compare(JVERSION, '1.6.0', '>=') ? "com_users" : "com_user";
                 $link = 'index.php?option=' . $comuser . '&view=login&return=' . base64_encode($link);
                 $link = JRoute::_($link);
                 JFactory::getApplication()->redirect($link, JText::_('JEV_LOGIN_TO_VIEWEVENT'));
                 return null;
             }
         }
         // See if a plugin can find our missing event - maybe on another menu item
         JPluginHelper::importPlugin('jevents');
         $dispatcher = JEventDispatcher::getInstance();
         $dispatcher->trigger('onMissingEvent', array(&$row, $rpid, $jevtype, $year, $month, $day, $uid));
         return null;
     }
 }
Exemplo n.º 9
0
function DefaultViewEventRowAdmin($view, $row, $manage = false)
{
    $popup = false;
    $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
    if ($params->get("editpopup", 0)) {
        JHTML::_('behavior.modal');
        JEVHelper::script('editpopup.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
        $popup = true;
        $popupw = $params->get("popupw", 800);
        $popuph = $params->get("popuph", 600);
    }
    $editLink = $row->editLink(true);
    $editLink = $popup ? "javascript:jevEditPopup('" . $editLink . "',{$popupw}, {$popuph});" : $editLink;
    $modifylink = "";
    if (!$manage && JEVHelper::canEditEvent($row)) {
        $modifylink = '<a href="' . $row->editlink(true) . '" title="' . JText::_('JEV_MODIFY') . '"><b>' . JText::_('JEV_MODIFY') . "</b></a>\n";
        $modifylink = '<a href="' . $editLink . '" title="' . JText::_('JEV_MODIFY') . '"><b>' . JText::_('JEV_MODIFY') . "</b></a>\n";
    }
    $deletelink = "";
    if (!$manage && JEVHelper::canDeleteEvent($row)) {
        $deletelink = '<a href="' . $row->deletelink(false) . "&rettask=admin.listevents" . '" title="' . JText::_('JEV_DELETE') . '"><b>' . JText::_('JEV_DELETE') . "</b></a>\n";
    }
    if (!$manage && JEVHelper::canPublishEvent($row)) {
        if ($row->published()) {
            $publishlink = '<a href="' . $row->unpublishlink(false) . "&rettask=admin.listevents" . '" title="' . JText::_('UNPUBLISH') . '"><b>' . JText::_('UNPUBLISH') . "</b></a>\n";
        } else {
            $publishlink = '<a href="' . $row->publishlink(false) . "&rettask=admin.listevents" . '" title="' . JText::_('PUBLISH') . '"><b>' . JText::_('PUBLISH') . "</b></a>\n";
        }
    } else {
        $publishlink = "";
    }
    $eventlink = $row->viewDetailLink($row->yup(), $row->mup(), $row->dup(), false);
    $eventlink = JRoute::_($eventlink . $view->datamodel->getCatidsOutLink());
    $border = "border-color:" . $row->bgcolor() . ";";
    ?>
		
		<li class="ev_td_li" style="<?php 
    echo $border;
    ?>
">
			<a class="<?php 
    echo $row->state() ? 'ev_link_row' : 'ev_link_unpublished';
    ?>
" href="<?php 
    echo $eventlink;
    ?>
" title="<?php 
    echo JEventsHTML::special($row->title()) . ($row->state() ? '' : JText::_('JEV_UNPUBLISHED'));
    ?>
"><?php 
    echo $row->title() . ($row->state() ? '' : JText::_('JEV_UNPUBLISHED'));
    ?>
</a>
			&nbsp;<?php 
    echo JText::_('JEV_BY');
    ?>
			&nbsp;<i><?php 
    echo $row->contactlink('', true);
    ?>
</i>
			&nbsp;&nbsp;<?php 
    echo $deletelink;
    ?>
			&nbsp;&nbsp;<?php 
    echo $modifylink;
    ?>
			&nbsp;&nbsp;<?php 
    echo $publishlink;
    ?>
		</li>
		<?php 
}
function DefaultEventManagementDialog16($view, $row, $mask, $bootstrap = false)
{
    $user = JFactory::getUser();
    if ($user->get("id") == 0) {
        return "";
    }
    if ((JEVHelper::canEditEvent($row) || JEVHelper::canPublishEvent($row) || JEVHelper::canDeleteEvent($row)) && !($mask & MASK_POPUP)) {
        $popup = false;
        $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
        if ($params->get("editpopup", 0) && JEVHelper::isEventCreator()) {
            JEVHelper::script('editpopup.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
            $popup = true;
            $popupw = $params->get("popupw", 800);
            $popuph = $params->get("popuph", 600);
        }
        $hasrepeat = false;
        $pathIMG = JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images';
        $editImg = $pathIMG . "/edit_f2.png";
        $editLink = $row->editLink();
        $editLink = $popup ? "javascript:jevEditPopup('" . $editLink . "',{$popupw}, {$popuph});" : $editLink;
        $editCopyImg = $pathIMG . "/copy_f2.png";
        $editCopyLink = $row->editCopyLink();
        $editCopyLink = $popup ? "javascript:jevEditPopup('" . $editCopyLink . "',{$popupw}, {$popuph});" : $editCopyLink;
        $deleteImg = $pathIMG . "/delete_f2.png";
        $deleteLink = $row->deleteLink();
        if ($row->until() != $row->dtstart() || $row->count() > 1) {
            $hasrepeat = true;
            $editRepeatImg = $pathIMG . "/edit_f2.png";
            $editRepeatLink = $row->editRepeatLink();
            $editRepeatLink = $popup ? "javascript:jevEditPopup('" . $editRepeatLink . "',{$popupw}, {$popuph});" : $editRepeatLink;
            $deleteRepeatImg = $pathIMG . "/delete_f2.png";
            $deleteRepeatLink = $row->deleteRepeatLink();
            $deleteFutureImg = $pathIMG . "/delete_f2.png";
            $deleteFutureLink = $row->deleteFutureLink();
        } else {
            $editRepeatLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        if (!JEVHelper::canEditEvent($row)) {
            $editLink = "";
            $editRepeatLink = "";
            $editCopyLink = "";
        }
        if (!JEVHelper::canDeleteEvent($row)) {
            $deleteLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        $publishLink = "";
        if (JEVHelper::canPublishEvent($row)) {
            if ($row->published() > 0) {
                $publishImg = $pathIMG . "/publish_r.png";
                $publishLink = $row->unpublishLink();
                $publishText = JText::_('UNPUBLISH_EVENT');
            } else {
                $publishImg = $pathIMG . "/publish_g.png";
                $publishLink = $row->publishLink();
                $publishText = JText::_('PUBLISH_EVENT');
            }
        }
        if ($publishLink . $editRepeatLink . $editLink . $deleteRepeatLink . $deleteLink . $deleteFutureLink == "") {
            return false;
        }
        ?>
            <div id="action_dialog" >
            	<div class="close_dialog" >
            		<a href="javascript:void(0)" onclick="closedialog()" >x</a>
            	</div>
                 <?php 
        if ($publishLink != "") {
            ?>
                 <a href="<?php 
            echo $publishLink;
            ?>
" id="publish_reccur"  title="<?php 
            echo $publishText;
            ?>
" ><img src="<?php 
            echo $publishImg;
            ?>
" alt="" /><?php 
            echo $publishText;
            ?>
</a><br/>
                 <?php 
        }
        ?>
                 <?php 
        if ($editRepeatLink != "") {
            ?>
                 <a href="<?php 
            echo $editRepeatLink;
            ?>
" id="edit_reccur"  title="edit event" ><img src="<?php 
            echo $editRepeatImg;
            ?>
" alt="" /><?php 
            echo JText::_('EDIT_REPEAT');
            ?>
</a><br/>
                 <?php 
        }
        if ($editLink != "") {
            ?>
            	<a href="<?php 
            echo $editLink;
            ?>
" id="edit_event" title="edit event" ><img src="<?php 
            echo $editImg;
            ?>
" alt="" /><?php 
            echo JText::_('EDIT_EVENT');
            ?>
</a><br/>
            	<a href="<?php 
            echo $editCopyLink;
            ?>
" id="edit_eventcopy" title="edit event" ><img src="<?php 
            echo $editCopyImg;
            ?>
" alt="" /><?php 
            echo JText::_('COPY_AND_EDIT_EVENT');
            ?>
</a><br/>
                 <?php 
        }
        if ($deleteRepeatLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteRepeatLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_RECURRENCE', true);
            ?>
')" id="delete_repeat"  title="delete repeat" ><img src="<?php 
            echo $deleteRepeatImg;
            ?>
" alt="" /><?php 
            echo JText::_('DELETE_THIS_REPEAT');
            ?>
</a><br/>
                 <?php 
        }
        if ($deleteLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_($hasrepeat ? 'ARE_YOU_SURE_YOU_WISH_TO_DELETE_THIS_EVENT_AND_ALL_ITS_REPEAT' : 'ARE_YOU_SURE_YOU_WISH_TO_DELETE_THIS_EVENT', true);
            ?>
')" id="delete_event"  title="delete event" ><img src="<?php 
            echo $deleteImg;
            ?>
" alt="" /><?php 
            echo JText::_($hasrepeat ? "DELETE_ALL_REPEATS" : "DELETE_EVENT");
            ?>
</a><br/>
            	<?php 
        }
        if ($deleteFutureLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteFutureLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WITH_TO_DELETE_THIS_EVENT_AND_ALL_FUTURE_REPEATS', true);
            ?>
')" id="delete_eventfuture"  title="delete event" ><img src="<?php 
            echo $deleteFutureImg;
            ?>
" alt="" /><?php 
            echo JText::_('JEV_DELETE_FUTURE_REPEATS');
            ?>
</a><br/>
            <?php 
        }
        ?>
	        </div>
	        <?php 
        return true;
    } else {
        return false;
    }
}
Exemplo n.º 11
0
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask, $template_value = false)
{
    $db = JFactory::getDBO();
    // find published template
    static $templates;
    static $fieldNameArray;
    if (!isset($templates)) {
        $templates = array();
        $fieldNameArray = array();
        $rawtemplates = array();
    }
    $specialmodules = false;
    if (!$template_value) {
        if (!array_key_exists($template_name, $templates)) {
            $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name) . " AND " . 'language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
            $rawtemplates = $db->loadObjectList();
            $templates[$template_name] = array();
            if ($rawtemplates) {
                foreach ($rawtemplates as $rt) {
                    if (!isset($templates[$template_name][$rt->language])) {
                        $templates[$template_name][$rt->language] = array();
                    }
                    $templates[$template_name][$rt->language][$rt->catid] = $rt;
                }
            }
            if (count($templates[$template_name]) == 0) {
                $templates[$template_name] = null;
                return false;
            }
            if (isset($templates[$template_name][JFactory::getLanguage()->getTag()])) {
                $templateArray = $templates[$template_name][JFactory::getLanguage()->getTag()];
                // We have the most specific by language now fill in the gaps
                if (isset($templates[$template_name]["*"])) {
                    foreach ($templates[$template_name]["*"] as $cat => $cattemplates) {
                        if (!isset($templateArray[$cat])) {
                            $templateArray[$cat] = $cattemplates;
                        }
                    }
                }
                $templates[$template_name] = $templateArray;
            } else {
                if (isset($templates[$template_name]["*"])) {
                    $templates[$template_name] = $templates[$template_name]["*"];
                } else {
                    if (is_array($templates[$template_name]) && count($templates[$template_name]) == 0) {
                        $templates[$template_name] = null;
                    } else {
                        if (is_array($templates[$template_name]) && count($templates[$template_name]) > 0) {
                            $templates[$template_name] = current($templates[$template_name]);
                        } else {
                            $templates[$template_name] = null;
                        }
                    }
                }
            }
            $matched = false;
            foreach (array_keys($templates[$template_name]) as $catid) {
                if ($templates[$template_name][$catid]->value != "") {
                    if (isset($templates[$template_name][$catid]->params)) {
                        $templates[$template_name][$catid]->params = new JRegistry($templates[$template_name][$catid]->params);
                        $specialmodules = $templates[$template_name][$catid]->params;
                    }
                    // Adjust template_value to include dynamic module output then strip it out afterwards
                    if ($specialmodules) {
                        $modids = $specialmodules->get("modid", array());
                        if (count($modids) > 0) {
                            $modvals = $specialmodules->get("modval", array());
                            // not sure how this can arise :(
                            if (is_object($modvals)) {
                                $modvals = get_object_vars($modvals);
                            }
                            for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                                $templates[$template_name][$catid]->value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                                // cleaned later!
                                //$templates[$template_name][$catid]->value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                                $templates[$template_name][$catid]->value .= $modvals[$count];
                                $templates[$template_name][$catid]->value .= "{{module end:MODULEEND}}";
                            }
                        }
                    }
                    // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
                    $templates[$template_name][$catid]->value = str_replace("\r", '', $templates[$template_name][$catid]->value);
                    $templates[$template_name][$catid]->value = str_replace("\n", '', $templates[$template_name][$catid]->value);
                    // non greedy replacement - because of the ?
                    $templates[$template_name][$catid]->value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $templates[$template_name][$catid]->value);
                    $matchesarray = array();
                    preg_match_all('|{{.*?}}|', $templates[$template_name][$catid]->value, $matchesarray);
                    $templates[$template_name][$catid]->matchesarray = $matchesarray;
                }
            }
        }
        if (is_null($templates[$template_name])) {
            return false;
        }
        $catids = $event->catids() && count($event->catids()) ? $event->catids() : array($event->catid());
        $catids[] = 0;
        // find the overlap
        $catids = array_intersect($catids, array_keys($templates[$template_name]));
        // At present must be an EXACT category match - no inheriting allowed!
        if (count($catids) == 0) {
            if (!isset($templates[$template_name][0]) || $templates[$template_name][0]->value == "") {
                return false;
            }
        }
        $template = false;
        foreach ($catids as $catid) {
            // use the first matching non-empty layout
            if ($templates[$template_name][$catid]->value != "") {
                $template = $templates[$template_name][$catid];
                break;
            }
        }
        if (!$template) {
            return false;
        }
        $template_value = $template->value;
        $specialmodules = $template->params;
        $matchesarray = $template->matchesarray;
    } else {
        // This is a special scenario where we call this function externally e.g. from RSVP Pro messages
        // In this scenario we have not gone through the displaycustomfields plugin
        static $pluginscalled = array();
        if (!isset($pluginscalled[$event->rp_id()])) {
            $dispatcher = JDispatcher::getInstance();
            JPluginHelper::importPlugin("jevents");
            $customresults = $dispatcher->trigger('onDisplayCustomFields', array(&$event));
            $pluginscalled[$event->rp_id()] = $event;
        } else {
            $event = $pluginscalled[$event->rp_id()];
        }
        // Adjust template_value to include dynamic module output then strip it out afterwards
        if ($specialmodules) {
            $modids = $specialmodules->get("modid", array());
            if (count($modids) > 0) {
                $modvals = $specialmodules->get("modval", array());
                // not sure how this can arise :(
                if (is_object($modvals)) {
                    $modvals = get_object_vars($modvals);
                }
                for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                    $template_value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                    // cleaned later!
                    //$template_value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                    $template_value .= $modvals[$count];
                    $template_value .= "{{module end:MODULEEND}}";
                }
            }
        }
        // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
        $template_value = str_replace("\r", '', $template_value);
        $template_value = str_replace("\n", '', $template_value);
        // non greedy replacement - because of the ?
        $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value);
        $matchesarray = array();
        preg_match_all('|{{.*?}}|', $template_value, $matchesarray);
    }
    if ($template_value == "") {
        return;
    }
    if (count($matchesarray) == 0) {
        return;
    }
    // now replace the fields
    $search = array();
    $replace = array();
    $blank = array();
    $rawreplace = array();
    $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
    for ($i = 0; $i < count($matchesarray[0]); $i++) {
        $strippedmatch = preg_replace('/(#|:|;)+[^}]*/', '', $matchesarray[0][$i]);
        if (in_array($strippedmatch, $search)) {
            continue;
        }
        // translation string
        if (strpos($strippedmatch, "{{_") === 0 && strpos($strippedmatch, " ") === false) {
            $search[] = $strippedmatch;
            $strippedmatch = substr($strippedmatch, 3, strlen($strippedmatch) - 5);
            $replace[] = JText::_($strippedmatch);
            $blank[] = "";
            continue;
        }
        // Built in fields
        switch ($strippedmatch) {
            case "{{TITLE}}":
                $search[] = "{{TITLE}}";
                $replace[] = $event->title();
                $blank[] = "";
                break;
            case "{{PRIORITY}}":
                $search[] = "{{PRIORITY}}";
                $replace[] = $event->priority();
                $blank[] = "";
                break;
            case "{{LINK}}":
            case "{{LINKSTART}}":
            case "{{LINKEND}}":
            case "{{TITLE_LINK}}":
                if ($view) {
                    // Title link
                    $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false);
                    $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink());
                    ob_start();
                    ?>
					<a class="ev_link_row" href="<?php 
                    echo $rowlink;
                    ?>
" title="<?php 
                    echo JEventsHTML::special($event->title());
                    ?>
">
						<?php 
                    $linkstart = ob_get_clean();
                } else {
                    $rowlink = $linkstart = "";
                }
                $search[] = "{{LINK}}";
                $replace[] = $rowlink;
                $blank[] = "";
                $search[] = "{{LINKSTART}}";
                $replace[] = $linkstart;
                $blank[] = "";
                $search[] = "{{LINKEND}}";
                $replace[] = "</a>";
                $blank[] = "";
                $fulllink = $linkstart . $event->title() . '</a>';
                $search[] = "{{TITLE_LINK}}";
                $replace[] = $fulllink;
                $blank[] = "";
                break;
            case "{{TRUNCTITLE}}":
                // for month calendar cell only
                if (isset($event->truncatedtitle)) {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->truncatedtitle;
                    $blank[] = "";
                } else {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->title();
                    $blank[] = "";
                }
                break;
            case "{{URL}}":
                $search[] = "{{URL}}";
                $replace[] = $event->url();
                $blank[] = "";
                break;
            case "{{TRUNCATED_DESC}}":
                $search[] = "{{TRUNCATED_DESC:.*?}}";
                $replace[] = $event->content();
                $blank[] = "";
                //	$search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content();
                break;
            case "{{DESCRIPTION}}":
                $search[] = "{{DESCRIPTION}}";
                $replace[] = $event->content();
                $blank[] = "";
                break;
            case "{{MANAGEMENT}}":
                $search[] = "{{MANAGEMENT}}";
                if ($view) {
                    ob_start();
                    $view->_viewNavAdminPanel();
                    $replace[] = ob_get_clean();
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{CATEGORY}}":
                $search[] = "{{CATEGORY}}";
                $replace[] = $event->catname();
                $blank[] = "";
                break;
            case "{{ALLCATEGORIES}}":
                $search[] = "{{ALLCATEGORIES}}";
                static $allcat_catids;
                if (!isset($allcat_catids)) {
                    $db = JFactory::getDBO();
                    $arr_catids = array();
                    $catsql = "SELECT cat.id, cat.title as name FROM #__categories  as cat WHERE cat.extension='com_jevents' ";
                    $db->setQuery($catsql);
                    $allcat_catids = $db->loadObjectList('id');
                }
                $db = JFactory::getDbo();
                $db->setQuery("Select catid from #__jevents_catmap  WHERE evid = " . $event->ev_id());
                $allcat_eventcats = $db->loadColumn();
                $allcats = array();
                foreach ($allcat_eventcats as $catid) {
                    if (isset($allcat_catids[$catid])) {
                        $allcats[] = $allcat_catids[$catid]->name;
                    }
                }
                $replace[] = implode(", ", $allcats);
                $blank[] = "";
                break;
            case "{{CALENDAR}}":
                $search[] = "{{CALENDAR}}";
                $replace[] = $event->getCalendarName();
                $blank[] = "";
                break;
            case "{{COLOUR}}":
            case "{{colour}}":
                $bgcolor = $event->bgcolor();
                $search[] = $strippedmatch;
                $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor;
                $blank[] = "";
                break;
            case "{{FGCOLOUR}}":
                $search[] = "{{FGCOLOUR}}";
                $replace[] = $event->fgcolor();
                $blank[] = "";
                break;
            case "{{TTTIME}}":
                $search[] = "{{TTTIME}}";
                $replace[] = "[[TTTIME]]";
                $blank[] = "";
                break;
            case "{{EVTTIME}}":
                $search[] = "{{EVTTIME}}";
                $replace[] = "[[EVTTIME]]";
                $blank[] = "";
                break;
            case "{{TOOLTIP}}":
                $search[] = "{{TOOLTIP}}";
                $replace[] = "[[TOOLTIP]]";
                $blank[] = "";
                break;
            case "{{CATEGORYLNK}}":
                $router = JRouter::getInstance("site");
                $catlinks = array();
                if ($jevparams->get("multicategory", 0)) {
                    $catids = $event->catids();
                    $catdata = $event->getCategoryData();
                } else {
                    $catids = array($event->catid());
                    $catdata = array($event->getCategoryData());
                }
                $vars = $router->getVars();
                foreach ($catids as $cat) {
                    $vars["catids"] = $cat;
                    $catname = "xxx";
                    foreach ($catdata as $cg) {
                        if ($cat == $cg->id) {
                            $catname = $cg->name;
                            break;
                        }
                    }
                    $eventlink = "index.php?";
                    foreach ($vars as $key => $val) {
                        // this is only used in the latest events module so do not perpetuate it here
                        if ($key == "filter_reset") {
                            continue;
                        }
                        if ($key == "task" && ($val == "icalrepeat.detail" || $val == "icalevent.detail")) {
                            $val = "week.listevents";
                        }
                        $eventlink .= $key . "=" . $val . "&";
                    }
                    $eventlink = substr($eventlink, 0, strlen($eventlink) - 1);
                    $eventlink = JRoute::_($eventlink);
                    $catlinks[] = '<a class="ev_link_cat" href="' . $eventlink . '"  title="' . JEventsHTML::special($catname) . '">' . $catname . '</a>';
                }
                $search[] = "{{CATEGORYLNK}}";
                $replace[] = implode(", ", $catlinks);
                $blank[] = "";
                break;
            case "{{CATEGORYIMG}}":
                $search[] = "{{CATEGORYIMG}}";
                $replace[] = $event->getCategoryImage();
                $blank[] = "";
                break;
            case "{{CATEGORYIMGS}}":
                $search[] = "{{CATEGORYIMGS}}";
                $replace[] = $event->getCategoryImage(true);
                $blank[] = "";
                break;
            case "{{CATDESC}}":
                $search[] = "{{CATDESC}}";
                $replace[] = $event->getCategoryDescription();
                $blank[] = "";
                break;
            case "{{CATID}}":
                $search[] = "{{CATID}}";
                $replace[] = $event->catid();
                $blank[] = "";
                break;
            case "{{PARENT_CATEGORY}}":
                $search[] = "{{PARENT_CATEGORY}}";
                $replace[] = $event->getParentCategory();
                $blank[] = "";
                break;
            case "{{ICALDIALOG}}":
            case "{{ICALBUTTON}}":
            case "{{EDITDIALOG}}":
            case "{{EDITBUTTON}}":
                static $styledone = false;
                if (!$styledone) {
                    $document = JFactory::getDocument();
                    $document->addStyleDeclaration("div.jevdialogs {position:relative;margin-top:35px;text-align:left;}\n div.jevdialogs img{float:none!important;margin:0px}");
                    $styledone = true;
                }
                if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) {
                    JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
                    $cssloaded = true;
                    ob_start();
                    ?>
						<a href="javascript:void(0)" onclick='clickIcalButton()' title="<?php 
                    echo JText::_('JEV_SAVEICAL');
                    ?>
">
							<img src="<?php 
                    echo JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images/jevents_event_sml.png';
                    ?>
" name="image"  alt="<?php 
                    echo JText::_('JEV_SAVEICAL');
                    ?>
" class="jev_ev_sml nothumb"/>
						</a>
						<div class="jevdialogs">
						<?php 
                    $search[] = "{{ICALDIALOG}}";
                    if ($view) {
                        ob_start();
                        $view->eventIcalDialog($event, $mask);
                        $dialog = ob_get_clean();
                        $replace[] = $dialog;
                    } else {
                        $replace[] = "";
                    }
                    $blank[] = "";
                    echo $dialog;
                    ?>
						</div>

						<?php 
                    $search[] = "{{ICALBUTTON}}";
                    $replace[] = ob_get_clean();
                    $blank[] = "";
                } else {
                    $search[] = "{{ICALBUTTON}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{ICALDIALOG}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                if (JEVHelper::canEditEvent($event) || JEVHelper::canPublishEvent($event) || JEVHelper::canDeleteEvent($event)) {
                    JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
                    ob_start();
                    ?>
						<a href="javascript:void(0)" onclick='clickEditButton()' title="<?php 
                    echo JText::_('JEV_E_EDIT');
                    ?>
">
							<?php 
                    echo JEVHelper::imagesite('edit.png', JText::_('JEV_E_EDIT'));
                    ?>
						</a>
						<div class="jevdialogs">
						<?php 
                    $search[] = "{{EDITDIALOG}}";
                    if ($view) {
                        ob_start();
                        $view->eventManagementDialog($event, $mask);
                        $dialog = ob_get_clean();
                        $replace[] = $dialog;
                    } else {
                        $replace[] = "";
                    }
                    $blank[] = "";
                    echo $dialog;
                    ?>
						</div>

						<?php 
                    $search[] = "{{EDITBUTTON}}";
                    $replace[] = ob_get_clean();
                    $blank[] = "";
                } else {
                    $search[] = "{{EDITBUTTON}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{EDITDIALOG}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{CREATED}}":
                $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
                $jtz = $compparams->get("icaltimezonelive", "");
                if ($jtz == "") {
                    $jtz = null;
                }
                $created = JevDate::getDate($event->created(), $jtz);
                $search[] = "{{CREATED}}";
                $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED"));
                $blank[] = "";
                break;
            case "{{ACCESS}}":
                $search[] = "{{ACCESS}}";
                $replace[] = $event->getAccessName();
                $blank[] = "";
                break;
            case "{{REPEATSUMMARY}}":
            case "{{STARTDATE}}":
            case "{{ENDDATE}}":
            case "{{STARTTIME}}":
            case "{{ENDTIME}}":
            case "{{STARTTZ}}":
            case "{{ENDTZ}}":
            case "{{ISOSTART}}":
            case "{{ISOEND}}":
            case "{{DURATION}}":
            case "{{MULTIENDDATE}}":
                if ($template_name == "icalevent.detail_body") {
                    $search[] = "{{REPEATSUMMARY}}";
                    $repeatsummary = $view->repeatSummary($event);
                    if (!$repeatsummary) {
                        $repeatsummary = $event->repeatSummary();
                    }
                    $replace[] = $repeatsummary;
                    //$replace[] = $event->repeatSummary();
                    $blank[] = "";
                    $row = $event;
                    $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                    $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                    $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                    $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                    $stop_time_midnightFix = $stop_time;
                    $stop_date_midnightFix = $stop_date;
                    if ($row->sdn() == 59 && $row->mindn() == 59) {
                        $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                        $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                    }
                    $search[] = "{{STARTDATE}}";
                    $replace[] = $start_date;
                    $blank[] = "";
                    $search[] = "{{ENDDATE}}";
                    $replace[] = $stop_date;
                    $blank[] = "";
                    $search[] = "{{STARTTIME}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTIME}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $search[] = "{{STARTTZ}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTZ}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                    $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                    $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime();
                    $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime();
                    $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                    $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                    $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $stop_date : "";
                    $search[] = "{{ISOSTART}}";
                    $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                    $blank[] = "";
                    $search[] = "{{ISOEND}}";
                    $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                    $blank[] = "";
                    $search[] = "{{MULTIENDDATE}}";
                    $replace[] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                    $blank[] = "";
                } else {
                    $row = $event;
                    $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                    $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                    $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                    $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                    $stop_time_midnightFix = $stop_time;
                    $stop_date_midnightFix = $stop_date;
                    if ($row->sdn() == 59 && $row->mindn() == 59) {
                        $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                        $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                    }
                    $search[] = "{{STARTDATE}}";
                    $replace[] = $start_date;
                    $blank[] = "";
                    $search[] = "{{ENDDATE}}";
                    $replace[] = $stop_date;
                    $blank[] = "";
                    $search[] = "{{STARTTIME}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTIME}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $search[] = "{{MULTIENDDATE}}";
                    $replace[] = $row->endDate() > $row->startDate() ? $stop_date : "";
                    $blank[] = "";
                    $search[] = "{{STARTTZ}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTZ}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                    $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                    $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime();
                    $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime();
                    $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                    $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                    $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                    if (strpos($template_value, "{{ISOSTART}}") !== false || strpos($template_value, "{{ISOEND}}") !== false) {
                        $search[] = "{{ISOSTART}}";
                        $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                        $blank[] = "";
                        $search[] = "{{ISOEND}}";
                        $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                        $blank[] = "";
                    }
                    // these would slow things down if not needed in the list
                    $dorepeatsummary = strpos($template_value, "{{REPEATSUMMARY}}") !== false;
                    if ($dorepeatsummary) {
                        $cfg = JEVConfig::getInstance();
                        $jevtask = JRequest::getString("jevtask");
                        $jevtask = str_replace(".listevents", "", $jevtask);
                        $showyeardate = $cfg->get("showyeardate", 0);
                        $row = $event;
                        $times = "";
                        if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "month.calendar" || $jevtask == "cat" || $jevtask == "range") {
                            $start_publish = $row->getUnixStartDate();
                            $stop_publish = $row->getUnixEndDate();
                            if ($stop_publish == $start_publish) {
                                if ($row->noendtime()) {
                                    $times = $start_time;
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        if ($start_time != $stop_time) {
                                            $times = $start_time . ' - ' . $stop_time_midnightFix;
                                        } else {
                                            $times = $start_time;
                                        }
                                    }
                                }
                                $times = $start_date . " " . $times . "<br/>";
                            } else {
                                if ($row->noendtime()) {
                                    $times = $start_time;
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        if ($start_time != $stop_time && !$row->alldayevent()) {
                                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix;
                                        }
                                    }
                                }
                                $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>";
                            }
                        } else {
                            if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) {
                                if ($row->noendtime()) {
                                    if ($showyeardate && $jevtask == "year") {
                                        $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                    } else {
                                        $times = $start_time . '&nbsp;';
                                    }
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                    }
                                }
                            }
                        }
                        $search[] = "{{REPEATSUMMARY}}";
                        $replace[] = $times;
                        $blank[] = "";
                    }
                }
                $search[] = "{{DURATION}}";
                $timedelta = $row->noendtime() ? "" : $row->getUnixEndTime() - $row->getUnixStartTime();
                if ($row->alldayevent()) {
                    $timedelta = $row->getUnixEndDate() - $row->getUnixStartDate() + 60 * 60 * 24;
                }
                $fieldval = JText::_("JEV_DURATION_FORMAT");
                $shownsign = false;
                // whole days!
                if (stripos($fieldval, "%wd") !== false) {
                    $days = intval($timedelta / (60 * 60 * 24));
                    $timedelta -= $days * 60 * 60 * 24;
                    if ($timedelta > 3610) {
                        //if more than 1 hour and 10 seconds over a day then round up the day output
                        $days += 1;
                    }
                    $fieldval = str_ireplace("%d", $days, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%d") !== false) {
                    $days = intval($timedelta / (60 * 60 * 24));
                    $timedelta -= $days * 60 * 60 * 24;
                    /*
                     if ($timedelta>3610){
                     //if more than 1 hour and 10 seconds over a day then round up the day output
                     $days +=1;
                     }
                    */
                    $fieldval = str_ireplace("%d", $days, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%h") !== false) {
                    $hours = intval($timedelta / (60 * 60));
                    $timedelta -= $hours * 60 * 60;
                    if ($shownsign) {
                        $hours = abs($hours);
                    }
                    $hours = sprintf("%02d", $hours);
                    $fieldval = str_ireplace("%h", $hours, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%m") !== false) {
                    $mins = intval($timedelta / 60);
                    $timedelta -= $hours * 60;
                    if ($mins) {
                        $mins = abs($mins);
                    }
                    $mins = sprintf("%02d", $mins);
                    $fieldval = str_ireplace("%m", $mins, $fieldval);
                }
                $replace[] = $fieldval;
                $blank[] = "";
                break;
            case "{{PREVIOUSNEXT}}":
                static $doprevnext;
                if (!isset($doprevnext)) {
                    $doprevnext = strpos($template_value, "{{PREVIOUSNEXT}}") !== false;
                }
                if ($doprevnext) {
                    $search[] = "{{PREVIOUSNEXT}}";
                    $replace[] = $event->previousnextLinks();
                    $blank[] = "";
                }
                break;
            case "{{PREVIOUSNEXTEVENT}}":
                static $doprevnextevent;
                if (!isset($doprevnextevent)) {
                    $doprevnextevent = strpos($template_value, "{{PREVIOUSNEXTEVENT}}") !== false;
                }
                if ($doprevnextevent) {
                    $search[] = "{{PREVIOUSNEXTEVENT}}";
                    $replace[] = $event->previousnextEventLinks();
                    $blank[] = "";
                }
                break;
            case "{{FIRSTREPEAT}}":
            case "{{FIRSTREPEATSTART}}":
                static $dofirstrepeat;
                if (!isset($dofirstrepeat)) {
                    $dofirstrepeat = strpos($template_value, "{{FIRSTREPEAT}}") !== false || strpos($template_value, "{{FIRSTREPEATSTART}}") !== false;
                }
                if ($dofirstrepeat) {
                    $search[] = "{{FIRSTREPEAT}}";
                    $firstrepeat = $event->getFirstRepeat();
                    if ($firstrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = "<a class='ev_firstrepeat' href='" . $firstrepeat->viewDetailLink($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), true) . "' title='" . JText::_('JEV_FIRSTREPEAT') . "' >" . JText::_('JEV_FIRSTREPEAT') . "</a>";
                    }
                    $blank[] = "";
                    $search[] = "{{FIRSTREPEATSTART}}";
                    if ($firstrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = JEventsHTML::getDateFormat($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), 0);
                        $rawreplace[] = $firstrepeat->yup() . "-" . $firstrepeat->mup() . "-" . $firstrepeat->dup() . " " . $firstrepeat->hup() . ":" . $firstrepeat->minup() . ":" . $firstrepeat->sup();
                    }
                    $blank[] = "";
                }
                break;
            case "{{LASTREPEAT}}":
            case "{{LASTREPEATEND}}":
                static $dolastrepeat;
                if (!isset($dolastrepeat)) {
                    $dolastrepeat = strpos($template_value, "{{LASTREPEAT}}") !== false || strpos($template_value, "{{LASTREPEATEND}}") !== false;
                }
                if ($dolastrepeat) {
                    $search[] = "{{LASTREPEAT}}";
                    $lastrepeat = $event->getLastRepeat();
                    if ($lastrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = "<a class='ev_lastrepeat' href='" . $lastrepeat->viewDetailLink($lastrepeat->yup(), $lastrepeat->mup(), $lastrepeat->dup(), true) . "' title='" . JText::_('JEV_LASTREPEAT') . "' >" . JText::_('JEV_LASTREPEAT') . "</a>";
                    }
                    $blank[] = "";
                    $search[] = "{{LASTREPEATEND}}";
                    if ($lastrepeat->rp_id() != $event->rp_id()) {
                        $replace[] = JEventsHTML::getDateFormat($lastrepeat->ydn(), $lastrepeat->mdn(), $lastrepeat->ddn(), 0);
                        $rawreplace[] = $lastrepeat->ydn() . "-" . $lastrepeat->mdn() . "-" . $lastrepeat->ddn() . " " . $lastrepeat->hdn() . ":" . $lastrepeat->mindn() . ":" . $lastrepeat->sdn();
                    } else {
                        $replace[] = "";
                    }
                    $blank[] = "";
                }
                break;
            case "{{CREATOR_LABEL}}":
                $search[] = "{{CREATOR_LABEL}}";
                $replace[] = JText::_('JEV_BY');
                $blank[] = "";
                break;
            case "{{CREATOR}}":
                $search[] = "{{CREATOR}}";
                $replace[] = $event->contactlink();
                $blank[] = "";
                break;
            case "{{HITS}}":
                $search[] = "{{HITS}}";
                $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits();
                $blank[] = "";
                break;
            case "{{LOCATION_LABEL}}":
            case "{{LOCATION}}":
                if ($event->hasLocation()) {
                    $search[] = "{{LOCATION_LABEL}}";
                    $replace[] = JText::_('JEV_EVENT_ADRESSE') . "&nbsp;";
                    $blank[] = "";
                    $search[] = "{{LOCATION}}";
                    $replace[] = $event->location();
                    $blank[] = "";
                } else {
                    $search[] = "{{LOCATION_LABEL}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{LOCATION}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{CONTACT_LABEL}}":
            case "{{CONTACT}}":
                if ($event->hasContactInfo()) {
                    if (strpos($event->contact_info(), '<script') === false) {
                        $dispatcher = JDispatcher::getInstance();
                        JPluginHelper::importPlugin('content');
                        //Contact
                        $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/]';
                        if (strpos($event->contact_info(), '<a href=') === false && $event->contact_info() != "") {
                            $event->contact_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->contact_info()));
                        }
                        // NO need to call conContentPrepate since its called on the template value below here
                    }
                    $search[] = "{{CONTACT_LABEL}}";
                    $replace[] = JText::_('JEV_EVENT_CONTACT') . "&nbsp;";
                    $blank[] = "";
                    $search[] = "{{CONTACT}}";
                    $replace[] = $event->contact_info();
                    $blank[] = "";
                } else {
                    $search[] = "{{CONTACT_LABEL}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{CONTACT}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{EXTRAINFO}}":
                //Extra
                if (strpos($event->extra_info(), '<script') === false && $event->extra_info() != "") {
                    $dispatcher = JDispatcher::getInstance();
                    JPluginHelper::importPlugin('content');
                    $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/#]';
                    if (strpos($event->extra_info(), '<a href=') === false) {
                        $event->extra_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->extra_info()));
                    }
                    //$row->extra_info(eregi_replace('[^(href=|href="|href=\')](((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $row->extra_info()));
                    // NO need to call conContentPrepate since its called on the template value below here
                }
                $search[] = "{{EXTRAINFO}}";
                $replace[] = $event->extra_info();
                $blank[] = "";
                break;
            case "{{RPID}}":
                $search[] = "{{RPID}}";
                $replace[] = $event->rp_id();
                $blank[] = "";
                break;
            default:
                $strippedmatch = str_replace(array("{", "}"), "", $strippedmatch);
                if (is_callable(array($event, $strippedmatch))) {
                    $search[] = "{{" . $strippedmatch . "}}";
                    $replace[] = $event->{$strippedmatch}();
                    $blank[] = "";
                }
                break;
        }
    }
    // Now do the plugins
    // get list of enabled plugins
    $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail";
    $jevplugins = JPluginHelper::getPlugin("jevents");
    foreach ($jevplugins as $jevplugin) {
        $classname = "plgJevents" . ucfirst($jevplugin->name);
        if (is_callable(array($classname, "substitutefield"))) {
            if (!isset($fieldNameArray[$classname])) {
                $fieldNameArray[$classname] = array();
            }
            if (!isset($fieldNameArray[$classname][$layout])) {
                //list($usec, $sec) = explode(" ", microtime());
                //$starttime = (float) $usec + (float) $sec;
                $fieldNameArray[$classname][$layout] = call_user_func(array($classname, "fieldNameArray"), $layout);
                //list ($usec, $sec) = explode(" ", microtime());
                //$time_end = (float) $usec + (float) $sec;
                //echo  "$classname::fieldNameArray = ".round($time_end - $starttime, 4)."<br/>";
            }
            if (isset($fieldNameArray[$classname][$layout]["values"])) {
                foreach ($fieldNameArray[$classname][$layout]["values"] as $fieldname) {
                    if (!strpos($template_value, $fieldname) !== false) {
                        continue;
                    }
                    $search[] = "{{" . $fieldname . "}}";
                    // is the event detail hidden - if so then hide any custom fields too!
                    if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                        $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname);
                        if (is_callable(array($classname, "blankfield"))) {
                            $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname);
                        } else {
                            $blank[] = "";
                        }
                    } else {
                        $blank[] = "";
                        $replace[] = "";
                    }
                }
            }
        }
    }
    // word counts etc.
    for ($s = 0; $s < count($search); $s++) {
        if (strpos($search[$s], "TRUNCATED_DESC:") > 0) {
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $replace[$s];
            $tempsearch = $search[$s];
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value);
        }
    }
    // Date/time formats etc.
    for ($s = 0; $s < count($search); $s++) {
        if (strpos($search[$s], "STARTDATE") > 0 || strpos($search[$s], "STARTTIME") > 0 || strpos($search[$s], "ENDDATE") > 0 || strpos($search[$s], "ENDTIME") > 0 || strpos($search[$s], "ENDTZ") > 0 || strpos($search[$s], "STARTTZ") > 0 || strpos($search[$s], "MULTIENDDATE") > 0 || strpos($search[$s], "FIRSTREPEATSTART") > 0 || strpos($search[$s], "LASTREPEATEND") > 0) {
            if (!isset($rawreplace[$search[$s]]) || !$rawreplace[$search[$s]]) {
                continue;
            }
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $rawreplace[$search[$s]];
            $tempsearch = str_replace("}}", ";.*?}}", $search[$s]);
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialDateFormatting', $template_value);
        }
    }
    for ($s = 0; $s < count($search); $s++) {
        global $tempreplace, $tempevent, $tempsearch, $tempblank;
        $tempreplace = $replace[$s];
        $tempblank = $blank[$s];
        $tempsearch = str_replace("}}", "#", $search[$s]);
        $tempevent = $event;
        $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value);
    }
    $template_value = str_replace($search, $replace, $template_value);
    if ($specialmodules) {
        $reg = JRegistry::getInstance("com_jevents");
        $parts = explode("{{MODULESTART#", $template_value);
        $dynamicmodules = array();
        foreach ($parts as $part) {
            $currentdynamicmodules = $reg->get("dynamicmodules", false);
            if (strpos($part, "{{MODULEEND}}") === false) {
                // strip out BAD HTML tags left by WYSIWYG editors
                if (substr($part, strlen($part) - 3) == "<p>") {
                    $template_value = substr($part, 0, strlen($part) - 3);
                } else {
                    $template_value = $part;
                }
                continue;
            }
            // start with module name
            $modname = substr($part, 0, strpos($part, "}}"));
            $modulecontent = substr($part, strpos($part, "}}") + 2);
            $modulecontent = substr($modulecontent, 0, strpos($modulecontent, "{{MODULEEND}}"));
            // strip out BAD HTML tags left by WYSIWYG editors
            if (strpos($modulecontent, "</p>") === 0) {
                $modulecontent = "<p>x@#" . $modulecontent;
            }
            if (substr($modulecontent, strlen($modulecontent) - 3) == "<p>") {
                $modulecontent .= "x@#</p>";
            }
            $modulecontent = str_replace("<p>x@#</p>", "", $modulecontent);
            if (isset($currentdynamicmodules[$modname])) {
                if (!is_array($currentdynamicmodules[$modname])) {
                    $currentdynamicmodules[$modname] = array($currentdynamicmodules[$modname]);
                }
                $currentdynamicmodules[$modname][] = $modulecontent;
                $dynamicmodules[$modname] = $currentdynamicmodules[$modname];
            } else {
                $dynamicmodules[$modname] = $modulecontent;
            }
        }
        $reg->set("dynamicmodules", $dynamicmodules);
    }
    // non greedy replacement - because of the ?
    $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value);
    // replace [[ with { to that other content plugins can work ok - but not for calendar cell or tooltip since we use [[ there already!
    if ($template_name != "month.calendar_cell" && $template_name != "month.calendar_tip") {
        $template_value = str_replace(array("[[", "]]"), array("{", "}"), $template_value);
    }
    //We add new line characters again to avoid being marked as SPAM when using tempalte in emails
    // do this before content plugins incase they insert javascript etc.
    $template_value = preg_replace("@(<\\s*(br)*\\s*\\/\\s*(p|td|tr|table|div|ul|li|ol|dd|dl|dt)*\\s*>)+?@i", "\$1\n", $template_value);
    // Call content plugins - BUT because emailcloak doesn't identify emails in input fields to a text substitution
    $template_value = str_replace("@", "@£@", $template_value);
    $params = new JRegistry(null);
    $tmprow = new stdClass();
    $tmprow->text = $template_value;
    $tmprow->event = $event;
    $dispatcher = JDispatcher::getInstance();
    JPluginHelper::importPlugin('content');
    $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
    $template_value = $tmprow->text;
    $template_value = str_replace("@£@", "@", $template_value);
    echo $template_value;
    return true;
}
/**
 * Creates mini event dialog for view detail page etc.
 * note this must be contained in a position:relative block element in order to work
 *
 * @param Jevent or descendent $row
 */
function DefaultEventManagementDialog($view, $row, $mask)
{
    if ((JEVHelper::canEditEvent($row) || JEVHelper::canPublishEvent($row) || JEVHelper::canDeleteEvent($row)) && !($mask & MASK_POPUP)) {
        $popup = false;
        $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
        if ($params->get("editpopup", 0)) {
            JHTML::_('behavior.modal');
            JEVHelper::script('editpopup.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
            $popup = true;
            $popupw = $params->get("popupw", 800);
            $popuph = $params->get("popuph", 600);
        }
        $hasrepeat = false;
        if (JVersion::isCompatible("1.6.0")) {
            $pathIMG = JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images';
        } else {
            $pathIMG = JURI::root() . 'administrator/images';
        }
        $editImg = $pathIMG . "/edit_f2.png";
        $editLink = $row->editLink();
        $editLink = $popup ? "javascript:jevEditPopup('" . $editLink . "',{$popupw}, {$popuph});" : $editLink;
        $editCopyImg = $pathIMG . "/copy_f2.png";
        $editCopyLink = $row->editCopyLink();
        $editCopyLink = $popup ? "javascript:jevEditPopup('" . $editCopyLink . "',{$popupw}, {$popuph});" : $editCopyLink;
        $deleteImg = $pathIMG . "/delete_f2.png";
        $deleteLink = $row->deleteLink();
        if ($row->until() != $row->dtstart() || $row->count() > 1) {
            $hasrepeat = true;
            $editRepeatImg = $pathIMG . "/edit_f2.png";
            $editRepeatLink = $row->editRepeatLink();
            $editRepeatLink = $popup ? "javascript:jevEditPopup('" . $editRepeatLink . "',{$popupw}, {$popuph});" : $editRepeatLink;
            $deleteRepeatImg = $pathIMG . "/delete_f2.png";
            $deleteRepeatLink = $row->deleteRepeatLink();
            $deleteFutureImg = $pathIMG . "/delete_f2.png";
            $deleteFutureLink = $row->deleteFutureLink();
        } else {
            $editRepeatLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        if (!JEVHelper::canEditEvent($row)) {
            $editLink = "";
            $editRepeatLink = "";
            $editCopyLink = "";
        }
        if (!JEVHelper::canDeleteEvent($row)) {
            $deleteLink = "";
            $deleteRepeatLink = "";
            $deleteFutureLink = "";
        }
        $publishLink = "";
        if (JEVHelper::canPublishEvent($row)) {
            if ($row->published() > 0) {
                $publishImg = $pathIMG . "/publish_r.png";
                $publishLink = $row->unpublishLink();
                $publishText = JText::_('UNPUBLISH_EVENT');
            } else {
                $publishImg = $pathIMG . "/publish_g.png";
                $publishLink = $row->publishLink();
                $publishText = JText::_('PUBLISH_EVENT');
            }
        }
        if ($publishLink . $editRepeatLink . $editLink . $deleteRepeatLink . $deleteLink . $deleteFutureLink == "") {
            return false;
        }
        ?>
            <div id="action_dialog"  style="position:absolute;right:0px;background-color:#dedede;border:solid 1px #000000;width:200px;padding:10px;visibility:hidden;z-index:999;">
            	<div style="width:12px!important;position:absolute;right:0px;top:0px;background-color:#ffffff;;border:solid #000000;border-width:0 0 1px 1px;text-align:center;">
            		<a href="javascript:void(0)" onclick="closedialog()" style="font-weight:bold;text-decoration:none;color:#000000;">x</a>
            	</div>
                 <?php 
        if ($publishLink != "") {
            ?>
                 <a href="<?php 
            echo $publishLink;
            ?>
" id="publish_reccur"  title="<?php 
            echo $publishText;
            ?>
" style="text-decoration:none;"><img src="<?php 
            echo $publishImg;
            ?>
" style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo $publishText;
            ?>
</a><br/>
                 <?php 
        }
        ?>
                 <?php 
        if ($editRepeatLink != "") {
            ?>
                 <a href="<?php 
            echo $editRepeatLink;
            ?>
" id="edit_reccur"  title="edit event" style="text-decoration:none;"><img src="<?php 
            echo $editRepeatImg;
            ?>
" style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_('EDIT_REPEAT');
            ?>
</a><br/>
                 <?php 
        }
        if ($editLink != "") {
            ?>
            	<a href="<?php 
            echo $editLink;
            ?>
" id="edit_event" title="edit event" style="text-decoration:none;"><img src="<?php 
            echo $editImg;
            ?>
" style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_('EDIT_EVENT');
            ?>
</a><br/>
            	<a href="<?php 
            echo $editCopyLink;
            ?>
" id="edit_eventcopy" title="edit event" style="text-decoration:none;"><img src="<?php 
            echo $editCopyImg;
            ?>
" style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_('COPY_AND_EDIT_EVENT');
            ?>
</a><br/>
                 <?php 
        }
        if ($deleteRepeatLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteRepeatLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WANT_TO_DELETE_THIS_RECURRENCE');
            ?>
')" id="delete_repeat"  title="delete repeat" style="text-decoration:none;"><img src="<?php 
            echo $deleteRepeatImg;
            ?>
"  style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_('DELETE_THIS_REPEAT');
            ?>
</a><br/>
                 <?php 
        }
        if ($deleteLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_($hasrepeat ? 'Are you sure you wish to delete this event and all its repeat' : 'Are you sure you wish to delete this event');
            ?>
')" id="delete_event"  title="delete event" style="text-decoration:none;"><img src="<?php 
            echo $deleteImg;
            ?>
"  style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_($hasrepeat ? "DELETE_ALL_REPEATS" : "DELETE_EVENT");
            ?>
</a><br/>
            	<?php 
        }
        if ($deleteFutureLink != "") {
            ?>
                 <a href="<?php 
            echo $deleteFutureLink;
            ?>
" onclick="return confirm('<?php 
            echo JText::_('ARE_YOU_SURE_YOU_WITH_TO_DELETE_THIS_EVENT_AND_ALL_FUTURE_REPEATS');
            ?>
')" id="delete_eventfuture"  title="delete event" style="text-decoration:none;"><img src="<?php 
            echo $deleteFutureImg;
            ?>
"  style="width:20px;height:20px;border:0px;margin-right:1em;vertical-align:middle;" alt="" /><?php 
            echo JText::_('JEV_DELETE_FUTURE_REPEATS');
            ?>
</a><br/>
            <?php 
        }
        ?>
	        </div>
	        <?php 
        return true;
    } else {
        return false;
    }
}
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask)
{
    $db = JFactory::getDBO();
    // find published template
    static $templates;
    if (!isset($templates)) {
        $templates = array();
    }
    if (!array_key_exists($template_name, $templates)) {
        $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name));
        $templates[$template_name] = $db->loadObject();
    }
    if (is_null($templates[$template_name]) || $templates[$template_name]->value == "") {
        return false;
    }
    $template = $templates[$template_name];
    // now replace the fields
    $search = array();
    $replace = array();
    $blank = array();
    $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
    // Built in fields
    $search[] = "{{TITLE}}";
    $replace[] = $event->title();
    $blank[] = "";
    // Title link
    $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false);
    $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink());
    ob_start();
    ?>
	<a class="ev_link_row" href="<?php 
    echo $rowlink;
    ?>
" style="font-weight:bold;" title="<?php 
    echo JEventsHTML::special($event->title());
    ?>
">
	<?php 
    $linkstart = ob_get_clean();
    $search[] = "{{LINK}}";
    $replace[] = $rowlink;
    $blank[] = "";
    $search[] = "{{LINKSTART}}";
    $replace[] = $linkstart;
    $blank[] = "";
    $search[] = "{{LINKEND}}";
    $replace[] = "</a>";
    $blank[] = "";
    $fulllink = $linkstart . $event->title() . '</a>';
    $search[] = "{{TITLE_LINK}}";
    $replace[] = $fulllink;
    $blank[] = "";
    $search[] = "{{URL}}";
    $replace[] = $event->url();
    $blank[] = "";
    $search[] = "{{TRUNCATED_DESC:.*}}";
    $replace[] = $event->content();
    $blank[] = "";
    //	$search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content();
    $search[] = "{{DESCRIPTION}}";
    $replace[] = $event->content();
    $blank[] = "";
    $search[] = "{{MANAGEMENT}}";
    ob_start();
    $view->_viewNavAdminPanel();
    $replace[] = ob_get_clean();
    $blank[] = "";
    $search[] = "{{CATEGORY}}";
    $replace[] = $event->catname();
    $blank[] = "";
    $bgcolor = $event->bgcolor();
    $search[] = "{{COLOUR}}";
    $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor;
    $blank[] = "";
    $search[] = "{{FGCOLOUR}}";
    $replace[] = $event->fgcolor();
    $blank[] = "";
    $search[] = "{{TTTIME}}";
    $replace[] = "[[TTTIME]]";
    $blank[] = "";
    $search[] = "{{EVTTIME}}";
    $replace[] = "[[EVTTIME]]";
    $blank[] = "";
    $search[] = "{{TOOLTIP}}";
    $replace[] = "[[TOOLTIP]]";
    $blank[] = "";
    $router = JRouter::getInstance("site");
    $vars = $router->getVars();
    $vars["catids"] = $event->catid();
    $eventlink = "index.php?";
    foreach ($vars as $key => $val) {
        $eventlink .= $key . "=" . $val . "&";
    }
    $eventlink = substr($eventlink, 0, strlen($eventlink) - 1);
    $eventlink = JRoute::_($eventlink);
    $catlink = '<a class="ev_link_cat" href="' . $eventlink . '"  title="' . JEventsHTML::special($event->catname()) . '">' . $event->catname() . '</a>';
    $search[] = "{{CATEGORYLNK}}";
    $replace[] = $catlink;
    $blank[] = "";
    $search[] = "{{CATEGORYIMG}}";
    $replace[] = $event->getCategoryImage();
    $blank[] = "";
    static $styledone = false;
    if (!$styledone) {
        $document = JFactory::getDocument();
        $document->addStyleDeclaration("div.jevdialogs {position:relative;margin-top:35px;text-align:left;}\n div.jevdialogs img{float:none!important;margin:0px}");
        $styledone = true;
    }
    if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) {
        JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
        $cssloaded = true;
        ob_start();
        ?>
		<a href="javascript:void(0)" onclick='clickIcalButton()' title="<?php 
        echo JText::_('JEV_SAVEICAL');
        ?>
">
			<img src="<?php 
        echo JURI::root() . 'administrator/components/' . JEV_COM_COMPONENT . '/assets/images/jevents_event_sml.png';
        ?>
" align="middle" name="image"  alt="<?php 
        echo JText::_('JEV_SAVEICAL');
        ?>
" style="height:24px;"/>
		</a>
        <div class="jevdialogs">
        <?php 
        $search[] = "{{ICALDIALOG}}";
        ob_start();
        $view->eventIcalDialog($event, $mask);
        $dialog = ob_get_clean();
        $replace[] = $dialog;
        $blank[] = "";
        echo $dialog;
        ?>
        </div>
		
		<?php 
        $search[] = "{{ICALBUTTON}}";
        $replace[] = ob_get_clean();
        $blank[] = "";
    } else {
        $search[] = "{{ICALBUTTON}}";
        $replace[] = "";
        $blank[] = "";
        $search[] = "{{ICALDIALOG}}";
        $replace[] = "";
        $blank[] = "";
    }
    if ((JEVHelper::canEditEvent($event) || JEVHelper::canPublishEvent($event) || JEVHelper::canDeleteEvent($event)) && !($mask & MASK_POPUP)) {
        JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
        ob_start();
        ?>
        <a href="javascript:void(0)" onclick='clickEditButton()' title="<?php 
        echo JText::_('JEV_E_EDIT');
        ?>
">
			<?php 
        echo JEVHelper::imagesite('edit.png', JText::_('JEV_E_EDIT'));
        ?>
        </a>
        <div class="jevdialogs">
        <?php 
        $search[] = "{{EDITDIALOG}}";
        ob_start();
        $view->eventManagementDialog($event, $mask);
        $dialog = ob_get_clean();
        $replace[] = $dialog;
        $blank[] = "";
        echo $dialog;
        ?>
        </div>
        
        <?php 
        $search[] = "{{EDITBUTTON}}";
        $replace[] = ob_get_clean();
        $blank[] = "";
    } else {
        $search[] = "{{EDITBUTTON}}";
        $replace[] = "";
        $blank[] = "";
        $search[] = "{{EDITDIALOG}}";
        $replace[] = "";
        $blank[] = "";
    }
    $created = JevDate::getDate($event->created());
    $search[] = "{{CREATED}}";
    $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED"));
    $blank[] = "";
    if ($template_name == "icalevent.detail_body") {
        $search[] = "{{REPEATSUMMARY}}";
        $replace[] = $event->repeatSummary();
        $blank[] = "";
        $row = $event;
        $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
        $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
        $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
        $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
        $stop_time_midnightFix = $stop_time;
        $stop_date_midnightFix = $stop_date;
        if ($row->sdn() == 59 && $row->mindn() == 59) {
            $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
            $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
        }
        $search[] = "{{STARTDATE}}";
        $replace[] = $start_date;
        $blank[] = "";
        $search[] = "{{ENDDATE}}";
        $replace[] = $stop_date;
        $blank[] = "";
        $search[] = "{{STARTTIME}}";
        $replace[] = $start_time;
        $blank[] = "";
        $search[] = "{{ENDTIME}}";
        $replace[] = $stop_time_midnightFix;
        $blank[] = "";
    } else {
        $row = $event;
        $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
        $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
        $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
        $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
        $stop_time_midnightFix = $stop_time;
        $stop_date_midnightFix = $stop_date;
        if ($row->sdn() == 59 && $row->mindn() == 59) {
            $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
            $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
        }
        $search[] = "{{STARTDATE}}";
        $replace[] = $start_date;
        $blank[] = "";
        $search[] = "{{ENDDATE}}";
        $replace[] = $stop_date;
        $blank[] = "";
        $search[] = "{{STARTTIME}}";
        $replace[] = $start_time;
        $blank[] = "";
        $search[] = "{{ENDTIME}}";
        $replace[] = $stop_time_midnightFix;
        $blank[] = "";
        // these would slow things down if not needed in the list
        static $dorepeatsummary;
        if (!isset($dorepeatsummary)) {
            $dorepeatsummary = strpos($template->value, ":REPEATSUMMARY}}") !== false;
        }
        if ($dorepeatsummary) {
            $cfg =& JEVConfig::getInstance();
            $jevtask = JRequest::getString("jevtask");
            $jevtask = str_replace(".listevents", "", $jevtask);
            $showyeardate = $cfg->get("showyeardate", 0);
            $row = $event;
            $times = "";
            if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "cat" || $jevtask == "range") {
                $start_publish = $row->getUnixStartDate();
                $stop_publish = $row->getUnixEndDate();
                if ($stop_publish == $start_publish) {
                    if ($row->noendtime()) {
                        $times = $start_time;
                    } else {
                        if ($row->alldayevent()) {
                            $times = "";
                        } else {
                            if ($start_time != $stop_time) {
                                $times = $start_time . ' - ' . $stop_time_midnightFix;
                            } else {
                                $times = $start_time;
                            }
                        }
                    }
                    $times = $start_date . " " . $times . "<br/>";
                } else {
                    if ($row->noendtime()) {
                        $times = $start_time;
                    } else {
                        if ($start_time != $stop_time && !$row->alldayevent()) {
                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix;
                        }
                    }
                    $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>";
                }
            } else {
                if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) {
                    if ($row->noendtime()) {
                        if ($showyeardate && $jevtask == "year") {
                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                        } else {
                            $times = $start_time . '&nbsp;';
                        }
                    } else {
                        $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                    }
                }
            }
            $search[] = "{{REPEATSUMMARY}}";
            $replace[] = $times;
            $blank[] = "";
        }
    }
    static $doprevnext;
    if (!isset($doprevnext)) {
        $doprevnext = strpos($template->value, ":PREVIOUSNEXT}}") !== false;
    }
    if ($doprevnext) {
        $search[] = "{{PREVIOUSNEXT}}";
        $replace[] = $event->previousnextLinks();
        $blank[] = "";
    }
    $search[] = "{{CREATOR_LABEL}}";
    $replace[] = JText::_('JEV_BY');
    $blank[] = "";
    $search[] = "{{CREATOR}}";
    $replace[] = $event->contactlink();
    $blank[] = "";
    $search[] = "{{HITS}}";
    $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits();
    $blank[] = "";
    if ($event->hasLocation()) {
        $search[] = "{{LOCATION_LABEL}}";
        $replace[] = JText::_('JEV_EVENT_ADRESSE') . "&nbsp;";
        $blank[] = "";
        $search[] = "{{LOCATION}}";
        $replace[] = $event->location();
        $blank[] = "";
    } else {
        $search[] = "{{LOCATION_LABEL}}";
        $replace[] = "";
        $blank[] = "";
        $search[] = "{{LOCATION}}";
        $replace[] = "";
        $blank[] = "";
    }
    if ($event->hasContactInfo()) {
        $search[] = "{{CONTACT_LABEL}}";
        $replace[] = JText::_('JEV_EVENT_CONTACT') . "&nbsp;";
        $blank[] = "";
        $search[] = "{{CONTACT}}";
        $replace[] = $event->contact_info();
        $blank[] = "";
    } else {
        $search[] = "{{CONTACT_LABEL}}";
        $replace[] = "";
        $blank[] = "";
        $search[] = "{{CONTACT}}";
        $replace[] = "";
        $blank[] = "";
    }
    $search[] = "{{EXTRAINFO}}";
    $replace[] = $event->extra_info();
    $blank[] = "";
    // Now do the plugins
    // get list of enabled plugins
    $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail";
    $jevplugins = JPluginHelper::getPlugin("jevents");
    foreach ($jevplugins as $jevplugin) {
        $classname = "plgJevents" . ucfirst($jevplugin->name);
        if (is_callable(array($classname, "substitutefield"))) {
            $fieldNameArray = call_user_func(array($classname, "fieldNameArray"), $layout);
            if (isset($fieldNameArray["values"])) {
                foreach ($fieldNameArray["values"] as $fieldname) {
                    $search[] = "{{" . $fieldname . "}}";
                    // is the event detail hidden - if so then hide any custom fields too!
                    if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                        $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname);
                        if (is_callable(array($classname, "blankfield"))) {
                            $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname);
                        } else {
                            $blank[] = "";
                        }
                    } else {
                        $blank[] = "";
                        $replace[] = "";
                    }
                }
            }
        }
    }
    $template_value = $template->value;
    // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
    $template_value = str_replace("\r", '', $template_value);
    $template_value = str_replace("\n", '', $template_value);
    // non greedy replacement - because of the ?
    $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value);
    // word counts etc.
    for ($s = 0; $s < count($search); $s++) {
        if (strpos($search[$s], "TRUNCATED_DESC:") > 0) {
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $replace[$s];
            $tempsearch = $search[$s];
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value);
        }
    }
    for ($s = 0; $s < count($search); $s++) {
        global $tempreplace, $tempevent, $tempsearch, $tempblank;
        $tempreplace = $replace[$s];
        $tempblank = $blank[$s];
        $tempsearch = str_replace("}}", "#", $search[$s]);
        $tempevent = $event;
        $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value);
    }
    $template_value = str_replace($search, $replace, $template_value);
    // non greedy replacement - because of the ?
    $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value);
    echo $template_value;
    return true;
}
Exemplo n.º 14
0
 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);
     // JREQUEST_ALLOWHTML requires at least Joomla 1.5 svn9979 (past 1.5 stable)
     $array = JRequest::get('request', JREQUEST_ALLOWHTML);
     // Should we allow raw content through unfiltered
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     if ($params->get("allowraw", 0)) {
         $array['jevcontent'] = JRequest::getString("jevcontent", "", "POST", JREQUEST_ALLOWRAW);
         $array['extra_info'] = JRequest::getString("extra_info", "", "POST", JREQUEST_ALLOWRAW);
     }
     // convert nl2br if there is no HTML
     if (strip_tags($array['jevcontent']) == $array['jevcontent']) {
         $array['jevcontent'] = nl2br($array['jevcontent']);
     }
     if (strip_tags($array['extra_info']) == $array['extra_info']) {
         $array['extra_info'] = nl2br($array['extra_info']);
     }
     // convert event data to objewct so we can test permissions
     $eventobj = new stdClass();
     foreach ($array as $key => $val) {
         $newkey = "_" . $key;
         $eventobj->{$newkey} = $val;
     }
     $eventobj->_icsid = $eventobj->_ics_id;
     if (is_array($eventobj->_catid)) {
         $eventobj->_catid = current($eventobj->_catid);
     }
     if (!JEVHelper::canCreateEvent($eventobj)) {
         throw new Exception(JText::_('ALERTNOTAUTH'), 403);
         return false;
     }
     $rrule = SaveIcalEvent::generateRRule($array);
     // ensure authorised
     if (isset($array["evid"]) && $array["evid"] > 0) {
         $event = $this->queryModel->getEventById(intval($array["evid"]), 1, "icaldb");
         if (!$event || !JEVHelper::canEditEvent($event)) {
             throw new Exception(JText::_('ALERTNOTAUTH'), 403);
             return false;
         }
     }
     $clearout = false;
     // remove all exceptions since they are no longer needed
     if (isset($array["evid"]) && $array["evid"] > 0 && JRequest::getInt("updaterepeats", 1)) {
         $clearout = true;
     }
     if ($event = SaveIcalEvent::save($array, $this->queryModel, $rrule)) {
         $row = new jIcalEventRepeat($event);
         if (JEVHelper::canPublishEvent($row)) {
             $msg = JText::_("Event_Saved", true);
         } else {
             $msg = JText::_("EVENT_SAVED_UNDER_REVIEW", true);
         }
         if ($clearout) {
             $db = JFactory::getDBO();
             $query = "DELETE FROM #__jevents_exception WHERE eventid = " . $array["evid"];
             $db->setQuery($query);
             $db->query();
             // TODO clear out old exception details
         }
     } else {
         $msg = JText::_("Event Not Saved", true);
         $row = null;
     }
     return $row;
 }