/** * Checks whether the logged-in user (if any) in the current environment has access to a CSV export. * * @return bool whether the logged-in user (if any) in the current environment has access to a CSV export. * * @throws BadMethodCallException */ public function hasAccess() { if ($this->getEvent() === NULL) { throw new BadMethodCallException('Please set an event first.', 1389096647); } if (!Tx_Oelib_FrontEndLoginManager::getInstance()->isLoggedIn()) { return FALSE; } $configuration = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars_pi1'); if (!$configuration->getAsBoolean('allowCsvExportOfRegistrationsInMyVipEventsView')) { return FALSE; } $user = Tx_Oelib_FrontEndLoginManager::getInstance()->getLoggedInUser('tx_seminars_Mapper_FrontEndUser'); $vipsGroupUid = $configuration->getAsInteger('defaultEventVipsFeGroupID'); return $this->getEvent()->isUserVip($user->getUid(), $vipsGroupUid); }
/** * Creates the salutation for the given user. * * The salutation is localized and gender-specific and contains the name of * the user. * * @param tx_seminars_Model_FrontEndUser $user * the user to create the salutation for * * @return string the localized, gender-specific salutation with a trailing comma, will not be empty */ public function getSalutation(tx_seminars_Model_FrontEndUser $user) { $salutationParts = array(); $salutationMode = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars')->getAsString('salutation'); switch ($salutationMode) { case 'informal': $salutationParts['dear'] = $this->translator->translate('email_hello_informal'); $salutationParts['name'] = $user->getFirstOrFullName(); break; default: $gender = $user->getGender(); $salutationParts['dear'] = $this->translator->translate('email_hello_formal_' . $gender); $salutationParts['title'] = $this->translator->translate('email_salutation_title_' . $gender); $salutationParts['name'] = $user->getLastOrFullName(); } foreach ($this->getHooks() as $hook) { if (method_exists($hook, 'modifySalutation')) { $hook->modifySalutation($salutationParts); } } return implode(' ', $salutationParts) . ','; }
/** * The constructor. */ public function __construct() { $this->configuration = Tx_Oelib_ConfigurationRegistry::get('plugin.tx_seminars'); }
/** * @test */ public function getByExtensionNameDoesNotDeleteLanguageLabelsNotAffectedByTypoScript() { $testingFramework = new Tx_Oelib_TestingFramework('oelib'); $testingFramework->createFakeFrontEnd(); $this->getFrontEndController()->initLLvars(); Tx_Oelib_ConfigurationRegistry::get('config')->set('language', 'default'); Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib._LOCAL_LANG')->setData(array('default.' => array())); Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib._LOCAL_LANG.default')->set('label_test_2', 'I am from TypoScript.'); self::assertSame('I am from file.', Tx_Oelib_TranslatorRegistry::get('oelib')->translate('label_test')); $testingFramework->discardFakeFrontEnd(); }
/** * Returns the localized labels from an extension's TypoScript setup. * * Returns only the labels set for the language stored in $this->languageKey * * @param string $extensionName * the extension name to get the localized labels from TypoScript setup for, * must not be empty, the corresponding extension must be loaded * * @return string[] the localized labels from the extension's TypoScript setup, will be empty if there are none */ private function getLocalizedLabelsFromTypoScript($extensionName) { if ($extensionName === '') { throw new InvalidArgumentException('The parameter $extensionName must not be empty.', 1331489630); } $result = array(); $namespace = 'plugin.tx_' . $extensionName . '._LOCAL_LANG.' . $this->languageKey; $configuration = Tx_Oelib_ConfigurationRegistry::get($namespace); foreach ($configuration->getArrayKeys() as $key) { // Converts the label from the source charset to the render // charset. $result[$key] = $this->charsetConversion->conv($configuration->getAsString($key), 'utf-8', $this->renderCharset, TRUE); } return $result; }
/** * @test */ public function getAfterSetReturnsManuallySetConfigurationEvenIfThereIsAPage() { $pageUid = $this->testingFramework->createFrontEndPage(); $this->testingFramework->createTemplate($pageUid, array('config' => 'plugin.tx_oelib.bar = 42')); Tx_Oelib_PageFinder::getInstance()->setPageUid($pageUid); $configuration = new Tx_Oelib_Configuration(); Tx_Oelib_ConfigurationRegistry::getInstance()->set('plugin.tx_oelib', $configuration); self::assertSame($configuration, Tx_Oelib_ConfigurationRegistry::get('plugin.tx_oelib')); }
/** * Returns the default country as localized string. * * @return string the default country's localized name, will be empty if there is no default country */ private function getDefaultCountry() { $defaultCountryCode = tx_oelib_ConfigurationRegistry::get('plugin.tx_staticinfotables_pi1')->getAsString('countryCode'); if ($defaultCountryCode === '') { return ''; } $this->initStaticInfo(); if (class_exists('SJBR\\StaticInfoTables\\Utility\\LocalizationUtility', TRUE)) { $currentLanguageCode = Tx_Oelib_ConfigurationRegistry::get('config')->getAsString('language'); $identifiers = array('iso' => $defaultCountryCode); $result = \SJBR\StaticInfoTables\Utility\LocalizationUtility::getLabelFieldValue($identifiers, 'static_countries', $currentLanguageCode, TRUE); } else { $result = tx_staticinfotables_div::getTitleFromIsoCode('static_countries', $defaultCountryCode, $this->staticInfo->getCurrentLanguage(), TRUE); } return $result; }