Exemple #1
0
 function bind($array, $ignore = array())
 {
     $cfg = JEVConfig::getInstance();
     $array['id'] = isset($array['id']) ? intval($array['id']) : 0;
     parent::bind($array);
     $params = new JRegistry($this->params);
     if (!$params->get("catcolour", false)) {
         $color = array_key_exists("color", $array) ? $array['color'] : "#000000";
         if (!preg_match("/^#[0-9a-f]+\$/i", $color)) {
             $color = "#000000";
         }
         $params->set("catcolor", $color);
     }
     if (!$params->get("admin", false)) {
         $admin = array_key_exists("admin", $array) ? $array['admin'] : 0;
         $params->set("admin", $admin);
     }
     if (!$params->get("overlaps", false)) {
         $overlaps = array_key_exists("overlaps", $array) ? intval($array['overlaps']) : 0;
         $params->set("overlaps", $overlaps);
     }
     if (!$params->get("image", false)) {
         $image = array_key_exists("image", $array) ? intval($array['image']) : "";
         $params->set("image", $image);
     }
     $this->params = (string) $params;
     // Fill in the gaps
     $this->parent_id = array_key_exists("parent_id", $array) ? intval($array['parent_id']) : 1;
     $this->level = array_key_exists("level", $array) ? intval($array['level']) : 1;
     $this->extension = "com_jevents";
     $this->language = "*";
     $this->setLocation(1, 'last-child');
     return true;
 }
