public function getBlockConfiguration() { $iniFile = new \eZINI('block.ini', 'extension/ezflow/settings', null, false, true); foreach (self::$configs as $config) { $iniFile->parseFile(self::$path . '/' . $config); } return $iniFile->getNamedArray(); }
public function setUp() { parent::setUp(); ezpINIHelper::setINISetting('site.ini', 'SearchSettings', 'AllowEmptySearch', 'enabled'); ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('eng-GB')); $this->findINI = eZINI::instance('ezfind.ini'); $this->findINI->loadCache(true); $this->solrSearch = new eZSolr(); $this->object = new ezpObject('folder', 2); $this->object->name = 'foo'; $this->object->publish(); $this->object->addNode(43); // Add a location under Media node $this->solrSearch->addObject($this->object->object); }
/** * Initializes/updates debug settings, system wide */ public function updateDebugSettings() { $ini = eZINI::instance(); $debugSettings = array(); $debugSettings['debug-enabled'] = ($ini->variable('DebugSettings', 'DebugOutput') == 'enabled' and $this->restINI->variable('DebugSettings', 'Debug') == 'enabled'); $debugSettings['debug-by-ip'] = $ini->variable('DebugSettings', 'DebugByIP') == 'enabled'; $debugSettings['debug-ip-list'] = $ini->variable('DebugSettings', 'DebugIPList'); $logList = $ini->variable('DebugSettings', 'AlwaysLog'); $logMap = array('notice' => eZDebug::LEVEL_NOTICE, 'warning' => eZDebug::LEVEL_WARNING, 'error' => eZDebug::LEVEL_ERROR, 'debug' => eZDebug::LEVEL_DEBUG, 'strict' => eZDebug::LEVEL_STRICT); $debugSettings['always-log'] = array(); foreach ($logMap as $name => $level) { $debugSettings['always-log'][$level] = in_array($name, $logList); } eZDebug::updateSettings($debugSettings); }
public function requestToken($Account) { $NGPushIni = eZINI::instance('ngpush.ini'); $ConsumerKey = $NGPushIni->variable($Account, 'ConsumerKey'); $ConsumerSecret = $NGPushIni->variable($Account, 'ConsumerSecret'); $AccessToken = $NGPushIni->variable($Account, 'AccessToken'); $AccessTokenSecret = $NGPushIni->variable($Account, 'AccessTokenSecret'); // If access tokens are given if ($AccessToken && $AccessTokenSecret) { // Save request signing tokens to cache ngPushBase::save_token($Account, $AccessToken, 'request_sign_oauth_token'); ngPushBase::save_token($Account, $AccessTokenSecret, 'request_sign_oauth_token_secret'); ngPushBase::save_token($Account, $AccessToken . '%%%' . $AccessTokenSecret, 'main_token'); } else { $connection = new TwitterOAuth($ConsumerKey, $ConsumerSecret); $connection->host = "https://api.twitter.com/1.1/"; $AdministrationUrl = '/'; eZURI::transformURI($AdministrationUrl, false, 'full'); $AdministrationUrl = base64_encode($AdministrationUrl); $SettingsBlock = base64_encode($Account); $temporary_credentials = $connection->getRequestToken('http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=twitter'); // Save request signing tokens to cache ngPushBase::save_token($Account, $temporary_credentials['oauth_token'], 'request_sign_oauth_token'); ngPushBase::save_token($Account, $temporary_credentials['oauth_token_secret'], 'request_sign_oauth_token_secret'); $redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE); self::$response['RequestPermissionsUrl'] = $redirect_url; } }
function initialize($params = array()) { eZExchangeRatesUpdateHandler::initialize($params); $shopINI = eZINI::instance('shop.ini'); if (!isset($params['ServerName'])) { $params['ServerName'] = ''; if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'ServerName')) { $params['ServerName'] = $shopINI->variable('ECBExchangeRatesSettings', 'ServerName'); } } if (!isset($params['ServerPort'])) { $params['ServerPort'] = ''; if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'ServerPort')) { $params['ServerPort'] = $shopINI->variable('ECBExchangeRatesSettings', 'ServerPort'); } } if (!isset($params['RatesURI'])) { $params['RatesURI'] = ''; if ($shopINI->hasVariable('ECBExchangeRatesSettings', 'RatesURI')) { $params['RatesURI'] = $shopINI->variable('ECBExchangeRatesSettings', 'RatesURI'); } } if (!isset($params['BaseCurrency'])) { // the ECB returns currencies against 'EUR' $params['BaseCurrency'] = 'EUR'; } $this->setServerName($params['ServerName']); $this->setServerPort($params['ServerPort']); $this->setRatesURI($params['RatesURI']); $this->setBaseCurrency($params['BaseCurrency']); }
function display() { // Get site templates from setup.ini $config = eZINI::instance( 'setup.ini' ); $thumbnailBase = $config->variable( 'SiteTemplates', 'ThumbnailBase' ); $thumbnailExtension = $config->variable( 'SiteTemplates', 'ThumbnailExtension' ); $site_templates = array(); $packages = eZPackage::fetchPackages( array( 'path' => 'kernel/setup/packages' ) ); foreach( $packages as $key => $package ) { $site_templates[$key]['name'] = $package->attribute( 'summary' ); $site_templates[$key]['identifier'] = $package->attribute( 'name' ); $thumbnails = $package->thumbnailList( 'default' ); if ( count( $thumbnails ) > 0 ) $site_templates[$key]['image_file_name'] = $package->fileItemPath( $thumbnails[0], 'default', 'kernel/setup/packages' ); else $site_templates[$key]['image_file_name'] = false; } $this->Tpl->setVariable( 'site_templates', $site_templates ); $this->Tpl->setVariable( 'error', $this->Error ); // Return template and data to be shown $result = array(); // Display template $result['content'] = $this->Tpl->fetch( 'design:setup/init/site_templates.tpl' ); $result['path'] = array( array( 'text' => ezpI18n::tr( 'design/standard/setup/init', 'Site template selection' ), 'url' => false ) ); return $result; }
static function create($user_id) { $config = eZINI::instance('site.ini'); $dateTime = time(); $row = array('id' => null, 'title' => ezpI18n::tr('kernel/pdfexport', 'New PDF Export'), 'show_frontpage' => 1, 'intro_text' => '', 'sub_text' => '', 'source_node_id' => 0, 'export_structure' => 'tree', 'export_classes' => '', 'site_access' => '', 'pdf_filename' => 'file.pdf', 'modifier_id' => $user_id, 'modified' => $dateTime, 'creator_id' => $user_id, 'created' => $dateTime, 'status' => 0, 'version' => 1); return new eZPDFExport($row); }
/** * Get singleton instance for filter * @param string $filterID * @return eZFindExtendedAttributeFilterInterface|false */ public static function getInstance($filterID) { if (!isset(self::$instances[$filterID])) { try { if (!self::$filtersList) { $ini = eZINI::instance('ezfind.ini'); self::$filtersList = $ini->variable('ExtendedAttributeFilters', 'FiltersList'); } if (!isset(self::$filtersList[$filterID])) { throw new Exception($filterID . ' extended attribute filter is not defined'); } $className = self::$filtersList[$filterID]; if (!class_exists($className)) { throw new Exception('Could not find class ' . $className); } $instance = new $className(); if (!$instance instanceof eZFindExtendedAttributeFilterInterface) { throw new Exception($className . ' is not a valid eZFindExtendedAttributeFilterInterface'); } self::$instances[$filterID] = $instance; } catch (Exception $e) { eZDebug::writeWarning($e->getMessage(), __METHOD__); self::$instances[$filterID] = false; } } return self::$instances[$filterID]; }
protected static function lazyDbHelper() { $dbMapping = array( 'ezmysqli' => 'mysql', 'ezmysql' => 'mysql', 'mysql' => 'mysql', 'mysqli' => 'mysql', 'postgresql' => 'pgsql', 'ezpostgresql' => 'pgsql', 'ezoracle' => 'oracle', 'oracle' => 'oracle' ); $ini = eZINI::instance(); list( $dbType, $dbHost, $dbPort, $dbUser, $dbPass, $dbName ) = $ini->variableMulti( 'DatabaseSettings', array( 'DatabaseImplementation', 'Server', 'Port', 'User', 'Password', 'Database', ) ); if ( !isset( $dbMapping[$dbType] ) ) { // @TODO: Add a proper exception type here. throw new Exception( "Unknown / unmapped DB type '$dbType'" ); } $dbType = $dbMapping[$dbType]; $dsnHost = $dbHost . ( $dbPort != '' ? ":$dbPort" : '' ); $dsnAuth = $dbUser . ( $dbPass != '' ? ":$dbPass" : '' ); $dsn = "{$dbType}://{$dbUser}:{$dbPass}@{$dsnHost}/{$dbName}"; return $dsn; }
function execute($process, $event) { $ini = eZINI::instance('workflow.ini'); $cost = $ini->variable("SimpleShippingWorkflow", "ShippingCost"); $description = $ini->variable("SimpleShippingWorkflow", "ShippingDescription"); $parameters = $process->attribute('parameter_list'); if (isset($parameters['order_id'])) { $orderID = $parameters['order_id']; $order = eZOrder::fetch($orderID); $orderItems = $order->attribute('order_items'); $addShipping = true; foreach ($orderItems as $orderItem) { if ($orderItem->attribute('type') == 'ezsimpleshipping') { $addShipping = false; break; } } if ($addShipping) { $productCollection = $order->attribute('productcollection'); $orderCurrency = $productCollection->attribute('currency_code'); $cost = eZShopFunctions::convertAdditionalPrice($orderCurrency, $cost); $orderItem = new eZOrderItem(array('order_id' => $orderID, 'description' => $description, 'price' => $cost, 'type' => 'ezsimpleshipping')); $orderItem->store(); } } return eZWorkflowType::STATUS_ACCEPTED; }
/** * Create a scheduled script that will store the modification made to an eZContentClass. * * @param eZContentClass Content class to be stored. * @param array[eZContentClassAttribute] Attributes of the new content class. * @param array Unordered view parameters */ public function store(eZContentClass $class, array $attributes, array &$unorderedParameters) { $script = eZScheduledScript::create('syncobjectattributes.php', eZINI::instance('ezscriptmonitor.ini')->variable('GeneralSettings', 'PhpCliCommand') . ' extension/ezscriptmonitor/bin/' . eZScheduledScript::SCRIPT_NAME_STRING . ' -s ' . eZScheduledScript::SITE_ACCESS_STRING . ' --classid=' . $class->attribute('id')); $script->store(); $unorderedParameters['ScheduledScriptID'] = $script->attribute('id'); $class->storeVersioned($attributes, eZContentClass::VERSION_STATUS_MODIFIED); }
function checkRecurrenceCondition($newsletter) { if (!$newsletter->attribute('recurrence_condition')) { return true; } if (0 < count($this->conditionExtensions)) { foreach ($this->conditionExtensions as $conditionExtension) { // TODO: Extend to ask multiple condition extensions to allow more complex checks $siteINI = eZINI::instance(); $siteINI->loadCache(); $extensionDirectory = $siteINI->variable('ExtensionSettings', 'ExtensionDirectory'); $extensionDirectories = eZDir::findSubItems($extensionDirectory); $directoryList = eZExtension::expandedPathList($extensionDirectories, 'condition_handler'); foreach ($directoryList as $directory) { $handlerFile = $directory . '/' . strtolower($conditionExtension) . 'handler.php'; // we only check one extension for now if ($conditionExtension === $newsletter->attribute('recurrence_condition') && file_exists($handlerFile)) { include_once $handlerFile; $className = $conditionExtension . 'Handler'; if (class_exists($className)) { $impl = new $className(); // Ask if condition is fullfilled return $impl->checkCondition($newsletter); } else { eZDebug::writeError("Class {$className} not found. Unable to verify recurrence condition. Blocked recurrence."); return false; } } } } } // If we have a condition but no match we prevent the sendout eZDebug::writeError("Newsletter recurrence condition '" . $newsletter->attribute('recurrence_condition') . "' extension not found "); return false; }
/** * Returns a shared instance of the eZNotificationTransport class. * * * @param string|false $transport Uses notification.ini[TransportSettings]DefaultTransport if false * @param bool $forceNewInstance * @return eZNotificationTransport */ static function instance($transport = false, $forceNewInstance = false) { $ini = eZINI::instance('notification.ini'); if ($transport == false) { $transport = $ini->variable('TransportSettings', 'DefaultTransport'); } $transportImpl =& $GLOBALS['eZNotificationTransportGlobalInstance_' . $transport]; $class = $transportImpl !== null ? strtolower(get_class($transportImpl)) : ''; $fetchInstance = false; if (!preg_match('/.*?transport/', $class)) { $fetchInstance = true; } if ($forceNewInstance) { $fetchInstance = true; } if ($fetchInstance) { $extraPluginPathArray = $ini->variable('TransportSettings', 'TransportPluginPath'); $pluginPathArray = array_merge(array('kernel/classes/notification/'), $extraPluginPathArray); foreach ($pluginPathArray as $pluginPath) { $transportFile = $pluginPath . $transport . 'notificationtransport.php'; if (file_exists($transportFile)) { include_once $transportFile; $className = $transport . 'notificationtransport'; $impl = new $className(); break; } } } if (!isset($impl)) { $impl = new eZNotificationTransport(); eZDebug::writeError('Transport implementation not supported: ' . $transport, __METHOD__); } return $impl; }
function sendMail(eZMail $mail) { $ini = eZINI::instance(); $sendmailOptions = ''; $emailFrom = $mail->sender(); $emailSender = $emailFrom['email']; if (!$emailSender || count($emailSender) <= 0) { $emailSender = $ini->variable('MailSettings', 'EmailSender'); } if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } if (!eZMail::validate($emailSender)) { $emailSender = false; } $isSafeMode = ini_get('safe_mode'); if ($isSafeMode and $emailSender and $mail->sender() == false) { $mail->setSenderText($emailSender); } $filename = time() . '-' . mt_rand() . '.mail'; $data = preg_replace('/(\\r\\n|\\r|\\n)/', "\r\n", $mail->headerText() . "\n" . $mail->body()); $returnedValue = eZFile::create($filename, 'var/log/mail', $data); if ($returnedValue === false) { eZDebug::writeError('An error occurred writing the e-mail file in var/log/mail', __METHOD__); } return $returnedValue; }
public function push($Account, $TwitterStatus) { $NGPushIni = eZINI::instance('ngpush.ini'); $Token = self::getToken($Account); if (!$Token) { self::requestToken($Account); $Token = self::getToken($Account); } if ($Token) { $tokenCredentials = explode('%%%', $Token); $connection = new TwitterOAuth($NGPushIni->variable($Account, 'ConsumerKey'), $NGPushIni->variable($Account, 'ConsumerSecret'), $tokenCredentials[0], $tokenCredentials[1]); $connection->host = "https://api.twitter.com/1.1/"; $TwitterResponse = $connection->post('statuses/update', array('status' => $TwitterStatus)); self::$response['response'] = $TwitterResponse; //Let's analyize some Twitter JSON response (lots of data but no clear structure and no status) if ($TwitterResponse->error) { self::$response['status'] = 'error'; self::$response['messages'][] = $TwitterResponse->error; } elseif ($TwitterResponse->errors) { self::$response['status'] = 'error'; foreach ($TwitterResponse->errors as $TwitterResponseError) { self::$response['messages'][] = $TwitterResponseError->message; } } else { self::$response['status'] = 'success'; if ($TwitterResponse->created_at) { self::$response['messages'][] = 'Status is published!'; } } } else { self::$response['status'] = 'error'; self::$response['messages'][] = 'You need access token to use this application with Twitter.'; } return self::$response; }
function initializeTopNodes($package, $http, $step, &$persistentData, $tpl, $module) { if (!isset($persistentData['top_nodes_map'])) { $persistentData['top_nodes_map'] = array(); $rootDOMNode = $this->rootDOMNode(); $topNodeListNode = $rootDOMNode->getElementsByTagName('top-node-list')->item(0); $ini = eZINI::instance('content.ini'); $defaultPlacementNodeID = $ini->variable('NodeSettings', 'RootNode'); $defaultPlacementNode = eZContentObjectTreeNode::fetch($defaultPlacementNodeID); $defaultPlacementName = $defaultPlacementNode->attribute('name'); foreach ($topNodeListNode->getElementsByTagName('top-node') as $topNodeDOMNode) { $persistentData['top_nodes_map'][(string) $topNodeDOMNode->getAttribute('node-id')] = array('old_node_id' => $topNodeDOMNode->getAttribute('node-id'), 'name' => $topNodeDOMNode->textContent, 'new_node_id' => $defaultPlacementNodeID, 'new_parent_name' => $defaultPlacementName); } } foreach (array_keys($persistentData['top_nodes_map']) as $topNodeArrayKey) { if ($http->hasPostVariable('BrowseNode_' . $topNodeArrayKey)) { eZContentBrowse::browse(array('action_name' => 'SelectObjectRelationNode', 'description_template' => 'design:package/installers/ezcontentobject/browse_topnode.tpl', 'from_page' => '/package/install', 'persistent_data' => array('PackageStep' => $http->postVariable('PackageStep'), 'InstallerType' => $http->postVariable('InstallerType'), 'InstallStepID' => $http->postVariable('InstallStepID'), 'ReturnBrowse_' . $topNodeArrayKey => 1)), $module); } else { if ($http->hasPostVariable('ReturnBrowse_' . $topNodeArrayKey) && !$http->hasPostVariable('BrowseCancelButton')) { $nodeIDArray = $http->postVariable('SelectedNodeIDArray'); if ($nodeIDArray != null) { $persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] = $nodeIDArray[0]; $contentNode = eZContentObjectTreeNode::fetch($nodeIDArray[0]); $persistentData['top_nodes_map'][$topNodeArrayKey]['new_parent_name'] = $contentNode->attribute('name'); } } } } $tpl->setVariable('top_nodes_map', $persistentData['top_nodes_map']); }
function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters) { switch ($operatorName) { case 'recaptcha_get_html': include_once 'extension/recaptcha/classes/recaptchalib.php'; // Retrieve the reCAPTCHA public key from the ini file $ini = eZINI::instance('recaptcha.ini'); $key = $ini->variable('Keys', 'PublicKey'); if (is_array($key)) { $hostname = eZSys::hostname(); if (isset($key[$hostname])) { $key = $key[$hostname]; } else { // try our luck with the first entry $key = array_shift($key); } } // check if the current user is able to bypass filling in the captcha and // return nothing so that no captcha is displayed $currentUser = eZUser::currentUser(); $accessAllowed = $currentUser->hasAccessTo('recaptcha', 'bypass_captcha'); if ($accessAllowed["accessWord"] == 'yes') { $operatorValue = 'User bypasses CAPTCHA'; } else { // Run the HTML generation code from the reCAPTCHA PHP library $operatorValue = recaptcha_get_html($key); } break; } }
function eZSimplifiedXMLInput(&$xmlData, $aliasedType, $contentObjectAttribute) { $this->eZXMLInputHandler($xmlData, $aliasedType, $contentObjectAttribute); $this->IsInputValid = true; $this->ContentObjectAttribute = $contentObjectAttribute; $contentIni = eZINI::instance('content.ini'); }
/** * Constructor * * If provided with $filePath, will use this file for further operations. * If not given, the file* methods must be used instead * * @param string $filePath Path of the file to handle * * @throws eZDBNoConnectionException DB connection failed */ function __construct($filePath = false) { if (self::$nonExistantStaleCacheHandling === null) { $fileINI = eZINI::instance('file.ini'); self::$nonExistantStaleCacheHandling = $fileINI->variable("ClusteringSettings", "NonExistantStaleCacheHandling"); unset($fileINI); } // DB Backend init if (self::$dbbackend === null) { self::$dbbackend = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'eZDFSClusteringSettings', 'iniVariable' => 'DBBackend'))); self::$dbbackend->_connect(false); $fileINI = eZINI::instance('file.ini'); if ($fileINI->variable('ClusterEventsSettings', 'ClusterEvents') === 'enabled' && self::$dbbackend instanceof eZClusterEventNotifier) { $listener = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'file.ini', 'iniSection' => 'ClusterEventsSettings', 'iniVariable' => 'Listener', 'handlerParams' => array(new eZClusterEventLoggerEzdebug())))); if ($listener instanceof eZClusterEventListener) { self::$dbbackend->registerListener($listener); $listener->initialize(); } } } if ($filePath !== false) { $filePath = self::cleanPath($filePath); eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor( '{$filePath}' )"); } else { eZDebugSetting::writeDebug('kernel-clustering', "dfs::ctor()"); } $this->filePath = $filePath; }
/** * Checks if a trigger is defined in worklow.ini/[OperationSettings]/AvailableOperations * * @param string $name * @return boolean true if the operation is available, false otherwise */ public static function operationIsAvailable($name) { $workflowINI = eZINI::instance('workflow.ini'); $operationList = $workflowINI->variableArray('OperationSettings', 'AvailableOperations'); $operationList = array_unique(array_merge($operationList, $workflowINI->variable('OperationSettings', 'AvailableOperationList'))); return in_array($name, $operationList) || in_array("before_{$name}", $operationList) || in_array("after_{$name}", $operationList); }
function initFrameMargins() { $this->ezFrame = array(); $config = eZINI::instance('pdf.ini'); $this->ezFrame['header'] = array('y0' => $this->ez['pageHeight'], 'leftMargin' => $config->variable('Header', 'LeftMargin'), 'rightMargin' => $config->variable('Header', 'RightMargin'), 'topMargin' => $config->variable('Header', 'TopMargin'), 'bottomMargin' => $config->variable('Header', 'BottomMargin')); $this->ezFrame['footer'] = array('y0' => $this->ez['bottomMargin'], 'leftMargin' => $config->variable('Footer', 'LeftMargin'), 'rightMargin' => $config->variable('Footer', 'RightMargin'), 'topMargin' => $config->variable('Footer', 'TopMargin'), 'bottomMargin' => $config->variable('Footer', 'BottomMargin')); }
/** * Figgure out if current user has rated, since eZ Publish changes session id as of 4.1 * on login / logout, a couple of things needs to be checked. * 1. Session variable 'ezsrRatedAttributeIdList' for list of attribute_id's * 2a. (annonymus user) check against session key * 2b. (logged in user) check against user id * * @param bool $returnRatedObject Return object if user has rated and [eZStarRating]AllowChangeRating=enabled * @return bool|ezsrRatingDataObject */ function userHasRated($returnRatedObject = false) { if ($this->currentUserHasRated === null) { $http = eZHTTPTool::instance(); if ($http->hasSessionVariable('ezsrRatedAttributeIdList')) { $attributeIdList = explode(',', $http->sessionVariable('ezsrRatedAttributeIdList')); } else { $attributeIdList = array(); } $ini = eZINI::instance(); $contentobjectAttributeId = $this->attribute('contentobject_attribute_id'); if (in_array($contentobjectAttributeId, $attributeIdList) && $ini->variable('eZStarRating', 'UseUserSession') === 'enabled') { $this->currentUserHasRated = true; } $returnRatedObject = $returnRatedObject && $ini->variable('eZStarRating', 'AllowChangeRating') === 'enabled'; if ($this->currentUserHasRated === null || $returnRatedObject) { $sessionKey = $this->attribute('session_key'); $userId = $this->attribute('user_id'); if ($userId == eZUser::anonymousId()) { $cond = array('user_id' => $userId, 'session_key' => $sessionKey, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId); } else { $cond = array('user_id' => $userId, 'contentobject_id' => $this->attribute('contentobject_id'), 'contentobject_attribute_id' => $contentobjectAttributeId); } if ($returnRatedObject) { $this->currentUserHasRated = eZPersistentObject::fetchObject(self::definition(), null, $cond); if ($this->currentUserHasRated === null) { $this->currentUserHasRated = false; } } else { $this->currentUserHasRated = eZPersistentObject::count(self::definition(), $cond, 'id') != 0; } } } return $this->currentUserHasRated; }
/** * Test scenario for LDAP login using GetGroupsTree * for issue #15334: LDAP GetGroupsTree should be able to find groups in multiple tree levels * * Test Outline * ------------ * 1. Set LDAPGroupMappingType = GetGroupsTree * 2. Login with username and password * 3. Check parent nodes of user object * 4. Login with username and password for another user * 5. Check parent nodes of user object * * @result: * The first user is placed in the newly created Empire and Sith groups * (the following assertions are not executed) * @expected: * The first user is placed in the existing Empire and Sith groups * The second user has two node assignments * The first assignment is the existing RebelAlliance group * The second assignment is the newly created Jedi group * @link http://issues.ez.no/15334 */ public function testLoginUserGetGroupsTree() { $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMappingType', 'GetGroupsTree'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupNameAttribute', 'ou'); $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupMemberAttribute', 'seeAlso'); $this->ldapINI->setVariable('LDAPSettings', 'KeepGroupAssignment', 'disabled'); // The Empire and Sith groups already exist $user = eZLDAPUser::loginUser('darth.vader', 'whosyourdaddy'); $contentObject = $user->attribute('contentobject'); $parentNodeIDs = $contentObject->attribute('parent_nodes'); sort($parentNodeIDs); self::assertEquals(array($this->empireGroupNodeId, $this->sithGroupNodeId), $parentNodeIDs); // Change the root node id, in order to create the Jedi group under the StarWars group $this->ldapINI->setVariable('LDAPSettings', 'LDAPGroupRootNodeId', $this->starWarsGroupNodeId); // Try a user with a group that is not in ezp $user = eZLDAPUser::loginUser('obi.wan', 'thesearenotthedroids'); $contentObject = $user->attribute('contentobject'); $parentNodeIDs = $contentObject->attribute('parent_nodes'); sort($parentNodeIDs); // The user should be assigned to 2 groups self::assertEquals(2, count($parentNodeIDs)); // The RebelAlliance group already exists $node0 = eZContentObjectTreeNode::fetch($parentNodeIDs[0]); self::assertEquals(array($this->rebelGroupNodeId, $this->starWarsGroupNodeId, 'RebelAlliance'), array($parentNodeIDs[0], $node0->attribute('parent_node_id'), $node0->attribute('name'))); // The Jedi group is created by the login handler $node1 = eZContentObjectTreeNode::fetch($parentNodeIDs[1]); self::assertEquals(array($this->starWarsGroupNodeId, 'Jedi'), array($node1->attribute('parent_node_id'), $node1->attribute('name'))); }
/** * construct * Load the configuration from ini file */ public function __construct() { //load configuration from ini $ini = eZINI::instance('ezcomments.ini'); $this->emailContentType = $ini->variable('NotificationSettings', 'MailContentType'); $this->emailFrom = $ini->variable('NotificationSettings', 'MailFrom'); }
function eZMimeType() { $this->SuffixList = array(); $this->PrefixList = array(); $this->MIMEList = array(); $ini = eZINI::instance( 'mime.ini' ); $this->QuickMIMETypes = array(); foreach ( $ini->groups() as $extension => $blockValues ) { foreach ( $blockValues['Types'] as $type ) { $this->QuickMIMETypes[] = array( $extension, $type ); } } foreach ( $this->QuickMIMETypes as $quickMIMEType ) { $mimeEntry =& $this->MIMEList[$quickMIMEType[1]]; if ( !isset( $mimeEntry ) ) $mimeEntry = array( 'suffixes' => array(), 'prefixes' => false ); $mimeEntry['suffixes'][] = $quickMIMEType[0]; } eZMimeType::prepareSuffixList( $this->SuffixList, $this->MIMEList ); eZMimeType::preparePrefixList( $this->PrefixList, $this->MIMEList ); }
/** * Session write handler * * @param $sessionId string * @param $sessionData string Binary session data * @return bool */ public function write($sessionId, $sessionData) { $db = eZDB::instance(); if (!$db->isConnected()) { return false; } $ini = eZINI::instance(); $expirationTime = time() + $ini->variable('Session', 'SessionTimeout'); if ($db->bindingType() != eZDBInterface::BINDING_NO) { $sessionData = $db->bindVariable($sessionData, array('name' => 'data')); } else { $sessionData = '\'' . $db->escapeString($sessionData) . '\''; } $escKey = $db->escapeString($sessionId); $userID = $db->escapeString(eZSession::userID()); // check if session already exists $sessionRes = !$this->userHasCookie ? false : $db->arrayQuery("SELECT session_key FROM ezsession WHERE session_key='{$escKey}'"); if ($sessionRes !== false and count($sessionRes) == 1) { $ret = $db->query("UPDATE ezsession SET expiration_time='{$expirationTime}', data={$sessionData}, user_id='{$userID}' WHERE session_key='{$escKey}'"); } else { $insertQuery = "INSERT INTO ezsession ( session_key, expiration_time, data, user_id )\n VALUES ( '{$escKey}', '{$expirationTime}', {$sessionData}, '{$userID}' )"; $ret = $db->query($insertQuery); } return true; }
/** * @return string */ protected static function getSecret() { if (self::$secret === null) { self::$secret = eZINI::instance('site.ini')->variable('HTMLForms', 'Secret'); } return self::$secret; }
/** * Return valid items for block with given $blockID * * @static * @param string $blockID * @param bool $asObject * @return array(eZContentObjectTreeNode) */ static function validNodes($blockID, $asObject = true) { if (isset($GLOBALS['eZFlowPool']) === false) { $GLOBALS['eZFlowPool'] = array(); } if (isset($GLOBALS['eZFlowPool'][$blockID])) { return $GLOBALS['eZFlowPool'][$blockID]; } $visibilitySQL = ""; if (eZINI::instance('site.ini')->variable('SiteAccessSettings', 'ShowHiddenNodes') !== 'true') { $visibilitySQL = "AND ezcontentobject_tree.is_invisible = 0 "; } $db = eZDB::instance(); $validNodes = $db->arrayQuery("SELECT ezm_pool.node_id\n FROM ezm_pool, ezcontentobject_tree, ezcontentobject\n WHERE ezm_pool.block_id='{$blockID}'\n AND ezm_pool.ts_visible>0\n AND ezm_pool.ts_hidden=0\n AND ezcontentobject_tree.node_id = ezm_pool.node_id\n AND ezcontentobject.id = ezm_pool.object_id\n AND " . eZContentLanguage::languagesSQLFilter('ezcontentobject') . "\n {$visibilitySQL}\n ORDER BY ezm_pool.priority DESC"); if ($asObject && !empty($validNodes)) { $validNodesObjects = array(); foreach ($validNodes as $node) { $validNodeObject = eZContentObjectTreeNode::fetch($node['node_id']); if ($validNodeObject instanceof eZContentObjectTreeNode && $validNodeObject->canRead()) { $validNodesObjects[] = $validNodeObject; } } $GLOBALS['eZFlowPool'][$blockID] = $validNodesObjects; return $validNodesObjects; } else { return $validNodes; } }
public function setUp() { parent::setUp(); $this->userLogin = uniqid( '', true ); $this->userEmail = "{$this->userLogin}@ez.no"; $ini = eZINI::instance(); $params = array( 'creator_id' => 14, 'class_identifier' => 'user', 'parent_node_id' => $ini->variable( 'UserSettings', 'DefaultUserPlacement' ), 'attributes' => array( 'first_name' => 'foo', 'last_name' => 'bar' ), ); $contentObject = eZContentFunctions::createAndPublishObject( $params ); if( !$contentObject instanceof eZContentObject ) { die( 'Impossible to create user object' ); } $this->userObject = $contentObject; }
static function loadHandler($directories, $handlerString) { $foundHandler = false; $includeFile = ''; $baseDirectory = eZExtension::baseDirectory(); $notificationINI = eZINI::instance('notification.ini'); $repositoryDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'RepositoryDirectories'); $extensionDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'ExtensionDirectories'); foreach ($extensionDirectories as $extensionDirectory) { $extensionPath = "{$baseDirectory}/{$extensionDirectory}/notification/handler/"; if (file_exists($extensionPath)) { $repositoryDirectories[] = $extensionPath; } } foreach ($repositoryDirectories as $repositoryDirectory) { $repositoryDirectory = trim($repositoryDirectory, '/'); $includeFile = "{$repositoryDirectory}/{$handlerString}/{$handlerString}handler.php"; if (file_exists($includeFile)) { $foundHandler = true; break; } } if (!$foundHandler) { eZDebug::writeError("Notification handler does not exist: {$handlerString}", __METHOD__); return false; } include_once $includeFile; $className = $handlerString . "handler"; return new $className(); }