コード例 #1
0
ファイル: module.php プロジェクト: Rikisha/proj
 /**
  * Renders a module script and returns the results as a string
  *
  * @param	string $name	The name of the module to render
  * @param	array $attribs	Associative array of values
  *
  * @return	string			The output of the script
  * @since   1.0
  */
 public function render($module, $attribs = array(), $content = null)
 {
     // add the environment data to attributes of module
     $registry = JRegistry::getInstance('document.environment');
     $env = $registry->getValue('params', array());
     $attribs = array_merge($env, $attribs);
     if (!is_object($module)) {
         $title = isset($attribs['title']) ? $attribs['title'] : null;
         $module = MigurModuleHelper::getModule($module, $title);
         if (!is_object($module)) {
             if (is_null($content)) {
                 return '';
             } else {
                 /**
                  * If module isn't found in the database but data has been pushed in the buffer
                  * we want to render it
                  */
                 $tmp = $module;
                 $module = new stdClass();
                 $module->params = null;
                 $module->module = $tmp;
                 $module->id = 0;
                 $module->user = 0;
             }
         }
     }
     // get the user and configuration object
     //$user = JFactory::getUser();
     $conf = JFactory::getConfig();
     // set the module content
     if (!is_null($content)) {
         $module->content = $content;
     }
     //get module parameters
     $params = new JRegistry();
     $params->loadJSON($module->params);
     // use parameters from template
     if (isset($attribs['params'])) {
         $template_params = new JRegistry();
         $template_params->loadJSON(html_entity_decode($attribs['params'], ENT_COMPAT, 'UTF-8'));
         $params->merge($template_params);
         $module = clone $module;
         $module->params = (string) $params;
     }
     $contents = '';
     $cachemode = $params->get('cachemode', 'oldstatic');
     // default for compatibility purposes. Set cachemode parameter or use JModuleHelper::moduleCache from within the module instead
     if ($params->get('cache', 0) == 1 && $conf->get('caching') >= 1 && $cachemode != 'id' && $cachemode != 'safeuri') {
         // default to itemid creating mehod and workarounds on
         $cacheparams = new stdClass();
         $cacheparams->cachemode = $cachemode;
         $cacheparams->class = 'JModuleHelper';
         $cacheparams->method = 'renderModule';
         $cacheparams->methodparams = array($module, $attribs);
         $contents = MigurModuleHelper::ModuleCache($module, $params, $cacheparams);
     } else {
         $contents = MigurModuleHelper::renderModule($module, $attribs);
     }
     return $contents;
 }
コード例 #2
0
ファイル: payments.php プロジェクト: bellodox/CrowdFunding
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get project id.
     $this->projectId = $this->input->getUint('pid');
     // Prepare log object
     $registry = JRegistry::getInstance('com_crowdfunding');
     /** @var  $registry Joomla\Registry\Registry */
     $fileName = $registry->get('logger.file');
     $tableName = $registry->get('logger.table');
     $file = JPath::clean($this->app->get('log_path') . DIRECTORY_SEPARATOR . $fileName);
     $this->log = new Prism\Log\Log();
     $this->log->addAdapter(new Prism\Log\Adapter\Database(JFactory::getDbo(), $tableName));
     $this->log->addAdapter(new Prism\Log\Adapter\File($file));
     // Create an object that contains a data used during the payment process.
     $this->paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $this->projectId;
     $this->paymentProcess = $this->app->getUserState($this->paymentProcessContext);
     // Set payment service name.
     if (!isset($this->paymentProcess->paymentService)) {
         $this->paymentProcess->paymentService = '';
     }
     // Local executing tasks. It needs to provide form token.
     $this->registerTask('checkout', 'process');
     // Remote executing tasks. It does not need to provide form token.
     $this->registerTask('doCheckout', 'process');
     $this->registerTask('completeCheckout', 'process');
 }
コード例 #3
0
 public function __construct($config = array())
 {
     parent::__construct($config);
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get project id.
     $this->projectId = $this->input->getUint("pid");
     // Prepare log object
     $registry = JRegistry::getInstance("com_crowdfunding");
     /** @var  $registry Joomla\Registry\Registry */
     $fileName = $registry->get("logger.file");
     $tableName = $registry->get("logger.table");
     $file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
     $this->log = new ITPrismLog();
     $this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
     $this->log->addWriter(new ITPrismLogWriterFile($file));
     // Create an object that contains a data used during the payment process.
     $this->paymentProcessContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->projectId;
     $this->paymentProcess = $app->getUserState($this->paymentProcessContext);
     // Prepare context
     $filter = new JFilterInput();
     $paymentService = JString::trim(JString::strtolower($this->input->getCmd("payment_service")));
     $paymentService = $filter->clean($paymentService, "ALNUM");
     $this->context = !empty($paymentService) ? 'com_crowdfunding.notify.' . $paymentService : 'com_crowdfunding.notify';
     // Prepare params
     $this->params = JComponentHelper::getParams("com_crowdfunding");
 }
コード例 #4
0
ファイル: helper.php プロジェクト: madcsaba/li-de
 public static function getDetailBody($modid)
 {
     if (trim($modid) == "") {
         return false;
     }
     $reg = JRegistry::getInstance("com_jevents");
     $moddata = $reg->get("dynamicmodules");
     if (isset($moddata[$modid])) {
         return $moddata[$modid];
     }
     return false;
 }
コード例 #5
0
ファイル: payments.php プロジェクト: pashakiz/crowdf
 public function __construct($config = array())
 {
     parent::__construct($config);
     $this->option = $this->input->getCmd("option");
     // Prepare log object
     $registry = JRegistry::getInstance("com_crowdfunding");
     /** @var $registry Joomla\Registry\Registry */
     $fileName = $registry->get("logger.file");
     $tableName = $registry->get("logger.table");
     $file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
     $this->log = new Prism\Log\Log();
     $this->log->addWriter(new Prism\Log\Writer\Database(JFactory::getDbo(), $tableName));
     $this->log->addWriter(new Prism\Log\Writer\File($file));
 }
コード例 #6
0
ファイル: compatwin.php プロジェクト: madcsaba/li-de
 /**
  * Callback function
  *
  * @static
  * @param mixed $pattern	array() search pattern or int date
  */
 public static function _cb_strftime($pattern)
 {
     // timestamp used during callback
     $registry = JRegistry::getInstance('jevents');
     $ts = $registry->get('jevents.strftime', time());
     switch ($pattern[0]) {
         case '%C':
             return sprintf("%02d", date("Y", $ts) / 100);
             break;
         case '%D':
             return '%m/%d/%y';
             break;
         case '%e':
             return sprintf("%' 2d", date("j", $ts));
             break;
         case '%g':
             return JevDate::strftime('%y', JEV_CompatWin::_getThursdayOfWeek($ts));
             break;
         case '%G':
             return JevDate::strftime('%Y', JEV_CompatWin::_getThursdayOfWeek($ts));
             break;
         case '%h':
             return '%b';
             break;
         case '%n':
             return "\n";
             break;
         case '%r':
             return '%I:%M:%S %p';
             break;
         case '%R':
             return '%H:%M';
             break;
         case '%t':
             return "\t";
             break;
         case '%T':
             return '%H:%M:%S';
             break;
         case '%u':
             return ($w = date("w", $ts)) ? $w : 7;
             break;
         case '%V':
             return JEV_CompatWin::_getWeekNumberISO8601($ts);
             break;
         default:
             return ' unknown specifier! ';
     }
 }
コード例 #7
0
 public function init()
 {
     // Prepare log object
     $registry = JRegistry::getInstance("com_crowdfunding");
     /** @var $registry Joomla\Registry\Registry */
     $fileName = $registry->get("logger.file");
     $tableName = $registry->get("logger.table");
     // Create log object
     $this->log = new ITPrismLog();
     // Set database writer.
     $this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
     // Set file writer.
     if (!empty($fileName)) {
         $file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
         $this->log->addWriter(new ITPrismLogWriterFile($file));
     }
     // Load language
     $this->loadLanguage();
 }
