/**
  * Test that new instance does not inherit events
  * (when not reading from ini settings)
  */
 public function testNewInstance()
 {
     $event = new ezpEvent(false);
     // test filter
     $this->assertEquals(null, $event->filter('test/filter', null));
     // test notify
     $this->assertFalse($event->notify('test/notify'));
 }
/**
 * @deprecated Since 5.0
 * @param string|null $templateResult
 */
function eZDisplayResult($templateResult)
{
    ob_start();
    if ($templateResult !== null) {
        $classname = eZINI::instance()->variable("OutputSettings", "OutputFilterName");
        //deprecated
        if (!empty($classname) && class_exists($classname)) {
            $templateResult = call_user_func(array($classname, 'filter'), $templateResult);
        }
        $templateResult = ezpEvent::getInstance()->filter('response/preoutput', $templateResult);
        $debugMarker = '<!--DEBUG_REPORT-->';
        $pos = strpos($templateResult, $debugMarker);
        if ($pos !== false) {
            $debugMarkerLength = strlen($debugMarker);
            echo substr($templateResult, 0, $pos);
            eZDisplayDebug();
            echo substr($templateResult, $pos + $debugMarkerLength);
        } else {
            echo $templateResult, eZDisplayDebug();
        }
    } else {
        eZDisplayDebug();
    }
    echo ezpEvent::getInstance()->filter('response/output', ob_get_clean());
}
 public function gc($maxLifeTime)
 {
     ezpEvent::getInstance()->notify('session/gc', array($maxLifeTime));
     $db = eZDB::instance();
     eZSession::triggerCallback('gc_pre', array($db, $maxLifeTime));
     $sfHandler = $this->storage->getSaveHandler();
     if (method_exists($sfHandler, 'gc')) {
         $sfHandler->gc($maxLifeTime);
     }
     eZSession::triggerCallback('gc_post', array($db, $maxLifeTime));
     return false;
 }
 function trashStoredObjectAttribute($contentObjectAttribute, $version = null)
 {
     $imageHandler = $contentObjectAttribute->attribute("content");
     $originalAlias = $imageHandler->imageAlias("original");
     // check if there is an actual image, 'is_valid' says if there is an image or not
     if ($originalAlias['is_valid'] != '1' && empty($originalAlias['filename'])) {
         return;
     }
     $basenameHashed = md5($originalAlias["basename"]);
     $trashedFolder = "{$originalAlias["dirpath"]}/trashed";
     $imageHandler->updateAliasPath($trashedFolder, $basenameHashed);
     if ($imageHandler->isStorageRequired()) {
         $imageHandler->store($contentObjectAttribute);
         $contentObjectAttribute->store();
     }
     // Now clean all other aliases, not cleanly registered within the attribute content
     // First get all remaining aliases full path to then safely move them to the trashed folder
     ezpEvent::getInstance()->notify('image/trashAliases', array($originalAlias['url']));
     $aliasNames = array_keys($imageHandler->aliasList());
     $aliasesPath = array();
     foreach ($aliasNames as $aliasName) {
         if ($aliasName === "original") {
             continue;
         }
         $aliasesPath[] = "{$originalAlias["dirpath"]}/{$originalAlias["basename"]}_{$aliasName}.{$originalAlias["suffix"]}";
     }
     if (empty($aliasesPath)) {
         return;
     }
     $conds = array("contentobject_attribute_id" => $contentObjectAttribute->attribute("id"), "filepath" => array($aliasesPath));
     $remainingAliases = eZPersistentObject::fetchObjectList(eZImageFile::definition(), null, $conds);
     unset($conds, $remainingAliasesPath);
     if (!empty($remainingAliases)) {
         foreach ($remainingAliases as $remainingAlias) {
             $filename = basename($remainingAlias->attribute("filepath"));
             $newFilePath = $trashedFolder . "/" . $basenameHashed . substr($filename, strrpos($filename, '_'));
             eZClusterFileHandler::instance($remainingAlias->attribute("filepath"))->move($newFilePath);
             // $newFilePath might have already been processed in eZImageFile
             // If so, $remainingAlias is a duplicate. We can then remove it safely
             $imageFile = eZImageFile::fetchByFilepath(false, $newFilePath, false);
             if (empty($imageFile)) {
                 $remainingAlias->setAttribute("filepath", $newFilePath);
                 $remainingAlias->store();
             } else {
                 $remainingAlias->remove();
             }
         }
     }
 }
 public function __construct()
 {
     $this->eventHandler = ezpEvent::getInstance();
     $fileINI = eZINI::instance('file.ini');
     $this->maxCopyTries = (int) $fileINI->variable('eZDFSClusteringSettings', 'MaxCopyRetries');
     if (defined('CLUSTER_METADATA_TABLE_CACHE')) {
         $this->metaDataTableCache = CLUSTER_METADATA_TABLE_CACHE;
     } else {
         if ($fileINI->hasVariable('eZDFSClusteringSettings', 'MetaDataTableNameCache')) {
             $this->metaDataTableCache = $fileINI->variable('eZDFSClusteringSettings', 'MetaDataTableNameCache');
         }
     }
     $this->cacheDir = eZINI::instance('site.ini')->variable('FileSettings', 'CacheDir');
     $this->storageDir = eZINI::instance('site.ini')->variable('FileSettings', 'StorageDir');
 }
/**
 * @deprecated Since 5.0
 * @param string|null $templateResult
 */