Exemple #2
0
 function getAdjacentYear($year, $month, $day, $direction = 1)
 {
     $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction);
     $day = JevDate::strftime("%d", $d1);
     $year = JevDate::strftime("%Y", $d1);
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $cfg = JEVConfig::getInstance();
     if (method_exists("JEVHelper", "getMinYear")) {
         $earliestyear = JEVHelper::getMinYear();
         $latestyear = JEVHelper::getMaxYear();
     } else {
         $earliestyear = $params->get("com_earliestyear", 1970);
         $latestyear = $params->get("com_latestyear", 2150);
     }
     if ($year > $latestyear || $year < $earliestyear) {
         return false;
     }
     $month = JevDate::strftime("%m", $d1);
     $task = JRequest::getString('jevtask');
     $Itemid = JEVHelper::getItemid();
     if (isset($Itemid)) {
         $item = "&Itemid={$Itemid}";
     } else {
         $item = "";
     }
     return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}");
 }
 function listevents()
 {
     list($year, $month, $day) = JEVHelper::getYMD();
     $Itemid = JEVHelper::getItemid();
     // get the view
     $document =& JFactory::getDocument();
     $viewType = $document->getType();
     $cfg =& JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "day";
     $this->addViewPath($this->_basePath . DS . "views" . DS . $theme);
     $this->view =& $this->getView($view, $viewType, $theme, array('base_path' => $this->_basePath, "template_path" => $this->_basePath . DS . "views" . DS . $theme . DS . $view . DS . 'tmpl', "name" => $theme . DS . $view));
     // Set the layout
     $this->view->setLayout('listevents');
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     // View caching logic -- simple... are we logged in?
     $cfg =& JEVConfig::getInstance();
     $useCache = intval($cfg->get('com_cache', 0));
     $user =& JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache =& JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
 protected function getLabel()
 {
     $cfg = JEVConfig::getInstance();
     if ($cfg->get("multicategory", 0)) {
         return parent::getLabel();
     }
     return "";
 }
 /**
  * Controler for the Ical Functions
  * @param array		configuration
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->registerTask('list', 'overview');
     $this->registerDefaultTask("overview");
     $cfg =& JEVConfig::getInstance();
     $this->_debug = $cfg->get('jev_debug', 0);
     $this->dataModel = new JEventsDataModel("JEventsAdminDBModel");
     $this->queryModel = new JEventsDBModel($this->dataModel);
 }
Exemple #6
0
 function detail()
 {
     // Do we have to be logged in to see this event
     $user = JFactory::getUser();
     if (JRequest::getInt("login", 0) && $user->id == 0) {
         $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);
         $this->setRedirect($link, JText::_('JEV_LOGIN_TO_VIEW_EVENT'));
         return;
     }
     $evid = JRequest::getInt("rp_id", 0);
     if ($evid == 0) {
         $evid = JRequest::getInt("evid", 0);
         // In this case I do not have a repeat id so I
     }
     // if cancelling from save of copy and edit use the old event id
     if ($evid == 0) {
         $evid = JRequest::getInt("old_evid", 0);
     }
     $pop = intval(JRequest::getVar('pop', 0));
     list($year, $month, $day) = JEVHelper::getYMD();
     $Itemid = JEVHelper::getItemid();
     $uid = urldecode(JRequest::getVar('uid', ""));
     $document =& JFactory::getDocument();
     $viewType = $document->getType();
     $cfg =& JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "icalevent";
     $this->addViewPath($this->_basePath . DS . "views" . DS . $theme);
     $this->view =& $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . DS . "views" . DS . $theme . DS . $view . DS . 'tmpl', "name" => $theme . DS . $view));
     // Set the layout
     $this->view->setLayout("detail");
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     $this->view->assign("pop", $pop);
     $this->view->assign("evid", $evid);
     $this->view->assign("jevtype", "icaldb");
     $this->view->assign("uid", $uid);
     // View caching logic -- simple... are we logged in?
     $cfg =& JEVConfig::getInstance();
     $useCache = intval($cfg->get('com_cache', 0));
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache =& JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
Exemple #7
0
 /**
  * Controler for the Ical Functions
  * @param array		configuration
  */
 function __construct($config = array())
 {
     parent::__construct($config);
     $this->registerTask('list', 'overview');
     $this->registerDefaultTask("overview");
     $cfg = JEVConfig::getInstance();
     $this->_debug = $cfg->get('jev_debug', 0);
     $this->dataModel = new JEventsDataModel("JEventsAdminDBModel");
     $this->queryModel = new JEventsDBModel($this->dataModel);
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin('finder');
 }
    /**
     * Method to get the field input markup.
     *
     * @return	string	The field input markup.
     * @since	1.6
     */
    protected function getInput()
    {
        $cfg = JEVConfig::getInstance();
        $hideColour = false;
        if ($cfg->get('com_calForceCatColorEventForm', 0) == 1 && !JFactory::getApplication()->isAdmin()) {
            $hideColour = true;
        } else {
            if ($cfg->get('com_calForceCatColorEventForm', 0) == 2) {
                $hideColour = true;
            } else {
                $hideColour = false;
            }
        }
        if (!$hideColour) {
            JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php");
            JEVHelper::ConditionalFields($this->element, $this->form->getName());
            ob_start();
            ?>
			<table id="pick1064797275" style="background-color:<?php 
            echo $this->value . ';color:' . JevMapColor($this->value);
            ?>
;border:solid 1px black;">
				<tr>	
					<td  nowrap="nowrap">
						<input type="hidden" id="pick1064797275field" name="color" value="<?php 
            echo $this->value;
            ?>
"/>
						<a id="colorPickButton" href="javascript:void(0)"  onclick="document.getElementById('fred').style.visibility='visible';"	  style="visibility:visible;color:<?php 
            echo JevMapColor($this->value);
            ?>
;font-weight:bold;"><?php 
            echo JText::_('JEV_COLOR_PICKER');
            ?>
</a>
					</td>
					<td>
						<div style="position:relative;z-index:9999;">
							<iframe id="fred" src="<?php 
            echo JURI::root() . "components/" . JEV_COM_COMPONENT . "/libraries/colours.html?id=fred";
            ?>
" class="jev_ev_colour_picker_i"></iframe>
						</div>
					</td>
				</tr>
			</table>
			<?php 
            return ob_get_clean();
        }
        return "";
    }
Exemple #9
0
 protected function setDescription($desc)
 {
     // TODO - run this through plugins first ?
     $icalformatted = JRequest::getInt("icf", 0);
     if (!$icalformatted) {
         $description = $this->replacetags($desc);
     } else {
         $description = $desc;
     }
     // wraplines	from vCard class
     $cfg =& JEVConfig::getInstance();
     if ($cfg->get("outlook2003icalexport", 0)) {
         return "DESCRIPTION:" . $this->wraplines($description, 76, false);
     } else {
         return "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . $this->wraplines($description);
     }
 }
function DefaultLoadModules($view, $position)
{
    $cfg = JEVConfig::getInstance();
    $article = JTable::getInstance('content');
    $article->text = "{loadposition {$position}}";
    $app = JFactory::getApplication();
    $params = JComponentHelper::getParams("com_content");
    JPluginHelper::importPlugin('content');
    $dispatcher = JEventDispatcher::getInstance();
    $results = $dispatcher->trigger('onContentPrepare', array('com_content.article', &$article, &$params, 0));
    if ($article->text == "{loadposition {$position}}") {
        // in case the content plugin is not enabled
        return "";
    } else {
        echo $article->text;
    }
}
Exemple #11
0
 function listevents()
 {
     $is_event_editor = JEVHelper::isEventCreator();
     $Itemid = JEVHelper::getItemid();
     $user = JFactory::getUser();
     if (!$is_event_editor) {
         $returnlink = JRoute::_('index.php?option=' . JEV_COM_COMPONENT . '&task=month.calendar&Itemid=' . $Itemid, false);
         $this->setRedirect($returnlink, html_entity_decode(JText::_('JEV_NOPERMISSION')));
         $this->redirect();
         return;
     }
     list($year, $month, $day) = JEVHelper::getYMD();
     // Joomla unhelpfully switched limitstart to start when sef is enabled!  includes/router.php line 390
     $limitstart = intval(JRequest::getVar('start', JRequest::getVar('limitstart', 0)));
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $limit = intval(JFactory::getApplication()->getUserStateFromRequest('jevlistlimit', 'limit', $params->get("com_calEventListRowsPpg", 15)));
     $Itemid = JEVHelper::getItemid();
     $task = $this->_task;
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $adminuser = $params->get("jevadmin", -1);
     if (JEVHelper::isAdminUser($user) || $user->id == $adminuser) {
         $creator_id = 'ADMIN';
     } else {
         $creator_id = $user->id;
     }
     // get the view
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $cfg = JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "admin";
     $this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
     $this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
     // Set the layout
     $this->view->setLayout('listevents');
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("limitstart", $limitstart);
     $this->view->assign("limit", $limit);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $task);
     $this->view->assign("creator_id", $creator_id);
     $this->view->display();
 }
 function rss()
 {
     JRequest::setVar("tmpl", "component");
     // get the view
     $this->view =& $this->getView("modlatest", "feed");
     // Set the layout
     $this->view->setLayout('rss');
     // View caching logic -- simple... are we logged in?
     $cfg =& JEVConfig::getInstance();
     $useCache = intval($cfg->get('com_cache', 0));
     $user =& JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->rss();
     } else {
         $cache =& JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'rss');
     }
 }