コード例 #8
0
ファイル: plugin.php プロジェクト: phpsource/CrowdFunding
 public function __construct(&$subject, $config = array())
 {
     parent::__construct($subject, $config);
     // Prepare log object
     $registry = JRegistry::getInstance("com_crowdfunding");
     /** @var  $registry Joomla\Registry\Registry */
     $fileName = $registry->get("logger.file");
     $tableName = $registry->get("logger.table");
     // Create log object
     $this->log = new ITPrismLog();
     // Set database writer.
     $this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
     // Set file writer.
     if (!empty($fileName)) {
         $app = JFactory::getApplication();
         /** @var $app JApplicationSite */
         $file = JPath::clean($app->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
         $this->log->addWriter(new ITPrismLogWriterFile($file));
     }
 }
コード例 #9
0
ファイル: payments.php プロジェクト: phpsource/CrowdFunding
 public function __construct($config = array())
 {
     parent::__construct($config);
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite * */
     // Get project id.
     $this->projectId = $this->input->getUint("pid");
     // Prepare log object
     $registry = JRegistry::getInstance("com_crowdfunding");
     /** @var  $registry Joomla\Registry\Registry */
     $fileName = $registry->get("logger.file");
     $tableName = $registry->get("logger.table");
     $file = JPath::clean(JFactory::getApplication()->get("log_path") . DIRECTORY_SEPARATOR . $fileName);
     $this->log = new ITPrismLog();
     $this->log->addWriter(new ITPrismLogWriterDatabase(JFactory::getDbo(), $tableName));
     $this->log->addWriter(new ITPrismLogWriterFile($file));
     // Create an object that contains a data used during the payment process.
     $this->paymentProcessContext = CrowdFundingConstants::PAYMENT_SESSION_CONTEXT . $this->projectId;
     $this->paymentProcess = $app->getUserState($this->paymentProcessContext);
 }
コード例 #10
0
ファイル: filters.php プロジェクト: hriggs/cs-website
 function jevFilter($tablename, $filterfield, $isString = false)
 {
     $registry = JRegistry::getInstance("jevents");
     $indexedvisiblefilters = $registry->get("indexedvisiblefilters", array());
     if (!is_array($indexedvisiblefilters)) {
         $indexedvisiblefilters = array();
     }
     // This is our best guess as to whether this filter is visible on this page.
     $this->isVisible(in_array($this->filterType, $indexedvisiblefilters));
     // If using caching should disable session filtering if not logged in
     $cfg = JEVConfig::getInstance();
     $joomlaconf = JFactory::getConfig();
     $useCache = intval($cfg->get('com_cache', 0)) && $joomlaconf->get('caching', 1);
     // New special code in jevents.php sets the session variables in the cache id calculation!
     $useCache = false;
     // Is the filter module setup to reset automatically
     $module = JModuleHelper::getModule("mod_jevents_filter");
     if ($module) {
         $modparams = new JRegistry($module->params);
         $option = JRequest::getCmd("option");
         if ($modparams->get("resetfilters") == "nonjevents" && $option != "com_jevents" && $option != "com_jevlocations" && $option != "com_jevpeople" && $option != "com_rsvppro" && $option != "com_jevtags") {
             JRequest::setVar('filter_reset', 1);
             JFactory::getApplication()->setUserState('active_filter_menu ', JRequest::getInt("Itemid", 0));
         } else {
             if ($modparams->get("resetfilters") == "newmenu" && !JRequest::getCmd("jevents_filter_submit", false, "POST")) {
                 // Must use JRequest::getInt("Itemid") since missing event finder resets active menu item!
                 if (JRequest::getInt("Itemid", 0) && JRequest::getInt("Itemid", 0) != JFactory::getApplication()->getUserState("jevents.filtermenuitem", 0)) {
                     JRequest::setVar('filter_reset', 1);
                     JFactory::getApplication()->setUserState('active_filter_menu ', JRequest::getInt("Itemid", 0));
                 }
             }
         }
     }
     $user = JFactory::getUser();
     // TODO chek this logic
     if (intval(JRequest::getVar('filter_reset', 0))) {
         $this->filter_value = $this->filterNullValue;
         for ($v = 0; $v < $this->valueNum; $v++) {
             $this->filter_values[$v] = $this->filterNullValues[$v];
         }
         $this->filter_value = JFactory::getApplication()->setUserState($this->filterType . '_fv_ses', $this->filterNullValue);
         for ($v = 0; $v < $this->valueNum; $v++) {
             $this->filter_values[$v] = JFactory::getApplication()->setUserState($this->filterType . '_fvs_ses' . $v, $this->filterNullValues[$v]);
         }
     } else {
         if ($user->get('id') == 0 && $useCache || !$this->visible) {
             $this->filter_value = JRequest::getVar($this->filterType . '_fv', $this->filterNullValue);
             for ($v = 0; $v < $this->valueNum; $v++) {
                 $this->filter_values[$v] = JRequest::getVar($this->filterType . '_fvs' . $v, $this->filterNullValues[$v]);
             }
         } else {
             $this->filter_value = JFactory::getApplication()->getUserStateFromRequest($this->filterType . '_fv_ses', $this->filterType . '_fv', $this->filterNullValue);
             for ($v = 0; $v < $this->valueNum; $v++) {
                 $this->filter_values[$v] = JFactory::getApplication()->getUserStateFromRequest($this->filterType . '_fvs_ses' . $v, $this->filterType . '_fvs' . $v, $this->filterNullValues[$v]);
             }
         }
     }
     /*
     }
     else {
     $this->filter_value = JRequest::getString($this->filterType.'_fv', $this->filterNullValue );
     for ($v=0;$v<$this->valueNum;$v++){
     $this->filter_values[$v] = JRequest::getInt($this->filterType."_fvs".$v, $this->filterNullValues[$v] );
     }
     }
     */
     $this->tableName = $tablename;
     $this->filterField = $filterfield;
     $this->filterIsString = $isString;
 }
コード例 #11
0
ファイル: installer.helper.php プロジェクト: Jougito/DynWeb
    protected function updateDatabase($step)
    {
        $db = JFactory::getDBO();
        $html = '';
        $status = true;
        $stopUpdate = false;
        $continue = false;
        // Insert configuration codes if needed
        $hasConfig = $this->dbhelper->_isExistDefaultConfig();
        if (!$hasConfig) {
            $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_UPDATE_CONFIG') . '</div>';
            $obj = new stdClass();
            $obj->name = 'dbversion';
            $obj->params = DBVERSION;
            if (!$db->insertObject('#__community_config', $obj)) {
                $html .= $this->failedStatus;
                $status = false;
                $errorCode = '7a';
            } else {
                $default = JPATH_BASE . '/components/com_community/default.ini';
                $registry = JRegistry::getInstance('community');
                $registry->loadFile($default, 'INI', 'community');
                // Set the site name
                $app = JFactory::getApplication();
                $registry->setValue('community.sitename', $app->getCfg('sitename'));
                // Set the photos path
                $photoPath = rtrim(dirname(JPATH_BASE), '/');
                $registry->setValue('community.photospath', $photoPath . '/images');
                // Set the videos folder
                $registry->setValue('community.videofolder', 'images');
                // Store the config
                $obj = new stdClass();
                $obj->name = 'config';
                $obj->params = $registry->toString('INI', 'community');
                if (!$this->dbhelper->insertTableEntry('#__community_config', $obj)) {
                    $html .= $this->failedStatus;
                    ob_start();
                    ?>
					<div>
						Error when trying to create default configurations.
						Please proceed to the configuration and set your own configuration instead.
					</div>
					<?php 
                    $html .= ob_get_contents();
                    @ob_end_clean();
                } else {
                    $html .= $this->successStatus;
                }
            }
        } else {
            $dbversionConfig = $this->dbhelper->getDBVersion();
            $dbversion = empty($dbversionConfig) ? 0 : $dbversionConfig;
            if ($dbversion < DBVERSION) {
                $updater = new CommunityInstallerUpdate();
                $html .= '<div style="width:150px; float:left;">' . JText::_('Updating DB from version ' . $dbversion) . '</div>';
                $updateResult = call_user_func(array($updater, 'update_' . $dbversion));
                $stopUpdate = empty($updateResult->stopUpdate) ? false : true;
                if ($updateResult->status) {
                    $html .= $this->successStatus;
                    $status = true;
                    $dbversion++;
                    if ($dbversionConfig === null && $dbversionConfig !== 0) {
                        $this->dbhelper->insertDBVersion($dbversion);
                    } else {
                        $this->dbhelper->updateDBVersion($dbversion);
                    }
                    if ($dbversion < DBVERSION) {
                        $continue = true;
                    }
                } else {
                    $html .= $this->failedStatus;
                    $status = false;
                    $errorCode = $updateResult->errorCode;
                }
                $html .= $updateResult->html;
            }
        }
        if (!$stopUpdate) {
            if (!$continue) {
                // Need to update the menu's component id if this is a reinstall
                if (menuExist()) {
                    $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_UPDATE_MENU_ITEMS') . '</div>';
                    if (!updateMenuItems()) {
                        ob_start();
                        ?>
						<p style="font-weight: 700; color: red;">
							System encountered an error while trying to update the existing menu items. You will need
							to update the existing menu structure manually.
						</p>
						<?php 
                        $html .= ob_get_contents();
                        @ob_end_clean();
                        $html .= $this->failedStatus;
                    } else {
                        $html .= $this->successStatus;
                    }
                } else {
                    $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_CREATE_MENU_ITEMS') . '</div>';
                    if (!addMenuItems()) {
                        ob_start();
                        ?>
						<p style="font-weight: 700; color: red;">
							System encountered an error while trying to create a menu item. You will need
							to create your menu item manually.
						</p>
						<?php 
                        $html .= ob_get_contents();
                        @ob_end_clean();
                        $html .= $this->failedStatus;
                    } else {
                        $html .= $this->successStatus;
                    }
                }
                // Jomsocial menu types
                if (!menuTypesExist()) {
                    $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_CREATE_TOOLBAR_MENU_ITEM') . '</div>';
                    if (!addDefaultMenuTypes()) {
                        ob_start();
                        ?>
						<p style="font-weight: 700; color: red;">
							System encountered an error while trying to create a menu type item. You will need
							to create your toolbar menu type item manually.
						</p>
						<?php 
                        $html .= ob_get_contents();
                        @ob_end_clean();
                        $html .= $this->failedStatus;
                    } else {
                        $html .= $this->successStatus;
                    }
                }
                //clean up registration table if the table installed previously.
                $this->dbhelper->cleanRegistrationTable();
                // Test if we are required to add default custom fields
                $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_ADD_DEFAULT_CUSTOM_FIELD') . '</div>';
                if (needsDefaultCustomFields()) {
                    addDefaultCustomFields();
                    $html .= $this->successStatus;
                } else {
                    $html .= $this->notApplicable;
                }
                // Test if we are required to add default group categories
                $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_ADD_DEFAULT_GROUP_CATEGORIES') . '</div>';
                if (needsDefaultGroupCategories()) {
                    addDefaultGroupCategories();
                    $html .= $this->successStatus;
                } else {
                    $html .= $this->notApplicable;
                }
                // Test if we are required to add default videos categories
                $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_ADD_DEFAULT_VIDEO_CATEGORIES') . '</div>';
                if (needsDefaultVideosCategories()) {
                    addDefaultVideosCategories();
                    $html .= $this->successStatus;
                } else {
                    $html .= $this->notApplicable;
                }
                // Test if we are required to add default event categories
                $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_ADD_DEFAULT_EVENT_CATEGORIES') . '</div>';
                if (needsDefaultEventsCategories()) {
                    addDefaultEventsCategories();
                    $html .= $this->successStatus;
                } else {
                    $html .= $this->notApplicable;
                }
                // Test if we are required to add default user points
                $html .= '<div style="width:150px; float:left;">' . JText::_('COM_COMMUNITY_INSTALLATION_ADD_DEFAULT_USERPOINTS') . '</div>';
                if (needsDefaultUserPoints()) {
                    //clean up userpoints table if the table installed from previous version of 1.0.128
                    $this->dbhelper->cleanUserPointsTable();
                    addDefaultUserPoints();
                    $html .= $this->successStatus;
                } else {
                    //cleanup some unused action rules.
                    $this->dbhelper->cleanUserPointsTable(array('friends.request.add', 'friends.request.reject', 'friends.request.cancel', 'friends.invite'));
                    $html .= $this->notApplicable;
                }
            }
            if ($status) {
                if (!empty($continue)) {
                    $step = $step - 1;
                }
                $autoSubmit = $this->getAutoSubmitFunction();
                $message = $autoSubmit . $html;
            } else {
                $errorMsg = $this->getErrorMessage(7, $errorCode);
                $message = $html . $errorMsg;
                $step = $step - 1;
            }
        } else {
            $message = $html;
        }
        $drawdata = new stdClass();
        $drawdata->message = $message;
        $drawdata->status = $status;
        $drawdata->step = $step;
        $drawdata->title = JText::_('COM_COMMUNITY_INSTALLATION_UPDATING_DATABASE');
        $drawdata->install = 1;
        return $drawdata;
    }
コード例 #12
0
ファイル: helper.php プロジェクト: jdrzaic/joomla-dummy
 /**
  * Fetch all installed extensions from the database
  *
  * @return  array
  */
 public static function findInstalledExtensions()
 {
     $registry = JRegistry::getInstance('JSNTplFramework');
     $installedExtensions = $registry->get('extension.installed', array());
     if (empty($installedExtensions)) {
         $db = JFactory::getDbo();
         $q = $db->getQuery(true);
         $q->select('element, manifest_cache');
         $q->from('#__extensions');
         $q->where('type IN ("component", "plugin", "module")');
         $db->setQuery($q);
         foreach ($db->loadObjectList() as $extension) {
             $installedExtensions[$extension->element] = json_decode($extension->manifest_cache);
         }
         $registry->set('extension.installed', $installedExtensions);
     }
     return $installedExtensions;
 }
コード例 #13
0
	/**
	 * Get the template
	 *
	 * @return string The template name
	 * @since 1.0
	 */
	public function getTemplate($params = false)
	{
		if(is_object($this->template))
		{
			if ($params) {
				return $this->template;
			}
			return $this->template->template;
		}

		$id = 0;
		$condition = '';

		$tid = JRequest::getVar('templateStyle', 0);
		if (is_numeric($tid) && (int) $tid > 0) {
			$id = (int) $tid;
		}


		$cache = JFactory::getCache('com_templates', '');
		if ($this->_language_filter) {
			$tag = JFactory::getLanguage()->getTag();
		}
		else {
			$tag ='';
		}
		$templates = array((object)array(
			'template'	=> 'default',
			'params'	=> JRegistry::getInstance('foobarTemplateParams')
		));

		if (isset($templates[$id])) {
			$template = $templates[$id];
		}
		else {
			$template = $templates[0];
		}

		// Allows for overriding the active template from the request
		$template->template = JRequest::getCmd('template', $template->template);
		$template->template = JFilterInput::getInstance()->clean($template->template, 'cmd'); // need to filter the default value as well

		// Fallback template
		if (!file_exists(JPATH_THEMES . '/' . $template->template . '/index.php')) {
			JError::raiseWarning(0, JText::_('JERROR_ALERTNOTEMPLATE'));
		    $template->template = 'beez_20';
		    if (!file_exists(JPATH_THEMES . '/beez_20/index.php')) {
		    	$template->template = '';
		    }
		}

		// Cache the result
		$this->template = $template;
		if ($params) {
			return $template;
		}
		return $template->template;
	}
コード例 #14
0
function DefaultLoadedFromTemplate($view, $template_name, $event, $mask, $template_value = false)
{
    $db = JFactory::getDBO();
    // find published template
    static $templates;
    static $fieldNameArray;
    if (!isset($templates)) {
        $templates = array();
        $fieldNameArray = array();
        $rawtemplates = array();
    }
    $specialmodules = false;
    if (!$template_value) {
        if (!array_key_exists($template_name, $templates)) {
            $db->setQuery("SELECT * FROM #__jev_defaults WHERE state=1 AND name= " . $db->Quote($template_name) . " AND " . 'language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
            $rawtemplates = $db->loadObjectList();
            $templates[$template_name] = array();
            if ($rawtemplates) {
                foreach ($rawtemplates as $rt) {
                    if (!isset($templates[$template_name][$rt->language])) {
                        $templates[$template_name][$rt->language] = array();
                    }
                    $templates[$template_name][$rt->language][$rt->catid] = $rt;
                }
            }
            if (count($templates[$template_name]) == 0) {
                $templates[$template_name] = null;
                return false;
            }
            if (isset($templates[$template_name][JFactory::getLanguage()->getTag()])) {
                $templateArray = $templates[$template_name][JFactory::getLanguage()->getTag()];
                // We have the most specific by language now fill in the gaps
                if (isset($templates[$template_name]["*"])) {
                    foreach ($templates[$template_name]["*"] as $cat => $cattemplates) {
                        if (!isset($templateArray[$cat])) {
                            $templateArray[$cat] = $cattemplates;
                        }
                    }
                }
                $templates[$template_name] = $templateArray;
            } else {
                if (isset($templates[$template_name]["*"])) {
                    $templates[$template_name] = $templates[$template_name]["*"];
                } else {
                    if (is_array($templates[$template_name]) && count($templates[$template_name]) == 0) {
                        $templates[$template_name] = null;
                    } else {
                        if (is_array($templates[$template_name]) && count($templates[$template_name]) > 0) {
                            $templates[$template_name] = current($templates[$template_name]);
                        } else {
                            $templates[$template_name] = null;
                        }
                    }
                }
            }
            $matched = false;
            foreach (array_keys($templates[$template_name]) as $catid) {
                if ($templates[$template_name][$catid]->value != "") {
                    if (isset($templates[$template_name][$catid]->params)) {
                        $templates[$template_name][$catid]->params = new JRegistry($templates[$template_name][$catid]->params);
                        $specialmodules = $templates[$template_name][$catid]->params;
                    }
                    // Adjust template_value to include dynamic module output then strip it out afterwards
                    if ($specialmodules) {
                        $modids = $specialmodules->get("modid", array());
                        if (count($modids) > 0) {
                            $modvals = $specialmodules->get("modval", array());
                            // not sure how this can arise :(
                            if (is_object($modvals)) {
                                $modvals = get_object_vars($modvals);
                            }
                            for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                                $templates[$template_name][$catid]->value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                                // cleaned later!
                                //$templates[$template_name][$catid]->value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                                $templates[$template_name][$catid]->value .= $modvals[$count];
                                $templates[$template_name][$catid]->value .= "{{module end:MODULEEND}}";
                            }
                        }
                    }
                    // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
                    $templates[$template_name][$catid]->value = str_replace("\r", '', $templates[$template_name][$catid]->value);
                    $templates[$template_name][$catid]->value = str_replace("\n", '', $templates[$template_name][$catid]->value);
                    // non greedy replacement - because of the ?
                    $templates[$template_name][$catid]->value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $templates[$template_name][$catid]->value);
                    $matchesarray = array();
                    preg_match_all('|{{.*?}}|', $templates[$template_name][$catid]->value, $matchesarray);
                    $templates[$template_name][$catid]->matchesarray = $matchesarray;
                }
            }
        }
        if (is_null($templates[$template_name])) {
            return false;
        }
        $catids = $event->catids() && count($event->catids()) ? $event->catids() : array($event->catid());
        $catids[] = 0;
        // find the overlap
        $catids = array_intersect($catids, array_keys($templates[$template_name]));
        // At present must be an EXACT category match - no inheriting allowed!
        if (count($catids) == 0) {
            if (!isset($templates[$template_name][0]) || $templates[$template_name][0]->value == "") {
                return false;
            }
        }
        $template = false;
        foreach ($catids as $catid) {
            // use the first matching non-empty layout
            if ($templates[$template_name][$catid]->value != "") {
                $template = $templates[$template_name][$catid];
                break;
            }
        }
        if (!$template) {
            return false;
        }
        $template_value = $template->value;
        $specialmodules = $template->params;
        $matchesarray = $template->matchesarray;
    } else {
        // This is a special scenario where we call this function externally e.g. from RSVP Pro messages
        // In this scenario we have not gone through the displaycustomfields plugin
        static $pluginscalled = array();
        if (!isset($pluginscalled[$event->rp_id()])) {
            $dispatcher = JDispatcher::getInstance();
            JPluginHelper::importPlugin("jevents");
            $customresults = $dispatcher->trigger('onDisplayCustomFields', array(&$event));
            $pluginscalled[$event->rp_id()] = $event;
        } else {
            $event = $pluginscalled[$event->rp_id()];
        }
        // Adjust template_value to include dynamic module output then strip it out afterwards
        if ($specialmodules) {
            $modids = $specialmodules->get("modid", array());
            if (count($modids) > 0) {
                $modvals = $specialmodules->get("modval", array());
                // not sure how this can arise :(
                if (is_object($modvals)) {
                    $modvals = get_object_vars($modvals);
                }
                for ($count = 0; $count < count($modids) && $count < count($modvals) && trim($modids[$count]) != ""; $count++) {
                    $template_value .= "{{module start:MODULESTART#" . $modids[$count] . "}}";
                    // cleaned later!
                    //$template_value .= preg_replace_callback('|{{.*?}}|', 'cleanLabels', $modvals[$count]);
                    $template_value .= $modvals[$count];
                    $template_value .= "{{module end:MODULEEND}}";
                }
            }
        }
        // strip carriage returns other wise the preg replace doesn;y work - needed because wysiwyg editor may add the carriage return in the template field
        $template_value = str_replace("\r", '', $template_value);
        $template_value = str_replace("\n", '', $template_value);
        // non greedy replacement - because of the ?
        $template_value = preg_replace_callback('|{{.*?}}|', 'cleanLabels', $template_value);
        $matchesarray = array();
        preg_match_all('|{{.*?}}|', $template_value, $matchesarray);
    }
    if ($template_value == "") {
        return;
    }
    if (count($matchesarray) == 0) {
        return;
    }
    // now replace the fields
    $search = array();
    $replace = array();
    $blank = array();
    $rawreplace = array();
    $jevparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
    for ($i = 0; $i < count($matchesarray[0]); $i++) {
        $strippedmatch = preg_replace('/(#|:|;)+[^}]*/', '', $matchesarray[0][$i]);
        if (in_array($strippedmatch, $search)) {
            continue;
        }
        // translation string
        if (strpos($strippedmatch, "{{_") === 0 && strpos($strippedmatch, " ") === false) {
            $search[] = $strippedmatch;
            $strippedmatch = substr($strippedmatch, 3, strlen($strippedmatch) - 5);
            $replace[] = JText::_($strippedmatch);
            $blank[] = "";
            continue;
        }
        // Built in fields
        switch ($strippedmatch) {
            case "{{TITLE}}":
                $search[] = "{{TITLE}}";
                $replace[] = $event->title();
                $blank[] = "";
                break;
            case "{{PRIORITY}}":
                $search[] = "{{PRIORITY}}";
                $replace[] = $event->priority();
                $blank[] = "";
                break;
            case "{{LINK}}":
            case "{{LINKSTART}}":
            case "{{LINKEND}}":
            case "{{TITLE_LINK}}":
                if ($view) {
                    // Title link
                    $rowlink = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), false);
                    $rowlink = JRoute::_($rowlink . $view->datamodel->getCatidsOutLink());
                    ob_start();
                    ?>
					<a class="ev_link_row" href="<?php 
                    echo $rowlink;
                    ?>
" title="<?php 
                    echo JEventsHTML::special($event->title());
                    ?>
">
						<?php 
                    $linkstart = ob_get_clean();
                } else {
                    $rowlink = $linkstart = "";
                }
                $search[] = "{{LINK}}";
                $replace[] = $rowlink;
                $blank[] = "";
                $search[] = "{{LINKSTART}}";
                $replace[] = $linkstart;
                $blank[] = "";
                $search[] = "{{LINKEND}}";
                $replace[] = "</a>";
                $blank[] = "";
                $fulllink = $linkstart . $event->title() . '</a>';
                $search[] = "{{TITLE_LINK}}";
                $replace[] = $fulllink;
                $blank[] = "";
                break;
            case "{{TRUNCTITLE}}":
                // for month calendar cell only
                if (isset($event->truncatedtitle)) {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->truncatedtitle;
                    $blank[] = "";
                } else {
                    $search[] = "{{TRUNCTITLE}}";
                    $replace[] = $event->title();
                    $blank[] = "";
                }
                break;
            case "{{URL}}":
                $search[] = "{{URL}}";
                $replace[] = $event->url();
                $blank[] = "";
                break;
            case "{{TRUNCATED_DESC}}":
                $search[] = "{{TRUNCATED_DESC:.*?}}";
                $replace[] = $event->content();
                $blank[] = "";
                //	$search[]="|{{TRUNCATED_DESC:(.*)}}|";$replace[]=$event->content();
                break;
            case "{{DESCRIPTION}}":
                $search[] = "{{DESCRIPTION}}";
                $replace[] = $event->content();
                $blank[] = "";
                break;
            case "{{MANAGEMENT}}":
                $search[] = "{{MANAGEMENT}}";
                if ($view) {
                    ob_start();
                    $view->_viewNavAdminPanel();
                    $replace[] = ob_get_clean();
                } else {
                    $replace[] = "";
                }
                $blank[] = "";
                break;
            case "{{CATEGORY}}":
                $search[] = "{{CATEGORY}}";
                $replace[] = $event->catname();
                $blank[] = "";
                break;
            case "{{ALLCATEGORIES}}":
                $search[] = "{{ALLCATEGORIES}}";
                static $allcat_catids;
                if (!isset($allcat_catids)) {
                    $db = JFactory::getDBO();
                    $arr_catids = array();
                    $catsql = "SELECT cat.id, cat.title as name FROM #__categories  as cat WHERE cat.extension='com_jevents' ";
                    $db->setQuery($catsql);
                    $allcat_catids = $db->loadObjectList('id');
                }
                $db = JFactory::getDbo();
                $db->setQuery("Select catid from #__jevents_catmap  WHERE evid = " . $event->ev_id());
                $allcat_eventcats = $db->loadColumn();
                $allcats = array();
                foreach ($allcat_eventcats as $catid) {
                    if (isset($allcat_catids[$catid])) {
                        $allcats[] = $allcat_catids[$catid]->name;
                    }
                }
                $replace[] = implode(", ", $allcats);
                $blank[] = "";
                break;
            case "{{CALENDAR}}":
                $search[] = "{{CALENDAR}}";
                $replace[] = $event->getCalendarName();
                $blank[] = "";
                break;
            case "{{COLOUR}}":
            case "{{colour}}":
                $bgcolor = $event->bgcolor();
                $search[] = $strippedmatch;
                $replace[] = $bgcolor == "" ? "#ffffff" : $bgcolor;
                $blank[] = "";
                break;
            case "{{FGCOLOUR}}":
                $search[] = "{{FGCOLOUR}}";
                $replace[] = $event->fgcolor();
                $blank[] = "";
                break;
            case "{{TTTIME}}":
                $search[] = "{{TTTIME}}";
                $replace[] = "[[TTTIME]]";
                $blank[] = "";
                break;
            case "{{EVTTIME}}":
                $search[] = "{{EVTTIME}}";
                $replace[] = "[[EVTTIME]]";
                $blank[] = "";
                break;
            case "{{TOOLTIP}}":
                $search[] = "{{TOOLTIP}}";
                $replace[] = "[[TOOLTIP]]";
                $blank[] = "";
                break;
            case "{{CATEGORYLNK}}":
                $router = JRouter::getInstance("site");
                $catlinks = array();
                if ($jevparams->get("multicategory", 0)) {
                    $catids = $event->catids();
                    $catdata = $event->getCategoryData();
                } else {
                    $catids = array($event->catid());
                    $catdata = array($event->getCategoryData());
                }
                $vars = $router->getVars();
                foreach ($catids as $cat) {
                    $vars["catids"] = $cat;
                    $catname = "xxx";
                    foreach ($catdata as $cg) {
                        if ($cat == $cg->id) {
                            $catname = $cg->name;
                            break;
                        }
                    }
                    $eventlink = "index.php?";
                    foreach ($vars as $key => $val) {
                        // this is only used in the latest events module so do not perpetuate it here
                        if ($key == "filter_reset") {
                            continue;
                        }
                        if ($key == "task" && ($val == "icalrepeat.detail" || $val == "icalevent.detail")) {
                            $val = "week.listevents";
                        }
                        $eventlink .= $key . "=" . $val . "&";
                    }
                    $eventlink = substr($eventlink, 0, strlen($eventlink) - 1);
                    $eventlink = JRoute::_($eventlink);
                    $catlinks[] = '<a class="ev_link_cat" href="' . $eventlink . '"  title="' . JEventsHTML::special($catname) . '">' . $catname . '</a>';
                }
                $search[] = "{{CATEGORYLNK}}";
                $replace[] = implode(", ", $catlinks);
                $blank[] = "";
                break;
            case "{{CATEGORYIMG}}":
                $search[] = "{{CATEGORYIMG}}";
                $replace[] = $event->getCategoryImage();
                $blank[] = "";
                break;
            case "{{CATEGORYIMGS}}":
                $search[] = "{{CATEGORYIMGS}}";
                $replace[] = $event->getCategoryImage(true);
                $blank[] = "";
                break;
            case "{{CATDESC}}":
                $search[] = "{{CATDESC}}";
                $replace[] = $event->getCategoryDescription();
                $blank[] = "";
                break;
            case "{{CATID}}":
                $search[] = "{{CATID}}";
                $replace[] = $event->catid();
                $blank[] = "";
                break;
            case "{{PARENT_CATEGORY}}":
                $search[] = "{{PARENT_CATEGORY}}";
                $replace[] = $event->getParentCategory();
                $blank[] = "";
                break;
            case "{{ICALDIALOG}}":
            case "{{ICALBUTTON}}":
            case "{{EDITDIALOG}}":
            case "{{EDITBUTTON}}":
                static $styledone = false;
                if (!$styledone) {
                    $document = JFactory::getDocument();
                    $document->addStyleDeclaration("div.jevdialogs {position:relative;margin-top:35px;text-align:left;}\n div.jevdialogs img{float:none!important;margin:0px}");
                    $styledone = true;
                }
                if ($jevparams->get("showicalicon", 0) && !$jevparams->get("disableicalexport", 0)) {
                    JEVHelper::script('view_detail.js', 'components/' . JEV_COM_COMPONENT . "/assets/js/");
                    $cssloaded = true;
                    ob_start();
                    ?>
						<a href="javascript:void(0)" onclick='clickIcalButton()' title="<?php 
                    echo JText::_('JEV_SAVEICAL');
                    ?>
">
							<img src="<?php 
                    echo JURI::root() . 'components/' . JEV_COM_COMPONENT . '/assets/images/jevents_event_sml.png';
                    ?>
" name="image"  alt="<?php 
                    echo JText::_('JEV_SAVEICAL');
                    ?>
" class="jev_ev_sml nothumb"/>
						</a>
						<div class="jevdialogs">
						<?php 
                    $search[] = "{{ICALDIALOG}}";
                    if ($view) {
                        ob_start();
                        $view->eventIcalDialog($event, $mask);
                        $dialog = ob_get_clean();
                        $replace[] = $dialog;
                    } else {
                        $replace[] = "";
                    }
                    $blank[] = "";
                    echo $dialog;
                    ?>
						</div>

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

						<?php 
                    $search[] = "{{EDITBUTTON}}";
                    $replace[] = ob_get_clean();
                    $blank[] = "";
                } else {
                    $search[] = "{{EDITBUTTON}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{EDITDIALOG}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{CREATED}}":
                $compparams = JComponentHelper::getParams(JEV_COM_COMPONENT);
                $jtz = $compparams->get("icaltimezonelive", "");
                if ($jtz == "") {
                    $jtz = null;
                }
                $created = JevDate::getDate($event->created(), $jtz);
                $search[] = "{{CREATED}}";
                $replace[] = $created->toFormat(JText::_("DATE_FORMAT_CREATED"));
                $blank[] = "";
                break;
            case "{{ACCESS}}":
                $search[] = "{{ACCESS}}";
                $replace[] = $event->getAccessName();
                $blank[] = "";
                break;
            case "{{REPEATSUMMARY}}":
            case "{{STARTDATE}}":
            case "{{ENDDATE}}":
            case "{{STARTTIME}}":
            case "{{ENDTIME}}":
            case "{{STARTTZ}}":
            case "{{ENDTZ}}":
            case "{{ISOSTART}}":
            case "{{ISOEND}}":
            case "{{DURATION}}":
            case "{{MULTIENDDATE}}":
                if ($template_name == "icalevent.detail_body") {
                    $search[] = "{{REPEATSUMMARY}}";
                    $repeatsummary = $view->repeatSummary($event);
                    if (!$repeatsummary) {
                        $repeatsummary = $event->repeatSummary();
                    }
                    $replace[] = $repeatsummary;
                    //$replace[] = $event->repeatSummary();
                    $blank[] = "";
                    $row = $event;
                    $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                    $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                    $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                    $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                    $stop_time_midnightFix = $stop_time;
                    $stop_date_midnightFix = $stop_date;
                    if ($row->sdn() == 59 && $row->mindn() == 59) {
                        $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                        $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                    }
                    $search[] = "{{STARTDATE}}";
                    $replace[] = $start_date;
                    $blank[] = "";
                    $search[] = "{{ENDDATE}}";
                    $replace[] = $stop_date;
                    $blank[] = "";
                    $search[] = "{{STARTTIME}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTIME}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $search[] = "{{STARTTZ}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTZ}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                    $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                    $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime();
                    $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime();
                    $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                    $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                    $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $stop_date : "";
                    $search[] = "{{ISOSTART}}";
                    $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                    $blank[] = "";
                    $search[] = "{{ISOEND}}";
                    $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                    $blank[] = "";
                    $search[] = "{{MULTIENDDATE}}";
                    $replace[] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                    $blank[] = "";
                } else {
                    $row = $event;
                    $start_date = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), 0);
                    $start_time = JEVHelper::getTime($row->getUnixStartTime(), $row->hup(), $row->minup());
                    $stop_date = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), 0);
                    $stop_time = JEVHelper::getTime($row->getUnixEndTime(), $row->hdn(), $row->mindn());
                    $stop_time_midnightFix = $stop_time;
                    $stop_date_midnightFix = $stop_date;
                    if ($row->sdn() == 59 && $row->mindn() == 59) {
                        $stop_time_midnightFix = JEVHelper::getTime($row->getUnixEndTime() + 1, 0, 0);
                        $stop_date_midnightFix = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn() + 1, 0);
                    }
                    $search[] = "{{STARTDATE}}";
                    $replace[] = $start_date;
                    $blank[] = "";
                    $search[] = "{{ENDDATE}}";
                    $replace[] = $stop_date;
                    $blank[] = "";
                    $search[] = "{{STARTTIME}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTIME}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $search[] = "{{MULTIENDDATE}}";
                    $replace[] = $row->endDate() > $row->startDate() ? $stop_date : "";
                    $blank[] = "";
                    $search[] = "{{STARTTZ}}";
                    $replace[] = $row->alldayevent() ? "" : $start_time;
                    $blank[] = "";
                    $search[] = "{{ENDTZ}}";
                    $replace[] = $row->noendtime() || $row->alldayevent() ? "" : $stop_time_midnightFix;
                    $blank[] = "";
                    $rawreplace["{{STARTDATE}}"] = $row->getUnixStartDate();
                    $rawreplace["{{ENDDATE}}"] = $row->getUnixEndDate();
                    $rawreplace["{{STARTTIME}}"] = $row->getUnixStartTime();
                    $rawreplace["{{ENDTIME}}"] = $row->getUnixEndTime();
                    $rawreplace["{{STARTTZ}}"] = $row->yup() . "-" . $row->mup() . "-" . $row->dup() . " " . $row->hup() . ":" . $row->minup() . ":" . $row->sup();
                    $rawreplace["{{ENDTZ}}"] = $row->ydn() . "-" . $row->mdn() . "-" . $row->ddn() . " " . $row->hdn() . ":" . $row->mindn() . ":" . $row->sdn();
                    $rawreplace["{{MULTIENDDATE}}"] = $row->endDate() > $row->startDate() ? $row->getUnixEndDate() : "";
                    if (strpos($template_value, "{{ISOSTART}}") !== false || strpos($template_value, "{{ISOEND}}") !== false) {
                        $search[] = "{{ISOSTART}}";
                        $replace[] = JEventsHTML::getDateFormat($row->yup(), $row->mup(), $row->dup(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hup(), $row->minup());
                        $blank[] = "";
                        $search[] = "{{ISOEND}}";
                        $replace[] = JEventsHTML::getDateFormat($row->ydn(), $row->mdn(), $row->ddn(), "%Y-%m-%d") . "T" . sprintf('%02d:%02d:00', $row->hdn(), $row->mindn());
                        $blank[] = "";
                    }
                    // these would slow things down if not needed in the list
                    $dorepeatsummary = strpos($template_value, "{{REPEATSUMMARY}}") !== false;
                    if ($dorepeatsummary) {
                        $cfg = JEVConfig::getInstance();
                        $jevtask = JRequest::getString("jevtask");
                        $jevtask = str_replace(".listevents", "", $jevtask);
                        $showyeardate = $cfg->get("showyeardate", 0);
                        $row = $event;
                        $times = "";
                        if ($showyeardate && $jevtask == "year" || $jevtask == "search.results" || $jevtask == "month.calendar" || $jevtask == "cat" || $jevtask == "range") {
                            $start_publish = $row->getUnixStartDate();
                            $stop_publish = $row->getUnixEndDate();
                            if ($stop_publish == $start_publish) {
                                if ($row->noendtime()) {
                                    $times = $start_time;
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        if ($start_time != $stop_time) {
                                            $times = $start_time . ' - ' . $stop_time_midnightFix;
                                        } else {
                                            $times = $start_time;
                                        }
                                    }
                                }
                                $times = $start_date . " " . $times . "<br/>";
                            } else {
                                if ($row->noendtime()) {
                                    $times = $start_time;
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        if ($start_time != $stop_time && !$row->alldayevent()) {
                                            $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix;
                                        }
                                    }
                                }
                                $times = $start_date . ' - ' . $stop_date . " " . $times . "<br/>";
                            }
                        } else {
                            if (($jevtask == "day" || $jevtask == "week") && $row->starttime() != $row->endtime() && !$row->alldayevent()) {
                                if ($row->noendtime()) {
                                    if ($showyeardate && $jevtask == "year") {
                                        $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                    } else {
                                        $times = $start_time . '&nbsp;';
                                    }
                                } else {
                                    if ($row->alldayevent()) {
                                        $times = "";
                                    } else {
                                        $times = $start_time . '&nbsp;-&nbsp;' . $stop_time_midnightFix . '&nbsp;';
                                    }
                                }
                            }
                        }
                        $search[] = "{{REPEATSUMMARY}}";
                        $replace[] = $times;
                        $blank[] = "";
                    }
                }
                $search[] = "{{DURATION}}";
                $timedelta = $row->noendtime() ? "" : $row->getUnixEndTime() - $row->getUnixStartTime();
                if ($row->alldayevent()) {
                    $timedelta = $row->getUnixEndDate() - $row->getUnixStartDate() + 60 * 60 * 24;
                }
                $fieldval = JText::_("JEV_DURATION_FORMAT");
                $shownsign = false;
                // whole days!
                if (stripos($fieldval, "%wd") !== false) {
                    $days = intval($timedelta / (60 * 60 * 24));
                    $timedelta -= $days * 60 * 60 * 24;
                    if ($timedelta > 3610) {
                        //if more than 1 hour and 10 seconds over a day then round up the day output
                        $days += 1;
                    }
                    $fieldval = str_ireplace("%d", $days, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%d") !== false) {
                    $days = intval($timedelta / (60 * 60 * 24));
                    $timedelta -= $days * 60 * 60 * 24;
                    /*
                     if ($timedelta>3610){
                     //if more than 1 hour and 10 seconds over a day then round up the day output
                     $days +=1;
                     }
                    */
                    $fieldval = str_ireplace("%d", $days, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%h") !== false) {
                    $hours = intval($timedelta / (60 * 60));
                    $timedelta -= $hours * 60 * 60;
                    if ($shownsign) {
                        $hours = abs($hours);
                    }
                    $hours = sprintf("%02d", $hours);
                    $fieldval = str_ireplace("%h", $hours, $fieldval);
                    $shownsign = true;
                }
                if (stripos($fieldval, "%m") !== false) {
                    $mins = intval($timedelta / 60);
                    $timedelta -= $hours * 60;
                    if ($mins) {
                        $mins = abs($mins);
                    }
                    $mins = sprintf("%02d", $mins);
                    $fieldval = str_ireplace("%m", $mins, $fieldval);
                }
                $replace[] = $fieldval;
                $blank[] = "";
                break;
            case "{{PREVIOUSNEXT}}":
                static $doprevnext;
                if (!isset($doprevnext)) {
                    $doprevnext = strpos($template_value, "{{PREVIOUSNEXT}}") !== false;
                }
                if ($doprevnext) {
                    $search[] = "{{PREVIOUSNEXT}}";
                    $replace[] = $event->previousnextLinks();
                    $blank[] = "";
                }
                break;
            case "{{PREVIOUSNEXTEVENT}}":
                static $doprevnextevent;
                if (!isset($doprevnextevent)) {
                    $doprevnextevent = strpos($template_value, "{{PREVIOUSNEXTEVENT}}") !== false;
                }
                if ($doprevnextevent) {
                    $search[] = "{{PREVIOUSNEXTEVENT}}";
                    $replace[] = $event->previousnextEventLinks();
                    $blank[] = "";
                }
                break;
            case "{{FIRSTREPEAT}}":
            case "{{FIRSTREPEATSTART}}":
                static $dofirstrepeat;
                if (!isset($dofirstrepeat)) {
                    $dofirstrepeat = strpos($template_value, "{{FIRSTREPEAT}}") !== false || strpos($template_value, "{{FIRSTREPEATSTART}}") !== false;
                }
                if ($dofirstrepeat) {
                    $search[] = "{{FIRSTREPEAT}}";
                    $firstrepeat = $event->getFirstRepeat();
                    if ($firstrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = "<a class='ev_firstrepeat' href='" . $firstrepeat->viewDetailLink($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), true) . "' title='" . JText::_('JEV_FIRSTREPEAT') . "' >" . JText::_('JEV_FIRSTREPEAT') . "</a>";
                    }
                    $blank[] = "";
                    $search[] = "{{FIRSTREPEATSTART}}";
                    if ($firstrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = JEventsHTML::getDateFormat($firstrepeat->yup(), $firstrepeat->mup(), $firstrepeat->dup(), 0);
                        $rawreplace[] = $firstrepeat->yup() . "-" . $firstrepeat->mup() . "-" . $firstrepeat->dup() . " " . $firstrepeat->hup() . ":" . $firstrepeat->minup() . ":" . $firstrepeat->sup();
                    }
                    $blank[] = "";
                }
                break;
            case "{{LASTREPEAT}}":
            case "{{LASTREPEATEND}}":
                static $dolastrepeat;
                if (!isset($dolastrepeat)) {
                    $dolastrepeat = strpos($template_value, "{{LASTREPEAT}}") !== false || strpos($template_value, "{{LASTREPEATEND}}") !== false;
                }
                if ($dolastrepeat) {
                    $search[] = "{{LASTREPEAT}}";
                    $lastrepeat = $event->getLastRepeat();
                    if ($lastrepeat->rp_id() == $event->rp_id()) {
                        $replace[] = "";
                    } else {
                        $replace[] = "<a class='ev_lastrepeat' href='" . $lastrepeat->viewDetailLink($lastrepeat->yup(), $lastrepeat->mup(), $lastrepeat->dup(), true) . "' title='" . JText::_('JEV_LASTREPEAT') . "' >" . JText::_('JEV_LASTREPEAT') . "</a>";
                    }
                    $blank[] = "";
                    $search[] = "{{LASTREPEATEND}}";
                    if ($lastrepeat->rp_id() != $event->rp_id()) {
                        $replace[] = JEventsHTML::getDateFormat($lastrepeat->ydn(), $lastrepeat->mdn(), $lastrepeat->ddn(), 0);
                        $rawreplace[] = $lastrepeat->ydn() . "-" . $lastrepeat->mdn() . "-" . $lastrepeat->ddn() . " " . $lastrepeat->hdn() . ":" . $lastrepeat->mindn() . ":" . $lastrepeat->sdn();
                    } else {
                        $replace[] = "";
                    }
                    $blank[] = "";
                }
                break;
            case "{{CREATOR_LABEL}}":
                $search[] = "{{CREATOR_LABEL}}";
                $replace[] = JText::_('JEV_BY');
                $blank[] = "";
                break;
            case "{{CREATOR}}":
                $search[] = "{{CREATOR}}";
                $replace[] = $event->contactlink();
                $blank[] = "";
                break;
            case "{{HITS}}":
                $search[] = "{{HITS}}";
                $replace[] = "<span class='hitslabel'>" . JText::_('JEV_EVENT_HITS') . '</span> : ' . $event->hits();
                $blank[] = "";
                break;
            case "{{LOCATION_LABEL}}":
            case "{{LOCATION}}":
                if ($event->hasLocation()) {
                    $search[] = "{{LOCATION_LABEL}}";
                    $replace[] = JText::_('JEV_EVENT_ADRESSE') . "&nbsp;";
                    $blank[] = "";
                    $search[] = "{{LOCATION}}";
                    $replace[] = $event->location();
                    $blank[] = "";
                } else {
                    $search[] = "{{LOCATION_LABEL}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{LOCATION}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{CONTACT_LABEL}}":
            case "{{CONTACT}}":
                if ($event->hasContactInfo()) {
                    if (strpos($event->contact_info(), '<script') === false) {
                        $dispatcher = JDispatcher::getInstance();
                        JPluginHelper::importPlugin('content');
                        //Contact
                        $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/]';
                        if (strpos($event->contact_info(), '<a href=') === false && $event->contact_info() != "") {
                            $event->contact_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->contact_info()));
                        }
                        // NO need to call conContentPrepate since its called on the template value below here
                    }
                    $search[] = "{{CONTACT_LABEL}}";
                    $replace[] = JText::_('JEV_EVENT_CONTACT') . "&nbsp;";
                    $blank[] = "";
                    $search[] = "{{CONTACT}}";
                    $replace[] = $event->contact_info();
                    $blank[] = "";
                } else {
                    $search[] = "{{CONTACT_LABEL}}";
                    $replace[] = "";
                    $blank[] = "";
                    $search[] = "{{CONTACT}}";
                    $replace[] = "";
                    $blank[] = "";
                }
                break;
            case "{{EXTRAINFO}}":
                //Extra
                if (strpos($event->extra_info(), '<script') === false && $event->extra_info() != "") {
                    $dispatcher = JDispatcher::getInstance();
                    JPluginHelper::importPlugin('content');
                    $pattern = '[a-zA-Z0-9&?_.,=%\\-\\/#]';
                    if (strpos($event->extra_info(), '<a href=') === false) {
                        $event->extra_info(preg_replace('@(https?://)(' . $pattern . '*)@i', '<a href="\\1\\2">\\1\\2</a>', $event->extra_info()));
                    }
                    //$row->extra_info(eregi_replace('[^(href=|href="|href=\')](((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)','\\1', $row->extra_info()));
                    // NO need to call conContentPrepate since its called on the template value below here
                }
                $search[] = "{{EXTRAINFO}}";
                $replace[] = $event->extra_info();
                $blank[] = "";
                break;
            case "{{RPID}}":
                $search[] = "{{RPID}}";
                $replace[] = $event->rp_id();
                $blank[] = "";
                break;
            default:
                $strippedmatch = str_replace(array("{", "}"), "", $strippedmatch);
                if (is_callable(array($event, $strippedmatch))) {
                    $search[] = "{{" . $strippedmatch . "}}";
                    $replace[] = $event->{$strippedmatch}();
                    $blank[] = "";
                }
                break;
        }
    }
    // Now do the plugins
    // get list of enabled plugins
    $layout = $template_name == "icalevent.list_row" || $template_name == "month.calendar_cell" || $template_name == "month.calendar_tip" ? "list" : "detail";
    $jevplugins = JPluginHelper::getPlugin("jevents");
    foreach ($jevplugins as $jevplugin) {
        $classname = "plgJevents" . ucfirst($jevplugin->name);
        if (is_callable(array($classname, "substitutefield"))) {
            if (!isset($fieldNameArray[$classname])) {
                $fieldNameArray[$classname] = array();
            }
            if (!isset($fieldNameArray[$classname][$layout])) {
                //list($usec, $sec) = explode(" ", microtime());
                //$starttime = (float) $usec + (float) $sec;
                $fieldNameArray[$classname][$layout] = call_user_func(array($classname, "fieldNameArray"), $layout);
                //list ($usec, $sec) = explode(" ", microtime());
                //$time_end = (float) $usec + (float) $sec;
                //echo  "$classname::fieldNameArray = ".round($time_end - $starttime, 4)."<br/>";
            }
            if (isset($fieldNameArray[$classname][$layout]["values"])) {
                foreach ($fieldNameArray[$classname][$layout]["values"] as $fieldname) {
                    if (!strpos($template_value, $fieldname) !== false) {
                        continue;
                    }
                    $search[] = "{{" . $fieldname . "}}";
                    // is the event detail hidden - if so then hide any custom fields too!
                    if (!isset($event->_privateevent) || $event->_privateevent != 3) {
                        $replace[] = call_user_func(array($classname, "substitutefield"), $event, $fieldname);
                        if (is_callable(array($classname, "blankfield"))) {
                            $blank[] = call_user_func(array($classname, "blankfield"), $event, $fieldname);
                        } else {
                            $blank[] = "";
                        }
                    } else {
                        $blank[] = "";
                        $replace[] = "";
                    }
                }
            }
        }
    }
    // word counts etc.
    for ($s = 0; $s < count($search); $s++) {
        if (strpos($search[$s], "TRUNCATED_DESC:") > 0) {
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $replace[$s];
            $tempsearch = $search[$s];
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialHandling', $template_value);
        }
    }
    // Date/time formats etc.
    for ($s = 0; $s < count($search); $s++) {
        if (strpos($search[$s], "STARTDATE") > 0 || strpos($search[$s], "STARTTIME") > 0 || strpos($search[$s], "ENDDATE") > 0 || strpos($search[$s], "ENDTIME") > 0 || strpos($search[$s], "ENDTZ") > 0 || strpos($search[$s], "STARTTZ") > 0 || strpos($search[$s], "MULTIENDDATE") > 0 || strpos($search[$s], "FIRSTREPEATSTART") > 0 || strpos($search[$s], "LASTREPEATEND") > 0) {
            if (!isset($rawreplace[$search[$s]]) || !$rawreplace[$search[$s]]) {
                continue;
            }
            global $tempreplace, $tempevent, $tempsearch;
            $tempreplace = $rawreplace[$search[$s]];
            $tempsearch = str_replace("}}", ";.*?}}", $search[$s]);
            $tempevent = $event;
            $template_value = preg_replace_callback("|{$tempsearch}|", 'jevSpecialDateFormatting', $template_value);
        }
    }
    for ($s = 0; $s < count($search); $s++) {
        global $tempreplace, $tempevent, $tempsearch, $tempblank;
        $tempreplace = $replace[$s];
        $tempblank = $blank[$s];
        $tempsearch = str_replace("}}", "#", $search[$s]);
        $tempevent = $event;
        $template_value = preg_replace_callback("|{$tempsearch}(.+?)}}|", 'jevSpecialHandling2', $template_value);
    }
    $template_value = str_replace($search, $replace, $template_value);
    if ($specialmodules) {
        $reg = JRegistry::getInstance("com_jevents");
        $parts = explode("{{MODULESTART#", $template_value);
        $dynamicmodules = array();
        foreach ($parts as $part) {
            $currentdynamicmodules = $reg->get("dynamicmodules", false);
            if (strpos($part, "{{MODULEEND}}") === false) {
                // strip out BAD HTML tags left by WYSIWYG editors
                if (substr($part, strlen($part) - 3) == "<p>") {
                    $template_value = substr($part, 0, strlen($part) - 3);
                } else {
                    $template_value = $part;
                }
                continue;
            }
            // start with module name
            $modname = substr($part, 0, strpos($part, "}}"));
            $modulecontent = substr($part, strpos($part, "}}") + 2);
            $modulecontent = substr($modulecontent, 0, strpos($modulecontent, "{{MODULEEND}}"));
            // strip out BAD HTML tags left by WYSIWYG editors
            if (strpos($modulecontent, "</p>") === 0) {
                $modulecontent = "<p>x@#" . $modulecontent;
            }
            if (substr($modulecontent, strlen($modulecontent) - 3) == "<p>") {
                $modulecontent .= "x@#</p>";
            }
            $modulecontent = str_replace("<p>x@#</p>", "", $modulecontent);
            if (isset($currentdynamicmodules[$modname])) {
                if (!is_array($currentdynamicmodules[$modname])) {
                    $currentdynamicmodules[$modname] = array($currentdynamicmodules[$modname]);
                }
                $currentdynamicmodules[$modname][] = $modulecontent;
                $dynamicmodules[$modname] = $currentdynamicmodules[$modname];
            } else {
                $dynamicmodules[$modname] = $modulecontent;
            }
        }
        $reg->set("dynamicmodules", $dynamicmodules);
    }
    // non greedy replacement - because of the ?
    $template_value = preg_replace_callback('|{{.*?}}|', 'cleanUnpublished', $template_value);
    // replace [[ with { to that other content plugins can work ok - but not for calendar cell or tooltip since we use [[ there already!
    if ($template_name != "month.calendar_cell" && $template_name != "month.calendar_tip") {
        $template_value = str_replace(array("[[", "]]"), array("{", "}"), $template_value);
    }
    //We add new line characters again to avoid being marked as SPAM when using tempalte in emails
    // do this before content plugins incase they insert javascript etc.
    $template_value = preg_replace("@(<\\s*(br)*\\s*\\/\\s*(p|td|tr|table|div|ul|li|ol|dd|dl|dt)*\\s*>)+?@i", "\$1\n", $template_value);
    // Call content plugins - BUT because emailcloak doesn't identify emails in input fields to a text substitution
    $template_value = str_replace("@", "@£@", $template_value);
    $params = new JRegistry(null);
    $tmprow = new stdClass();
    $tmprow->text = $template_value;
    $tmprow->event = $event;
    $dispatcher = JDispatcher::getInstance();
    JPluginHelper::importPlugin('content');
    $dispatcher->trigger('onContentPrepare', array('com_jevents', &$tmprow, &$params, 0));
    $template_value = $tmprow->text;
    $template_value = str_replace("@£@", "@", $template_value);
    echo $template_value;
    return true;
}
コード例 #15
0
ファイル: category.php プロジェクト: madcsaba/li-de
    /**
     * Load method - our version MUST set the access level correctly for iCal exports!
     *
     * @param   integer  $id  Id of category to load
     *
     * @return  void
     *
     * @since   11.1
     */
    protected function _load($id)
    {
        $registry = JRegistry::getInstance("jevents");
        // need both paths for Joomla 2.5 and 3.0
        $puser = $registry->get("jevents.icaluser", $registry->get("icaluser", false));
        if (!$puser) {
            $this->_options['currentlang'] = 0;
            return parent::_load($id);
        }
        $db = JFactory::getDbo();
        $app = JFactory::getApplication();
        // overload permissions for iCal Export
        $user = $puser;
        $extension = $this->_extension;
        // Record that has this $id has been checked
        $this->_checkedCategories[$id] = true;
        $query = $db->getQuery(true);
        // Right join with c for category
        $query->select('c.*');
        $case_when = ' CASE WHEN ';
        $case_when .= $query->charLength('c.alias');
        $case_when .= ' THEN ';
        $c_id = $query->castAsChar('c.id');
        $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
        $case_when .= ' ELSE ';
        $case_when .= $c_id . ' END as slug';
        $query->select($case_when);
        $query->from('#__categories as c');
        $query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')');
        if ($this->_options['access']) {
            $query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')');
        }
        if ($this->_options['published'] == 1) {
            $query->where('c.published = 1');
        }
        $query->order('c.lft');
        // s for selected id
        if ($id != 'root') {
            // Get the selected category
            $query->where('s.id=' . (int) $id);
            if ($app->isSite() && $app->getLanguageFilter()) {
                $query->leftJoin('#__categories AS s ON (s.lft < c.lft AND s.rgt > c.rgt AND c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')) OR (s.lft >= c.lft AND s.rgt <= c.rgt)');
            } else {
                $query->leftJoin('#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)');
            }
        } else {
            if ($app->isSite() && $app->getLanguageFilter()) {
                $query->where('c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . $db->Quote('*') . ')');
            }
        }
        $subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' . 'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) . ' AND parent.published != 1 GROUP BY cat.id) ';
        $query->leftJoin($subQuery . 'AS badcats ON badcats.id = c.id');
        $query->where('badcats.id is null');
        // i for item
        if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1) {
            if ($this->_options['published'] == 1) {
                $query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1');
            } else {
                $query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id');
            }
            $query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems');
        }
        // Group by
        $query->group('c.id, c.asset_id, c.access, c.alias, c.checked_out, c.checked_out_time,
 			c.created_time, c.created_user_id, c.description, c.extension, c.hits, c.language, c.level,
		 	c.lft, c.metadata, c.metadesc, c.metakey, c.modified_time, c.note, c.params, c.parent_id,
 			c.path, c.published, c.rgt, c.title, c.modified_user_id');
        // Get the results
        $db->setQuery($query);
        $results = $db->loadObjectList('id');
        $childrenLoaded = false;
        if (count($results)) {
            // Foreach categories
            foreach ($results as $result) {
                // Deal with root category
                if ($result->id == 1) {
                    $result->id = 'root';
                }
                // Deal with parent_id
                if ($result->parent_id == 1) {
                    $result->parent_id = 'root';
                }
                // Create the node
                if (!isset($this->_nodes[$result->id])) {
                    // Create the JCategoryNode and add to _nodes
                    $this->_nodes[$result->id] = new JCategoryNode($result, $this);
                    // If this is not root and if the current node's parent is in the list or the current node parent is 0
                    if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1)) {
                        // Compute relationship between node and its parent - set the parent in the _nodes field
                        $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
                    }
                    // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0),
                    // then remove the node from the list
                    if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) {
                        unset($this->_nodes[$result->id]);
                        continue;
                    }
                    if ($result->id == $id || $childrenLoaded) {
                        $this->_nodes[$result->id]->setAllLoaded();
                        $childrenLoaded = true;
                    }
                } elseif ($result->id == $id || $childrenLoaded) {
                    // Create the JCategoryNode
                    $this->_nodes[$result->id] = new JCategoryNode($result, $this);
                    if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id)) {
                        // Compute relationship between node and its parent
                        $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]);
                    }
                    if (!isset($this->_nodes[$result->parent_id])) {
                        unset($this->_nodes[$result->id]);
                        continue;
                    }
                    if ($result->id == $id || $childrenLoaded) {
                        $this->_nodes[$result->id]->setAllLoaded();
                        $childrenLoaded = true;
                    }
                }
            }
        } else {
            $this->_nodes[$id] = null;
        }
    }