function eZDisplayResult($templateResult)
{
    ob_start();
    if ($templateResult !== null) {
        $templateResult = ezpEvent::getInstance()->filter('response/preoutput', $templateResult);
        $debugMarker = '<!--DEBUG_REPORT-->';
        $pos = strpos($templateResult, $debugMarker);
        if ($pos !== false) {
            $debugMarkerLength = strlen($debugMarker);
            echo substr($templateResult, 0, $pos);
            eZDisplayDebug();
            echo substr($templateResult, $pos + $debugMarkerLength);
        } else {
            echo $templateResult, eZDisplayDebug();
        }
    } else {
        eZDisplayDebug();
    }
    echo ezpEvent::getInstance()->filter('response/output', ob_get_clean());
}
Exemple #7
0
    /**
     * Creates the image alias $aliasName if it's not already part of the
     * existing aliases
     *
     * @param string $aliasName Name of the alias to create
     * @param array $existingAliasList
     *        Reference to the current alias list. The created alias will be
     *        added to the list.
     * @param array $parameters
     *        Optional array that can be used to specify the image's basename
     * @return bool true if the alias was created, false if it wasn't
     */
    function createImageAlias( $aliasName, &$existingAliasList, $parameters = array() )
    {
        $fname = "createImageAlias( $aliasName )";

        // check for $aliasName validity
        $aliasList = $this->aliasList();
        if ( !isset( $aliasList[$aliasName] ) )
        {
            eZDebug::writeWarning( "Alias name $aliasName does not exist, cannot create it" );
            return false;
        }

        // check if the reference alias is defined, and if no, use original as ref
        $currentAliasInfo = $aliasList[$aliasName];
        $referenceAlias = $currentAliasInfo['reference'];
        if ( $referenceAlias and !$this->hasAlias( $referenceAlias ) )
        {
            eZDebug::writeError( "The referenced alias '$referenceAlias' for image alias '$aliasName' does not exist, cannot use it for reference.\n" .
                                 "Will use 'original' alias instead.",
                                 __METHOD__ );
            $referenceAlias = false;
        }
        if ( !$referenceAlias )
            $referenceAlias = 'original';

        // generate the reference alias if it hasn't been generated yet
        $hasReference = false;
        if ( array_key_exists( $referenceAlias, $existingAliasList ) )
        {
            $fileHandler = eZClusterFileHandler::instance();
            if ( $fileHandler->fileExists( $existingAliasList[$referenceAlias]['url'] ) )
            {
                $hasReference = true;
            }
            else
            {
                eZDebug::writeError( "The reference alias $referenceAlias file {$existingAliasList[$referenceAlias]['url']} does not exist", __METHOD__ );
            }
        }
        if ( !$hasReference )
        {
            if ( $referenceAlias == 'original' )
            {
                eZDebug::writeError( "Original alias does not exist, cannot create other aliases without it" );
                return false;
            }
            if ( !$this->createImageAlias( $referenceAlias, $existingAliasList, $parameters ) )
            {
                eZDebug::writeError( "Failed creating the referenced alias $referenceAlias, cannot create alias $aliasName", __METHOD__ );
                return false;
            }
        }

        // from now on, our reference image (either reference or original)
        // exists
        $aliasInfo = $existingAliasList[$referenceAlias];
        $aliasFilePath = $aliasInfo['url'];
        $aliasKey = $currentAliasInfo['alias_key'];

        $sourceMimeData = eZMimeType::findByFileContents( $aliasFilePath );

        /**
         * at first, destinationMimeData (mimedata for the alias we're
         * generating) is the same as sourceMimeData. It will evolve as
         * alias generation goes on
         */
        $destinationMimeData = $sourceMimeData;
        if ( isset( $parameters['basename'] ) )
        {
            $sourceMimeData['basename'] = $parameters['basename'];
            eZMimeType::changeBasename( $destinationMimeData, $parameters['basename'] );
        }

        /**
         * Concurrency protection
         * startCacheGeneration will return true if the file is not
         * already being generated by another process. If it is, it will
         * return the maximum time before the generating process enters
         * generation timeout
         */
        while ( true )
        {
            $convertHandler = eZClusterFileHandler::instance( $sourceMimeData['url'] );
            $startGeneration = $convertHandler->startCacheGeneration();
            if ( $startGeneration === true )
            {
                $destinationMimeData['is_valid'] = false;
                if ( $this->convert( $sourceMimeData, $destinationMimeData, $aliasName, $parameters ) )
                {
                    /**
                     * At this point, we consider that the image exists and destinationMimeData
                     * has been filled with the proper information
                     *
                     * If we were locked during alias generation, we need to recreate
                     * this structure so that the image can actually be used, but ONLY
                     * if it was the same alias... sounds like a HUGE mess.
                     *
                     * Can we reload the alias list somehow ?
                     */
                    $currentAliasData = array( 'url' => $destinationMimeData['url'],
                                               'dirpath' => $destinationMimeData['dirpath'],
                                               'filename' => $destinationMimeData['filename'],
                                               'suffix' => $destinationMimeData['suffix'],
                                               'basename' => $destinationMimeData['basename'],
                                               'alternative_text' => $aliasInfo['alternative_text'],
                                               'name' => $aliasName,
                                               'sub_type' => false,
                                               'timestamp' => time(),
                                               'alias_key' => $aliasKey,
                                               'mime_type' => $destinationMimeData['name'],
                                               'override_mime_type' => false,
                                               'info' => false,
                                               'width' => false,
                                               'height' => false,
                                               'is_valid' => true,
                                               'is_new' => true );

                    if ( isset( $destinationMimeData['override_mime_type'] ) )
                        $currentAliasData['override_mime_type'] = $destinationMimeData['override_mime_type'];
                    if ( isset( $destinationMimeData['info'] ) )
                        $currentAliasData['info'] = $destinationMimeData['info'];
                    $currentAliasData['full_path'] = $currentAliasData['url'];

                    if ( function_exists( 'getimagesize' ) )
                    {
                        /**
                         * we may want to fetch a unique name here, since we won't use
                         * the data for anything else
                         */
                        $fileHandler = eZClusterFileHandler::instance( $destinationMimeData['url'] );
                        if ( $tempPath = $fileHandler->fetchUnique() )
                        {
                            $info = getimagesize( $tempPath );
                            if ( $info )
                            {
                                list( $currentAliasData['width'], $currentAliasData['height'] ) = $info;
                            }
                            else
                            {
                                eZDebug::writeError("The size of the generated image {$destinationMimeData['url']} could not be read by getimagesize()", __METHOD__ );
                            }
                            $fileHandler->fileDeleteLocal( $tempPath );
                        }
                        else
                        {
                            eZDebug::writeError( "The destination image {$destinationMimeData['url']} does not exist, cannot figure out image size", __METHOD__ );
                        }
                    }
                    else
                    {
                        eZDebug::writeError( "Unknown function 'getimagesize', cannot get image size", __METHOD__ );
                    }
                    $existingAliasList[$aliasName] = $currentAliasData;

                    $convertHandler->endCacheGeneration( false );

                    // Notify about image alias generation. Parameters are alias
                    // url and alias name.
                    ezpEvent::getInstance()->notify( 'image/alias', array( $currentAliasData['url'],
                                                                           $currentAliasData['name'] ) );
                    
                    return true;
                }
                // conversion failed, we abort generation
                else
                {
                    $sourceFile = $sourceMimeData['url'];
                    $destinationDir = $destinationMimeData['dirpath'];
                    eZDebug::writeError( "Failed converting $sourceFile to alias '$aliasName' in directory '$destinationDir'", __METHOD__ );
                    $convertHandler->abortCacheGeneration();
                    return false;
                }
            }
            // we were not granted file generation (someone else is doing it)
            // we wait for max. $remainingGenerationTime and check if the
            // file has been generated in between
            // Actually, we have no clue if the generated file was the one we were
            // looking for, and it doesn't seem possible to RELOAD the alias list.
            // We don't even know what attribute we're using... CRAP
            else
            {
                eZDebug::writeDebug( "An alias is already being generated for this image, let's wait", __METHOD__ );
                while ( true )
                {
                    $startGeneration = $convertHandler->startCacheGeneration();
                    // generation lock granted: we can start again by breaking to
                    // the beggining of the while loop
                    if ( $startGeneration === true )
                    {
                        eZDebug::writeDebug( "Got granted generation permission, restarting !", __METHOD__ );
                        $convertHandler->abortCacheGeneration();
                        continue 2;
                    }
                    else
                    {
                        sleep( 1 );
                    }
                }
            }
        }
        return false;
    }
 public function __construct()
 {
     $this->eventHandler = ezpEvent::getInstance();
 }
    /**
     * Remove all session data (Truncate table)
     *
     * @return bool
     */
    public function cleanup()
    {
        ezpEvent::getInstance()->notify( 'session/cleanup', array() );
        $db = eZDB::instance();

        eZSession::triggerCallback( 'cleanup_pre', array( $db ) );
        $db->query( 'TRUNCATE TABLE ezsession' );
        eZSession::triggerCallback( 'cleanup_post', array( $db ) );

        return true;
    }
