Exemple #1
0
 function getEvents(&$params)
 {
     // Reuse existing language file from JomSocial
     $language = JFactory::getLanguage();
     $language->load('com_jevents', JPATH_ROOT);
     $query_start_date = null;
     $query_end_date = null;
     if ($params->get('time_range') == 'time_span' || $params->get('rangespan') != 'all_events') {
         $query_start_date = $params->get('startmin');
         $startMax = $params->get('startmax', false);
         if ($startMax !== false) {
             $query_end_date = $startMax;
         }
     }
     // setup for all required function and classes
     $file = JPATH_SITE . '/components/com_jevents/mod.defines.php';
     if (file_exists($file)) {
         include_once $file;
         include_once JEV_LIBS . "/modfunctions.php";
     } else {
         die("JEvents Calendar\n<br />This module needs the JEvents component");
     }
     // load language constants
     JEVHelper::loadLanguage('modlatest');
     $datamodel = new JEventsDataModel();
     $showrepeats = $params->get('jevents_norepeats', 0) == 0 ? true : false;
     //$myItemid = $this->datamodel->setupModuleCatids($this->modparams);
     //$catout	= $this->datamodel->getCatidsOutLink(true);
     $params->set('catid0', $params->get('jevents_category', 0));
     $myItemid = $datamodel->setupModuleCatids($params);
     $catout = $datamodel->getCatidsOutLink(true);
     $reg =& JevRegistry::getInstance("jevents");
     $reg->setReference("jevents.datamodel", $datamodel);
     if (!empty($query_start_date)) {
         $rstartdate = new RokMiniEvents_Date($query_start_date);
         if ($params->get('jevents_past', 0) == 0 && $rstartdate->toUnix() < time()) {
             $rstartdate = new RokMiniEvents_Date(time());
         }
         $dates_start = $rstartdate->toISO8601();
     } else {
         if ($params->get('jevents_past', 0) == 0) {
             $rstartdate = new RokMiniEvents_Date(time());
             $dates_start = $rstartdate->toISO8601();
         } else {
             $dates_start = date('Y-m-d\\T23:59:59', strtotime("-1 month"));
         }
     }
     if (empty($query_end_date)) {
         $dates_end = date('Y-m-d\\T23:59:59', strtotime("+1 year"));
     } else {
         $dates_end = $query_end_date;
     }
     $rows = $datamodel->queryModel->listIcalEventsByRange($dates_start, $dates_end, 0, 0, $showrepeats);
     $events = array();
     $total_count = 1;
     $total_max = $params->get('jevents_total', 10);
     foreach ($rows as $row) {
         if ($params->get('jevents_links') != 'link_no') {
             if ($params->get('jevents_links') == 'event_internal' || $params->get('jevents_links') == 'event_external') {
                 $link = array('internal' => $params->get('jevents_links') == 'event_internal' ? true : false, 'link' => self::getCalendarLink($myItemid, $catout, TRUE, $row->_eventid));
             } else {
                 $link = array('internal' => $params->get('jevents_links') == 'link_internal' ? true : false, 'link' => self::getCalendarLink($myItemid, $catout));
             }
         } else {
             $link = false;
         }
         $event = new RokMiniEvents_Event($row->_unixstarttime, $row->_unixendtime, $row->_title, $row->_content, $link);
         $events[] = $event;
         $total_count++;
         if ($total_count > $total_max) {
             break;
         }
     }
     return $events;
 }
 /**
  * Search method
  *
  * The sql must return the following fields that are used in a common display
  * routine: href, title, section, created, text, browsernav
  * @param string Target search string
  * @param string matching option, exact|any|all
  * @param string ordering option, newest|oldest|popular|alpha|category
  */
 function onSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDBO();
     $user = JFactory::getUser();
     $groups = version_compare(JVERSION, '1.6.0', '>=') ? implode(',', $user->getAuthorisedViewLevels()) : false;
     $limit = version_compare(JVERSION, '1.6.0', '>=') ? $this->params->get('search_limit', 50) : $this->_params->def('search_limit', 50);
     $dateformat = version_compare(JVERSION, '1.6.0', ">=") ? $this->params->get('date_format', "%d %B %Y") : $this->_params->def('date_format', "%d %B %Y");
     $allLanguages = $this->params->get('all_language_search', true);
     $limit = "\n LIMIT {$limit}";
     $text = trim($text);
     if ($text == '') {
         return array();
     }
     if (is_array($areas)) {
         $test = array_keys(plgSearchEventsSearchAreas());
         if (!array_intersect($areas, array_keys(plgSearchEventsSearchAreas()))) {
             return array();
         }
     }
     $params = JComponentHelper::getParams("com_jevents");
     // See http://www.php.net/manual/en/timezones.php
     $tz = $params->get("icaltimezonelive", "");
     if ($tz != "" && is_callable("date_default_timezone_set")) {
         $timezone = date_default_timezone_get();
         date_default_timezone_set($tz);
         $this->jeventstimezone = $timezone;
     }
     $search_ical_attributes = array('det.summary', 'det.description', 'det.location', 'det.contact', 'det.extra_info');
     // process the new plugins
     // get extra data and conditionality from plugins
     $extrawhere = array();
     $extrajoin = array();
     $needsgroup = false;
     $filterarray = array("published");
     $dataModel = new JEventsDataModel();
     $compparams = JComponentHelper::getParams("com_jevents");
     if ($compparams->get("multicategory", 0)) {
         $catwhere = "\n AND catmap.catid IN(" . $dataModel->accessibleCategoryList(null, null, null, $allLanguages) . ")";
         $catjoin = "\n LEFT JOIN #__jevents_catmap as catmap ON catmap.evid = rpt.eventid";
         $catjoin .= "\n LEFT JOIN #__categories AS b ON catmap.catid = b.id";
     } else {
         $catwhere = "\n AND ev.catid IN(" . $dataModel->accessibleCategoryList(null, null, null, $allLanguages) . ")";
         $catjoin = "\n INNER JOIN #__categories AS b ON b.id = ev.catid";
     }
     // If there are extra filters from the module then apply them now
     $reg = JFactory::getConfig();
     $modparams = $reg->get("jev.modparams", false);
     if ($modparams && $modparams->get("extrafilters", false)) {
         $filterarray = array_merge($filterarray, explode(",", $modparams->get("extrafilters", false)));
     }
     $filters = jevFilterProcessing::getInstance($filterarray);
     $filters->setWhereJoin($extrawhere, $extrajoin);
     $needsgroup = $filters->needsGroupBy();
     JPluginHelper::importPlugin('jevents');
     $dispatcher = JDispatcher::getInstance();
     $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     $extrajoin = count($extrajoin) ? " \n LEFT JOIN " . implode(" \n LEFT JOIN ", $extrajoin) : '';
     $extrawhere = count($extrawhere) ? ' AND ' . implode(' AND ', $extrawhere) : '';
     $extrasearchfields = array();
     $dispatcher->trigger('onSearchEvents', array(&$extrasearchfields, &$extrajoin, &$needsgroup));
     $wheres = array();
     $wheres_ical = array();
     switch ($phrase) {
         case 'exact':
             $text = $db->Quote('%' . $db->escape($text, true) . '%', false);
             // ical
             $wheres2 = array();
             foreach ($search_ical_attributes as $search_item) {
                 $wheres2[] = "LOWER({$search_item}) LIKE " . $text;
             }
             $where_ical = '(' . implode(') OR (', $wheres2) . ')';
             break;
         case 'all':
         case 'any':
         default:
             $words = explode(' ', $text);
             $text = $db->Quote('%' . $db->escape($text, true) . '%', false);
             // ical
             $wheres = array();
             foreach ($words as $word) {
                 $word = $db->Quote('%' . $db->escape($word) . '%', false);
                 $wheres2 = array();
                 foreach ($search_ical_attributes as $search_item) {
                     $wheres2[] = "LOWER({$search_item}) LIKE " . $word;
                 }
                 $wheres[] = implode(' OR ', $wheres2);
             }
             $where_ical = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')';
             break;
     }
     if (count($extrasearchfields) > 0) {
         $extraor = implode(" OR ", $extrasearchfields);
         $extraor = " OR " . $extraor;
         // replace the ### placeholder with the keyword
         // $text is already exscaped above
         $extraor = str_replace("###", $text, $extraor);
         $where_ical .= $extraor;
     }
     // some of the where statements may already be escaped
     $where_ical = str_replace("%'%'", "%'", $where_ical);
     $where_ical = str_replace("''", "'", $where_ical);
     $where_ical = str_replace("'%'%", "'%", $where_ical);
     $morder = '';
     $morder_ical = '';
     switch ($ordering) {
         case 'oldest':
             $order = 'a.created ASC';
             $order_ical = 'det.created ASC';
             break;
         case 'popular':
             $order = 'a.hits DESC';
             $order_ical = 'det.created ASC';
             // no hit field available
             break;
         case 'alpha':
             $order = 'a.title ASC';
             $order_ical = 'det.summary ASC';
             break;
         case 'category':
             $order = 'b.title ASC, a.title ASC';
             $morder = 'a.title ASC';
             $order_ical = 'b.title ASC, det.summary ASC';
             $morder_ical = 'det.summary ASC';
             break;
         case 'newest':
         default:
             $order = 'a.created DESC';
             $order_ical = 'det.created DESC';
             break;
     }
     $eventstitle = JText::_("Events Calendar");
     // Now Search Icals
     $display2 = array();
     foreach ($search_ical_attributes as $search_ical_attribute) {
         $display2[] = "{$search_ical_attribute}";
     }
     $display = 'CONCAT(' . implode(", ' ', ", $display2) . ')';
     $query = "SELECT det.evdet_id, det.summary as title," . "\n ev.created as created," . "\n {$display} as text," . "\n CONCAT('{$eventstitle}','/',det.summary) AS section," . "\n CONCAT('index.php?option=com_jevents&task=icalrepeat.detail&evid=',min(rpt.rp_id)) AS href," . "\n '2' AS browsernav ," . "\n rpt.startrepeat, rpt.rp_id " . "\n FROM (#__jevents_vevent as ev)" . "\n LEFT  JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . $catjoin . "\n LEFT  JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT  JOIN #__jevents_icsfile as icsf ON icsf.ics_id = ev.icsid" . $extrajoin . "\n WHERE ({$where_ical})" . "\n AND icsf.state = 1" . "\n AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . $groups . ')' : ' <=  ' . $user->gid) . "\n AND ev.state = 1" . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . $groups . ')' : ' <=  ' . $user->gid) . "\n AND b.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . $groups . ')' : ' <=  ' . $user->gid) . "\n AND b.published = '1'" . $extrawhere . $catwhere . "\n GROUP BY det.evdet_id" . "\n ORDER BY " . ($morder_ical ? $morder_ical : $order_ical) . $limit;
     $db->setQuery($query);
     $list_ical = $db->loadObjectList('evdet_id');
     jimport('joomla.utilities.date');
     if ($list_ical) {
         foreach ($list_ical as $id => $item) {
             $user = JFactory::getUser();
             $query = "SELECT ev.*, ev.state as published, rpt.*, rr.*, det.*, ev.created as created, ex_id, exception_type " . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat  ) as ydn, MONTH(rpt.endrepeat   ) as mdn, DAYOFMONTH(rpt.endrepeat   ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat  ) as hdn, MINUTE(rpt.endrepeat   ) as mindn, SECOND(rpt.endrepeat   ) as sdn" . "\n FROM #__jevents_vevent as ev" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_exception as ex ON det.evdet_id = ex.eventdetail_id" . "\n WHERE ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . $groups . ')' : ' <=  ' . $user->gid) . "\n AND det.evdet_id = {$id}" . "\n ORDER BY rpt.startrepeat ASC limit 1";
             $db->setQuery($query);
             $row = $db->loadObject();
             if (!$row) {
                 continue;
             }
             $event = new jIcalEventRepeat($row);
             // only get the next repeat IF its not an exception
             if (is_null($row->ex_id)) {
                 $event = $event->getNextRepeat();
             }
             $startdate = new JevDate(strtotime($event->_startrepeat));
             $item->title = $item->title . " (" . $startdate->toFormat($dateformat) . ")";
             $item->startrepeat = $event->_startrepeat;
             $myitemid = $this->params->get("target_itemid", 0);
             if ($myitemid == 0) {
                 // I must find the itemid that allows this event to be shown
                 $catidsOut = $modcatids = $catidList = $modparams = $showall = "";
                 // Use the plugin params to ensure menu item is picked up
                 //$modparams = new JRegistry($this->_plugin->params);
                 $modparams = new JRegistry(null);
                 // pretend to have category restriction
                 $modparams->set("catid0", $row->catid);
                 $modparams->set("ignorecatfilter", 1);
                 $myitemid = findAppropriateMenuID($catidsOut, $modcatids, $catidList, $modparams->toObject(), $showall);
             }
             $item->href = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false, $myitemid);
             $link = $item->href;
             $list_ical[$id] = $item;
         }
     }
     // Must reset the timezone back!!
     if ($tz && is_callable("date_default_timezone_set")) {
         date_default_timezone_set($timezone);
     }
     return $list_ical;
 }