コード例 #16
0
ファイル: legend.php プロジェクト: poorgeek/JEvents
 function displayCalendarLegend($style = "list")
 {
     // do not display normal legend if dynamic legend is visible on this page
     $registry = JRegistry::getInstance("jevents");
     if ($registry->get("jevents.dynamiclegend", 0)) {
         return;
     }
     // since this is meant to be a comprehensive legend look for catids from menu first:
     $cfg = JEVConfig::getInstance();
     $Itemid = $this->myItemid;
     $user = JFactory::getUser();
     $db = JFactory::getDBO();
     // Parameters - This module should only be displayed alongside a com_jevents calendar component!!!
     $cfg = JEVConfig::getInstance();
     $option = JRequest::getCmd('option');
     if ($this->disable && $option != JEV_COM_COMPONENT) {
         return;
     }
     $catidList = "";
     include_once JPATH_ADMINISTRATOR . "/components/" . JEV_COM_COMPONENT . "/libraries/colorMap.php";
     $menu = JFactory::getApplication()->getMenu();
     $active = $menu->getActive();
     if (!is_null($active) && $active->component == JEV_COM_COMPONENT || !isset($Itemid)) {
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     } else {
         // If accessing this function from outside the component then I must load suitable parameters
         $params = $menu->getParams($Itemid);
     }
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $c = 0;
     $catids = array();
     // New system
     $newcats = $params->get("catidnew", false);
     if ($newcats && is_array($newcats)) {
         foreach ($newcats as $newcat) {
             if (!in_array($newcat, $catids)) {
                 $catids[] = $newcat;
                 $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $newcat;
             }
         }
     } else {
         while ($nextCatId = $params->get("catid{$c}", null)) {
             if (!in_array($nextCatId, $catids)) {
                 $catids[] = $nextCatId;
                 $catidList .= (JString::strlen($catidList) > 0 ? "," : "") . $nextCatId;
             }
             $c++;
         }
     }
     $jevleghelper = new modJeventsLegendHelper();
     if ($catidList == "" && $params->get("catid0", "xxx") == "xxx") {
         modJeventsLegendHelper::getAllCats($this->_params, $catids, $catidList);
     }
     $separator = $params->get("catseparator", "|");
     $catidsOut = str_replace(",", $separator, $catidList);
     // I should only show legend for items that **can** be shown in calendar so must filter based on GET/POST
     $catidsIn = JRequest::getVar('catids', "NONE");
     if ($catidsIn != "NONE" && $catidsIn != "0") {
         $catidsGP = explode($separator, $catidsIn);
     } else {
         $catidsGP = array();
     }
     $catidsGPList = implode(",", $catidsGP);
     // This produces a full tree of categories
     $allrows = $this->getCategoryHierarchy($catidList, $catidsGPList);
     // This is the full set of top level catids
     $availableCatsIds = "";
     foreach ($allrows as $row) {
         $availableCatsIds .= (JString::strlen($availableCatsIds) > 0 ? $separator : "") . $row->id;
     }
     $allcats = new catLegend("0", JText::_('JEV_LEGEND_ALL_CATEGORIES'), "#d3d3d3", JText::_('JEV_LEGEND_ALL_CATEGORIES_DESC'));
     $allcats->activeBranch = true;
     array_push($allrows, $allcats);
     if (count($allrows) == 0) {
         return "";
     } else {
         if ($Itemid < 999999) {
             $itm = "&Itemid={$Itemid}";
         }
         $task = JRequest::getVar('jevcmd', $cfg->get('com_startview'));
         list($year, $month, $day) = JEVHelper::getYMD();
         $tsk = "";
         if ($task == "month.calendar" || $task == "year.listeventsevents" || $task == "week.listevents" || $task == "year.listevents" || $task == "day.listevents" || $task == "cat.listevents") {
             $tsk = "&task={$task}&year={$year}&month={$month}&day={$day}";
         } else {
             $tsk = "&task={$this->myTask}&year={$year}&month={$month}&day={$day}";
         }
         switch ($style) {
             case 'list':
                 $content = '<div class="event_legend_container">';
                 $content .= '<table border="0" cellpadding="0" cellspacing="5" width="100%">';
                 foreach ($allrows as $row) {
                     if (isset($row->activeBranch)) {
                         $content .= $this->listKids($row, $itm, $tsk, $availableCatsIds);
                     }
                 }
                 $content .= "</table>\n";
                 $content .= "</div>";
                 break;
             case 'block':
             default:
                 $content = '<div class="event_legend_container">';
                 foreach ($allrows as $row) {
                     if (isset($row->activeBranch)) {
                         $content .= $this->blockKids($row, $itm, $tsk, $availableCatsIds);
                     }
                 }
                 // stop floating legend items
                 $content .= '<br style="clear:both" />' . "</div>\n";
         }
         // only if called from module
         if (isset($this->_params)) {
             if ($this->_params->get('show_admin', 0) && isset($year) && isset($month) && isset($day) && isset($Itemid)) {
                 // This is only displayed when JEvents is the component so I can get the component view
                 $component = JComponentHelper::getComponent(JEV_COM_COMPONENT);
                 $registry = JRegistry::getInstance("jevents");
                 $controller =& $registry->get("jevents.controller", null);
                 if (!$controller) {
                     return $content;
                 }
                 $view = $controller->view;
                 //include_once(JPATH_SITE."/components/$option/events.html.php");
                 ob_start();
                 if (method_exists($view, "_viewNavAdminPanel")) {
                     echo $view->_viewNavAdminPanel();
                 }
                 $content .= ob_get_contents();
                 ob_end_clean();
             }
         }
         return $content;
     }
 }