Exemple #13
0
 protected function getInput()
 {
     $cfg = JEVConfig::getInstance();
     $hideColour = false;
     if ($cfg->get('com_calForceCatColorEventForm', 0) == 1 && !JFactory::getApplication()->isAdmin()) {
         $hideColour = true;
     } else {
         if ($cfg->get('com_calForceCatColorEventForm', 0) == 2) {
             $hideColour = true;
         } else {
             $hideColour = false;
         }
     }
     if (!$hideColour) {
         return parent::getInput();
     }
     return "";
 }
function DefaultEventsLegend($view)
{
    $cfg =& JEVConfig::getInstance();
    $theme = JEV_CommonFunctions::getJEventsViewName();
    $modpath = JModuleHelper::getLayoutPath('mod_jevents_legend', $theme . DS . "legend");
    if (!file_exists($modpath)) {
        return;
    }
    // load the helper class
    require_once JPATH_SITE . '/modules/mod_jevents_legend/helper.php';
    require_once $modpath;
    $viewclass = ucfirst($theme) . "ModLegendView";
    $module = JModuleHelper::getModule("mod_jevents_legend", false);
    $params = new JParameter($module->params);
    $modview = new $viewclass($params, $module->id);
    echo $modview->displayCalendarLegend("block");
    echo "<br style='clear:both'/>";
}
Exemple #15
0
 protected function setDescription($desc)
 {
     // TODO - run this through plugins first ?
     // See http://www.jevents.net/forum/viewtopic.php?f=23&t=21939&p=115231#wrap
     // can we use 	X-ALT-DESC;FMTTYPE=text/html: as well as DESCRIPTION
     $icalformatted = JRequest::getInt("icf", 0);
     if (!$icalformatted) {
         $description = $this->replacetags($desc);
     } else {
         $description = $desc;
     }
     // wraplines	from vCard class
     $cfg = JEVConfig::getInstance();
     if ($cfg->get("outlook2003icalexport", 0)) {
         return "DESCRIPTION:" . $this->wraplines($description, 76, false);
     } else {
         return "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . $this->wraplines($description);
     }
 }
Exemple #16
0
 function rss()
 {
     JRequest::setVar("tmpl", "component");
     // get the view
     $this->view = $this->getView("modlatest", "feed");
     // Set the layout
     $this->view->setLayout('rss');
     // View caching logic -- simple... are we logged in?
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     $user = JFactory::getUser();
     // Stupid Joomla 3.1 problem where its not possible to use the view cache on RSS feed output!
     if (JevJoomlaVersion::isCompatible("3.1") || $user->get('id') || !$useCache) {
         $this->view->rss();
     } else {
         $cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'rss');
     }
 }