Exemple #3
0
 /**
  * Test to see if user can add events from the front end
  *
  * @return boolean
  */
 public static function isEventCreator()
 {
     static $isEventCreator;
     if (!isset($isEventCreator)) {
         $isEventCreator = false;
         $user = JEVHelper::getAuthorisedUser();
         if (is_null($user)) {
             $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
             $juser = JFactory::getUser();
             $authorisedonly = $params->get("authorisedonly", 0);
             if (!$authorisedonly) {
                 if ($params->get("category_allow_deny", 1) == 0) {
                     // this is too heavy on database queries - keep this in the file so that sites that want to use this approach can uncomment this block
                     list($usec, $sec) = explode(" ", microtime());
                     $time_start = (double) $usec + (double) $sec;
                     if ($juser->get("id")) {
                         $okcats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
                         $juser = JFactory::getUser();
                         if (count($okcats)) {
                             $dataModel = new JEventsDataModel();
                             $dataModel->setupComponentCatids();
                             $allowedcats = explode(",", $dataModel->accessibleCategoryList());
                             $intersect = array_intersect($okcats, $allowedcats);
                             if (count($intersect) > 0) {
                                 $isEventCreator = true;
                             }
                         }
                     }
                     list($usec, $sec) = explode(" ", microtime());
                     $time_end = (double) $usec + (double) $sec;
                     //echo "time taken = ". round($time_end -  $time_start, 4)."<Br/>";
                     //if ($isEventCreator) return $isEventCreator;
                 } else {
                     $isEventCreator = $juser->authorise('core.create', 'com_jevents');
                     if ($isEventCreator) {
                         $okcats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
                         if (count($okcats) > 0) {
                             $juser = JFactory::getUser();
                             $dataModel = new JEventsDataModel();
                             $dataModel->setupComponentCatids();
                             $allowedcats = explode(",", $dataModel->accessibleCategoryList());
                             $intersect = array_intersect($okcats, $allowedcats);
                             if (count($intersect) == 0) {
                                 $isEventCreator = false;
                             }
                         } else {
                             $isEventCreator = false;
                         }
                     }
                 }
             } else {
                 if ($juser->id > 0 && JEVHelper::isAdminUser($juser)) {
                     JError::raiseWarning("403", JText::_("JEV_AUTHORISED_USER_MODE_ENABLED_BUT_NO_ENTRY_FOR_SUPER_USER"));
                 }
             }
         } else {
             if ($user->cancreate) {
                 // Check maxevent count
                 if ($user->eventslimit > 0) {
                     $db = JFactory::getDBO();
                     $db->setQuery("SELECT count(*) FROM #__jevents_vevent where created_by=" . $user->user_id);
                     $eventcount = intval($db->loadResult());
                     if ($eventcount < $user->eventslimit) {
                         $isEventCreator = true;
                     } else {
                         $isEventCreator = false;
                     }
                 } else {
                     $isEventCreator = true;
                 }
                 // are we blocked by category or calendar constraints
                 if ($isEventCreator && $user->categories != "" && $user->categories != "all") {
                     $okcats = explode("|", $user->categories);
                     $juser = JFactory::getUser();
                     $dataModel = new JEventsDataModel();
                     $dataModel->setupComponentCatids();
                     $allowedcats = explode(",", $dataModel->accessibleCategoryList());
                     $intersect = array_intersect($okcats, $allowedcats);
                     if (count($intersect) == 0) {
                         $isEventCreator = false;
                     }
                 }
             }
         }
         JPluginHelper::importPlugin("jevents");
         $dispatcher = JEventDispatcher::getInstance();
         $dispatcher->trigger('isEventCreator', array(&$isEventCreator));
     }
     if (is_null($isEventCreator)) {
         $isEventCreator = false;
     }
     return $isEventCreator;
 }