Exemple #10
0
        $tag->setAttribute('parent_id', $newParentID);
        $tag->store();
        if (!$newParentTag instanceof eZTagsObject) {
            $newParentTag = false;
        }
        if ($updatePathString) {
            $tag->updatePathString($newParentTag);
        }
        if ($updateDepth) {
            $tag->updateDepth($newParentTag);
        }
        $tag->updateModified();
        $tag->registerSearchObjects();
        /* Extended Hook */
        if (class_exists('ezpEvent', false)) {
            $tag = ezpEvent::getInstance()->filter('tag/edit', $tag);
        }
        $db->commit();
        return $Module->redirectToView('id', array($tagID));
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('tag', $tag);
$tpl->setVariable('warning', $warning);
$tpl->setVariable('error', $error);
$Result = array();
$Result['content'] = $tpl->fetch('design:tags/edit.tpl');
$Result['ui_context'] = 'edit';
$Result['path'] = array();
$tempTag = $tag;
while ($tempTag->hasParent()) {
Exemple #11
0
 /**
  * Clears all state limitation cache files.
  */
 static function clearStateLimitations($cacheItem)
 {
     $cachePath = eZSys::cacheDirectory();
     $fileHandler = eZClusterFileHandler::instance();
     $fileHandler->fileDelete($cachePath, 'statelimitations_');
     ezpEvent::getInstance()->notify('content/state/cache/all');
 }
if ( $Month )
    $Month = (int) $Month;
if ( $Day )
    $Day = (int) $Day;

$NodeID = (int) $NodeID;

if ( $NodeID < 2 )
{
    return $Module->handleError( eZError::KERNEL_NOT_FOUND, 'kernel' );
}

$ini = eZINI::instance();

// Be able to filter node id for general use
$NodeID = ezpEvent::getInstance()->filter( 'content/view', $NodeID, $ini );

$testingHandler = new ezpMultivariateTest( ezpMultivariateTest::getHandler() );

if ( $testingHandler->isEnabled() )
    $NodeID = $testingHandler->execute( $NodeID );

$viewCacheEnabled = ( $ini->variable( 'ContentSettings', 'ViewCaching' ) == 'enabled' );

if ( isset( $Params['ViewCache'] ) )
{
    $viewCacheEnabled = $Params['ViewCache'];
}
elseif ( $viewCacheEnabled && !in_array( $ViewMode, $ini->variableArray( 'ContentSettings', 'CachedViewModes' ) ) )
{
    $viewCacheEnabled = false;
Exemple #13
0
    return $Module->redirectToView('dashboard', array());
} else {
    if ($http->hasPostVariable('YesButton')) {
        $db = eZDB::instance();
        foreach ($tagsList as $tag) {
            if ($tag->getSubTreeLimitationsCount() > 0 || $tag->attribute('main_tag_id') != 0) {
                continue;
            }
            $db->begin();
            $parentTag = $tag->getParent(true);
            if ($parentTag instanceof eZTagsObject) {
                $parentTag->updateModified();
            }
            /* Extended Hook */
            if (class_exists('ezpEvent', false)) {
                ezpEvent::getInstance()->filter('tag/delete', $tag);
            }
            $tag->recursivelyDeleteTag();
            $db->commit();
        }
        $http->removeSessionVariable('eZTagsDeleteIDArray');
        if ($parentTagID > 0) {
            return $Module->redirectToView('id', array($parentTagID));
        }
        return $Module->redirectToView('dashboard', array());
    }
}
$tpl = eZTemplate::factory();
$tpl->setVariable('tags', $tagsList);
$Result = array();
$Result['content'] = $tpl->fetch('design:tags/deletetags.tpl');
 static function clearObjectViewCache($objectID, $versionNum = true, $additionalNodeList = false)
 {
     eZDebug::accumulatorStart('node_cleanup_list', '', 'Node cleanup list');
     $nodeList = eZContentCacheManager::nodeList($objectID, $versionNum);
     if ($nodeList === false and !is_array($additionalNodeList)) {
         return false;
     }
     if ($nodeList === false) {
         $nodeList = array();
     }
     if (is_array($additionalNodeList)) {
         array_splice($nodeList, count($nodeList), 0, $additionalNodeList);
     }
     if (count($nodeList) == 0) {
         return false;
     }
     $nodeList = array_unique($nodeList);
     eZDebug::accumulatorStop('node_cleanup_list');
     eZDebugSetting::writeDebug('kernel-content-edit', count($nodeList), "count in nodeList");
     $ini = eZINI::instance();
     if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
         $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
         $options = new ezpExtensionOptions($optionArray);
         $staticCacheHandler = eZExtension::getHandlerClass($options);
         $staticCacheHandler->generateAlwaysUpdatedCache();
         $staticCacheHandler->generateNodeListCache($nodeList);
     }
     eZDebug::accumulatorStart('node_cleanup', '', 'Node cleanup');
     $nodeList = ezpEvent::getInstance()->filter('content/cache', $nodeList);
     eZContentObject::expireComplexViewModeCache();
     $cleanupValue = eZContentCache::calculateCleanupValue(count($nodeList));
     if (eZContentCache::inCleanupThresholdRange($cleanupValue)) {
         eZContentCache::cleanup($nodeList);
     } else {
         eZDebug::writeDebug("Expiring all view cache since list of nodes({$cleanupValue}) related to object({$objectID}) exeeds site.ini\\[ContentSettings]\\CacheThreshold", __METHOD__);
         eZContentObject::expireAllViewCache();
     }
     eZDebug::accumulatorStop('node_cleanup');
     return true;
 }
}
if ($http->hasPostVariable("ConfirmButton")) {
    foreach ($deleteIDArray as $deleteID) {
        eZContentClassGroup::removeSelected($deleteID);
        eZContentClassClassGroup::removeGroupMembers($deleteID);
        foreach ($deleteClassIDList as $deleteClassID) {
            $deleteClass = eZContentClass::fetch($deleteClassID);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
            $deleteClass = eZContentClass::fetch($deleteClassID, true, eZContentClass::VERSION_STATUS_TEMPORARY);
            if ($deleteClass) {
                $deleteClass->remove(true);
            }
            ezpEvent::getInstance()->notify('content/class/cache', array($deleteClassID));
        }
        ezpEvent::getInstance()->notify('content/class/group/cache', array($deleteID));
    }
    $Module->redirectTo('/class/grouplist/');
}
if ($http->hasPostVariable("CancelButton")) {
    $Module->redirectTo('/class/grouplist/');
}
$Module->setTitle(ezpI18n::tr('kernel/class', 'Remove class groups') . ' ' . $GroupName);
$tpl = eZTemplate::factory();
$tpl->setVariable("DeleteResult", $deleteResult);
$tpl->setVariable("module", $Module);
$tpl->setVariable("groups_info", $groupsInfo);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/removegroup.tpl");
$Result['path'] = array(array('url' => '/class/grouplist/', 'text' => ezpI18n::tr('kernel/class', 'Class groups')), array('url' => false, 'text' => ezpI18n::tr('kernel/class', 'Remove class groups')));
Exemple #16
0
    if (!$mainTag instanceof eZTagsObject) {
        $error = ezpI18n::tr('extension/eztags/errors', 'Selected target tag is invalid.');
    }
    if (empty($error)) {
        $db = eZDB::instance();
        $db->begin();
        $oldParentTag = false;
        if ($tag->attribute('parent_id') != $mainTag->attribute('parent_id')) {
            $oldParentTag = $tag->getParent(true);
            if ($oldParentTag instanceof eZTagsObject) {
                $oldParentTag->updateModified();
            }
        }
        /* Extended Hook */
        if (class_exists('ezpEvent', false)) {
            ezpEvent::getInstance()->filter('tag/merge', array('tag' => $tag, 'newParentTag' => $mainTag, 'oldParentTag' => $oldParentTag));
        }
        $tag->moveChildrenBelowAnotherTag($mainTag);
        foreach ($tag->getSynonyms(true) as $synonym) {
            $synonym->registerSearchObjects();
            $synonym->transferObjectsToAnotherTag($mainTag);
            $synonym->remove();
        }
        $tag->registerSearchObjects();
        $tag->transferObjectsToAnotherTag($mainTag);
        $tag->remove();
        $mainTag->updateModified();
        $db->commit();
        return $Module->redirectToView('id', array($mainTag->attribute('id')));
    }
}
 /**
  * Clears view caches of nodes, parent nodes and relating nodes
  * of content objects with ids contained in $objectIDList.
  * It will use 'viewcache.ini' to determine additional nodes.
  *
  * @see clearObjectViewCache
  *
  * @param array $objectIDList List of object ID
  */
 public static function clearObjectViewCacheArray(array $objectIDList)
 {
     eZDebug::accumulatorStart('node_cleanup_list', '', 'Node cleanup list');
     $nodeList = array();
     foreach ($objectIDList as $objectID) {
         $tempNodeList = self::nodeList($objectID, true);
         if ($tempNodeList !== false) {
             $nodeList = array_merge($nodeList, $tempNodeList);
         }
     }
     $nodeList = array_unique($nodeList);
     eZDebug::accumulatorStop('node_cleanup_list');
     eZDebugSetting::writeDebug('kernel-content-edit', count($nodeList), "count in nodeList");
     if (eZINI::instance()->variable('ContentSettings', 'StaticCache') === 'enabled') {
         $staticCacheHandler = eZExtension::getHandlerClass(new ezpExtensionOptions(array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler')));
         $staticCacheHandler->generateAlwaysUpdatedCache();
         $staticCacheHandler->generateNodeListCache($nodeList);
     }
     eZDebug::accumulatorStart('node_cleanup', '', 'Node cleanup');
     $nodeList = ezpEvent::getInstance()->filter('content/cache', $nodeList);
     eZContentObject::expireComplexViewModeCache();
     $cleanupValue = eZContentCache::calculateCleanupValue(count($nodeList));
     if (eZContentCache::inCleanupThresholdRange($cleanupValue)) {
         eZContentCache::cleanup($nodeList);
     } else {
         eZDebug::writeDebug("Expiring all view cache since list of nodes({$cleanupValue}) exceeds site.ini\\[ContentSettings]\\CacheThreshold", __METHOD__);
         eZContentObject::expireAllViewCache();
     }
     eZDebug::accumulatorStop('node_cleanup');
     return true;
 }
Exemple #18
0
 /**
  * Stores the tags to database
  *
  * @param eZContentObjectAttribute $attribute
  */
 function store($attribute)
 {
     if (!($attribute instanceof eZContentObjectAttribute && is_numeric($attribute->attribute('id')))) {
         return;
     }
     $attributeID = $attribute->attribute('id');
     $attributeVersion = $attribute->attribute('version');
     $objectID = $attribute->attribute('contentobject_id');
     $db = eZDB::instance();
     $currentTime = time();
     //get existing tags for object attribute
     $existingTagIDs = array();
     $existingTags = $db->arrayQuery("SELECT DISTINCT keyword_id FROM eztags_attribute_link WHERE objectattribute_id = {$attributeID} AND objectattribute_version = {$attributeVersion}");
     if (is_array($existingTags)) {
         foreach ($existingTags as $t) {
             $existingTagIDs[] = (int) $t['keyword_id'];
         }
     }
     //get tags to delete from object attribute
     $tagsToDelete = array();
     $tempIDArray = array();
     // if for some reason already existing tags are added with ID = 0 with fromString
     // check to see if they really exist, so we don't delete them by mistake
     foreach (array_keys($this->IDArray) as $key) {
         if ($this->IDArray[$key] == 0) {
             $existing = eZTagsObject::fetchList(array('keyword' => array('like', trim($this->KeywordArray[$key])), 'parent_id' => $this->ParentArray[$key]));
             if (is_array($existing) && !empty($existing)) {
                 $tempIDArray[] = $existing[0]->attribute('id');
             }
         } else {
             $tempIDArray[] = $this->IDArray[$key];
         }
     }
     foreach ($existingTagIDs as $tid) {
         if (!in_array($tid, $tempIDArray)) {
             $tagsToDelete[] = $tid;
         }
     }
     //and delete them
     if (!empty($tagsToDelete)) {
         $dbString = $db->generateSQLINStatement($tagsToDelete, 'keyword_id', false, true, 'int');
         $db->query("DELETE FROM eztags_attribute_link WHERE {$dbString} AND eztags_attribute_link.objectattribute_id = {$attributeID} AND eztags_attribute_link.objectattribute_version = {$attributeVersion}");
     }
     //get tags that are new to the object attribute
     $newTags = array();
     $tagsToLink = array();
     foreach (array_keys($this->IDArray) as $key) {
         if (!in_array($this->IDArray[$key], $existingTagIDs)) {
             if ($this->IDArray[$key] == 0) {
                 // We won't allow adding tags to the database that already exist, but instead, we link to the existing tags
                 $existing = eZTagsObject::fetchList(array('keyword' => array('like', trim($this->KeywordArray[$key])), 'parent_id' => $this->ParentArray[$key]));
                 if (is_array($existing) && !empty($existing)) {
                     if (!in_array($existing[0]->attribute('id'), $existingTagIDs)) {
                         $tagsToLink[] = $existing[0]->attribute('id');
                     }
                 } else {
                     $newTags[] = array('id' => $this->IDArray[$key], 'keyword' => $this->KeywordArray[$key], 'parent_id' => $this->ParentArray[$key]);
                 }
             } else {
                 $tagsToLink[] = $this->IDArray[$key];
             }
         }
     }
     //we need to check if user really has access to tags/add, taking into account policy and subtree limits
     $attributeSubTreeLimit = $attribute->contentClassAttribute()->attribute(eZTagsType::SUBTREE_LIMIT_FIELD);
     $userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
     if ($userLimitations['accessWord'] != 'no' && !empty($newTags)) {
         //first we need to fetch all locations user has access to
         $userLimitations = isset($userLimitations['simplifiedLimitations']['Tag']) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
         $allowedLocations = self::getAllowedLocations($attributeSubTreeLimit, $userLimitations);
         foreach ($newTags as $t) {
             //and then for each tag check if user can save in one of the allowed locations
             $parentTag = eZTagsObject::fetch($t['parent_id']);
             $pathString = $parentTag instanceof eZTagsObject ? $parentTag->attribute('path_string') : '/';
             $depth = $parentTag instanceof eZTagsObject ? (int) $parentTag->attribute('depth') + 1 : 1;
             if (self::canSave($pathString, $allowedLocations)) {
                 $db->query("INSERT INTO eztags ( parent_id, main_tag_id, keyword, depth, path_string, modified, remote_id ) VALUES ( " . $t['parent_id'] . ", 0, '" . $db->escapeString(trim($t['keyword'])) . "', {$depth}, '{$pathString}', 0, '" . eZTagsObject::generateRemoteID() . "' )");
                 $tagID = (int) $db->lastSerialID('eztags', 'id');
                 $db->query("UPDATE eztags SET path_string = CONCAT(path_string, CAST({$tagID} AS CHAR), '/') WHERE id = {$tagID}");
                 $pathArray = explode('/', trim($pathString, '/'));
                 array_push($pathArray, $tagID);
                 $db->query("UPDATE eztags SET modified = {$currentTime} WHERE " . $db->generateSQLINStatement($pathArray, 'id', false, true, 'int'));
                 $tagsToLink[] = $tagID;
                 if (class_exists('ezpEvent', false)) {
                     ezpEvent::getInstance()->filter('tag/add', array('tag' => eZTagsObject::fetch($tagID), 'parentTag' => $parentTag));
                 }
             }
         }
     }
     //link tags to objects taking into account subtree limit
     if (!empty($tagsToLink)) {
         $dbString = $db->generateSQLINStatement($tagsToLink, 'id', false, true, 'int');
         $tagsToLink = $db->arrayQuery("SELECT id, path_string FROM eztags WHERE {$dbString}");
         if (is_array($tagsToLink) && !empty($tagsToLink)) {
             foreach ($tagsToLink as $t) {
                 if ($attributeSubTreeLimit == 0 || $attributeSubTreeLimit > 0 && strpos($t['path_string'], '/' . $attributeSubTreeLimit . '/') !== false) {
                     $db->query("INSERT INTO eztags_attribute_link ( keyword_id, objectattribute_id, objectattribute_version, object_id ) VALUES ( " . $t['id'] . ", {$attributeID}, {$attributeVersion}, {$objectID} )");
                 }
             }
         }
     }
 }
Exemple #19
0
    $GroupID = $Params["GroupID"];
}
$class = eZContentClass::fetch($ClassID);
$ClassName = $class->attribute('name');
$classObjects = eZContentObject::fetchSameClassList($ClassID);
$ClassObjectsCount = count($classObjects);
if ($ClassObjectsCount == 0) {
    $ClassObjectsCount .= " object";
} else {
    $ClassObjectsCount .= " objects";
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable("ConfirmButton")) {
    $class->remove(true);
    eZContentClassClassGroup::removeClassMembers($ClassID, 0);
    ezpEvent::getInstance()->notify('content/class/cache', array($ClassID));
    $Module->redirectTo('/class/classlist/' . $GroupID);
}
if ($http->hasPostVariable("CancelButton")) {
    $Module->redirectTo('/class/classlist/' . $GroupID);
}
$Module->setTitle("Deletion of class " . $ClassID);
$tpl = eZTemplate::factory();
$tpl->setVariable("module", $Module);
$tpl->setVariable("GroupID", $GroupID);
$tpl->setVariable("ClassID", $ClassID);
$tpl->setVariable("ClassName", $ClassName);
$tpl->setVariable("ClassObjectsCount", $ClassObjectsCount);
$Result = array();
$Result['content'] = $tpl->fetch("design:class/delete.tpl");
$Result['path'] = array(array('url' => '/class/delete/', 'text' => ezpI18n::tr('kernel/class', 'Remove class')));
 static function clearAllContentCache($ignoreINISettings = false)
 {
     if (!$ignoreINISettings) {
         $ini = eZINI::instance();
         $viewCacheEnabled = $ini->variable('ContentSettings', 'ViewCaching') === 'enabled';
         $templateCacheEnabled = $ini->variable('TemplateSettings', 'TemplateCache') === 'enabled';
     } else {
         $viewCacheEnabled = true;
         $templateCacheEnabled = true;
     }
     if ($viewCacheEnabled || $templateCacheEnabled) {
         // view cache and/or ordinary template block cache
         eZContentObject::expireAllCache();
         ezpEvent::getInstance()->notify('content/cache/all');
         // subtree template block caches
         if ($templateCacheEnabled) {
             eZSubtreeCache::cleanupAll();
         }
     }
 }
 /**
  * Generate result data for a node view
  *
  * @param eZTemplate $tpl
  * @param eZContentObjectTreeNode $node
  * @param eZContentObject $object
  * @param bool|string $languageCode
  * @param string $viewMode
  * @param int $offset
  * @param array $viewParameters
  * @param bool|array $collectionAttributes
  * @param bool $validation
  * @return array Result array for view
  */
 static function generateNodeViewData(eZTemplate $tpl, eZContentObjectTreeNode $node, eZContentObject $object, $languageCode, $viewMode, $offset, array $viewParameters = array('offset' => 0, 'year' => false, 'month' => false, 'day' => false), $collectionAttributes = false, $validation = false)
 {
     $section = eZSection::fetch($object->attribute('section_id'));
     if ($section) {
         $navigationPartIdentifier = $section->attribute('navigation_part_identifier');
         $sectionIdentifier = $section->attribute('identifier');
     } else {
         $navigationPartIdentifier = null;
         $sectionIdentifier = null;
     }
     $keyArray = array(array('object', $object->attribute('id')), array('node', $node->attribute('node_id')), array('parent_node', $node->attribute('parent_node_id')), array('class', $object->attribute('contentclass_id')), array('class_identifier', $node->attribute('class_identifier')), array('view_offset', $offset), array('viewmode', $viewMode), array('remote_id', $object->attribute('remote_id')), array('node_remote_id', $node->attribute('remote_id')), array('navigation_part_identifier', $navigationPartIdentifier), array('depth', $node->attribute('depth')), array('url_alias', $node->attribute('url_alias')), array('class_group', $object->attribute('match_ingroup_id_list')), array('state', $object->attribute('state_id_array')), array('state_identifier', $object->attribute('state_identifier_array')), array('section', $object->attribute('section_id')), array('section_identifier', $sectionIdentifier));
     $parentClassID = false;
     $parentClassIdentifier = false;
     $parentNodeRemoteID = false;
     $parentObjectRemoteID = false;
     $parentNode = $node->attribute('parent');
     if (is_object($parentNode)) {
         $parentNodeRemoteID = $parentNode->attribute('remote_id');
         $keyArray[] = array('parent_node_remote_id', $parentNodeRemoteID);
         $parentObject = $parentNode->attribute('object');
         if (is_object($parentObject)) {
             $parentObjectRemoteID = $parentObject->attribute('remote_id');
             $keyArray[] = array('parent_object_remote_id', $parentObjectRemoteID);
             $parentClass = $parentObject->contentClass();
             if (is_object($parentClass)) {
                 $parentClassID = $parentClass->attribute('id');
                 $parentClassIdentifier = $parentClass->attribute('identifier');
                 $keyArray[] = array('parent_class', $parentClassID);
                 $keyArray[] = array('parent_class_identifier', $parentClassIdentifier);
             }
         }
     }
     $res = eZTemplateDesignResource::instance();
     $res->setKeys($keyArray);
     if ($languageCode) {
         $oldLanguageCode = $node->currentLanguage();
         $node->setCurrentLanguage($languageCode);
     }
     $tpl->setVariable('node', $node);
     $tpl->setVariable('viewmode', $viewMode);
     $tpl->setVariable('language_code', $languageCode);
     if (isset($viewParameters['_custom'])) {
         foreach ($viewParameters['_custom'] as $customVarName => $customValue) {
             $tpl->setVariable($customVarName, $customValue);
         }
         unset($viewParameters['_custom']);
     }
     $tpl->setVariable('view_parameters', $viewParameters);
     $tpl->setVariable('collection_attributes', $collectionAttributes);
     $tpl->setVariable('validation', $validation);
     $tpl->setVariable('persistent_variable', false);
     $parents = $node->attribute('path');
     $path = array();
     $titlePath = array();
     foreach ($parents as $parent) {
         $path[] = array('text' => $parent->attribute('name'), 'url' => '/content/view/full/' . $parent->attribute('node_id'), 'url_alias' => $parent->attribute('url_alias'), 'node_id' => $parent->attribute('node_id'));
     }
     $titlePath = $path;
     $path[] = array('text' => $object->attribute('name'), 'url' => false, 'url_alias' => false, 'node_id' => $node->attribute('node_id'));
     $titlePath[] = array('text' => $object->attribute('name'), 'url' => false, 'url_alias' => false);
     $tpl->setVariable('node_path', $path);
     $event = ezpEvent::getInstance();
     $event->notify('content/pre_rendering', array($node, $tpl, $viewMode));
     $Result = array();
     $Result['content'] = $tpl->fetch('design:node/view/' . $viewMode . '.tpl');
     $Result['view_parameters'] = $viewParameters;
     $Result['path'] = $path;
     $Result['title_path'] = $titlePath;
     $Result['section_id'] = $object->attribute('section_id');
     $Result['node_id'] = $node->attribute('node_id');
     $Result['navigation_part'] = $navigationPartIdentifier;
     $contentInfoArray = array();
     $contentInfoArray['object_id'] = $object->attribute('id');
     $contentInfoArray['node_id'] = $node->attribute('node_id');
     $contentInfoArray['parent_node_id'] = $node->attribute('parent_node_id');
     $contentInfoArray['class_id'] = $object->attribute('contentclass_id');
     $contentInfoArray['class_identifier'] = $node->attribute('class_identifier');
     $contentInfoArray['remote_id'] = $object->attribute('remote_id');
     $contentInfoArray['node_remote_id'] = $node->attribute('remote_id');
     $contentInfoArray['offset'] = $offset;
     $contentInfoArray['viewmode'] = $viewMode;
     $contentInfoArray['navigation_part_identifier'] = $navigationPartIdentifier;
     $contentInfoArray['node_depth'] = $node->attribute('depth');
     $contentInfoArray['url_alias'] = $node->attribute('url_alias');
     $contentInfoArray['current_language'] = $object->attribute('current_language');
     $contentInfoArray['language_mask'] = $object->attribute('language_mask');
     $contentInfoArray['main_node_id'] = $node->attribute('main_node_id');
     $contentInfoArray['main_node_url_alias'] = false;
     // Add url alias for main node if it is not current node and user has access to it
     if (!$node->isMain()) {
         $mainNode = $object->mainNode();
         if ($mainNode->canRead()) {
             $contentInfoArray['main_node_url_alias'] = $mainNode->attribute('url_alias');
         }
     }
     $contentInfoArray['persistent_variable'] = false;
     if ($tpl->variable('persistent_variable') !== false) {
         $contentInfoArray['persistent_variable'] = $tpl->variable('persistent_variable');
         $keyArray[] = array('persistent_variable', $contentInfoArray['persistent_variable']);
         $res->setKeys($keyArray);
     }
     $contentInfoArray['class_group'] = $object->attribute('match_ingroup_id_list');
     $contentInfoArray['state'] = $object->attribute('state_id_array');
     $contentInfoArray['state_identifier'] = $object->attribute('state_identifier_array');
     $contentInfoArray['parent_class_id'] = $parentClassID;
     $contentInfoArray['parent_class_identifier'] = $parentClassIdentifier;
     $contentInfoArray['parent_node_remote_id'] = $parentNodeRemoteID;
     $contentInfoArray['parent_object_remote_id'] = $parentObjectRemoteID;
     $Result['content_info'] = $contentInfoArray;
     // Store which templates were used to make this cache.
     $Result['template_list'] = $tpl->templateFetchList();
     // Check if time to live is set in template
     if ($tpl->hasVariable('cache_ttl')) {
         $cacheTTL = $tpl->variable('cache_ttl');
     }
     if (!isset($cacheTTL)) {
         $cacheTTL = -1;
     }
     $Result['cache_ttl'] = $cacheTTL;
     // if cache_ttl is set to 0 from the template, we need to add a no-cache advice
     // to the node's data. That way, the retrieve callback on the next calls
     // will be able to determine earlier that no cache generation should be started
     // for this node
     if ($cacheTTL == 0) {
         $Result['no_cache'] = true;
     }
     if ($languageCode) {
         $node->setCurrentLanguage($oldLanguageCode);
     }
     return $Result;
 }
Exemple #22
0
}
if ($http->hasPostVariable('ConfirmRemoveSectionButton')) {
    $currentUser = eZUser::currentUser();
    $accessResult = $currentUser->hasAccessTo('section', 'edit');
    if ($accessResult['accessWord'] == 'yes') {
        if ($http->hasSessionVariable('SectionIDArray')) {
            $sectionIDArray = $http->sessionVariable('SectionIDArray');
            $db = eZDB::instance();
            $db->begin();
            foreach ($sectionIDArray as $sectionID) {
                $section = eZSection::fetch($sectionID);
                if (is_object($section) and $section->canBeRemoved()) {
                    // Clear content cache if needed
                    eZContentCacheManager::clearContentCacheIfNeededBySectionID($sectionID);
                    $section->remove();
                    ezpEvent::getInstance()->notify('content/section/cache', array($sectionID));
                }
            }
            $db->commit();
        }
    } else {
        return $Module->handleError(eZError::KERNEL_ACCESS_DENIED, 'kernel');
    }
}
$viewParameters = array('offset' => $offset);
$sectionArray = eZSection::fetchByOffset($offset, $limit);
$sectionCount = eZSection::sectionCount();
$currentUser = eZUser::currentUser();
$allowedAssignSectionList = $currentUser->canAssignSectionList();
$tpl->setVariable("limit", $limit);
$tpl->setVariable('section_array', $sectionArray);
Exemple #23
0
 /**
  * Resets instance
  */
 public static function resetInstance()
 {
     self::$instance = null;
 }