Exemple #17
0
 function listevents()
 {
     list($year, $month, $day) = JEVHelper::getYMD();
     // Joomla unhelpfully switched limitstart to start when sef is enabled!  includes/router.php line 390
     $limitstart = intval(JRequest::getVar('start', JRequest::getVar('limitstart', 0)));
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $limit = intval(JFactory::getApplication()->getUserStateFromRequest('jevlistlimit', 'limit', $params->get("com_calEventListRowsPpg", 15)));
     //	$catid 	= intval( JRequest::getVar( 	'catid', 		0 ) );
     $catids = JRequest::getVar('catids', "");
     $catids = explode("|", $catids);
     $Itemid = JEVHelper::getItemid();
     // get the view
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $cfg = JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "cat";
     $this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
     $this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
     // Set the layout
     $this->view->setLayout('listevents');
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("limitstart", $limitstart);
     $this->view->assign("limit", $limit);
     $this->view->assign("catids", $catids);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     // View caching logic -- simple... are we logged in?
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     $user = JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
 function getAdjacentYear($year, $month, $day, $direction = 1)
 {
     $d1 = JevDate::mktime(0, 0, 0, $month, $day, $year + $direction);
     $day = JevDate::strftime("%d", $d1);
     $year = JevDate::strftime("%Y", $d1);
     $cfg =& JEVConfig::getInstance();
     $earliestyear = $cfg->get('com_earliestyear');
     $latestyear = $cfg->get('com_latestyear');
     if ($year > $latestyear || $year < $earliestyear) {
         return false;
     }
     $month = JevDate::strftime("%m", $d1);
     $task = JRequest::getString('jevtask');
     $Itemid = JEVHelper::getItemid();
     if (isset($Itemid)) {
         $item = "&Itemid={$Itemid}";
     } else {
         $item = "";
     }
     return JRoute::_("index.php?option=" . JEV_COM_COMPONENT . "&task={$task}{$item}&year={$year}&month={$month}&day={$day}");
 }
Exemple #19
0
 function listevents()
 {
     JRequest::setVar("tmpl", "component");
     list($year, $month, $day) = JEVHelper::getYMD();
     // Joomla unhelpfully switched limitstart to start when sef is enabled!  includes/router.php line 390
     $limitstart = intval(JRequest::getVar('start', JRequest::getVar('limitstart', 0)));
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $limit = $params->get("com_calEventListRowsPpg", 15);
     // Crawler should list at least 100 events for efficiency
     $limit = intval($limit) < 100 ? 100 : $limit;
     $Itemid = JEVHelper::getItemid();
     // get the view
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $cfg = JEVConfig::getInstance();
     $theme = "default";
     $view = "crawler";
     $this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
     $this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
     // Set the layout
     $this->view->setLayout('listevents');
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("limitstart", $limitstart);
     $this->view->assign("limit", $limit);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     // View caching logic -- simple... are we logged in?
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     $user = JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
Exemple #20
0
 function eventdata()
 {
     $this->datamodel = new JEventsDataModel();
     list($year, $month, $day) = JEVHelper::getYMD();
     $start = JRequest::getVar('start', "{$year}-{$month}-{$day}");
     $end = JRequest::getVar('end', "{$year}-{$month}-{$day}");
     $limitstart = 0;
     $limit = 0;
     $myItemid = JEVHelper::getItemid();
     // Force repeats to show
     $cfg = JEVConfig::getInstance();
     $cfg->set("com_showrepeats", true);
     // TODO Check for sanity of $start and $end
     $this->datamodel = new JEventsDataModel();
     $data = $this->datamodel->getRangeData($start, $end, $limitstart, $limit);
     $events = array();
     foreach ($data['rows'] as $event) {
         $eventArray = array();
         $eventArray['title'] = $event->title();
         $eventArray['start'] = $event->yup() . "-" . $event->mup() . "-" . $event->dup() . " " . date("H:i", $event->getUnixStartTime());
         $eventArray['end'] = $event->yup() . "-" . $event->mup() . "-" . $event->dup() . " " . date("H:i", $event->getUnixStartTime());
         $eventArray['textcolor'] = $event->fgcolor();
         $eventArray['backgroundColor'] = $event->bgcolor();
         $link = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false, $myItemid);
         $eventArray['url'] = JRoute::_($link . $this->datamodel->getCatidsOutLink());
         if ($event->hasrepetition()) {
             $eventArray['id'] = $event->ev_id();
         }
         $events[] = $eventArray;
     }
     // Get the document object.
     $document =& JFactory::getDocument();
     // Set the MIME type for JSON output.
     $document->setMimeEncoding('application/json');
     // Change the suggested filename.
     JResponse::setHeader('Content-Disposition', 'attachment;filename="eventdata.json"');
     // Output the JSON data.
     echo json_encode($events);
     exit;
 }
Exemple #21
0
 function bind($array)
 {
     $cfg =& JEVConfig::getInstance();
     if (JVersion::isCompatible("1.6.0")) {
         $array['id'] = isset($array['id']) ? intval($array['id']) : 0;
         $array['extension'] = "com_jevents";
         $array['parent_id'] = 1;
         $array['language'] = "*";
         if (!isset($array['access'])) {
             $array['access'] = JRequest::getInt("access", -1);
             if ($array['access'] == -1) {
                 $array['access'] = (int) JFactory::getConfig()->get('access');
             }
         }
         $array['alias'] = JApplication::stringURLSafe($array['title']);
         $array['path'] = $array['alias'];
         $this->setLocation($array['parent_id'], 'last-child');
         parent::bind($array);
     } else {
         $array['id'] = isset($array['id']) ? intval($array['id']) : 0;
         parent::bind($array);
         if (!isset($this->_catextra)) {
             $this->_catextra = new CatExtra($this->_db);
         }
         $this->_catextra->color = array_key_exists("color", $array) ? $array['color'] : "#000000";
         if (!preg_match("/^#[0-9a-f]+\$/i", $this->_catextra->color)) {
             $this->_catextra->color = "#000000";
         }
         unset($this->color);
         $this->_catextra->admin = array_key_exists("admin", $array) ? $array['admin'] : 0;
         unset($this->admin);
         $this->_catextra->overlaps = array_key_exists("overlaps", $array) ? intval($array['overlaps']) : 0;
         // Fill in the gaps
         $this->name = $this->title;
         $this->section = "com_jevents";
         $this->image_position = "left";
     }
     return true;
 }
Exemple #22
0
 function listevents()
 {
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $fixedDay = $params->get('fixedday', '');
     if ($fixedDay) {
         $year = date('Y', strtotime($fixedDay));
         $month = date('m', strtotime($fixedDay));
         $day = date('d', strtotime($fixedDay));
     } else {
         list($year, $month, $day) = JEVHelper::getYMD();
     }
     $Itemid = JEVHelper::getItemid();
     // get the view
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $cfg = JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "day";
     $this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
     $this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
     // Set the layout
     $this->view->setLayout('listevents');
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     // View caching logic -- simple... are we logged in?
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     $user = JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
function DefaultEventsLegend($view)
{
    $cfg = JEVConfig::getInstance();
    if ($cfg->get('com_calShowLegend', 1) == 1) {
        $theme = JEV_CommonFunctions::getJEventsViewName();
        $modpath = JModuleHelper::getLayoutPath('mod_jevents_legend', $theme . '/' . "legend");
        if (!file_exists($modpath) || !file_exists(JPATH_SITE . '/modules/mod_jevents_legend/helper.php')) {
            return;
        }
        // load the helper class
        require_once JPATH_SITE . '/modules/mod_jevents_legend/helper.php';
        require_once $modpath;
        $viewclass = ucfirst($theme) . "ModLegendView";
        $module = JModuleHelper::getModule("mod_jevents_legend", false);
        $params = new JRegistry($module->params);
        $modview = new $viewclass($params, $module->id);
        echo $modview->displayCalendarLegend("block");
        echo "<br style='clear:both;height:0px;line-height:0px;'/>";
    } else {
        //Do nothing
    }
}
function JevViewCopyright()
{
    $cfg =& JEVConfig::getInstance();
    $version =& JEventsVersion::getInstance();
    if ($cfg->get('com_copyright', 1) == 1) {
        ?>
		<p align="center">
			<a href="<?php 
        echo $version->getUrl();
        ?>
" target="_blank" style="font-size:xx-small;" title="Events Website"><?php 
        echo $version->getLongVersion();
        ?>
</a>
			&nbsp;
			<span style="color:#999999; font-size:9px;"><?php 
        echo $version->getShortCopyright();
        ?>
</span>
		</p>
		<?php 
    }
}
Exemple #25
0
 function detail()
 {
     $evid = JRequest::getInt("evid", 0);
     $pop = intval(JRequest::getVar('pop', 0));
     list($year, $month, $day) = JEVHelper::getYMD();
     $Itemid = JEVHelper::getItemid();
     // get the view
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $cfg = JEVConfig::getInstance();
     $theme = JEV_CommonFunctions::getJEventsViewName();
     $view = "jevent";
     $this->addViewPath($this->_basePath . '/' . "views" . '/' . $theme);
     $this->view = $this->getView($view, $viewType, $theme . "View", array('base_path' => $this->_basePath, "template_path" => $this->_basePath . '/' . "views" . '/' . $theme . '/' . $view . '/' . 'tmpl', "name" => $theme . '/' . $view));
     // Set the layout
     $this->view->setLayout("detail");
     $this->view->assign("Itemid", $Itemid);
     $this->view->assign("month", $month);
     $this->view->assign("day", $day);
     $this->view->assign("year", $year);
     $this->view->assign("task", $this->_task);
     $this->view->assign("pop", $pop);
     $this->view->assign("evid", $evid);
     $this->view->assign("jevtype", "jevent");
     // View caching logic -- simple... are we logged in?
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     $user = JFactory::getUser();
     if ($user->get('id') || !$useCache) {
         $this->view->display();
     } else {
         $cache = JFactory::getCache(JEV_COM_COMPONENT, 'view');
         $cache->get($this->view, 'display');
     }
 }
Exemple #26
0
 function repeatSummary()
 {
     $cfg = JEVConfig::getInstance();
     // i.e. 1 = follow english word order by default
     $grammar = intval(JText::_('JEV_REPEAT_GRAMMAR'));
     // if starttime and end time the same then show no times!
     if ($this->start_date == $this->stop_date) {
         if ($this->start_time != $this->stop_time && !$this->alldayevent()) {
             echo $this->start_date . ',&nbsp;' . $this->start_time . '&nbsp;-&nbsp;' . $this->stop_time_midnightFix;
         } else {
             echo $this->start_date;
         }
     } else {
         // recurring events should have time related to recurrance not range of dates
         if ($this->start_time != $this->stop_time && !($this->reccurtype() > 0)) {
             echo JText::_('JEV_FROM') . '&nbsp;' . $this->start_date . '&nbsp;-&nbsp; ' . $this->start_time . '<br />' . JText::_('JEV_TO') . '&nbsp;' . $this->stop_date . '&nbsp;-&nbsp;' . $this->stop_time_midnightFix . '<br/>';
         } else {
             echo JText::_('JEV_FROM') . '&nbsp;' . $this->start_date . '<br />' . JText::_('JEV_TO') . '&nbsp;' . $this->stop_date . '<br/>';
         }
     }
     if ($this->reccurtype() > 0) {
         switch ($this->reccurtype()) {
             case '1':
                 $reccur = JText::_('JEV_REP_WEEK');
                 break;
             case '2':
                 $reccur = JText::_('JEV_REP_WEEK');
                 break;
             case '3':
                 $reccur = JText::_('JEV_REP_MONTH');
                 break;
             case '4':
                 $reccur = JText::_('JEV_REP_MONTH');
                 break;
             case '5':
                 $reccur = JText::_('JEV_REP_YEAR');
                 break;
         }
         if ($this->reccurday() >= 0 || ($this->reccurtype() == 1 || $this->reccurtype() == 2)) {
             $timeString = "";
             if ($this->start_time != $this->stop_time) {
                 $timeString = $this->start_time . "&nbsp;-&nbsp;" . $this->stop_time_midnightFix . "&nbsp;";
             }
             echo $timeString;
             if (intval($this->reccurday()) < 0) {
                 $event_start_date = JevDate::strtotime($this->startDate());
                 $reccurday = intval(date('w', $event_start_date));
             } else {
                 $reccurday = $this->reccurday();
             }
             if ($this->reccurtype() == 1) {
                 $dayname = JEventsHTML::getDayName($reccurday);
                 echo $dayname . '&nbsp;' . JText::_('JEV_EACHOF') . '&nbsp;' . $reccur;
             } else {
                 if ($this->reccurtype() == 2) {
                     $each = JText::_('JEV_EACH') . '&nbsp;';
                     if ($grammar == 1) {
                         $each = strtolower($each);
                     }
                     $daystring = "";
                     if (JString::strlen($this->reccurweeks()) == 0) {
                         $days = explode("|", $this->reccurweekdays());
                         for ($d = 0; $d < count($days); $d++) {
                             $daystring .= JEventsHTML::getDayName($days[$d]);
                             $daystring .= ($d == 0 ? "," : "") . "&nbsp;";
                         }
                         $weekstring = "";
                     } else {
                         $days = explode("|", $this->reccurweekdays());
                         for ($d = 0; $d < count($days); $d++) {
                             $daystring .= JEventsHTML::getDayName($days[$d]);
                             $daystring .= ($d == 0 ? "," : "") . "&nbsp;";
                         }
                         $weekstring = $this->reccurweeks() == 'pair' ? JText::_('JEV_REP_WEEKPAIR') : ($this->reccurweeks() == 'impair' ? JText::_('JEV_REP_WEEKIMPAIR') : "");
                         if ($weekstring == "") {
                             switch ($grammar) {
                                 case 1:
                                     $weekstring = "- " . JText::_('JEV_REP_WEEK') . " ";
                                     $weekstring .= str_replace("|", ", ", $this->reccurweeks()) . " ";
                                     $weekstring .= strtolower(JText::_('JEV_EACHMONTH'));
                                     break;
                                 default:
                                     $weekstring = str_replace("|", ", ", $this->reccurweeks()) . " ";
                                     $weekstring .= $reccur;
                                     $weekstring .= JText::_('JEV_EACHMONTH');
                                     break;
                             }
                         }
                     }
                     $firstword = true;
                     switch ($grammar) {
                         case 1:
                             echo $daystring . $weekstring;
                             break;
                         default:
                             echo $each . $daystring . $weekstring;
                             break;
                     }
                 } else {
                     echo JText::_('JEV_EACH') . '&nbsp;' . $reccur;
                 }
             }
         } else {
             echo JText::_('JEV_EACH') . '&nbsp;' . $reccur;
         }
     } else {
         if ($this->start_date != $this->stop_date) {
             echo JText::_('JEV_ALLDAYS');
         }
     }
 }
Exemple #27
0
 * @copyright   Copyright (C)  2008-2009 GWE Systems Ltd
 * @license     GNU/GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
 * @link        http://www.jevents.net
 */
defined('_JEXEC') or die('Restricted access');
JHTML::_('behavior.tooltip');
$db =& JFactory::getDBO();
$user = JFactory::getUser();
// get configuration object
$cfg =& JEVConfig::getInstance();
$pathIMG = JURI::root() . 'administrator/images/';
$pathJeventsIMG = JURI::root() . "administrator/components/" . JEV_COM_COMPONENT . "/assets/images/";
global $task;
JHTML::_('behavior.tooltip');
// get configuration object
$cfg =& JEVConfig::getInstance();
?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
	<table cellpadding="4" cellspacing="0" border="0" width="100%">
		<tr>
			<td width="100%">
			&nbsp;
			</td>
			<td align="right"><?php 
echo $this->clist;
?>
 </td>
			<td><?php 
echo JText::_('JEV_SEARCH');
?>
&nbsp;</td>
 function import($filename, $rawtext = "")
 {
     @ini_set("max_execution_time", 600);
     echo JText::sprintf("Importing events from ical file %s", $filename) . "<br/>";
     $cfg =& JEVConfig::getInstance();
     $option = JEV_COM_COMPONENT;
     // resultant data goes here
     if ($filename != "") {
         $file = $filename;
         if (!@file_exists($file)) {
             $file = JPATH_SITE . "/components/{$option}/" . $filename;
         }
         if (!file_exists($file)) {
             echo "I hope this is a URL!!<br/>";
             $file = $filename;
         }
         // get name
         $isFile = false;
         if (isset($_FILES['upload']) && is_array($_FILES['upload'])) {
             $uploadfile = $_FILES['upload'];
             // MSIE sets a mime-type of application/octet-stream
             if ($uploadfile['size'] != 0 && ($uploadfile['type'] == "text/calendar" || $uploadfile['type'] == "text/csv" || $uploadfile['type'] == "application/octet-stream" || $uploadfile['type'] == "text/html")) {
                 $this->srcURL = $uploadfile['name'];
                 $isFile = true;
             }
         }
         if ($this->srcURL == "") {
             $this->srcURL = $file;
         }
         // $this->rawData = iconv("ISO-8859-1","UTF-8",file_get_contents($file));
         if (!$isFile && is_callable("curl_exec")) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, ($isFile ? "file://" : "") . $file);
             curl_setopt($ch, CURLOPT_VERBOSE, 1);
             curl_setopt($ch, CURLOPT_POST, 0);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             $this->rawData = curl_exec($ch);
             curl_close($ch);
             // try file_get_contents as a backup
             if ($isFile && $this->rawData === false) {
                 $this->rawData = @file_get_contents($file);
             }
         } else {
             $this->rawData = @file_get_contents($file);
         }
         if ($this->rawData === false) {
             // file_get_contents: no or blocked wrapper for $file
             JError::raiseNotice(0, 'file_get_contents() failed, try fsockopen');
             $parsed_url = parse_url($file);
             if ($parsed_url === false) {
                 JError::raiseWarning(0, 'url not parsed: ' . $file);
             } else {
                 if ($parsed_url['scheme'] == 'http' || $parsed_url['scheme'] == 'https' || $parsed_url['scheme'] == 'webcal') {
                     // try socked connection
                     $fsockhost = $parsed_url['host'];
                     $fsockport = 80;
                     if ($parsed_url['scheme'] == 'https') {
                         $fsockhost = 'ssl://' . $fsockhost;
                         $fsockport = 443;
                     }
                     if (array_key_exists('port', $parsed_url)) {
                         $fsockport = $parsed_url['port'];
                     }
                     $fh = @fsockopen($fsockhost, $fsockport, $errno, $errstr, 3);
                     if ($fh === false) {
                         // fsockopen: no connect
                         JError::raiseWarning(0, 'fsockopen: no connect for ' . $file . ' - ' . $errstr);
                         return false;
                     } else {
                         $fsock_path = (array_key_exists('path', $parsed_url) ? $parsed_url['path'] : '') . (array_key_exists('query', $parsed_url) ? $parsed_url['query'] : '') . (array_key_exists('fragment', $parsed_url) ? $parsed_url['fragment'] : '');
                         fputs($fh, "GET {$fsock_path} HTTP/1.0\r\n");
                         fputs($fh, "Host: " . $parsed_url['host'] . "\r\n\r\n");
                         while (!feof($fh)) {
                             $this->rawData .= fread($fh, 4096);
                         }
                         fclose($fh);
                         $this->rawData = JString::substr($this->rawData, JString::strpos($this->rawData, "\r\n\r\n") + 4);
                     }
                 }
             }
         }
         // Returns true if $string is valid UTF-8 and false otherwise.
         /*
         $isutf8 = $this->detectUTF8($this->rawData);
         if ($isutf8) {
         $this->rawData = iconv("ISO-8859-1","UTF-8",$this->rawData);
         }
         */
     } else {
         $this->srcURL = "n/a";
         $this->rawData = $rawtext;
     }
     // get rid of spurious carriage returns and spaces
     //$this->rawData = preg_replace("/[\r\n]+ ([:;])/","$1",$this->rawData);
     // simplify line feed
     $this->rawData = str_replace("\r\n", "\n", $this->rawData);
     // remove spurious lines before calendar start
     if (!JString::stristr($this->rawData, 'BEGIN:VCALENDAR')) {
         // check for CSV format
         $firstLine = JString::substr($this->rawData, 0, JString::strpos($this->rawData, "\n") + 1);
         if (JString::stristr($firstLine, 'SUMMARY') && JString::stristr($firstLine, 'DTSTART') && JString::stristr($firstLine, 'DTEND') && JString::stristr($firstLine, 'CATEGORIES') && JString::stristr($firstLine, 'TIMEZONE')) {
             $timezone = date_default_timezone_get();
             $csvTrans = new CsvToiCal($file);
             $this->rawData = $csvTrans->getRawData();
             date_default_timezone_set($timezone);
         } else {
             JError::raiseWarning(0, 'Not a valid VCALENDAR data file: ' . $this->srcURL);
             //JError::raiseWarning(0, 'Not a valid VCALENDAR or CSV data file: ' . $this->srcURL);
             // return false so that we don't remove a valid calendar because of a bad URL load!
             return false;
         }
     }
     $begin = JString::strpos($this->rawData, "BEGIN:VCALENDAR", 0);
     $this->rawData = JString::substr($this->rawData, $begin);
     //		$this->rawData = preg_replace('/^.*\n(BEGIN:VCALENDAR)/s', '$1', $this->rawData, 1);
     // unfold content lines according the unfolding procedure of rfc2445
     $this->rawData = str_replace("\n ", "", $this->rawData);
     $this->rawData = str_replace("\n\t", "", $this->rawData);
     // TODO make sure I can always ignore the second line
     // Some google calendars has spaces and carriage returns in their UIDs
     // Convert string into array for easier processing
     $this->rawData = explode("\n", $this->rawData);
     $skipuntil = null;
     foreach ($this->rawData as $vcLine) {
         //$vcLine = trim($vcLine); // trim one line
         if (!empty($vcLine)) {
             // skip unhandled block
             if ($skipuntil) {
                 if (trim($vcLine) == $skipuntil) {
                     // found end of block to skip
                     $skipuntil = null;
                 }
                 continue;
             }
             $matches = explode(":", $vcLine, 2);
             if (count($matches) == 2) {
                 list($this->key, $value) = $matches;
                 //$value = str_replace('\n', "\n", $value);
                 //$value = stripslashes($value);
                 $append = false;
                 // Treat Accordingly
                 switch ($vcLine) {
                     case "BEGIN:VTODO":
                         // start of VTODO section
                         $this->todoCount++;
                         $parent = "VTODO";
                         break;
                     case "BEGIN:VEVENT":
                         // start of VEVENT section
                         $this->eventCount++;
                         $parent = "VEVENT";
                         break;
                     case "BEGIN:VCALENDAR":
                     case "BEGIN:DAYLIGHT":
                     case "BEGIN:VTIMEZONE":
                     case "BEGIN:STANDARD":
                         $parent = $value;
                         // save tu array under value key
                         break;
                     case "END:VTODO":
                     case "END:VEVENT":
                     case "END:VCALENDAR":
                     case "END:DAYLIGHT":
                     case "END:VTIMEZONE":
                     case "END:STANDARD":
                         $parent = "VCALENDAR";
                         break;
                     default:
                         // skip unknown BEGIN/END blocks
                         if ($this->key == 'BEGIN') {
                             $skipuntil = 'END:' . $value;
                             break;
                         }
                         // Generic processing
                         $this->add_to_cal($parent, $this->key, $value, $append);
                         break;
                 }
             } else {
                 // ignore these lines go
             }
         }
     }
     // Sort the events into start date order
     // there's little point in doing this id an RRULE is present!
     //	usort($this->cal['VEVENT'], array("iCalImport","comparedates"));
     // Populate vevent class - should do this first trawl through !!
     if (array_key_exists("VEVENT", $this->cal)) {
         foreach ($this->cal["VEVENT"] as $vevent) {
             // trap for badly constructed all day events
             if (isset($vevent["DTSTARTRAW"]) && isset($vevent["DTENDRAW"]) && $vevent["DTENDRAW"] == $vevent["DTSTARTRAW"]) {
                 $vevent["DTEND"] += 86400;
             }
             $this->vevents[] = iCalEvent::iCalEventFromData($vevent);
         }
     }
     return $this;
 }
