function execute($process, $event) { // get object being published $parameters = $process->attribute('parameter_list'); $objectID = $parameters['object_id']; eZDebug::writeDebug('Update object state for object: ' . $objectID); $object = eZContentObject::fetch($objectID); $state_before = $event->attribute('state_before'); $state_after = $event->attribute('state_after'); if ($object == null) { eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } if ($state_before == null || $state_after == null) { eZDebug::writeError('Update object state failed: badly configured states', __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } $currentStateIDArray = $object->attribute('state_id_array'); if (in_array($state_before->attribute('id'), $currentStateIDArray)) { $canAssignStateIDList = $object->attribute('allowed_assign_state_id_list'); if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) { eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__); } else { eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__); if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) { $operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id')))); } else { eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id'))); } } } return eZWorkflowType::STATUS_ACCEPTED; }
function attribute( $attr ) { switch ( $attr ) { case "workflow_event_id" : { return $this->WorkflowEventID; }break; case "workflow_event_version" : { return $this->WorkflowEventVersion; }break; case "entry_list" : { return $this->Entries; }break; case 'classattribute_id_list' : { return $this->classAttributeIDList(); } default : { eZDebug::writeError( "Attribute '$attr' does not exist", __METHOD__ ); return null; }break; } }
public function execute($process, $event) { $params = $process->attribute('parameter_list'); $object_id = $params['object_id']; $object = eZContentObject::fetch($object_id); if (!is_object($object)) { eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__); return eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } // current parent node(s) $parentNodeIds = $object->attribute('parent_nodes'); $checkedObjs = array(); foreach ($parentNodeIds as $parentNodeId) { //eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ ); $parentNode = eZContentObjectTreeNode::fetch($parentNodeId); $parentObj = $parentNode->attribute('object'); if (!in_array($parentObj->attribute('id'), $checkedObjs)) { //eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ ); foreach ($parentObj->attribute('assigned_nodes') as $node) { if (!in_array($node->attribute('node_id'), $parentNodeIds)) { //eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ ); // the current obj has no node which is children of the given node of one of its parent objects $operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true); if ($operationResult == null || $operationResult['status'] != true) { eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__); } } else { //eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ ); } } } $checkedObjs[] = $parentObj->attribute('id'); } return eZWorkflowType::STATUS_ACCEPTED; }
function sendMail(eZMail $mail) { $ini = eZINI::instance(); $parameters = array(); $parameters['host'] = $ini->variable('MailSettings', 'TransportServer'); $parameters['helo'] = $ini->variable('MailSettings', 'SenderHost'); $parameters['port'] = $ini->variable('MailSettings', 'TransportPort'); $parameters['connectionType'] = $ini->variable('MailSettings', 'TransportConnectionType'); $user = $ini->variable('MailSettings', 'TransportUser'); $password = $ini->variable('MailSettings', 'TransportPassword'); if ($user and $password) { $parameters['auth'] = true; $parameters['user'] = $user; $parameters['pass'] = $password; } /* If email sender hasn't been specified or is empty * we substitute it with either MailSettings.EmailSender or AdminEmail. */ if (!$mail->senderText()) { $emailSender = $ini->variable('MailSettings', 'EmailSender'); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'AdminEmail'); } eZMail::extractEmail($emailSender, $emailSenderAddress, $emailSenderName); if (!eZMail::validate($emailSenderAddress)) { $emailSender = false; } if ($emailSender) { $mail->setSenderText($emailSender); } } $excludeHeaders = $ini->variable('MailSettings', 'ExcludeHeaders'); if (count($excludeHeaders) > 0) { $mail->Mail->appendExcludeHeaders($excludeHeaders); } $options = new ezcMailSmtpTransportOptions(); if ($parameters['connectionType']) { $options->connectionType = $parameters['connectionType']; } $smtp = new ezcMailSmtpTransport($parameters['host'], $user, $password, $parameters['port'], $options); // If in debug mode, send to debug email address and nothing else if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') { $mail->Mail->to = array(new ezcMailAddress($ini->variable('MailSettings', 'DebugReceiverEmail'))); $mail->Mail->cc = array(); $mail->Mail->bcc = array(); } // send() from ezcMailSmtpTransport doesn't return anything (it uses exceptions in case // something goes bad) try { eZPerfLogger::accumulatorStart('mail_sent'); $smtp->send($mail->Mail); eZPerfLogger::accumulatorStop('mail_sent'); } catch (ezcMailException $e) { eZPerfLogger::accumulatorStop('mail_send'); eZDebug::writeError($e->getMessage(), __METHOD__); return false; } // return true in case of no exceptions return true; }
private function solrMetaDataExists( $contentObjectID=0, $attributeIdentifier='', $subattr='' ) { try { $contentObject = eZContentObject::fetch( $contentObjectID ); $dataMap = $contentObject->dataMap(); if ( array_key_exists( $attributeIdentifier, $dataMap ) ) { $contentObjectAttribute = $dataMap[$attributeIdentifier]; $eZType = eZDataType::create( solrMetaDataType::DATA_TYPE_STRING ); $value = $eZType->getValue( $contentObjectAttribute->ID, $subattr ); return ( ! empty( $value ) ); } else { eZDebug::writeError( 'Object '.$contentObjectID.' has no attribute '.$attributeIdentifier, 'solrMetaDataExists Error' ); } return false; } catch ( Exception $e ) { eZDebug::writeError( $e, 'solrMetaDataExists Exception' ); return false; } }
static function read($filename, $returnArray = false) { $fd = @fopen($filename, 'rb'); if ($fd) { $buf = fread($fd, 100); fclose($fd); if (preg_match('#^<\\?' . "php#", $buf)) { include $filename; if ($returnArray) { $params = array(); if (isset($schema)) { $params['schema'] = $schema; } if (isset($data)) { $params['data'] = $data; } return $params; } else { return $schema; } } else { if (preg_match('#a:[0-9]+:{#', $buf)) { return unserialize(file_get_contents($filename)); } else { eZDebug::writeError("Unknown format for file {$filename}"); return false; } } } return false; }
public function getTimeline($pageID = false, $limit = 20, $type = 'feed') { $result = array('result' => array()); $accumulator = $this->debugAccumulatorGroup . '_facebook_timeline'; eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'timeline'); $cacheFileHandler = $this->getCacheFileHandler('_timeline', array($pageID, $limit, $type)); try { if ($this->isCacheExpired($cacheFileHandler)) { eZDebug::writeDebug(array('page_id' => $pageID, 'limit' => $limit), self::$debugMessagesGroup); $response = $this->API->api(($pageID === false ? 'me/home' : '/' . $pageID) . '/' . $type, array('access_token' => $this->acessToken, 'limit' => $limit)); $messages = array(); $currentTime = time(); foreach ($response['data'] as $message) { $createdAt = strtotime($message['created_time']); $message['created_ago'] = self::getCreatedAgoString($createdAt, $currentTime); $message['created_timestamp'] = $createdAt; if (isset($message['message'])) { $message['message'] = self::fixMessageLinks($message['message']); } $messages[] = $message; } $cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($messages)); } else { $messages = unserialize($cacheFileHandler->fetchContents()); } eZDebug::accumulatorStop($accumulator); $result['result'] = $messages; return $result; } catch (Exception $e) { eZDebug::accumulatorStop($accumulator); eZDebug::writeError($e->getMessage(), self::$debugMessagesGroup); return $result; } }
function handleFileDownload($contentObject, $contentObjectAttribute, $type, $fileInfo) { $fileName = $fileInfo['filepath']; $file = eZClusterFileHandler::instance($fileName); if ($fileName != "" and $file->exists()) { $fileSize = $file->size(); if (isset($_SERVER['HTTP_RANGE']) && preg_match("/^bytes=(\\d+)-(\\d+)?\$/", trim($_SERVER['HTTP_RANGE']), $matches)) { $fileOffset = $matches[1]; $contentLength = isset($matches[2]) ? $matches[2] - $matches[1] + 1 : $fileSize - $matches[1]; } else { $fileOffset = 0; $contentLength = $fileSize; } // Figure out the time of last modification of the file right way to get the file mtime ... the $fileModificationTime = $file->mtime(); // stop output buffering, and stop the session so that browsing can be continued while downloading eZSession::stop(); ob_end_clean(); eZFile::downloadHeaders($fileName, self::dispositionType($fileInfo['mime_type']) === 'attachment', false, $fileOffset, $contentLength, $fileSize); try { $file->passthrough($fileOffset, $contentLength); } catch (eZClusterFileHandlerNotFoundException $e) { eZDebug::writeError($e->getMessage, __METHOD__); header($_SERVER["SERVER_PROTOCOL"] . ' 500 Internal Server Error'); } catch (eZClusterFileHandlerGeneralException $e) { eZDebug::writeError($e->getMessage, __METHOD__); header($_SERVER["SERVER_PROTOCOL"] . ' 404 Not Found'); } eZExecution::cleanExit(); } return eZBinaryFileHandler::RESULT_UNAVAILABLE; }
static function continueWorkflow($workflowProcessID) { $operationResult = null; $theProcess = eZWorkflowProcess::fetch($workflowProcessID); if ($theProcess != null) { //restore memento and run it $bodyMemento = eZOperationMemento::fetchChild($theProcess->attribute('memento_key')); if ($bodyMemento === null) { eZDebug::writeError($bodyMemento, "Empty body memento in workflow.php"); return $operationResult; } $bodyMementoData = $bodyMemento->data(); $mainMemento = $bodyMemento->attribute('main_memento'); if (!$mainMemento) { return $operationResult; } $mementoData = $bodyMemento->data(); $mainMementoData = $mainMemento->data(); $mementoData['main_memento'] = $mainMemento; $mementoData['skip_trigger'] = false; $mementoData['memento_key'] = $theProcess->attribute('memento_key'); $bodyMemento->remove(); $operationParameters = array(); if (isset($mementoData['parameters'])) { $operationParameters = $mementoData['parameters']; } $operationResult = eZOperationHandler::execute($mementoData['module_name'], $mementoData['operation_name'], $operationParameters, $mementoData); } return $operationResult; }
/** * Returns the specified attribute * * @param string $name * @return mixed */ function attribute($name) { switch ($name) { case 'tags': return $this->tags(); break; case 'tag_ids': return $this->IDArray; break; case 'id_string': return $this->idString(); break; case 'keyword_string': return $this->keywordString(); break; case 'meta_keyword_string': return $this->keywordString(", "); break; case 'parent_string': return $this->parentString(); break; default: eZDebug::writeError("Attribute '{$name}' does not exist", "eZTags::attribute"); return null; break; } }
function sendMail(ezcMail $mail) { $ini = eZINI::instance(); $parameters = array(); $parameters['host'] = $ini->variable('MailSettings', 'TransportServer'); $parameters['helo'] = $ini->variable('MailSettings', 'TransportServer'); $parameters['port'] = $ini->variable('MailSettings', 'TransportPort'); $parameters['connectionType'] = $ini->variable('MailSettings', 'TransportConnectionType'); $user = $ini->variable('MailSettings', 'TransportUser'); $password = $ini->variable('MailSettings', 'TransportPassword'); if ($user and $password) { $parameters['auth'] = true; $parameters['user'] = $user; $parameters['pass'] = $password; } $options = new ezcMailSmtpTransportOptions(); if ($parameters['connectionType']) { $options->connectionType = $parameters['connectionType']; } $smtp = new ezcMailSmtpTransport($parameters['host'], $user, $password, $parameters['port'], $options); try { $smtp->send($mail); return true; } catch (ezcMailException $e) { eZDebug::writeError("Error sending SMTP mail: " . $e->getMessage(), 'eZSMTPTransport::sendMail'); echo "SMTP ERROR: " . $e->getMessage(); return false; } return false; }
function attribute($name) { if ($name == 'is_valid') { return $this->IsValid; } else { if ($name == 'cpu_type') { return $this->CPUType; } else { if ($name == 'cpu_unit') { return $this->CPUUnit; } else { if ($name == 'cpu_speed') { return $this->CPUSpeed; } else { if ($name == 'memory_size') { return $this->MemorySize; } else { eZDebug::writeError("Attribute '{$name}' does not exist", __METHOD__); return null; } } } } } }
function install($package, $installType, $parameters, $name, $os, $filename, $subdirectory, $content, &$installParameters, &$installData) { $path = $package->path(); $databaseType = false; if (isset($parameters['database-type'])) { $databaseType = $parameters['database-type']; } $path .= '/' . eZDBPackageHandler::sqlDirectory(); if ($databaseType) { $path .= '/' . $databaseType; } if (file_exists($path)) { $db = eZDB::instance(); $canInsert = true; if ($databaseType and $databaseType != $db->databaseName()) { $canInsert = false; } if ($canInsert) { eZDebug::writeDebug("Installing SQL file {$path}/{$filename}"); $db->insertFile($path, $filename, false); return true; } else { eZDebug::writeDebug("Skipping SQL file {$path}/{$filename}"); } } else { eZDebug::writeError("Could not find SQL file {$path}/{$filename}"); } return false; }
function attribute($name) { switch ($name) { case 'input_xml': return $this->inputXML(); break; case 'edit_template_name': return $this->editTemplateName(); break; case 'information_template_name': return $this->informationTemplateName(); break; case 'aliased_type': eZDebug::writeWarning("'aliased_type' is deprecated as of 4.1 and not in use anymore, meaning it will always return false.", __METHOD__); return $this->AliasedType; break; case 'aliased_handler': if ($this->AliasedHandler === null) { $this->AliasedHandler = eZXMLText::inputHandler($this->XMLData, $this->AliasedType, false, $this->ContentObjectAttribute); } return $this->AliasedHandler; break; default: eZDebug::writeError("Attribute '{$name}' does not exist", __METHOD__); return null; break; } }
function attribute($attr) { switch ($attr) { case 'error_count': return count($this->ErrorList); break; case 'error_list': return $this->ErrorList; break; case 'warning_count': return count($this->WarningList); break; case 'warning_list': return $this->WarningList; break; case 'step_template': return $this->stepTemplate(); break; case 'variable_list': return $this->variableList(); break; case 'url': return $this->WizardURL; break; default: eZDebug::writeError("Attribute '{$attr}' does not exist", __METHOD__); return null; break; } }
static function create( $name, $command, $userID = false ) { if ( trim( $name ) == '' ) { eZDebug::writeError( 'Empty name. You must supply a valid script name string.', 'ezscriptmonitor' ); return false; } if ( trim( $command ) == '' ) { eZDebug::writeError( 'Empty command. You must supply a valid command string.', 'ezscriptmonitor' ); return false; } if ( !$userID ) { $userID = eZUser::currentUserID(); } $scriptMonitorIni = eZINI::instance( 'ezscriptmonitor.ini' ); $scriptSiteAccess = $scriptMonitorIni->variable( 'GeneralSettings', 'ScriptSiteAccess' ); $command = str_replace( self::SCRIPT_NAME_STRING, $name, $command ); $command = str_replace( self::SITE_ACCESS_STRING, $scriptSiteAccess, $command ); // Negative progress means not started yet return new self( array( 'name' => $name, 'command' => $command, 'last_report_timestamp' => time(), 'progress' => -1, 'user_id' => $userID ) ); }
static function createClass( $tpl, $module, $stepArray, $basePath, $storageName = false, $metaData = false ) { if ( !$storageName ) { $storageName = 'eZWizard'; } if ( !$metaData ) { $http = eZHTTPTool::instance(); $metaData = $http->sessionVariable( $storageName . '_meta' ); } if ( !isset( $metaData['current_step'] ) || $metaData['current_step'] < 0 ) { $metaData['current_step'] = 0; eZDebug::writeNotice( 'Setting wizard step to : ' . $metaData['current_step'], __METHOD__ ); } $currentStep = $metaData['current_step']; if ( count( $stepArray ) <= $currentStep ) { eZDebug::writeError( 'Invalid wizard step count: ' . $currentStep, __METHOD__ ); return false; } $filePath = $basePath . $stepArray[$currentStep]['file']; if ( !file_exists( $filePath ) ) { eZDebug::writeError( 'Wizard file not found : ' . $filePath, __METHOD__ ); return false; } include_once( $filePath ); $className = $stepArray[$currentStep]['class']; eZDebug::writeNotice( 'Creating class : ' . $className, __METHOD__ ); $returnClass = new $className( $tpl, $module, $storageName ); if ( isset( $stepArray[$currentStep]['operation'] ) ) { $operation = $stepArray[$currentStep]['operation']; return $returnClass->$operation(); eZDebug::writeNotice( 'Running : "' . $className . '->' . $operation . '()". Specified in StepArray', __METHOD__ ); } if ( isset( $metaData['current_stage'] ) ) { $returnClass->setMetaData( 'current_stage', $metaData['current_stage'] ); eZDebug::writeNotice( 'Setting wizard stage to : ' . $metaData['current_stage'], __METHOD__ ); } return $returnClass; }
public static function getEvents(eZContentObjectTreeNode $node, array $parameters) { $events = array(); $base = array('name' => $node->attribute('name'), 'main_node_id' => $node->attribute('main_node_id'), 'main_url_alias' => $node->attribute('url_alias'), 'fields' => array('attr_from_time_dt' => 0, 'attr_to_time_dt' => 0)); try { $startDate = new DateTime('now', OCCalendarData::timezone()); $startDate->setDate(date('Y', $parameters['search_from_timestamp']), date('n', $parameters['search_from_timestamp']), date('j', $parameters['search_from_timestamp'])); $endDate = clone $startDate; $endDate->add(new DateInterval($parameters['interval'])); $byDayInterval = new DateInterval('P1D'); /** @var DateTime[] $byDayPeriod */ $byDayPeriod = new DatePeriod($startDate, $byDayInterval, $endDate); $timeTable = self::getTimeTableFromNode($node); foreach ($byDayPeriod as $date) { $weekDay = $date->format('w'); if (isset($timeTable[$weekDay])) { foreach ($timeTable[$weekDay] as $value) { $newEvent = $base; $date->setTime($value['from_time']['hour'], $value['from_time']['minute']); $newEvent['fields']['attr_from_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z'); $date->setTime($value['to_time']['hour'], $value['to_time']['minute']); $newEvent['fields']['attr_to_time_dt'] = $date->format('Y-m-d\\TH:i:s\\Z'); $item = OCCalendarItem::fromEzfindResultArray($newEvent); $events[] = $item; } } } } catch (Exception $e) { eZDebug::writeError($e->getMessage(), __METHOD__); } return $events; }
/** * 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; }
/** * Fetches a pending actions list by action name * @param string $action * @param array $aCreationDateFilter Created date filter array (default is empty array). Must be a 2 entries array. * First entry is the filter token (can be '=', '<', '<=', '>', '>=') * Second entry is the filter value (timestamp) * @return array|null Array of eZPendingActions or null if no entry has been found */ public static function fetchByAction( $action, array $aCreationDateFilter = array() ) { $filterConds = array( 'action' => $action ); // Handle creation date filter if( !empty( $aCreationDateFilter ) ) { if( count( $aCreationDateFilter ) != 2 ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong number of entries for Creation date filter array' ); return null; } list( $filterToken, $filterValue ) = $aCreationDateFilter; $aAuthorizedFilterTokens = array( '=', '<', '>', '<=', '>=' ); if( !is_string( $filterToken ) || !in_array( $filterToken, $aAuthorizedFilterTokens ) ) { eZDebug::writeError( __CLASS__.'::'.__METHOD__.' : Wrong filter type for creation date filter' ); return null; } $filterConds['created'] = array( $filterToken, $filterValue ); } $result = parent::fetchObjectList( self::definition(), null, $filterConds ); return $result; }
public function searchActivities($query, $limit = 20, $sorting = 'best') { $result = array('result' => array()); $accumulator = $this->debugAccumulatorGroup . '_google_activities_search'; eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'activities/search'); $cacheFileHandler = $this->getCacheFileHandler('_activities_search', array($query, $limit, $sorting)); try { if ($this->isCacheExpired($cacheFileHandler)) { eZDebug::writeDebug(array('query' => $query, 'limit' => $limit, 'sorting' => $sorting), self::$debugMessagesGroup); $response = $this->API->activities->search($query, array('maxResults' => $limit, 'orderBy' => $sorting)); $activities = array(); $currentTime = time(); foreach ($response['items'] as $activity) { $createdAt = strtotime($activity['published']); $activity['created_ago'] = self::getCreatedAgoString($createdAt, $currentTime); $activity['created_timestamp'] = $createdAt; $activities[] = $activity; } $cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($activities)); } else { $activities = unserialize($cacheFileHandler->fetchContents()); } eZDebug::accumulatorStop($accumulator); $result['result'] = $activities; return $result; } catch (Exception $e) { eZDebug::accumulatorStop($accumulator); eZDebug::writeError($e, self::$debugMessagesGroup); return $result; } }
function attribute($attr) { switch ($attr) { case "contentclass_attributeid": return $this->ClassAttributeID; break; case "contentclass_attributeversion": return $this->ClassAttributeVersion; break; case "enum_list": return $this->Enumerations; break; case "enumobject_list": return $this->ObjectEnumerations; break; case "enum_ismultiple": return $this->IsmultipleEnum; break; case "enum_isoption": return $this->IsoptionEnum; break; default: eZDebug::writeError("Attribute '{$attr}' does not exist", __METHOD__); return null; break; } }
function attribute( $name ) { switch ( $name ) { case 'keywords' : { return $this->KeywordArray; }break; case 'keyword_string' : { return $this->keywordString(); }break; case 'related_objects' : case 'related_nodes' : { return $this->relatedObjects(); }break; default: { eZDebug::writeError( "Attribute '$name' does not exist", __METHOD__ ); return null; }break; } }
function nodeID( $name ) { if ( is_numeric( $name ) ) { $nodeID = false; $node = eZContentObjectTreeNode::fetch( $name, false, false ); if ( $node ) $nodeID = $node['node_id']; return $nodeID; } $contentINI = eZINI::instance( 'content.ini' ); switch ( $name ) { case 'root': { return $contentINI->variable( 'NodeSettings', 'RootNode' ); } case 'users': { return $contentINI->variable( 'NodeSettings', 'UserRootNode' ); } case 'none': { return false; } default: { eZDebug::writeError( "Unknown node type '$name'", __METHOD__ ); } break; } return false; }
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; }
function sendMail(eZMail $mail) { $ini = eZINI::instance(); $sendmailOptions = ''; $emailFrom = $mail->sender(); $emailSender = isset($emailFrom['email']) ? $emailFrom['email'] : false; 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') != 0; $sendmailOptionsArray = $ini->variable('MailSettings', 'SendmailOptions'); if (is_array($sendmailOptionsArray)) { $sendmailOptions = implode(' ', $sendmailOptionsArray); } elseif (!is_string($sendmailOptionsArray)) { $sendmailOptions = $sendmailOptionsArray; } if (!$isSafeMode and $emailSender) { $sendmailOptions .= ' -f' . $emailSender; } if ($isSafeMode and $emailSender and $mail->sender() == false) { $mail->setSenderText($emailSender); } if (function_exists('mail')) { $message = $mail->body(); $sys = eZSys::instance(); $excludeHeaders = array('Subject'); // If not Windows PHP mail() implementation, we can not specify a To: header in the $additional_headers parameter, // because then there will be 2 To: headers in the resulting e-mail. // However, we can use "undisclosed-recipients:;" in $to. if ($sys->osType() != 'win32') { $excludeHeaders[] = 'To'; $receiverEmailText = count($mail->ReceiverElements) > 0 ? $mail->receiverEmailText() : 'undisclosed-recipients:;'; } else { $receiverEmailText = $mail->receiverEmailText(); } // If in debug mode, send to debug email address and nothing else if ($ini->variable('MailSettings', 'DebugSending') == 'enabled') { $receiverEmailText = $ini->variable('MailSettings', 'DebugReceiverEmail'); $excludeHeaders[] = 'To'; $excludeHeaders[] = 'Cc'; $excludeHeaders[] = 'Bcc'; } $extraHeaders = $mail->headerText(array('exclude-headers' => $excludeHeaders)); $returnedValue = mail($receiverEmailText, $mail->subject(), $message, $extraHeaders, $sendmailOptions); if ($returnedValue === false) { eZDebug::writeError('An error occurred while sending e-mail. Check the Sendmail error message for further information (usually in /var/log/messages)', __METHOD__); } return $returnedValue; } else { eZDebug::writeWarning("Unable to send mail: 'mail' function is not compiled into PHP.", __METHOD__); } return false; }
static function setValue( $name, $value, $storeUserID = false ) { $db = eZDB::instance(); $name = $db->escapeString( $name ); $rawValue = $value; $value = $db->escapeString( $value ); $isCurrentUser = true; if ( $storeUserID === false ) { $user = eZUser::currentUser(); } else { $currentID = eZUser::currentUserID(); if ( $currentID != $storeUserID ) $isCurrentUser = false; $user = eZUser::fetch( $storeUserID ); if ( !is_object( $user ) ) { eZDebug::writeError( "Cannot set preference for user $storeUserID, the user does not exist" ); return false; } } // We must store the database changes if: // a - The current user is logged in (ie. not anonymous) // b - We have specified a specific user (not the current). // in which case isLoggedIn() will fail. if ( $storeUserID !== false or $user->isLoggedIn() ) { // Only store in DB if user is logged in or we have // a specific user ID defined $userID = $user->attribute( 'contentobject_id' ); $existingRes = $db->arrayQuery( "SELECT * FROM ezpreferences WHERE user_id = $userID AND name='$name'" ); if ( count( $existingRes ) > 0 ) { $prefID = $existingRes[0]['id']; $query = "UPDATE ezpreferences SET value='$value' WHERE id = $prefID AND name='$name'"; $db->query( $query ); } else { $query = "INSERT INTO ezpreferences ( user_id, name, value ) VALUES ( $userID, '$name', '$value' )"; $db->query( $query ); } } // We also store in session if this is the current user (anonymous or normal user) // use $rawValue as value will be escaped by session code (see #014520) if ( $isCurrentUser ) { eZPreferences::storeInSession( $name, $rawValue ); } return true; }
function attribute($attr) { if ($attr == 'columns') { return $this->ColumnNames; } eZDebug::writeError("Attribute '{$attr}' does not exist", 'eZMatrixDefinition::attribute'); return null; }
function attribute($attr) { if ($attr == 'columns') { return $this->ColumnNames; } eZDebug::writeError("Attribute '{$attr}' does not exist", __METHOD__); return null; }