Exemple #24
0
                        }
                    } else {
                        if ($result['status'] === true) {
                            $aliasText = $result['path'];
                            if (strcmp($aliasText, $origAliasText) != 0) {
                                $infoCode = "feedback-alias-cleanup";
                                $infoData['orig_alias'] = $origAliasText;
                                $infoData['new_alias'] = $aliasText;
                            } else {
                                $infoData['new_alias'] = $aliasText;
                            }
                            if ($infoCode == 'no-errors') {
                                $infoCode = "feedback-alias-created";
                            }
                            $aliasText = false;
                            ezpEvent::getInstance()->notify('content/cache', array($NodeID));
                        }
                    }
                }
            }
        }
    }
}
// Fetch generated names of node
$filter = new eZURLAliasQuery();
$filter->actions = array('eznode:' . $node->attribute('node_id'));
$filter->type = 'name';
$filter->limit = false;
$elements = $filter->fetchAll();
// Fetch custom aliases for node
$limit = 25;
Exemple #25
0
$state = $StateIdentifier ? $group->stateByIdentifier($StateIdentifier) : $group->newState();
if (!is_object($state)) {
    return $Module->handleError(eZError::KERNEL_NOT_FOUND, 'kernel');
}
$redirectUrl = "state/group/{$GroupIdentifier}";
$tpl = eZTemplate::factory();
$currentAction = $Module->currentAction();
if ($currentAction == 'Cancel') {
    return $Module->redirectTo($redirectUrl);
} else {
    if ($currentAction == 'Store') {
        $state->fetchHTTPPersistentVariables();
        $messages = array();
        $isValid = $state->isValid($messages);
        if ($isValid) {
            $state->store();
            ezpEvent::getInstance()->notify('content/state/cache', array($state->attribute('id')));
            return $Module->redirectTo($redirectUrl);
        }
        $tpl->setVariable('is_valid', $isValid);
        $tpl->setVariable('validation_messages', $messages);
    }
}
$tpl->setVariable('state', $state);
$tpl->setVariable('group', $group);
if ($StateIdentifier === null) {
    $path = array(array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'State')), array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'New')), array('url' => false, 'text' => $GroupIdentifier));
} else {
    $path = array(array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'State')), array('url' => false, 'text' => ezpI18n::tr('kernel/state', 'Edit')), array('url' => false, 'text' => $GroupIdentifier), array('url' => false, 'text' => $StateIdentifier));
}
$Result = array('path' => $path, 'content' => $tpl->fetch('design:state/edit.tpl'));
 protected function requestInit()
 {
     if ($this->isInitialized) {
         return;
     }
     eZExecution::setCleanExit(false);
     $scriptStartTime = microtime(true);
     $GLOBALS['eZRedirection'] = false;
     $this->access = eZSiteAccess::current();
     eZDebug::setScriptStart($scriptStartTime);
     eZDebug::addTimingPoint("Script start");
     $this->uri = eZURI::instance(eZSys::requestURI());
     $GLOBALS['eZRequestedURI'] = $this->uri;
     // Be able to do general events early in process
     ezpEvent::getInstance()->notify('request/preinput', array($this->uri));
     // Initialize module loading
     $this->siteBasics['module-repositories'] = eZModule::activeModuleRepositories();
     eZModule::setGlobalPathList($this->siteBasics['module-repositories']);
     // make sure we get a new $ini instance now that it has been reset
     $ini = eZINI::instance();
     // start: eZCheckValidity
     // pre check, setup wizard related so needs to be before session/db init
     // TODO: Move validity check in the constructor? Setup is not meant to be launched at each (sub)request is it?
     if ($ini->variable('SiteAccessSettings', 'CheckValidity') === 'true') {
         $this->check = array('module' => 'setup', 'function' => 'init');
         // Turn off some features that won't bee needed yet
         $this->siteBasics['policy-check-omit-list'][] = 'setup';
         $this->siteBasics['show-page-layout'] = $ini->variable('SetupSettings', 'PageLayout');
         $this->siteBasics['validity-check-required'] = true;
         $this->siteBasics['session-required'] = $this->siteBasics['user-object-required'] = false;
         $this->siteBasics['db-required'] = $this->siteBasics['no-cache-adviced'] = $this->siteBasics['url-translator-allowed'] = false;
         $this->siteBasics['site-design-override'] = $ini->variable('SetupSettings', 'OverrideSiteDesign');
         $this->access = eZSiteAccess::change(array('name' => 'setup', 'type' => eZSiteAccess::TYPE_URI));
         eZTranslatorManager::enableDynamicTranslations();
     }
     // stop: eZCheckValidity
     if ($this->siteBasics['session-required']) {
         // Check if this should be run in a cronjob
         if ($ini->variable('Session', 'BasketCleanup') !== 'cronjob') {
             eZSession::addCallback('destroy_pre', function (eZDBInterface $db, $key, $escapedKey) {
                 $basket = eZBasket::fetch($key);
                 if ($basket instanceof eZBasket) {
                     $basket->remove();
                 }
             });
             eZSession::addCallback('gc_pre', function (eZDBInterface $db, $time) {
                 eZBasket::cleanupExpired($time);
             });
             eZSession::addCallback('cleanup_pre', function (eZDBInterface $db) {
                 eZBasket::cleanup();
             });
         }
         // addCallBack to update session id for shop basket on session regenerate
         eZSession::addCallback('regenerate_post', function (eZDBInterface $db, $escNewKey, $escOldKey) {
             $db->query("UPDATE ezbasket SET session_id='{$escNewKey}' WHERE session_id='{$escOldKey}'");
         });
         // TODO: Session starting should be made only once in the constructor
         $this->sessionInit();
     }
     // if $this->siteBasics['db-required'], open a db connection and check that db is connected
     if ($this->siteBasics['db-required'] && !eZDB::instance()->isConnected()) {
         $this->warningList[] = array('error' => array('type' => 'kernel', 'number' => eZError::KERNEL_NO_DB_CONNECTION), 'text' => 'No database connection could be made, the system might not behave properly.');
     }
     // eZCheckUser: pre check, RequireUserLogin & FORCE_LOGIN related so needs to be after session init
     if (!isset($this->check)) {
         $this->check = eZUserLoginHandler::preCheck($this->siteBasics, $this->uri);
     }
     ezpEvent::getInstance()->notify('request/input', array($this->uri));
     // Initialize with locale settings
     // TODO: Move to constructor? Is it relevant to init the locale/charset for each (sub)requests?
     $this->languageCode = eZLocale::instance()->httpLocaleCode();
     $phpLocale = trim($ini->variable('RegionalSettings', 'SystemLocale'));
     if ($phpLocale != '') {
         setlocale(LC_ALL, explode(',', $phpLocale));
     }
     $this->httpCharset = eZTextCodec::httpCharset();
     // TODO: are these parameters supposed to vary across potential sub-requests?
     $this->site = array('title' => $ini->variable('SiteSettings', 'SiteName'), 'design' => $ini->variable('DesignSettings', 'SiteDesign'), 'http_equiv' => array('Content-Type' => 'text/html; charset=' . $this->httpCharset, 'Content-language' => $this->languageCode));
     // Read role settings
     $this->siteBasics['policy-check-omit-list'] = array_merge($this->siteBasics['policy-check-omit-list'], $ini->variable('RoleSettings', 'PolicyOmitList'));
     $this->isInitialized = true;
 }