function DefaultViewHelperViewNavAdminPanel($view)
{
    $cfg = JEVConfig::getInstance();
    if ($cfg->get('show_adminpanel', 1) == 1) {
        $is_event_editor = JEVHelper::isEventCreator();
        $user = JFactory::getUser();
        JEVHelper::script('view_detailJQ.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
        JLoader::register('jevFilterProcessing', JEV_PATH . "/libraries/filters.php");
        $pluginsDir = JPATH_ROOT . '/' . 'plugins' . '/' . 'jevents';
        $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "reset"));
        $cfg = JEVConfig::getInstance();
        if (JRequest::getInt('pop', 0)) {
            return;
        }
        if ($is_event_editor) {
            if ($cfg->get("bootstrapchosen", 1)) {
                // Load Bootstrap
                JevHtmlBootstrap::framework();
                JHtml::_('formbehavior.chosen', '#jevents select:not(.notchosen)');
            }
            if ($cfg->get("bootstrapcss", 1) == 1) {
                // This version of bootstrap has maximum compatability with JEvents due to enhanced namespacing
                JHTML::stylesheet("com_jevents/bootstrap.css", array(), true);
            } else {
                if ($cfg->get("bootstrapcss", 1) == 2) {
                    JHtmlBootstrap::loadCss();
                }
            }
            // Load event adding language string
            JText::script('JEV_ADD_EVENT');
            JText::script('JEV_IMPORT_ICALEVENT');
            ?>
			<div class="ev_adminpanel">
				<div align="left" class="nav_bar_cell">
					<?php 
            $editLink = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.edit' . '&year=' . $view->year . '&month=' . $view->month . '&day=' . $view->day . '&Itemid=' . $view->Itemid, true);
            $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;
            }
            $eventlinkadd = $popup ? "javascript:jevEditPopup('" . $editLink . "');" : $editLink;
            ?>
					<a href="<?php 
            echo $eventlinkadd;
            ?>
" title="<?php 
            echo JText::_('JEV_ADDEVENT');
            ?>
">
						<b><?php 
            echo JText::_('JEV_ADDEVENT');
            ?>
</b>
					</a>
					<?php 
            // offer frontend import ?
            if ($params->get("feimport", 0)) {
                $importLink = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icals.importform&tmpl=component&Itemid=' . $view->Itemid, true);
                //JevHtmlBootstrap::modal();
                JEVHelper::script('editpopupJQ.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
                $eventimport = "javascript:jevImportPopup('" . $importLink . "');";
                ?>
						<br/><a href="<?php 
                echo $eventimport;
                ?>
" title="<?php 
                echo JText::_('JEV_IMPORT_ICALEVENT', true);
                ?>
">
							<b><?php 
                echo JText::_('JEV_IMPORT_ICALEVENT');
                ?>
</b>
						</a>
						<?php 
            }
            if ($user->id > 0) {
                $datamodel = new JEventsDataModel();
                // find appropriate Itemid and setup catids for datamodel
                $myItemid = JEVHelper::getItemid();
                $datamodel->setupComponentCatids();
                list($year, $month, $day) = JEVHelper::getYMD();
                $evid = JRequest::getVar("evid", false);
                $jevtype = JRequest::getVar("jevtype", false);
                // FORM for filter submission
                $form_link = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=' . JRequest::getVar("jevtask", "month.calendar") . ($evid ? '&evid=' . $evid : '') . ($jevtype ? '&jevtype=' . $jevtype : '') . ($year ? '&year=' . $year : '') . ($month ? '&month=' . $month : '') . ($day ? '&day=' . $day : '') . "&Itemid=" . $myItemid, false);
                ?>
						<form action="<?php 
                echo $form_link;
                ?>
"  method="post">
							<?php 
                $filterHTML = $filters->getFilterHTML();
                $Itemid = JEVHelper::getItemid();
                foreach ($filterHTML as $filter) {
                    echo "<div>" . $filter["title"] . " " . $filter["html"] . "</div>";
                }
                /*
                 $eventmylinks = JRoute::_( 'index.php?option=' . JEV_COM_COMPONENT . '&task=admin.listevents'
                 . '&year=' . $view->year . '&month=' . $view->month . '&day=' . $view->day
                 . '&Itemid=' . $view->Itemid ); ?>
                 <a href="<?php echo $eventmylinks; ?>" title="<?php echo JText::_('JEV_MYEVENTS'); ?>">
                 <b><?php echo JText::_('JEV_MYEVENTS'); ?></b>
                 </a>
                 <?php
                */
                ?>
						</form>
					<?php 
            }
            ?>
				</div>
			</div>
		<?php 
        }
    }
}
Exemple #5
0
<?php