コード例 #17
0
ファイル: mod_jevents_filter.php プロジェクト: madcsaba/li-de
/**
 * JEvents Component for Joomla 1.5.x
 *
 * @version     $Id: mod_jevents_filter.php 941 2010-05-20 13:21:57Z geraintedwards $
 * @package     JEvents
 * @subpackage  Module JEvents Filter
 * @copyright   Copyright (C) 2008-2015 GWE Systems Ltd
 * @license     GNU/GPLv2, see http://www.gnu.org/licenses/gpl-2.0.html
 * @link        http://www.gwesystems.com
 */
defined('_JEXEC') or die('Restricted access');
require_once dirname(__FILE__) . '/' . 'helper.php';
// reset filters when viewed on non-JEvents page - make this a configurable option
$jevhelper = new modJeventsFilterHelper($params);
// record what is running - used by the filters
$registry = JRegistry::getInstance("jevents");
$registry->set("jevents.activeprocess", "mod_jevents_filter");
$registry->set("jevents.moduleid", $module->id);
$registry->set("jevents.moduleparams", $params);
$option = JRequest::getCmd("option");
if ($params->get("alwaystarget", 0) && $params->get("target_itemid", 0) > 0) {
    JFactory::getApplication()->setUserState("jevents.filtermenuitem", $params->get("target_itemid", 0));
} else {
    if ($option == "com_jevents") {
        $menu = JFactory::getApplication()->getMenu();
        $active = $menu->getActive();
        if ($active) {
            JFactory::getApplication()->setUserState("jevents.filtermenuitem", $active->id);
        }
    }
}
コード例 #18
0
/**
* @copyright	Copyright (C) 2015-2015 GWE Systems Ltd. All rights reserved.
 * @license		By negoriation with author via http://www.gwesystems.com
*/
function ProcessJsonRequest(&$requestObject, $returnData)
{
    //$file4 = JPATH_SITE . '/components/com_jevents/libraries/checkconflict.php';
    //if (JFile::exists($file4)) JFile::delete($file4);
    $returnData->allclear = 1;
    ini_set("display_errors", 0);
    $lang = JFactory::getLanguage();
    $lang->load("com_jevents", JPATH_SITE);
    $lang->load("com_jevents", JPATH_ADMINISTRATOR);
    include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
    $params = JComponentHelper::getParams("com_jevents");
    if (!$params->get("checkconflicts", 0)) {
        return $returnData;
    }
    // Do we ignore overlaps
    if (JEVHelper::isEventDeletor(true) && isset($requestObject->formdata->overlapoverride) && $requestObject->formdata->overlapoverride == 1) {
        return $returnData;
    }
    // Enforce referrer
    if (!$params->get("skipreferrer", 0)) {
        if (!array_key_exists("HTTP_REFERER", $_SERVER)) {
            PlgSystemGwejson::throwerror("There was an error - no referrer info available");
        }
        $live_site = $_SERVER['HTTP_HOST'];
        $ref_parts = parse_url($_SERVER["HTTP_REFERER"]);
        if (!isset($ref_parts["host"]) || $ref_parts["host"] . (isset($ref_parts["port"]) ? ':' . $ref_parts["port"] : '') != $live_site) {
            PlgSystemGwejson::throwerror("There was an error - missing host in referrer");
        }
    }
    if ($params->get("icaltimezonelive", "") != "" && is_callable("date_default_timezone_set") && $params->get("icaltimezonelive", "") != "") {
        $timezone = date_default_timezone_get();
        $tz = $params->get("icaltimezonelive", "");
        date_default_timezone_set($tz);
        $registry = JRegistry::getInstance("jevents");
        $registry->set("jevents.timezone", $timezone);
    }
    $token = JSession::getFormToken();
    if (!isset($requestObject->token) || strcmp($requestObject->token, $token) !== 0) {
        PlgSystemGwejson::throwerror("There was an error - bad token.  Please refresh the page and try again.");
    }
    $user = JFactory::getUser();
    if (!JEVHelper::isEventCreator()) {
        PlgSystemGwejson::throwerror("There was an error - not an event creator");
    }
    if (intval($requestObject->formdata->evid) > 0) {
        $db = JFactory::getDBO();
        $dataModel = new JEventsDataModel("JEventsAdminDBModel");
        $queryModel = new JEventsDBModel($dataModel);
        $event = $queryModel->getEventById(intval($requestObject->formdata->evid), 1, "icaldb");
        //$db->setQuery("SELECT * FROM #__jevents_vevent where ev_id=".intval($requestObject->formdata->evid));
        //	$event = $db->loadObject();
        if (!$event || !JEVHelper::canEditEvent($event)) {
            PlgSystemGwejson::throwerror("There was an error - cannot edit this event");
        }
    }
    $returnData->overlaps = array();
    if ($requestObject->pressbutton == "icalrepeat.apply" || $requestObject->pressbutton == "icalrepeat.save") {
        $testrepeat = simulateSaveRepeat($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkRepeatOverlaps($testrepeat, $returnData, intval($requestObject->formdata->evid), $requestObject);
    } else {
        $testevent = simulateSaveEvent($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkEventOverlaps($testevent, $returnData, intval($requestObject->formdata->evid), $requestObject);
    }
    if (count($overlaps) > 0) {
        $returnData->allclear = 0;
        foreach ($overlaps as $olp) {
            $overlap = new stdClass();
            $overlap->event_id = $olp->eventid;
            $overlap->eventdetail_id = $olp->eventdetail_id;
            $overlap->summary = $olp->summary;
            $overlap->rp_id = $olp->rp_id;
            $overlap->startrepeat = $olp->startrepeat;
            $overlap->endrepeat = $olp->endrepeat;
            list($y, $m, $d, $h, $m, $d) = sscanf($olp->startrepeat, "%d-%d-%d %d:%d:%d");
            $tstring = JText::_("JEV_OVERLAP_MESSAGE");
            $overlap->conflictMessage = sprintf($tstring, $olp->summary, JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->startrepeat)), JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->endrepeat)), $olp->conflictCause);
            $overlap->conflictMessage = addslashes($overlap->conflictMessage);
            $overlap->url = JURI::root() . "index.php?option=com_jevents&task=icalrepeat.detail&evid=" . $olp->rp_id . "&year={$y}&month={$m}&day={$d}";
            $overlap->url = str_replace("components/com_jevents/libraries/", "", $overlap->url);
            $returnData->overlaps[] = $overlap;
        }
    }
    if ($requestObject->error) {
        $returnData->allclear = 0;
        return "Error";
    }
    return $returnData;
}
コード例 #19
0
ファイル: helper.php プロジェクト: madcsaba/li-de
 public static function getBaseAccess()
 {
     // Store the ical in the registry so we can retrieve the access level
     $registry = JRegistry::getInstance("jevents");
     $icsfile = $registry->get("jevents.icsfile", false);
     if ($icsfile) {
         return $icsfile->access;
     }
     static $base;
     if (!isset($base)) {
         // NB this method is no use if you delete the public access level - it assumes that 1 always exists!!!
         //$levels = JAccess::getAuthorisedViewLevels(0);
         $levels = array();
         if (count($levels) > 0) {
             $base = $levels[0];
         } else {
             // Get a database object.
             $db = JFactory::getDBO();
             // Set the query for execution.
             $db->setQuery("SELECT id FROM #__viewlevels order by ordering limit 1");
             $base = $db->loadResult();
         }
     }
     return $base;
 }
