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;
     }
 }
 /**
  * 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];
 }
 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;
 }
 /**
  * Modifies SolR query params according to filter parameters
  * @param array $queryParams
  * @param array $filterParams
  * @return array $queryParams
  */
 public function filterQueryParams(array $queryParams, array $filterParams)
 {
     try {
         if (!isset($filterParams['field'])) {
             throw new Exception('Missing filter parameter "field"');
         }
         if (!isset($filterParams['latitude'])) {
             throw new Exception('Missing filter parameter "latitude"');
         }
         if (!isset($filterParams['longitude'])) {
             throw new Exception('Missing filter parameter "longitude"');
         }
         $fieldName = eZSolr::getFieldName($filterParams['field']);
         //geodist custom parameters
         $queryParams['sfield'] = $fieldName;
         $queryParams['pt'] = $filterParams['latitude'] . ',' . $filterParams['longitude'];
         //sort by geodist
         $queryParams['sort'] = 'geodist() asc,' . $queryParams['sort'];
         //exclude unlocated documents
         $queryParams['fq'][] = $fieldName . ':[-90,-90 TO 90,90]';
     } catch (Exception $e) {
         eZDebug::writeWarning($e->getMessage(), __CLASS__);
     }
     return $queryParams;
 }
 public function generateMarkup()
 {
     $ttlInfos = $this->parseTTL();
     $markup = '<esi:include src="' . $this->Src . '" ttl="' . $ttlInfos['ttl_value'] . $ttlInfos['ttl_unit'] . '" onerror="continue"/>';
     eZDebug::writeNotice($markup, __METHOD__);
     return $markup;
 }