/**
 * JEvents Component for Joomla 1.5.x
 *
 * @version     $Id: default.php 3323 2012-03-08 13:37:46Z geraintedwards $
 * @package     JEvents
 * @subpackage  Module JEvents Filter
 * @copyright   Copyright (C) 2008-2015 GWE Systems Ltd
 * @license     GNU/GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
 * @link        http://www.gwesystems.com
 */
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die;
$datamodel = new JEventsDataModel();
// find appropriate Itemid and setup catids for datamodel
$Itemid = JRequest::getInt("Itemid");
$option = JRequest::getCmd("option");
$jevtask = false;
if ($option == JEV_COM_COMPONENT) {
    $myItemid = $Itemid;
    $jevtask = JRequest::getVar("jevtask", "year.listevents");
} else {
    $myItemid = $params->get("target_itemid", 0);
}
// if always to target then set it here
if ($params->get("target_itemid", 0) && $params->get("alwaystarget", 0)) {
    $myItemid = $params->get("target_itemid", 0);
}
if ($myItemid == 0) {
    $myItemid = $datamodel->setupModuleCatids($params);
function DefaultViewHelperViewNavAdminPanel($view)
{
    $is_event_editor = JEVHelper::isEventCreator();
    $user = JFactory::getUser();
    JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
    JLoader::register('jevFilterProcessing', JEV_PATH . "/libraries/filters.php");
    $pluginsDir = JPATH_ROOT . DS . 'plugins' . DS . 'jevents';
    $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "reset"));
    $cfg =& JEVConfig::getInstance();
    if (JRequest::getInt('pop', 0)) {
        return;
    }
    if ($is_event_editor) {
        ?>
		<div class="ev_adminpanel">
		<table width="100%" border="0" align="center">
			<tr>
				<td align="left" class="nav_bar_cell">
                        <?php 
        $editLink = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.edit' . '&year=' . $view->year . '&month=' . $view->month . '&day=' . $view->day . '&Itemid=' . $view->Itemid, true);
        $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);
        }
        $eventlinkadd = $popup ? "javascript:jevEditPopup('" . $editLink . "',{$popupw}, {$popuph});" : $editLink;
        ?>
                        <a href="<?php 
        echo $eventlinkadd;
        ?>