コード例 #20
0
ファイル: iCalICSFile.php プロジェクト: madseller/coperio
 function newICSFileFromURL($uploadURL, $icsid, $catid, $access = 0, $state = 1, $label = "", $autorefresh = 0, $ignoreembedcat = 0)
 {
     $db =& JFactory::getDBO();
     $temp = new iCalICSFile($db);
     $temp->_setup($icsid, $catid, $access, $state, $autorefresh, $ignoreembedcat);
     if ($access == 0) {
         $temp->access = intval(JEVHelper::getBaseAccess());
     }
     $urlParts = parse_url($uploadURL);
     $pathParts = pathinfo($urlParts['path']);
     /*
     if (isset($pathParts['basename'])) $temp->filename =  $pathParts['basename'];
     else $temp->filename = $uploadURL;
     */
     $temp->filename = 'Remote-' . md5($uploadURL);
     $temp->icaltype = 0;
     // i.e. from URL
     if ($label != "") {
         $temp->label = $label;
     } else {
         $temp->label = $temp->filename;
     }
     $temp->srcURL = $uploadURL;
     // Store the ical in the registry so we can retrieve the access level
     $registry =& JRegistry::getInstance("jevents");
     $registry->setValue("jevents.icsfile", $temp);
     if (false === ($temp->_icalInfo =& JEVHelper::iCalInstance($uploadURL))) {
         return false;
     }
     return $temp;
 }