Exemple #29
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;
 }
Exemple #30
0
 function getAjaxCal($modid = 0, $month, $year)
 {
     // capture module id so that we can use it for ajax type navigation
     if ($modid != 0) {
         $this->_modid = $modid;
     }
     $user =& JFactory::getUser();
     $db =& JFactory::getDBO();
     static $isloaded_css = false;
     // this will get the viewname based on which classes have been implemented
     $cfg =& JEVConfig::getInstance();
     $viewname = ucfirst($cfg->get('com_calViewName', "default"));
     $cfg =& JEVConfig::getInstance();
     // get array
     $day_name = JEVHelper::getWeekdayLetter(null, 1);
     $day_name[0] = '<span class="sunday">' . $day_name[0] . '</span>';
     $day_name[6] = '<span class="saturday">' . $day_name[6] . '</span>';
     $content = "";
     $mod = "";
     if (isset($this->_modid) && $this->_modid > 0) {
         $mod = 'id="modid_' . $this->_modid . '" ';
         $content .= "<span id='testspan" . $this->_modid . "' style='display:none'></span>\n";
     }
     $temptime = JevDate::mktime(12, 0, 0, $month, 15, $year);
     //$content .= $this->_displayCalendarMod($temptime,$this->com_starday, JText::_('JEV_THIS_MONTH'),$day_name, false);
     $thisDayOfMonth = date("j", $temptime);
     $daysLeftInMonth = date("t", $temptime) - date("j", $temptime) + 1;
     // calculate month offset from first of month
     $first_of_current_month = JevDate::strtotime(date('Y-m-01', $temptime));
     $base_year = date("Y", $temptime);
     $base_month = date("m", $temptime);
     $basefirst_of_month = JevDate::mktime(0, 0, 0, $base_month, 1, $base_year);
     if ($this->disp_lastMonth && (!$this->disp_lastMonthDays || $thisDayOfMonth <= $this->disp_lastMonthDays)) {
         $content .= $this->_displayCalendarMod(JevDate::strtotime("-1 month", $first_of_current_month), $this->com_starday, JText::_('JEV_LAST_MONTH'), $day_name, $this->disp_lastMonth == 2, $first_of_current_month);
     }
     $content .= $this->_displayCalendarMod($temptime, $this->com_starday, JText::_('JEV_THIS_MONTH'), $day_name, false, $first_of_current_month);
     if ($this->disp_nextMonth && (!$this->disp_nextMonthDays || $daysLeftInMonth <= $this->disp_nextMonthDays)) {
         $content .= $this->_displayCalendarMod(JevDate::strtotime("+1 month", $first_of_current_month), $this->com_starday, JText::_('JEV_NEXT_MONTH'), $day_name, $this->disp_nextMonth == 2, $first_of_current_month);
     }
     return $content;
 }