Пример #1
0
 function getFilters()
 {
     JLoader::register('jevFilterProcessing', JEV_PATH . "/libraries/filters.php");
     $pluginsDir = JPATH_ROOT . '/' . 'plugins' . '/' . 'jevents';
     $filterlist = explode(",", str_replace(" ", "", $this->params->get('filters', "search")));
     //$filters = jevFilterProcessing::getInstance(array("artist","category","reset"),$pluginsDir.'/'."filters".'/');
     $filters = jevFilterProcessing::getInstance($filterlist, $pluginsDir . '/' . "filters" . '/');
     return $filters;
 }
function DefaultViewNavCatText($view, $catid, $option, $task, $Itemid)
{
    $filters = jevFilterProcessing::getInstance(array("category"));
    $filterHTML = $filters->getFilterHTML();
    ?>

    	<table cellpadding="0" cellspacing="0" border="0" width="100%">
      		<tr>
        		<td align="center" width="100%">
        			<form action="<?php 
    echo JRoute::_("index.php");
    ?>
" method="get">
        				<input type="hidden" name="option" value="<?php 
    echo $option;
    ?>
" />
        				<input type="hidden" name="task" value="<?php 
    echo $task;
    ?>
" />
        				<input type="hidden" name="offset" value="1" />
        				<?php 
    /*Categories Select*/
    /*
            				echo JEventsHTML::buildCategorySelect( $catid, 'onchange="submit(this.form)" style="font-size:10px;"',
    $view->datamodel->accessibleCategoryList() ,false, false, 0,'catids'); 
    */
    foreach ($filterHTML as $filter) {
        echo $filter["html"];
    }
    ?>
        					
        				<input type="hidden" name="Itemid" value="<?php 
    echo $Itemid;
    ?>
" />
        			</form>
        		</td>
        	</tr>
        </table>
        <?php 
}
Пример #3
0
function DefaultViewNavCatText($view, $catid, $option, $task, $Itemid)
{
    $filters = jevFilterProcessing::getInstance(array("category"));
    $filterHTML = $filters->getFilterHTML();
    ?>

    <table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
            <td align="center" width="100%">
                <form action="<?php 
    echo JRoute::_("index.php");
    ?>
" method="get">
                    <input type="hidden" name="option" value="<?php 
    echo $option;
    ?>
" />
                    <input type="hidden" name="task" value="<?php 
    echo $task;
    ?>
" />
                    <input type="hidden" name="offset" value="1" />
                    <?php 
    foreach ($filterHTML as $filter) {
        echo $filter["html"];
    }
    ?>

                    <input type="hidden" name="Itemid" value="<?php 
    echo $Itemid;
    ?>
" />
                </form>
            </td>
        </tr>
    </table>
    <?php 
}
 /**
  * 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;
 }
Пример #5
0
defined('_JEXEC') or die('Restricted access');
$cfg = JEVConfig::getInstance();
$this->data = $data = $this->datamodel->getDataForAdmin($this->creator_id, $this->limit, $this->limitstart);
$frontendPublish = intval($cfg->get('com_frontendPublish', 0)) > 0;
$num_events = count($data['rows']);
$chdate = '';
echo '<fieldset><legend class="ev_fieldset">' . JText::_('JEV_ADMINPANEL') . '</legend><br />' . "\n";
$myItemid = JEVHelper::getAdminItemid();
$form_link = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=admin.listevents' . "&Itemid=" . $myItemid, false);
?>
<form action="<?php 
echo $form_link;
?>
"  method="post">
<?php 
$filters = jevFilterProcessing::getInstance(array("startdate"));
$filterHTML = $filters->getFilterHTML();
foreach ($filterHTML as $filter) {
    echo "<div class='jev_adminfilter'>" . $filter["title"] . "<br/>" . $filter["html"] . "</div>";
}
?>
</form>
<?php 
echo '<table align="center" width="90%" cellspacing="0" cellpadding="5" class="ev_table">' . "\n";
if ($num_events > 0) {
    for ($r = 0; $r < $num_events; $r++) {
        $row = $data['rows'][$r];
        $event_month_year = $row->mup() . $row->yup();
        if ($event_month_year != $chdate && $chdate != "") {
            echo '</ul></td></tr>' . "\n";
        }
Пример #6
0
 function __construct($item, $filterpath = false)
 {
     jimport('joomla.filesystem.folder');
     $this->filterpath = array();
     if (is_array($filterpath)) {
         $this->filterpath = array_merge($this->filterpath, $filterpath);
     } else {
         $this->filterpath[] = $filterpath;
     }
     settype($this->filterpath, 'array');
     //force to array
     $this->filterpath[] = dirname(__FILE__) . '/' . "filters";
     jimport('joomla.filesystem.folder');
     if (JFolder::exists(JPATH_SITE . "/plugins/jevents")) {
         $others = JFolder::folders(JPATH_SITE . "/plugins/jevents", 'filters', true, true);
         if (is_array($others)) {
             $this->filterpath = array_merge($this->filterpath, $others);
         }
     }
     // Find if filter type module is visible and therefore if the filters should have 'memory'
     if (!isset(self::$visiblefilters)) {
         self::$visiblefilters = array();
         // TODO Watch out if this becomes private - it just saves a DB query for the time being
         $visblemodules = JevModuleHelper::getVisibleModules();
         // note that $visblemodules are only those modules 'visible' on this page - could be overruled by special template
         //  but we can't do anything about that
         foreach ($visblemodules as $module) {
             $modparams = new JRegistry($module->params);
             if ($module->module == "mod_jevents_filter") {
                 $filters = $modparams->get("filters", "");
             } else {
                 $filters = $modparams->get("jevfilters", "");
             }
             if (trim($filters) != "") {
                 self::$visiblefilters = array_merge(explode(",", $filters), self::$visiblefilters);
             }
         }
         foreach (self::$visiblefilters as &$vf) {
             $vf = ucfirst(trim($vf));
         }
         unset($vf);
         // Make sure the visible filters are preloaded before they appear in the modules - I need to know their filtertype values!!
         self::$indexedvisiblefilters = array();
         $registry = JRegistry::getInstance("jevents");
         $registry->set("indexedvisiblefilters", false);
         foreach (self::$visiblefilters as $filtername) {
             $filter = "jev" . ucfirst($filtername) . "Filter";
             if (!class_exists($filter)) {
                 $filterFile = ucfirst($filtername) . '.php';
                 $filterFilePath = JPath::find($this->filterpath, $filterFile);
                 if ($filterFilePath) {
                     include_once $filterFilePath;
                 } else {
                     //echo "Missing filter file $filterFile<br/>";
                     continue;
                 }
             }
             if (defined($filter . "::filterType")) {
                 $thefilter = new $filter("", $filtername);
                 self::$indexedvisiblefilters[$filtername] = $thefilter->filterType;
                 //self::$indexedvisiblefilters[$filtername] = $filter::filterType;
             } else {
                 $thefilter = new $filter("", $filtername);
                 self::$indexedvisiblefilters[$filtername] = $thefilter->filterType;
             }
         }
         $registry = JRegistry::getInstance("jevents");
         $registry->set("indexedvisiblefilters", self::$indexedvisiblefilters);
     }
     // get filter details
     if (is_object($item)) {
         $filters = $item->getFilters();
     } else {
         if (is_array($item)) {
             $filters = $item;
         } else {
             if (is_string($item)) {
                 $filters = array();
             }
         }
     }
     $this->filters = array();
     // extract filters if set
     foreach ($filters as $filtername) {
         $filter = "jev" . ucfirst($filtername) . "Filter";
         if (!class_exists($filter)) {
             $filterFile = ucfirst($filtername) . '.php';
             $filterFilePath = JPath::find($this->filterpath, $filterFile);
             if ($filterFilePath) {
                 include_once $filterFilePath;
             } else {
                 echo "Missing filter file {$filterFile}<br/>";
                 continue;
             }
         }
         $theFilter = new $filter("", $filtername);
         $this->filters[] = $theFilter;
     }
     foreach ($this->filters as $filter) {
         $sqlFilter = $filter->_createFilter();
         if ($sqlFilter != "") {
             $this->where[] = $sqlFilter;
         }
         $joinFilter = $filter->_createJoinFilter();
         if ($joinFilter != "") {
             $this->join[] = $joinFilter;
         }
         if ($filter->needsgroupby) {
             $this->needsgroupby = true;
         }
     }
 }
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 
        }
    }
}
Пример #8
0
 function listEventsByKeyword($keyword, $order, &$limit, &$limitstart, &$total, $useRegX = false)
 {
     $user = JFactory::getUser();
     $adminuser = JEVHelper::isAdminUser($user);
     $db = JFactory::getDBO();
     $rows_per_page = $limit;
     if (empty($limitstart) || !$limitstart) {
         $limitstart = 0;
     }
     $limitstring = "";
     if ($rows_per_page > 0) {
         $limitstring = "LIMIT {$limitstart}, {$rows_per_page}";
     }
     $where = "";
     $having = "";
     if (!JRequest::getInt('showpast', 0)) {
         $datenow =& JevDate::getDate("-12 hours");
         $having = " AND rpt.endrepeat>'" . $datenow->toMysql() . "'";
     }
     if (!$order) {
         $order = 'publish_up';
     }
     $order = preg_replace("/[\t ]+/", '', $order);
     $orders = explode(",", $order);
     // this function adds #__events. to the beginning of each ordering field
     function app_db($strng)
     {
         return '#__events.' . $strng;
     }
     $order = implode(',', array_map('app_db', $orders));
     $total = 0;
     // process the new plugins
     // get extra data and conditionality from plugins
     $extrawhere = array();
     $extrajoin = array();
     $extrafields = "";
     // must have comma prefix
     $needsgroup = false;
     $filterarray = array("published");
     // If there are extra filters from the module then apply them now
     $reg =& JFactory::getConfig();
     $modparams = $reg->getValue("jev.modparams", false);
     if ($modparams && $modparams->getValue("extrafilters", false)) {
         $filterarray = array_merge($filterarray, explode(",", $modparams->getValue("extrafilters", false)));
     }
     $filters = jevFilterProcessing::getInstance($filterarray);
     $filters->setWhereJoin($extrawhere, $extrajoin);
     $needsgroup = $filters->needsGroupBy();
     JPluginHelper::importPlugin('jevents');
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     $catwhere = "\n WHERE ev.catid IN(" . $this->accessibleCategoryList() . ")";
     $params = JComponentHelper::getParams("com_jevents");
     if ($params->get("multicategory", 0)) {
         $extrajoin[] = "\n #__jevents_catmap as catmap ON catmap.evid = rpt.eventid";
         $extrajoin[] = "\n #__categories AS catmapcat ON catmap.catid = catmapcat.id";
         $extrafields .= ", GROUP_CONCAT(DISTINCT catmap.catid SEPARATOR ',') as catids";
         $extrawhere[] = " catmapcat.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user));
         $extrawhere[] = " catmap.catid IN(" . $this->accessibleCategoryList() . ")";
         $needsgroup = true;
         $catwhere = "\n WHERE 1 ";
     }
     $extrajoin = count($extrajoin) ? " \n LEFT JOIN " . implode(" \n LEFT JOIN ", $extrajoin) : '';
     $extrawhere = count($extrawhere) ? ' AND ' . implode(' AND ', $extrawhere) : '';
     $extrasearchfields = array();
     $dispatcher->trigger('onSearchEvents', array(&$extrasearchfields, &$extrajoin, &$needsgroup));
     if (count($extrasearchfields) > 0) {
         $extraor = implode(" OR ", $extrasearchfields);
         $extraor = " OR " . $extraor;
         // replace the ### placeholder with the keyword
         $extraor = str_replace("###", $keyword, $extraor);
         $searchpart = $useRegX ? "(det.summary RLIKE '{$keyword}' OR det.description RLIKE '{$keyword}' OR det.extra_info RLIKE '{$keyword}' {$extraor})\n" : " (MATCH (det.summary, det.description, det.extra_info) AGAINST ('{$keyword}' IN BOOLEAN MODE) {$extraor})\n";
     } else {
         $searchpart = $useRegX ? "(det.summary RLIKE '{$keyword}' OR det.description RLIKE '{$keyword}'  OR det.extra_info RLIKE '{$keyword}')\n" : "MATCH (det.summary, det.description, det.extra_info) AGAINST ('{$keyword}' IN BOOLEAN MODE)\n";
     }
     // Now Search Icals
     $query = "SELECT count( distinct det.evdet_id) FROM #__jevents_vevent as ev" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . $extrajoin . $catwhere . "\n AND icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user)) . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user)) . "\n AND ";
     $query .= $searchpart;
     $query .= $extrawhere;
     $query .= $having;
     $db->setQuery($query);
     //echo $db->explain();
     $total += intval($db->loadResult());
     if ($total < $limitstart) {
         $limitstart = 0;
     }
     $rows = array();
     if ($total == 0) {
         return $rows;
     }
     // Now Search Icals
     // New version
     $query = "SELECT DISTINCT det.evdet_id FROM  #__jevents_vevdetail as det" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventdetail_id = det.evdet_id" . "\n LEFT JOIN #__jevents_vevent as ev ON ev.ev_id = rpt.eventid" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . $extrajoin . $catwhere . "\n  AND icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user)) . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user));
     $query .= " AND ";
     $query .= $searchpart;
     $query .= $extrawhere;
     $query .= $having;
     $query .= "\n ORDER BY rpt.startrepeat ASC ";
     $query .= "\n {$limitstring}";
     $db->setQuery($query);
     if ($adminuser) {
         //echo $db->_sql;
         //echo $db->explain();
     }
     //echo $db->explain();
     $details = $db->loadResultArray();
     $icalrows = array();
     foreach ($details as $detid) {
         $query2 = "SELECT ev.*, rpt.*, det.* {$extrafields}" . "\n , YEAR(rpt.startrepeat) as yup, MONTH(rpt.startrepeat ) as mup, DAYOFMONTH(rpt.startrepeat ) as dup" . "\n , YEAR(rpt.endrepeat  ) as ydn, MONTH(rpt.endrepeat   ) as mdn, DAYOFMONTH(rpt.endrepeat   ) as ddn" . "\n , HOUR(rpt.startrepeat) as hup, MINUTE(rpt.startrepeat ) as minup, SECOND(rpt.startrepeat ) as sup" . "\n , HOUR(rpt.endrepeat  ) as hdn, MINUTE(rpt.endrepeat   ) as mindn, SECOND(rpt.endrepeat   ) as sdn" . "\n FROM #__jevents_vevent as ev" . "\n LEFT JOIN #__jevents_repetition as rpt ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid" . $extrajoin . "\n WHERE rpt.eventdetail_id = {$detid}" . $extrawhere . $having . "\n ORDER BY rpt.startrepeat ASC limit 1";
         $db->setQuery($query2);
         //echo $db->explain();
         $data = $db->loadObject();
         // belts and braces - some servers have a MYSQLK bug on the  user of DISTINCT!
         if (!$data->ev_id) {
             continue;
         }
         $icalrows[] = $data;
     }
     $num_events = count($icalrows);
     for ($i = 0; $i < $num_events; $i++) {
         // convert rows to jevents
         $icalrows[$i] = new jIcalEventRepeat($icalrows[$i]);
     }
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onDisplayCustomFieldsMultiRow', array(&$icalrows));
     $dispatcher->trigger('onDisplayCustomFieldsMultiRowUncached', array(&$icalrows));
     return $icalrows;
 }
function 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 
    }
}
Пример #10
0
function Defaultgetstartenddates($view)
{
    $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
    // fix to allow start/end date to be preserved during pagination IF filter module before/after dates are used
    $Itemid = JRequest::getInt("Itemid", 0);
    // This causes the filter module to reset
    $filters = jevFilterProcessing::getInstance(array());
    $activeFilterMenu = JFactory::getApplication()->getUserState('active_filter_menu ', $Itemid);
    if (intval(JRequest::getVar('filter_reset', 0)) || $activeFilterMenu > 0 && $activeFilterMenu != $Itemid) {
        JRequest::setVar('startdate', '');
        JRequest::setVar('enddate', '');
        JFactory::getApplication()->setUserState('range_enddate' . $Itemid, '');
        JFactory::getApplication()->setUserState('range_startdate' . $Itemid, '');
        JFactory::getApplication()->setUserState('active_filter_menu ', 0);
    }
    $startdate = JFactory::getApplication()->getUserStateFromRequest('range_startdate' . $Itemid, 'startdate', "");
    $enddate = JFactory::getApplication()->getUserStateFromRequest('range_enddate' . $Itemid, 'enddate', "");
    if ($startdate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $startdate = $params->get("absstart", "");
            list($startyear, $startmonth, $startday) = explode("-", $startdate);
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strstart", "");
                $value = new JevDate(JevDate::strtotime($value));
                $startdate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relstart", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $startdate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate == "") {
        if ($params->get("relative", "rel") == "abs") {
            $enddate = $params->get("absend", "");
        } else {
            if ($params->get("relative", "rel") == "strtotime") {
                $value = $params->get("strend", "");
                $value = new JevDate(JevDate::strtotime($value));
                $enddate = $value->toFormat("%Y-%m-%d");
            } else {
                $value = $params->get("relend", "");
                $value = str_replace(",", " ", $value);
                $value = str_replace("y", "year", $value);
                $value = str_replace("d", "day", $value);
                $value = str_replace("w", "week", $value);
                $value = str_replace("m", "month", $value);
                $value = new JevDate($value);
                $enddate = $value->toFormat("%Y-%m-%d");
            }
        }
    }
    if ($enddate < $startdate) {
        // default to 1 year when input dates are not valid!
        $value = new JevDate($startdate);
        $value->add(new DateInterval('P1Y'));
        $enddate = $value->toFormat("%Y-%m-%d");
    }
    return array($startdate, $enddate);
}