コード例 #21
0
ファイル: datamodel.php プロジェクト: hriggs/cs-website
 function setupComponentCatids()
 {
     // if no catids from GET or POST default to the menu values
     // Note that module links must pass a non default value
     $Itemid = JEVHelper::getItemid();
     $this->myItemid = $Itemid;
     $menu = JFactory::getApplication()->getMenu();
     $active = $menu->getActive();
     if (!is_null($active) && $active->component == JEV_COM_COMPONENT) {
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     } else {
         // If accessing this function from outside the component then I must load suitable parameters
         // We may be calling from a Jevents module so we should use the target menu item if available
         $registry = JRegistry::getInstance("jevents");
         $moduleparams = $registry->get("jevents.moduleparams", false);
         $moduleid = $registry->get("jevents.moduleid", "");
         if ($moduleparams && $moduleparams->get("target_itemid", 0) > 0 && $moduleid) {
             $menuitem = $menu->getItem($moduleparams->get("target_itemid", 0));
             if (!is_null($menuitem) && $menuitem->component == JEV_COM_COMPONENT) {
                 $this->myItemid = $moduleparams->get("target_itemid", 0);
             }
         }
         $params = $menu->getParams($this->myItemid);
     }
     $separator = $params->get("catseparator", "|");
     $catidsIn = JRequest::getVar('catids', 'NONE');
     if ($catidsIn == "NONE" || $catidsIn == 0) {
         $catidsIn = JRequest::getVar('category_fv', 'NONE');
     }
     // set menu/module constraint values for later use
     $this->mmcatids = array();
     // New system
     $newcats = $params->get("catidnew", false);
     if ($newcats && is_array($newcats)) {
         foreach ($newcats as $newcat) {
             if (!in_array($newcat, $this->mmcatids)) {
                 $this->mmcatids[] = $newcat;
             }
         }
     } else {
         for ($c = 0; $c < 999; $c++) {
             $nextCID = "catid{$c}";
             //  stop looking for more catids when you reach the last one!
             if (!($nextCatId = $params->get($nextCID, null))) {
                 break;
             }
             if (!in_array($nextCatId, $this->mmcatids)) {
                 $this->mmcatids[] = $nextCatId;
             }
         }
     }
     $this->mmcatidList = implode(",", $this->mmcatids);
     // if resettting then always reset to module/menu value
     if (intval(JRequest::getVar('filter_reset', 0))) {
         $this->catids = $this->mmcatids;
         $this->catidList = $this->mmcatidList;
     } else {
         $this->catids = array();
         if ($catidsIn == "NONE" || $catidsIn == 0) {
             $this->catidList = "";
             // New system
             $newcats = $params->get("catidnew", false);
             if ($newcats && is_array($newcats)) {
                 foreach ($newcats as $newcat) {
                     if (!in_array($newcat, $this->catids)) {
                         $this->catids[] = $newcat;
                     }
                 }
             } else {
                 for ($c = 0; $c < 999; $c++) {
                     $nextCID = "catid{$c}";
                     //  stop looking for more catids when you reach the last one!
                     if (!($nextCatId = $params->get($nextCID, null))) {
                         break;
                     }
                     if (!in_array($nextCatId, $this->catids)) {
                         $this->catids[] = $nextCatId;
                     }
                 }
             }
             $this->catidList = implode(",", $this->catids);
             // no need to set catidsOut for menu item since the menu item knows this information already!
             //$this->catidsOut = str_replace( ',', $separator, $this->catidList );
         } else {
             $this->catids = explode($separator, $catidsIn);
             // hardening!
             $this->catidList = JEVHelper::forceIntegerArray($this->catids, true);
             $this->catidsOut = str_replace(',', $separator, $this->catidList);
         }
     }
     // some functions e.g. JEventCal::viewDetailLink don't have access to a datamodel so set a global value
     // as a backup
     global $catidsOut;
     $catidsOut = $this->catidsOut;
 }