Пример #6
0
 /**
  * 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;
     }
 }
Пример #7
0
 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;
 }
Пример #8
0
    function runFile( $Params, $file, $params_as_var )
    {
        $Result = null;
        if ( $params_as_var )
        {
            foreach ( $Params as $key => $dummy )
            {
                if ( $key != "Params" and
                     $key != "this" and
                     $key != "file" and
                     !is_numeric( $key ) )
                {
                    ${$key} = $Params[$key];
                }
            }
        }

        if ( file_exists( $file ) )
        {
            $includeResult = include( $file );
            if ( empty( $Result ) &&
                 $includeResult != 1 )
            {
                $Result = $includeResult;
            }
        }
        else
            eZDebug::writeWarning( "PHP script $file does not exist, cannot run.",
                                   "eZProcess" );
        return $Result;
    }
Пример #9
0
 function validateClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     //checking if the recaptcha key is set up if recaptcha is enabled
     $ini = eZINI::instance('ezcomments.ini');
     $fields = $ini->variable('FormSettings', 'AvailableFields');
     if (in_array('recaptcha', $fields)) {
         $publicKey = $ini->variable('RecaptchaSetting', 'PublicKey');
         $privateKey = $ini->variable('RecaptchaSetting', 'PrivateKey');
         if ($publicKey === '' || $privateKey === '') {
             eZDebug::writeNotice('reCAPTCHA key is not set up. For help please visit http://projects.ez.no/ezcomments', __METHOD__);
         }
     }
     if ($http->hasPostVariable('StoreButton') || $http->hasPostVariable('ApplyButton')) {
         // find the class and count how many Comments dattype
         $cond = array('contentclass_id' => $classAttribute->attribute('contentclass_id'), 'version' => eZContentClass::VERSION_STATUS_TEMPORARY, 'data_type_string' => $classAttribute->attribute('data_type_string'));
         $classAttributeList = eZContentClassAttribute::fetchFilteredList($cond);
         // if there is more than 1 comment attribute, return it as INVALID
         if (!is_null($classAttributeList) && count($classAttributeList) > 1) {
             if ($classAttributeList[0]->attribute('id') == $classAttribute->attribute('id')) {
                 eZDebug::writeNotice('There are more than 1 comment attribute in the class.', __METHOD__);
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
 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;
 }
Пример #11
0
    function run( &$benchmark, $display = false )
    {
        $this->Results = array();
        $this->CurrentResult = false;
        if ( is_subclass_of( $benchmark, 'ezbenchmarkunit' ) )
        {
            $markList = $benchmark->markList();
            foreach ( $markList as $mark )
            {
                $type = $this->markEntryType( $benchmark, $mark );
                if ( $type )
                {
                    $mark['type'] = $type;
                    $this->prepareMarkEntry( $benchmark, $mark );

                    $this->runMarkEntry( $benchmark, $mark );

                    $this->finalizeMarkEntry( $benchmark, $mark, $display );
                }
                else
                    $this->addToCurrentResult( $mark,
                                               "Unknown mark type for mark " . $benchmark->name() . '::' . $mark['name'] );
            }
        }
        else
        {
            eZDebug::writeWarning( "Tried to run test on an object which is not subclassed from eZBenchmarkCase", __METHOD__ );
        }
    }
 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;
 }
 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;
 }
Пример #14
0
function getXMLString($name = false, $data, $ret = false, $debug = false)
{
    // given string $data, will return the text string content of the $name attribute content of a given valid xml document.
    if ($debug) {
        ezDebug::writeNotice($name, 'getXMLString:name');
    }
    // get information out of eZXML
    $xml = new eZXML();
    $xmlDoc = $data;
    if ($debug) {
        ezDebug::writeNotice($data, 'getXMLString:data');
    }
    // continue only with content
    if ($xmlDoc != null and $name != null) {
        $dom = $xml->domTree($xmlDoc);
        $element = $dom->elementsByName("{$name}");
        if (is_object($element[0])) {
            $string = $element[0]->textContent();
            $ret = $string;
        } else {
            eZDebug::writeNotice('Key "' . $name . '" does not exist.', 'wrap_operator');
        }
    }
    if ($debug) {
        ezDebug::writeNotice($ret, 'getXMLString:ret');
    }
    return $ret;
}
 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;
 }
    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 ) );
    }
    /**
     * 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 shorten($url)
 {
     $call = $this->serviceCallUrl . urlencode($url);
     $shortUrl = $this->shortenUrl($call);
     eZDebug::writeDebug("Shortened {$url} to {$shortUrl}", __METHOD__);
     return $shortUrl;
 }
 /**
  * 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;
 }
Пример #20
0
    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;
        }
    }
Пример #21
0
 function setDiffEngineType($diffEngineType)
 {
     if (isset($diffEngineType)) {
         $this->DiffEngine = $diffEngineType;
         eZDebug::writeNotice("Changing diff engine to type: " . $diffEngineType, 'eZDiff');
     }
 }
Пример #22
0
 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;
     }
 }
Пример #23
0
    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;
    }
 function execute($process, $event)
 {
     $parameters = $process->attribute('parameter_list');
     $http = eZHTTPTool::instance();
     eZDebug::writeNotice($parameters, "parameters");
     $orderID = $parameters['order_id'];
     $order = eZOrder::fetch($orderID);
     if (empty($orderID) || get_class($order) != 'ezorder') {
         eZDebug::writeWarning("Can't proceed without a Order ID.", "SimpleStockCheck");
         return eZWorkflowEventType::STATUS_FETCH_TEMPLATE_REPEAT;
     }
     // Decrement the quantitity field
     $order = eZOrder::fetch($orderID);
     $productCollection = $order->productCollection();
     $ordereditems = $productCollection->itemList();
     foreach ($ordereditems as $item) {
         $contentObject = $item->contentObject();
         $contentObjectVersion = $contentObject->version($contentObject->attribute('current_version'));
         $contentObjectAttributes = $contentObjectVersion->contentObjectAttributes();
         foreach (array_keys($contentObjectAttributes) as $key) {
             $contentObjectAttribute = $contentObjectAttributes[$key];
             $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
             // Each attribute has an attribute identifier called 'quantity' that identifies it.
             if ($contentClassAttribute->attribute("identifier") == "quantity") {
                 $contentObjectAttribute->setAttribute("data_int", $contentObjectAttribute->attribute("value") - $item->ItemCount);
                 $contentObjectAttribute->store();
             }
         }
     }
     return eZWorkflowEventType::STATUS_ACCEPTED;
 }
Пример #25
0
 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;
     }
 }
 /**
  * Helper function for {@link eZHTTPPersistence::fetch()}
  *
  * @param string $base_name
  * @param array $def Definition for $object, uses the same syntax as {@link eZPersistentObject}
  * @param object $object
  * @param eZHTTPTool $http
  * @param int|string|false $index Index in HTTP POST data corresponding to $object.
  *                                Set as string will make use of corresponding field in $def
  *                                Set to false if posted data is not an array.
  * @see eZHTTPPersistence::fetch()
  * @return void
  */
 static function fetchElement($base_name, array $def, $object, eZHTTPTool $http, $index)
 {
     $fields = $def["fields"];
     $keys = $def["keys"];
     foreach ($fields as $field_name => $field_member) {
         if (!in_array($field_name, $keys)) {
             $post_var = $base_name . "_" . $field_name;
             if ($http->hasPostVariable($post_var)) {
                 $post_value = $http->postVariable($post_var);
                 if ($index === false) {
                     if ($post_value !== null && $field_member['datatype'] === 'string' && array_key_exists('max_length', $field_member) && $field_member['max_length'] > 0 && strlen($post_value) > $field_member['max_length']) {
                         $post_value = substr($post_value, 0, $field_member['max_length']);
                         eZDebug::writeDebug($post_value, "truncation of {$field_name} to max_length=" . $field_member['max_length']);
                     }
                     $object->setAttribute($field_name, $post_value);
                 } else {
                     if (is_string($index)) {
                         $object->setAttribute($field_name, $post_value[$object->attribute($index)]);
                     } else {
                         $object->setAttribute($field_name, $post_value[$index]);
                     }
                 }
             }
         }
     }
 }
Пример #27
0
 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;
                     }
                 }
             }
         }
     }
 }
Пример #28
0
 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;
 }
Пример #29
0
 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;
     }
 }
Пример #30
0
function addFiles(&$index, $dirname, $dirArray)
{
    try {
        $dir = new eZClusterDirectoryIterator($dirname);
    } catch (Exception $e) {
        if ($e instanceof UnexpectedValueException) {
            eZDebug::writeDebug("Cannot add {$dirname} to the sitemaps index because it does not exist");
            return;
        }
    }
    foreach ($dir as $file) {
        $f = eZClusterFileHandler::instance($file->name());
        if ($f->exists()) {
            $exists = true;
            break;
        }
    }
    if (false != $exists) {
        foreach ($dir as $file) {
            if (in_array($file->name(), $dirArray)) {
                continue;
            }
            if ($file->size() > 50) {
                $date = new xrowSitemapItemModified();
                $date->date = new DateTime("@" . $file->mtime());
                $loc = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $file->name();
                if (!in_array($loc, $GLOBALS['loc'])) {
                    $GLOBALS['loc'][] = $loc;
                    $index->add($loc, array($date));
                }
            }
        }
    }
}