Exemple #27
0
    exitWithInternalError("'{$moduleName}' module does not exist, or is not a valid module.");
    return;
}
// check existance of view
$viewName = $uri->element(1);
$moduleViews = $module->attribute('views');
if (!isset($moduleViews[$viewName])) {
    exitWithInternalError("'{$viewName}' view does not exist on the current module.");
    return;
}
// Check if module / view is disabled
$moduleCheck = eZModule::accessAllowed($uri);
if (!$moduleCheck['result']) {
    exitWithInternalError('$moduleName/$viewName is disabled.');
}
// check access to view
$ini = eZINI::instance();
$currentUser = eZUser::currentUser();
if (!hasAccessToBySetting($moduleName, $viewName, $ini->variable('RoleSettings', 'PolicyOmitList')) && !$currentUser->hasAccessToView($module, $viewName, $params)) {
    exitWithInternalError("User does not have access to the {$moduleName}/{$viewName} policy.");
    return;
}
// run module view
$uri->increase();
$uri->increase();
$GLOBALS['eZRequestedModule'] = $module;
$moduleResult = $module->run($viewName, $uri->elements(false), false, $uri->userParameters());
// ouput result and end exit cleanly
eZDB::checkTransactionCounter();
echo ezpEvent::getInstance()->filter('response/output', $moduleResult['content']);
eZExecution::cleanExit();
            $tpl->setVariable('is_edit', $Module->isCurrentAction('Edit'));
            $Result['content'] = $tpl->fetch('design:content/translationnew.tpl');
            $Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Translation'), 'url' => false), array('text' => 'New', 'url' => false));
            return;
        }
    }
}
if ($Module->isCurrentAction('Remove')) {
    $seletedIDList = $Module->actionParameter('SelectedTranslationList');
    $db = eZDB::instance();
    $db->begin();
    foreach ($seletedIDList as $translationID) {
        eZContentLanguage::removeLanguage($translationID);
    }
    $db->commit();
    ezpEvent::getInstance()->notify('content/translations/cache', array($seletedIDList));
}
if ($Params['TranslationID']) {
    $translation = eZContentLanguage::fetch($Params['TranslationID']);
    if (!$translation) {
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
    $tpl->setVariable('translation', $translation);
    $Result['content'] = $tpl->fetch('design:content/translationview.tpl');
    $Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Content translations'), 'url' => 'content/translations'), array('text' => $translation->attribute('name'), 'url' => false));
    return;
}
$availableTranslations = eZContentLanguage::fetchList();
$tpl->setVariable('available_translations', $availableTranslations);
$Result['content'] = $tpl->fetch('design:content/translations.tpl');
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Languages'), 'url' => false));
 static function printReport($newWindow = false, $as_html = true, $returnReport = false, $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false)
 {
     if (!self::isDebugEnabled()) {
         return null;
     }
     $debug = self::instance();
     $report = $debug->printReportInternal($as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles);
     if ($newWindow == true) {
         $debugFilePath = eZDir::path(array(eZSys::varDirectory(), 'cache', 'debug.html'));
         $debugFileURL = $debugFilePath;
         eZURI::transformURI($debugFileURL, true);
         print "\n<script type='text/javascript'>\n<!--\n\n(function()\n{\n    var debugWindow;\n\n    if  (navigator.appName == \"Microsoft Internet Explorer\")\n    {\n        //Microsoft Internet Explorer\n        debugWindow = window.open( '{$debugFileURL}', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.close();\n        debugWindow.location.reload();\n    }\n    else if (navigator.appName == \"Opera\")\n    {\n        //Opera\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.location.href=\"{$debugFileURL}\";\n        debugWindow.navigate(\"{$debugFileURL}\");\n    }\n    else\n    {\n        //Mozilla, Firefox, etc.\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.location.href=\"{$debugFileURL}\";\n    };\n})();\n\n// -->\n</script>\n";
         $header = "<!DOCTYPE html><html><head><title>eZ debug</title></head><body>";
         $footer = "</body></html>";
         $fullPage = ezpEvent::getInstance()->filter('response/output', $header . $report . $footer);
         file_put_contents($debugFilePath, $fullPage);
     } else {
         if ($returnReport) {
             return $report;
         }
     }
     return null;
 }
Exemple #30
0
            $nodeAssignments = array_merge($nodeAssignments, $ownerNodeAssignments);
        }
    }
}
// If exists location that current user has access to and location is visible.
$canAccess = false;
$isContentDraft = $contentObject->attribute('status') == eZContentObject::STATUS_DRAFT;
foreach ($nodeAssignments as $nodeAssignment) {
    if (eZContentObjectTreeNode::showInvisibleNodes() || !$nodeAssignment->attribute('is_invisible') and $nodeAssignment->canRead()) {
        $canAccess = true;
        break;
    }
}
if (!$canAccess && !$isContentDraft) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
// If $version is not current version (published)
// we should check permission versionRead for the $version.
if ($version != $currentVersion || $isContentDraft) {
    $versionObj = eZContentObjectVersion::fetchVersion($version, $contentObjectID);
    if (is_object($versionObj) and !$versionObj->canVersionRead()) {
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
}
ezpEvent::getInstance()->notify('content/download', array('contentObjectID' => $contentObjectID, 'contentObjectAttributeID' => $contentObjectAttributeID));
$fileHandler = eZBinaryFileHandler::instance();
$result = $fileHandler->handleDownload($contentObject, $contentObjectAttribute, eZBinaryFileHandler::TYPE_FILE);
if ($result == eZBinaryFileHandler::RESULT_UNAVAILABLE) {
    eZDebug::writeError("The specified file could not be found.");
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}