" title="<?php 
        echo JText::_('JEV_ADDEVENT');
        ?>
">
                            <b><?php 
        echo JText::_('JEV_ADDEVENT');
        ?>
</b>
                        </a>
                        <?php 
        // offer frontend import ?
        if ($params->get("feimport", 0)) {
            $importLink = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=icals.importform&tmpl=component&Itemid=' . $view->Itemid, true);
            JHTML::_('behavior.modal');
            JEVHelper::script('editpopup.js', 'components/' . JEV_COM_COMPONENT . '/assets/js/');
            $eventimport = "javascript:jevImportPopup('" . $importLink . "',400, 400);";
            ?>
	                        <br/><a href="<?php 
            echo $eventimport;
            ?>
" title="<?php 
            echo JText::_('JEV_IMPORT_ICALEVENT', true);
            ?>
">
	                            <b><?php 
            echo JText::_('JEV_IMPORT_ICALEVENT');
            ?>
</b>
	                        </a>
	                        <?php 
        }
        if ($user->id > 0) {
            $datamodel = new JEventsDataModel();
            // find appropriate Itemid and setup catids for datamodel
            $myItemid = JEVHelper::getItemid();
            $datamodel->setupComponentCatids();
            list($year, $month, $day) = JEVHelper::getYMD();
            $evid = JRequest::getVar("evid", false);
            $jevtype = JRequest::getVar("jevtype", false);
            // FORM for filter submission
            $form_link = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=' . JRequest::getVar("jevtask", "month.calendar") . ($evid ? '&evid=' . $evid : '') . ($jevtype ? '&jevtype=' . $jevtype : '') . ($year ? '&year=' . $year : '') . ($month ? '&month=' . $month : '') . ($day ? '&day=' . $day : '') . "&Itemid=" . $myItemid, false);
            ?>
						<form action="<?php 
            echo $form_link;
            ?>
"  method="post">
						<?php 
            $filterHTML = $filters->getFilterHTML();
            $Itemid = JEVHelper::getItemid();
            foreach ($filterHTML as $filter) {
                echo "<div>" . $filter["title"] . " " . $filter["html"] . "</div>";
            }
            /*
            $eventmylinks = JRoute::_( 'index.php?option=' . JEV_COM_COMPONENT . '&task=admin.listevents'
            . '&year=' . $view->year . '&month=' . $view->month . '&day=' . $view->day
            . '&Itemid=' . $view->Itemid ); ?>
            <a href="<?php echo $eventmylinks; ?>" title="<?php echo JText::_('JEV_MYEVENTS'); ?>">
            <b><?php echo JText::_('JEV_MYEVENTS'); ?></b>
            </a>
            <?php
            */
            ?>
						</form>
						<?php 
        }
        ?>
				</td>
			</tr>
		</table>
		</div>
		<?php 
    }
}
 /**
  * Test to see if user can add events from the front end
  *
  * @return boolean
  */
 public static function isEventCreator()
 {
     static $isEventCreator;
     if (!isset($isEventCreator)) {
         $isEventCreator = false;
         $user = JEVHelper::getAuthorisedUser();
         if (is_null($user)) {
             $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
             $authorisedonly = $params->get("authorisedonly", 0);
             if (!$authorisedonly) {
                 $juser = JFactory::getUser();
                 $isEventCreator = $juser->authorise('core.create', 'com_jevents');
                 // this is too heavy on database queries - keep this in the file so that sites that want to use this approach can uncomment this block
                 if (false) {
                     if (!$isEventCreator) {
                         $cats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
                         if (count($cats) > 0) {
                             $isEventCreator = true;
                         }
                     }
                 } else {
                     if ($isEventCreator) {
                         $okcats = JEVHelper::getAuthorisedCategories($juser, 'com_jevents', 'core.create');
                         if (count($okcats) > 0) {
                             $juser = JFactory::getUser();
                             $dataModel = new JEventsDataModel();
                             $dataModel->setupComponentCatids();
                             $allowedcats = explode(",", $dataModel->accessibleCategoryList());
                             $intersect = array_intersect($okcats, $allowedcats);
                             if (count($intersect) == 0) {
                                 $isEventCreator = false;
                             }
                         } else {
                             $isEventCreator = false;
                         }
                     }
                 }
             }
         } else {
             if ($user->cancreate) {
                 // Check maxevent count
                 if ($user->eventslimit > 0) {
                     $db = JFactory::getDBO();
                     $db->setQuery("SELECT count(*) FROM #__jevents_vevent where created_by=" . $user->user_id);
                     $eventcount = intval($db->loadResult());
                     if ($eventcount < $user->eventslimit) {
                         $isEventCreator = true;
                     } else {
                         $isEventCreator = false;
                     }
                 } else {
                     $isEventCreator = true;
                 }
                 // are we blocked by category or calendar constraints
                 if ($isEventCreator && $user->categories != "" && $user->categories != "all") {
                     $okcats = explode("|", $user->categories);
                     $juser = JFactory::getUser();
                     $dataModel = new JEventsDataModel();
                     $dataModel->setupComponentCatids();
                     $allowedcats = explode(",", $dataModel->accessibleCategoryList());
                     $intersect = array_intersect($okcats, $allowedcats);
                     if (count($intersect) == 0) {
                         $isEventCreator = false;
                     }
                 }
             }
         }
         JPluginHelper::importPlugin("jevents");
         $dispatcher = JDispatcher::getInstance();
         $dispatcher->trigger('isEventCreator', array(&$isEventCreator));
     }
     return $isEventCreator;
 }