コード例 #22
0
ファイル: icals.php プロジェクト: madseller/coperio
 function export()
 {
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     if ($params->get("disableicalexport", 0)) {
         JError::raiseError(403, JText::_('ALERTNOTAUTH'));
     }
     $years = JRequest::getVar('years', 'NONE');
     $cats = JRequest::getVar('catids', 'NONE');
     // validate the key
     $icalkey = $params->get("icalkey", "secret phrase");
     $outlook2003icalexport = JRequest::getInt("outlook2003", 0) && $params->get("outlook2003icalexport", 0);
     if ($outlook2003icalexport) {
         JRequest::setVar("icf", 1);
     }
     $privatecalendar = false;
     $k = JRequest::getString("k", "NONE");
     $pk = JRequest::getString("pk", "NONE");
     $userid = JRequest::getInt("i", 0);
     if ($pk != "NONE") {
         if (!$userid) {
             JError::raiseError(403, "JEV_ERROR");
         }
         $privatecalendar = true;
         $puser = JUser::getInstance($userid);
         $key = md5($icalkey . $cats . $years . $puser->password . $puser->username . $puser->id);
         if ($key != $pk) {
             JError::raiseError(403, "JEV_ERROR");
         }
         if (JVersion::isCompatible("1.6.0")) {
             // ensure "user" can access non-public categories etc.
             $this->dataModel->aid = JEVHelper::getAid($puser);
             $this->dataModel->accessuser = $puser->get('id');
         } else {
             // Get an ACL object
             $acl =& JFactory::getACL();
             // Get the user group from the ACL
             $grp = $acl->getAroGroup($puser->get('id'));
             //Mark the user as logged in
             $puser->set('guest', 0);
             $puser->set('aid', 1);
             // Fudge Authors, Editors, Publishers and Super Administrators into the special access group
             if ($acl->is_group_child_of($grp->name, 'Registered') || $acl->is_group_child_of($grp->name, 'Public Backend')) {
                 $puser->set('aid', 2);
             }
             // ensure "user" can access non-public categories etc.
             $this->dataModel->aid = $puser->aid;
             $this->dataModel->accessuser = $puser->get('id');
         }
         $registry =& JRegistry::getInstance("jevents");
         $registry->setValue("jevents.icaluser", $puser);
     } else {
         if ($k != "NONE") {
             $key = md5($icalkey . $cats . $years);
             if ($key != $k) {
                 JError::raiseError(403, "JEV_ERROR");
             }
         } else {
             JError::raiseError(403, "JEV_ERROR");
         }
     }
     // Fix the cats
     $cats = explode(',', $cats);
     // hardening!
     JEVHelper::forceIntegerArray($cats, false);
     if ($cats != array(0)) {
         JRequest::setVar("catids", implode("|", $cats));
     } else {
         JRequest::setVar("catids", '');
     }
     //Parsing variables from URL
     //Year
     // All years
     if ($years == 0) {
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         $years = array();
         for ($y = $params->get("com_earliestyear", date('Y')); $y <= $params->get("com_latestyear", date('Y')); $y++) {
             if (!in_array($y, $years)) {
                 $years[] = $y;
             }
         }
         JArrayHelper::toInteger($years);
     } else {
         if ($years != "NONE") {
             $years = explode(",", JRequest::getVar('years'));
             if (!is_array($years) || count($years) == 0) {
                 list($y, $m, $d) = JEVHelper::getYMD();
                 $years = array($y);
             }
             JArrayHelper::toInteger($years);
         } else {
             list($y, $m, $d) = JEVHelper::getYMD();
             $years = array($y);
         }
     }
     // Lockin hte categories from the URL
     $this->dataModel->setupComponentCatids();
     $dispatcher =& JDispatcher::getInstance();
     // just incase we don't have jevents plugins registered yet
     JPluginHelper::importPlugin("jevents");
     //And then the real work
     // Force all only the one repeat
     $cfg =& JEVConfig::getInstance();
     $cfg->set('com_showrepeats', 0);
     $icalEvents = array();
     foreach ($years as $year) {
         $startdate = $year . "-01-01";
         $enddate = $year . "-12-31";
         $rows = $this->dataModel->getRangeData($startdate, $enddate, 0, 0);
         if (!isset($rows["rows"])) {
             continue;
         }
         foreach ($rows["rows"] as $row) {
             if (!array_key_exists($row->ev_id(), $icalEvents)) {
                 $dispatcher->trigger('onExportRow', array(&$row));
                 $icalEvents[$row->ev_id()] = $row;
             }
         }
         unset($rows);
     }
     if ($userid) {
         $user = JUser::getInstance($userid);
     }
     $mainframe = JFactory::getApplication();
     // get the view
     $this->view =& $this->getView("icals", "html");
     $this->view->setLayout("export");
     $this->view->assign("dataModel", $this->dataModel);
     $this->view->assign("outlook2003icalexport", $outlook2003icalexport);
     $this->view->assign("icalEvents", $icalEvents);
     $this->view->export();
     return;
 }
コード例 #23
0
 /**
  * Test the JRegistry::getInstance method.
  *
  * @covers  JRegistry::getInstance
  *
  * @return void
  */
 public function testGetInstance()
 {
     // Test INI format.
     $a = JRegistry::getInstance('a');
     $b = JRegistry::getInstance('a');
     $c = JRegistry::getInstance('c');
     // Check the object type.
     $this->assertThat($a instanceof JRegistry, $this->isTrue(), 'Line: ' . __LINE__ . '.');
     // Check cache handling for same registry id.
     $this->assertThat($a, $this->identicalTo($b), 'Line: ' . __LINE__ . '.');
     // Check cache handling for different registry id.
     $this->assertThat($a, $this->logicalNot($this->identicalTo($c)), 'Line: ' . __LINE__ . '.');
 }
コード例 #24
0
ファイル: dbmodel.php プロジェクト: madseller/coperio
 function listIcalEventsByRange($startdate, $enddate, $limitstart, $limit, $showrepeats = true, $order = "rpt.startrepeat asc, rpt.endrepeat ASC, det.summary ASC", $filters = false, $extrafields = "", $extratables = "", $count = false)
 {
     list($year, $month, $day) = explode('-', $startdate);
     list($thisyear, $thismonth, $thisday) = JEVHelper::getYMD();
     //$startdate 	= $this->cfg->getValue("showyearpast",1)?JevDate::mktime( 0, 0, 0, intval($month),intval($day),intval($year) ):JevDate::mktime( 0, 0, 0, $thismonth,$thisday, $thisyear );
     $startdate = JevDate::mktime(0, 0, 0, intval($month), intval($day), intval($year));
     $startdate = JevDate::strftime('%Y-%m-%d', $startdate);
     if (strlen($startdate) == 10) {
         $startdate .= " 00:00:00";
     }
     if (strlen($enddate) == 10) {
         $enddate .= " 23:59:59";
     }
     // This code is used by the iCals code with a spoofed user so check if this is what is happening
     if (JRequest::getString("jevtask", "") == "icals.export") {
         $registry =& JRegistry::getInstance("jevents");
         $user = $registry->getValue("jevents.icaluser", false);
         if (!$user) {
             $user = JFactory::getUser();
         }
     } else {
         $user = JFactory::getUser();
     }
     $db = JFactory::getDBO();
     $lang =& JFactory::getLanguage();
     $langtag = $lang->getTag();
     // process the new plugins
     // get extra data and conditionality from plugins
     $extrawhere = array();
     $extrajoin = array();
     $extrafields = "";
     // must have comma prefix
     $needsgroup = false;
     if (!$filters) {
         $filters = jevFilterProcessing::getInstance(array("published", "justmine", "category", "search"));
         $filters->setWhereJoin($extrawhere, $extrajoin);
         $needsgroup = $filters->needsGroupBy();
         $dispatcher =& JDispatcher::getInstance();
         $dispatcher->trigger('onListIcalEvents', array(&$extrafields, &$extratables, &$extrawhere, &$extrajoin, &$needsgroup));
     } else {
         $filters->setWhereJoin($extrawhere, $extrajoin);
     }
     $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) : '';
     // This version picks the details from the details table
     if ($count) {
         $query = "SELECT count(distinct rpt.rp_id)";
     } else {
         $query = "SELECT ev.*, rpt.*, rr.*, det.*, ev.state as published {$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";
     }
     $query .= "\n FROM #__jevents_repetition as rpt" . "\n LEFT JOIN #__jevents_vevent as ev ON rpt.eventid = ev.ev_id" . "\n LEFT JOIN #__jevents_icsfile as icsf ON icsf.ics_id=ev.icsid " . "\n LEFT JOIN #__jevents_vevdetail as det ON det.evdet_id = rpt.eventdetail_id" . "\n LEFT JOIN #__jevents_rrule as rr ON rr.eventid = rpt.eventid" . $extrajoin . $catwhere . "\n AND rpt.endrepeat >= '{$startdate}' AND rpt.startrepeat <= '{$enddate}'" . "\n AND NOT (rpt.startrepeat < '{$startdate}' AND det.multiday=0) " . $extrawhere . "\n AND ev.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user)) . "  AND icsf.state=1 AND icsf.access " . (version_compare(JVERSION, '1.6.0', '>=') ? ' IN (' . JEVHelper::getAid($user) . ')' : ' <=  ' . JEVHelper::getAid($user));
     if (!$showrepeats && !$count) {
         $query .= "\n GROUP BY ev.ev_id";
     } else {
         if ($needsgroup && !$count) {
             $query .= "\n GROUP BY rpt.rp_id";
         }
     }
     if ($order != "") {
         $query .= " ORDER BY " . $order;
     }
     if ($limit != "" && $limit != 0) {
         $query .= " LIMIT " . ($limitstart != "" ? $limitstart . "," : "") . $limit;
     }
     if ($count) {
         $db =& JFactory::getDBO();
         $db->setQuery($query);
         $res = $db->loadResult();
         return $res;
     }
     $cache =& JFactory::getCache(JEV_COM_COMPONENT);
     $rows = $cache->call('JEventsDBModel::_cachedlistIcalEvents', $query, $langtag, $count);
     $dispatcher =& JDispatcher::getInstance();
     $dispatcher->trigger('onDisplayCustomFieldsMultiRowUncached', array(&$rows));
     return $rows;
 }
コード例 #25
0
ファイル: icals.php プロジェクト: poorgeek/JEvents
 function export()
 {
     $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
     $years = JRequest::getVar('years', 'NONE');
     $cats = JRequest::getVar('catids', 'NONE');
     // validate the key
     $icalkey = $params->get("icalkey", "secret phrase");
     $outlook2003icalexport = JRequest::getInt("outlook2003", 0) && $params->get("outlook2003icalexport", 0);
     if ($outlook2003icalexport) {
         JRequest::setVar("icf", 1);
     }
     $privatecalendar = false;
     $k = JRequest::getString("k", "NONE");
     $pk = JRequest::getString("pk", "NONE");
     $userid = JRequest::getInt("i", 0);
     if ($pk != "NONE") {
         if (!$userid) {
             throw new Exception(JText::_('JEV_ERROR'), 403);
             return false;
         }
         $privatecalendar = true;
         $puser = JUser::getInstance($userid);
         $key = md5($icalkey . $cats . $years . $puser->password . $puser->username . $puser->id);
         if ($key != $pk) {
             throw new Exception(JText::_('JEV_ERROR'), 403);
             return false;
         }
         // ensure "user" can access non-public categories etc.
         $this->dataModel->aid = JEVHelper::getAid($puser);
         $this->dataModel->accessuser = $puser->get('id');
         $registry = JRegistry::getInstance("jevents");
         $registry->set("jevents.icaluser", $puser);
     } else {
         if ($k != "NONE") {
             if ($params->get("disableicalexport", 0)) {
                 throw new Exception(JText::_('ALERTNOTAUTH'), 403);
                 return false;
             }
             $key = md5($icalkey . $cats . $years);
             if ($key != $k) {
                 throw new Exception(JText::_('JEV_ERROR'), 403);
                 return false;
             }
         } else {
             throw new Exception(JText::_('JEV_ERROR'), 403);
             return false;
         }
     }
     // Fix the cats
     $cats = explode(',', $cats);
     // hardening!
     JEVHelper::forceIntegerArray($cats, false);
     if ($cats != array(0)) {
         JRequest::setVar("catids", implode("|", $cats));
     } else {
         JRequest::setVar("catids", '');
     }
     //Parsing variables from URL
     //Year
     // All years
     if ($years == 0) {
         $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
         $years = array();
         for ($y = JEVHelper::getMinYear(); $y <= JEVHelper::getMaxYear(); $y++) {
             if (!in_array($y, $years)) {
                 $years[] = $y;
             }
         }
         JArrayHelper::toInteger($years);
     } else {
         if ($years != "NONE") {
             $years = explode(",", JRequest::getVar('years'));
             if (!is_array($years) || count($years) == 0) {
                 list($y, $m, $d) = JEVHelper::getYMD();
                 $years = array($y);
             }
             JArrayHelper::toInteger($years);
         } else {
             list($y, $m, $d) = JEVHelper::getYMD();
             $years = array($y);
         }
     }
     // Lockin hte categories from the URL
     $Itemid = JRequest::getInt("Itemid", 0);
     if (!$Itemid) {
         JRequest::setVar("Itemid", 1);
     }
     $this->dataModel->setupComponentCatids();
     $dispatcher = JDispatcher::getInstance();
     // just incase we don't have jevents plugins registered yet
     JPluginHelper::importPlugin("jevents");
     //And then the real work
     // Force all only the one repeat
     $cfg = JEVConfig::getInstance();
     $cfg->set('com_showrepeats', 0);
     $icalEvents = array();
     foreach ($years as $year) {
         $startdate = $year . "-01-01";
         $enddate = $year . "-12-31";
         $rows = $this->dataModel->getRangeData($startdate, $enddate, 0, 0);
         if (!isset($rows["rows"])) {
             continue;
         }
         foreach ($rows["rows"] as $row) {
             if (!array_key_exists($row->ev_id(), $icalEvents)) {
                 $dispatcher->trigger('onExportRow', array(&$row));
                 $icalEvents[$row->ev_id()] = $row;
             }
         }
         unset($rows);
     }
     if ($userid) {
         $user = JUser::getInstance($userid);
     }
     $mainframe = JFactory::getApplication();
     // get the view
     $this->view = $this->getView("icals", "html");
     $this->view->setLayout("export");
     $this->view->assign("dataModel", $this->dataModel);
     $this->view->assign("outlook2003icalexport", $outlook2003icalexport);
     $this->view->assign("icalEvents", $icalEvents);
     $this->view->assign("withrepeats", true);
     $this->view->export();
     return;
 }
コード例 #26
0
ファイル: iCalICSFile.php プロジェクト: hriggs/cs-website
 public static function newICSFileFromURL($uploadURL, $icsid, $catid, $access = 0, $state = 1, $label = "", $autorefresh = 0, $ignoreembedcat = 0)
 {
     $db = JFactory::getDBO();
     $temp = new iCalICSFile($db);
     $temp->_setup($icsid, $catid, $access, $state, $autorefresh, $ignoreembedcat);
     if ($access == 0) {
         $temp->access = intval(JEVHelper::getBaseAccess());
     }
     if (false !== stripos($uploadURL, 'webcal://')) {
         $headers = @get_headers($uploadURL);
         if ($headers && $headers[0] == 'HTTP/1.1 200 OK') {
             $uploadURL = $uploadURL;
         } else {
             $headers = get_headers(str_replace('webcal://', 'https://', $uploadURL));
             if ($headers && $headers[0] == 'HTTP/1.1 200 OK') {
                 $uploadURL = str_replace('webcal://', 'https://', $uploadURL);
             } else {
                 $uploadURL = str_replace('webcal://', 'http://', $uploadURL);
             }
         }
     }
     $urlParts = parse_url($uploadURL);
     $pathParts = pathinfo($urlParts['path']);
     /*
     if (isset($pathParts['basename'])) $temp->filename =  $pathParts['basename'];
     else $temp->filename = $uploadURL;
     */
     $temp->filename = 'Remote-' . md5($uploadURL);
     $temp->icaltype = 0;
     // i.e. from URL
     if ($label != "") {
         $temp->label = $label;
     } else {
         $temp->label = $temp->filename;
     }
     $temp->srcURL = $uploadURL;
     // Store the ical in the registry so we can retrieve the access level
     $registry = JRegistry::getInstance("jevents");
     $registry->set("jevents.icsfile", $temp);
     if (false === ($temp->_icalInfo = JEVHelper::iCalInstance($uploadURL))) {
         return false;
     }
     return $temp;
 }
コード例 #27
0
function createConfig()
{
    $db = DBHelper::db();
    $config = JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_easyblog' . DS . 'configuration.ini';
    $raw = JFile::read($config);
    $version = getJoomlaVersion();
    $registry = JRegistry::getInstance('eblog');
    if ($version >= '1.6') {
        $registry->loadString($raw);
    } else {
        $registry->loadINI($raw, '');
    }
    $obj = new stdClass();
    $obj->name = 'config';
    $obj->params = $registry->toString('INI', 'eblog');
    return $db->insertObject('#__easyblog_configs', $obj);
}
コード例 #28
0
ファイル: rule.php プロジェクト: angelexevior/jedchecker
 /**
  * Attempts to load a .ini param file of this rule.
  *
  * @return    JRegistry
  */
 protected function loadParams()
 {
     // Try to determine the name and location of the params file
     $file_name = str_replace('jedcheckerrules', '', strtolower(get_class($this)));
     $params_file = JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/' . $file_name . '.ini';
     $params = JRegistry::getInstance('jedchecker.rule.' . $file_name);
     // Load the params from the ini file
     if (file_exists($params_file)) {
         // Due to a bug in Joomla 2.5.6, this method cannot be used
         // $params->loadFile($params_file, 'INI');
         // Get the contents of the file
         $data = file_get_contents($params_file);
         if ($data) {
             $obj = (object) parse_ini_string($data);
             if (is_object($obj)) {
                 $params->loadObject($obj);
             }
         }
     }
     return $params;
 }
コード例 #29
0
function ProcessRequest(&$requestObject, $returnData)
{
    define("REQUESTOBJECT", serialize($requestObject));
    define("RETURNDATA", serialize($returnData));
    require_once JPATH_BASE . DS . 'includes' . DS . 'defines.php';
    require_once JPATH_BASE . DS . 'includes' . DS . 'framework.php';
    $requestObject = unserialize(REQUESTOBJECT);
    $returnData = unserialize(RETURNDATA);
    $returnData->allclear = 1;
    ini_set("display_errors", 0);
    global $option;
    $client = "site";
    if (isset($requestObject->client) && in_array($requestObject->client, array("site", "administrator"))) {
        $client = $requestObject->client;
    }
    $mainframe = JFactory::getApplication($client);
    JFactory::getApplication()->initialise();
    $option = "com_jevents";
    // Not sure why this is needed but it is if (use use $mainframe =& JFactory::getApplication($client); )!!!
    // needed for Joomla 1.5 plugins
    $GLOBALS['mainframe'] = $mainframe;
    $lang =& JFactory::getLanguage();
    $lang->load("com_jevents", JPATH_SITE);
    $lang->load("com_jevents", JPATH_ADMINISTRATOR);
    include_once JPATH_SITE . "/components/com_jevents/jevents.defines.php";
    $params =& JComponentHelper::getParams("com_jevents");
    if (!$params->get("checkclashes", 0) && !$params->get("noclashes", 0)) {
        return $returnData;
    }
    // Enforce referrer
    if (!$params->get("skipreferrer", 0)) {
        if (!array_key_exists("HTTP_REFERER", $_SERVER)) {
            throwerror("There was an error");
        }
        $live_site = $_SERVER['HTTP_HOST'];
        $ref_parts = parse_url($_SERVER["HTTP_REFERER"]);
        if (!isset($ref_parts["host"]) || $ref_parts["host"] . (isset($ref_parts["port"]) ? ':' . $ref_parts["port"] : '') != $live_site) {
            throwerror("There was an error - missing host in referrer");
        }
    }
    if ($params->get("icaltimezonelive", "") != "" && is_callable("date_default_timezone_set") && $params->get("icaltimezonelive", "") != "") {
        $timezone = date_default_timezone_get();
        $tz = $params->get("icaltimezonelive", "");
        date_default_timezone_set($tz);
        $registry =& JRegistry::getInstance("jevents");
        $registry->setValue("jevents.timezone", $timezone);
    }
    $token = JUtility::getToken();
    if (!isset($requestObject->token) || $requestObject->token != $token) {
        throwerror("There was an error - bad token.  Please refresh the page and try again.");
    }
    $user = JFactory::getUser();
    if (!JEVHelper::isEventCreator()) {
        throwerror("There was an error");
    }
    if (intval($requestObject->formdata->evid) > 0) {
        $db = JFactory::getDBO();
        $dataModel = new JEventsDataModel("JEventsAdminDBModel");
        $queryModel = new JEventsDBModel($dataModel);
        $event = $queryModel->getEventById(intval($requestObject->formdata->evid), 1, "icaldb");
        //$db->setQuery("SELECT * FROM #__jevents_vevent where ev_id=".intval($requestObject->formdata->evid));
        //	$event = $db->loadObject();
        if (!$event || !JEVHelper::canEditEvent($event)) {
            throwerror("There was an error");
        }
    }
    $returnData->overlaps = array();
    if ($requestObject->pressbutton == "icalrepeat.apply" || $requestObject->pressbutton == "icalrepeat.save") {
        $testrepeat = simulateSaveRepeat($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkRepeatOverlaps($testrepeat, $returnData, intval($requestObject->formdata->evid), $requestObject);
    } else {
        $testevent = simulateSaveEvent($requestObject);
        // now we have out event and its repetitions we now check to see for overlapping events
        $overlaps = checkEventOverlaps($testevent, $returnData, intval($requestObject->formdata->evid), $requestObject);
    }
    if (count($overlaps) > 0) {
        $returnData->allclear = 0;
        foreach ($overlaps as $olp) {
            $overlap = new stdClass();
            $overlap->event_id = $olp->eventid;
            $overlap->eventdetail_id = $olp->eventdetail_id;
            $overlap->summary = $olp->summary;
            $overlap->rp_id = $olp->rp_id;
            $overlap->startrepeat = $olp->startrepeat;
            $overlap->endrepeat = $olp->endrepeat;
            list($y, $m, $d, $h, $m, $d) = sscanf($olp->startrepeat, "%d-%d-%d %d:%d:%d");
            $tstring = JText::_("JEV_OVERLAP_MESSAGE");
            $overlap->conflictMessage = sprintf($tstring, $olp->summary, JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->startrepeat)), JEV_CommonFunctions::jev_strftime(JText::_("DATE_FORMAT_4"), JevDate::strtotime($olp->endrepeat)), $olp->conflictCause);
            $overlap->conflictMessage = addslashes($overlap->conflictMessage);
            $overlap->url = JURI::root() . "index.php?option=com_jevents&task=icalrepeat.detail&evid=" . $olp->rp_id . "&year={$y}&month={$m}&day={$d}";
            $overlap->url = str_replace("components/com_jevents/libraries/", "", $overlap->url);
            $returnData->overlaps[] = $overlap;
        }
    }
    if ($requestObject->error) {
        $returnData->allclear = 0;
        return "Error";
    }
    return $returnData;
}
コード例 #30
0
 function fixDtstart()
 {
     // must only ever do this once!
     if (isset($this->dtfixed) && $this->dtfixed) {
         return;
     }
     $this->dtfixed = 1;
     $db =& JFactory::getDBO();
     // Now get the first repeat since dtstart may have been set in a different timezeone and since it is a unixdate it would then be wrong
     if (strtolower($this->freq()) == "none") {
         $repeat = $this->getFirstRepeat();
         $this->dtstart($repeat->getUnixStartTime());
         $this->dtend($repeat->getUnixEndTime());
     } else {
         $repeat = $this->getFirstRepeat();
         // Is this repeat an exception?
         $db->setQuery("SELECT * FROM #__jevents_exception WHERE rp_id=" . intval($repeat->rp_id()));
         $exception = $db->loadObject();
         if (!$exception) {
             $this->dtstart($repeat->getUnixStartTime());
             $this->dtend($repeat->getUnixEndTime());
         } else {
             // This is the scenario where the first repeat is an exception so check to see if we need to be worried
             $jregistry =& JRegistry::getInstance("jevents");
             // This is the server default timezone
             $jtimezone = $jregistry->getValue("jevents.timezone", false);
             if ($jtimezone) {
                 // This is the JEvents set timezone
                 $timezone = date_default_timezone_get();
                 // Only worry if the JEvents  set timezone is different to the server timezone
                 if ($timezone != $jtimezone) {
                     // look for repeats that are not exceptions
                     $repeat2 = $this->getFirstRepeat(false);
                     // if we have none then use the first repeat and give a warning
                     if (!$repeat2) {
                         $this->dtstart($repeat->getUnixStartTime());
                         $this->dtend($repeat->getUnixEndTime());
                         JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT'));
                     } else {
                         // Calculate the time adjustment (if any) then check against the non-exceptional repeat
                         // Convert dtstart using system timezone to date
                         date_default_timezone_set($jtimezone);
                         $truestarttime = JevDate::strftime("%H:%M:%S", $this->dtstart());
                         // if the system timezone version of dtstart is the same time as the first non-exceptional repeat
                         // then we are safe to use this adjustment mechanism to dtstart.  We use the real "date" and convert
                         // back into unix time using the  Jevents timezone
                         if ($truestarttime == JevDate::strftime("%H:%M:%S", JevDate::mktime($repeat2->hup(), $repeat2->minup(), $repeat2->sup(), 0, 0, 0))) {
                             $truedtstart = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtstart());
                             $truedtend = JevDate::strftime("%Y-%m-%d %H:%M:%S", $this->dtend());
                             // switch timezone back to Jevents timezone
                             date_default_timezone_set($timezone);
                             $this->dtstart(JevDate::strtotime($truedtstart));
                             $this->dtend(JevDate::strtotime($truedtend));
                         } else {
                             // In this scenario we have no idea what the time should be unfortunately
                             JFactory::getApplication()->enqueueMessage(JText::_('JEV_PLEASE_CHECK_START_AND_END_TIMES_FOR_THIS_EVENT'));
                             // switch timezone back
                             date_default_timezone_set($timezone);
                         }
                     }
                 }
             }
         }
     }
 }