function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters, $placement)
 {
     switch ($operatorName) {
         case 'ezpreference':
             $name = $namedParameters['name'];
             $value = eZPreferences::value($name);
             $operatorValue = $value;
             break;
         default:
             eZDebug::writeError("Unknown kernel operator: {$operatorName}");
             break;
     }
 }
Ejemplo n.º 2
0
            } else {
                if ($module->isCurrentAction('UpdateAutoRates')) {
                    $error = eZShopFunctions::updateAutoRates();
                }
            }
        }
    }
}
if ($error !== false) {
    if ($error['code'] != 0) {
        $error['style'] = 'message-error';
    } else {
        $error['style'] = 'message-feedback';
    }
}
switch (eZPreferences::value('currencies_list_limit')) {
    case '2':
        $limit = 25;
        break;
    case '3':
        $limit = 50;
        break;
    default:
        $limit = 10;
        break;
}
// fetch currencies
$currencyList = eZCurrencyData::fetchList(null, true, $offset, $limit);
$currencyCount = eZCurrencyData::fetchListCount();
$viewParameters = array('offset' => $offset);
$tpl = eZTemplate::factory();
Ejemplo n.º 3
0
$conds = array();
//$conds['user_id'] =  $userID;
$conds['status'] = array(array(eZWorkflow::STATUS_DEFERRED_TO_CRON, eZWorkflow::STATUS_FETCH_TEMPLATE, eZWorkflow::STATUS_REDIRECT, eZWorkflow::STATUS_WAITING_PARENT));
$db = eZDB::instance();
if ($db->databaseName() == 'oracle') {
    $conds['LENGTH(memento_key)'] = array('!=', 0);
} else {
    $conds['memento_key'] = array('!=', '');
}
$offset = $Params['Offset'];
if (!is_numeric($offset)) {
    $offset = 0;
}
$limitList = array(1 => 10, 2 => 25, 3 => 50, 4 => 100);
$limit = 10;
$limitId = eZPreferences::value('admin_workflow_processlist_limit');
if ($limitId and isset($limitList[$limitId])) {
    $limit = $limitList[$limitId];
}
$viewParameters = array('offset' => $offset);
$plist = eZWorkflowProcess::fetchList($conds, true, $offset, $limit);
$plistCount = eZWorkflowProcess::count(eZWorkflowProcess::definition(), $conds);
$totalProcessCount = 0;
$outList2 = array();
foreach ($plist as $p) {
    $mementoMain = eZOperationMemento::fetchMain($p->attribute('memento_key'));
    $mementoChild = eZOperationMemento::fetchChild($p->attribute('memento_key'));
    if (!$mementoMain or !$mementoChild) {
        continue;
    }
    $mementoMainData = $mementoMain->data();
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.07.0
 * @package kernel
 */
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$NodeID = $Params['NodeID'];
if ($http->hasPostVariable("BackButton")) {
    $userRedirectURI = $http->sessionVariable('userRedirectURIReverseRelatedList');
    $http->removeSessionVariable('userRedirectURIReverseRelatedList');
    return $Module->redirectTo($userRedirectURI);
}
if (!isset($Offset)) {
    $Offset = false;
}
$children_list_limit = eZPreferences::value("reverse_children_list_limit");
switch ($children_list_limit) {
    case 0:
        $pageLimit = 10;
        break;
    case 1:
        $pageLimit = 10;
        break;
    case 2:
        $pageLimit = 25;
        break;
    case 3:
        $pageLimit = 50;
        break;
    default:
        $pageLimit = 10;
Ejemplo n.º 5
0
    {
        $cli->output( "Could not remove expired sessions, current session handler does not support session garbage collection (not backend based)." );
    }
    else
    {
        $cli->output( "Removing expired sessions,", false );
        eZSession::garbageCollector();
        $activeCount = eZSession::countActive();
        $cli->output( " " . $cli->stylize( 'emphasize', $activeCount ) . " left" );
    }
}

if ( $clean['preferences'] )
{
    $cli->output( "Removing all preferences" );
    eZPreferences::cleanup();
}

if ( $clean['browse'] )
{
    $cli->output( "Removing all recent items and bookmarks for browse page" );
    eZContentBrowseRecent::cleanup();
    eZContentBrowseBookmark::cleanup();
}

if ( $clean['tipafriend'] )
{
    $cli->output( "Removing all counters for tip-a-friend" );
    eZTipafriendCounter::cleanup();
}
 /**
  * Set user preferences
  * Only needed for operations, call eZPreferences::setValue() directly if you want to set user preferences
  *
  * @param string $key
  * @param string $value
  *
  * @return array An array with operation status, always true
  */
 public static function preferences($key, $value)
 {
     eZPreferences::setValue($key, $value);
     return array('status' => true);
 }
Ejemplo n.º 7
0
 * @filesource
 */
// Blacklist User by nl user id or by email
// update all nessesarry status fields to blacklisted
$module = $Params['Module'];
$templateFile = 'design:newsletter/blacklist_item_list.tpl';
require_once 'kernel/common/i18n.php';
include_once 'kernel/common/template.php';
$http = eZHTTPTool::instance();
$tpl = templateInit();
$http = eZHTTPTool::instance();
$db = eZDB::instance();
$viewParameters = array('offset' => 0, 'namefilter' => '');
$userParameters = $Params['UserParameters'];
$viewParameters = array_merge($viewParameters, $userParameters);
$limit = 10;
$limitArray = array(10, 10, 25, 50);
$limitArrayKey = eZPreferences::value('admin_blacklist_item_list_limit');
// get user limit preference
if (isset($limitArray[$limitArrayKey])) {
    $limit = $limitArray[$limitArrayKey];
}
$blacklistItemList = CjwNewsletterBlacklistItem::fetchAllBlacklistItems($limit, $viewParameters['offset']);
$blacklistItemListCount = CjwNewsletterBlacklistItem::fetchAllBlacklistItemsCount();
$tpl->setVariable('view_parameters', $viewParameters);
$tpl->setVariable('blacklist_item_list', $blacklistItemList);
$tpl->setVariable('blacklist_item_list_count', $blacklistItemListCount);
$tpl->setVariable('limit', $limit);
$Result = array();
$Result['content'] = $tpl->fetch($templateFile);
$Result['path'] = array(array('url' => 'newsletter/index', 'text' => ezi18n('cjw_newsletter/path', 'Newsletter')), array('url' => false, 'text' => ezi18n('cjw_newsletter/blacklist_item_list', 'Blacklists')));
Ejemplo n.º 8
0
<?php

/**
 * @copyright Copyright (C) 1999-2013 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2013.11
 * @package kernel
 */
$Module = $Params['Module'];
$ViewMode = $Params['ViewMode'];
if (eZPreferences::value('admin_url_list_limit')) {
    switch (eZPreferences::value('admin_url_list_limit')) {
        case '2':
            $limit = 25;
            break;
        case '3':
            $limit = 50;
            break;
        default:
            $limit = 10;
            break;
    }
} else {
    $limit = 10;
}
$offset = $Params['Offset'];
if (!is_numeric($offset)) {
    $offset = 0;
}
if ($ViewMode != 'all' && $ViewMode != 'invalid' && $ViewMode != 'valid') {
    $ViewMode = 'all';
Ejemplo n.º 9
0
$http = eZHTTPTool::instance();
$module = $Params['Module'];

$allSettingsList = $module->actionParameter( 'AllSettingsList' );

if ( $module->hasActionParameter( 'SelectedList' ) )
    $selectedList = $module->actionParameter( 'SelectedList' );
else
    $selectedList=array();

$siteAccess = $module->actionParameter( 'SiteAccess' );
if ( !$siteAccess )
    $siteAccess = 'global_override';

eZPreferences::setValue( 'admin_quicksettings_siteaccess', $siteAccess );

$iniFiles = array();

foreach( $allSettingsList as $index => $setting )
{
    $settingArray = explode( ';', $setting );

    if ( !array_key_exists( $settingArray[2], $iniFiles ) )
        $iniFiles[$settingArray[2]] = array();

    $iniFiles[$settingArray[2]][] = array ( $settingArray[0], $settingArray[1], in_array( $index, $selectedList ) );
}
unset( $setting );

$iniPath = ( $siteAccess == "global_override" ) ? "settings/override" : "settings/siteaccess/$siteAccess";
if ($tpl->hasVariable('node_url_alias', $rootNamespace)) {
    $tpl->warning('def', "Variable 'node_url_alias' is already defined.", array(0 => array(0 => 2, 1 => 0, 2 => 23), 1 => array(0 => 19, 1 => 0, 2 => 1205), 2 => 'design/admin/templates/window_controls.tpl'));
    $tpl->setVariable('node_url_alias', $var, $rootNamespace);
} else {
    $tpl->setLocalVariable('node_url_alias', $var, $rootNamespace);
}
// def $tabs_disabled
if ($tpl->hasVariable('tabs_disabled', $rootNamespace)) {
    $tpl->warning('def', "Variable 'tabs_disabled' is already defined.", array(0 => array(0 => 2, 1 => 0, 2 => 23), 1 => array(0 => 19, 1 => 0, 2 => 1205), 2 => 'design/admin/templates/window_controls.tpl'));
    $tpl->setVariable('tabs_disabled', false, $rootNamespace);
} else {
    $tpl->setLocalVariable('tabs_disabled', false, $rootNamespace);
}
// def $admin_navigation_content_pref
unset($var);
$var = eZPreferences::value("admin_navigation_content");
if (!isset($var)) {
    $var = NULL;
}
while (is_object($var) and method_exists($var, 'templateValue')) {
    $var = $var->templateValue();
}
if ($tpl->hasVariable('admin_navigation_content_pref', $rootNamespace)) {
    $tpl->warning('def', "Variable 'admin_navigation_content_pref' is already defined.", array(0 => array(0 => 2, 1 => 0, 2 => 23), 1 => array(0 => 19, 1 => 0, 2 => 1205), 2 => 'design/admin/templates/window_controls.tpl'));
    $tpl->setVariable('admin_navigation_content_pref', $var, $rootNamespace);
} else {
    $tpl->setLocalVariable('admin_navigation_content_pref', $var, $rootNamespace);
}
// def $default_tab
if ($tpl->hasVariable('default_tab', $rootNamespace)) {
    $tpl->warning('def', "Variable 'default_tab' is already defined.", array(0 => array(0 => 2, 1 => 0, 2 => 23), 1 => array(0 => 19, 1 => 0, 2 => 1205), 2 => 'design/admin/templates/window_controls.tpl'));
 public static function setCookie()
 {
     $ini = eZINI::instance('scachecookie.ini');
     $siteIni = eZINI::instance('site.ini');
     $hasUserData = false;
     $displayedData = $ini->variable('CacheCookieSettings', 'DisplayedData');
     $cookieValue = $ini->variable('CacheCookieSettings', 'CookieValue') || 'true';
     if ($cookieValue === true) {
         $cookieValue = 'true';
     }
     $useDetailedValue = $ini->variable('CacheCookieSettings', 'DetailedCookieValue') == 'enabled';
     $detailedValue = '';
     if (in_array('basket', $displayedData)) {
         $http = eZHTTPTool::instance();
         $sessionID = $http->sessionID();
         $basket = eZBasket::fetch($sessionID);
         if ($basket) {
             if (!$basket->isEmpty()) {
                 $hasUserData = true;
                 if ($useDetailedValue) {
                     $detailedValue .= ',basket';
                 }
             }
         }
     }
     if ((!$hasUserData || $useDetailedValue) && in_array('wishlist', $displayedData)) {
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
         $WishListArray = eZPersistentObject::fetchObjectList(eZWishList::definition(), null, array("user_id" => $userID), null, null, true);
         if (count($WishListArray) > 0) {
             if ($WishListArray[0]->itemCount() > 0) {
                 $hasUserData = true;
                 if ($useDetailedValue) {
                     $detailedValue .= ',wishlist';
                 }
             }
         }
     }
     if (!$hasUserData || $useDetailedValue) {
         $prefs = eZPreferences::values();
         $hasPrefs = false;
         foreach ($prefs as $key => $val) {
             if ($key != '') {
                 if (in_array('preferences', $displayedData) || in_array($key, $displayedData)) {
                     if ($val != '') {
                         $hasUserData = true;
                         if ($useDetailedValue) {
                             if (in_array('preferences', $displayedData) && !$hasPrefs) {
                                 $detailedValue .= ',preferences';
                             }
                             if (in_array($key, $displayedData)) {
                                 $detailedValue .= ",{$key}:{$val}";
                             }
                         }
                         $hasPrefs = true;
                     }
                 }
             }
         }
     }
     $value = $hasUserData ? $cookieValue . $detailedValue : false;
     $wwwDir = eZSys::wwwDir();
     $cookiePath = $wwwDir != '' ? $wwwDir : '/';
     setcookie($ini->variable('CacheCookieSettings', 'CookieName'), $value, time() + (int) $siteIni->variable('Session', 'SessionTimeout'), $cookiePath);
 }
Ejemplo n.º 12
0
<?php

/**
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version //autogentag//
 * @package kernel
 */
$http = eZHTTPTool::instance();
$Module = $Params['Module'];
$tpl = eZTemplate::factory();
$tpl->setVariable('module', $Module);
$offset = $Params['Offset'];
if (eZPreferences::value('admin_section_list_limit')) {
    switch (eZPreferences::value('admin_section_list_limit')) {
        case '2':
            $limit = 25;
            break;
        case '3':
            $limit = 50;
            break;
        default:
            $limit = 10;
            break;
    }
} else {
    $limit = 10;
}
if ($http->hasPostVariable('CreateSectionButton')) {
    $Module->redirectTo($Module->functionURI("edit") . '/0/');
    return;
            $assignments[$key]->remove();
            unset( $assignments[$key] );
            eZDebugSetting::writeDebug( 'kernel-content-edit', "placement is not validated" );
        }

        if ( isset( $assignments[$key] ) &&
             $assignments[$key]->attribute( 'is_main' ) == 1 )
        {
            $mainFound = true;
            break;
        }
    }
    $db->commit();
    if ( !$mainFound and count( $assignments ) > 0 )
    {
        if( eZPreferences::value( 'admin_edit_show_locations' ) == '0' )
        {
            $validation[ 'placement' ][] = array( 'text' => ezpI18n::tr( 'kernel/content', 'No main node selected, please select one.' ) );
            $validation[ 'processed' ] = true;
            $inputValidated = false;
            eZDebugSetting::writeDebug( 'kernel-content-edit', "placement is not validated" );
        }
    }
    else
        eZDebugSetting::writeDebug( 'kernel-content-edit', "placement is validated" );

}

// After the object has been validated we can check for other actions
$Result = '';
if ( $inputValidated == true )
                        eZURLWildcard::expireCache();
                        $infoData['wildcard_src_url'] = $wildcardSrcText;
                        $infoData['wildcard_dst_url'] = $wildcardDstText;
                        $wildcardSrcText = false;
                        $wildcardDstText = false;
                        $wildcardType = false;
                        $infoCode = "feedback-wildcard-created";
                    }
                }
            }
        }
    }
}
// User preferences
$limitList = array(array('id' => 1, 'value' => 10), array('id' => 2, 'value' => 25), array('id' => 3, 'value' => 50), array('id' => 4, 'value' => 100));
$limitID = eZPreferences::value('admin_urlwildcard_list_limit');
foreach ($limitList as $limitEntry) {
    $limitIDs[] = $limitEntry['id'];
    $limitValues[$limitEntry['id']] = $limitEntry['value'];
}
if (!in_array($limitID, $limitIDs)) {
    $limitID = 2;
}
// Fetch wildcads
$wildcardsLimit = $limitValues[$limitID];
$wildcardsCount = eZURLWildcard::fetchListCount();
// check offset, it can be out of range if some wildcards were removed.
if ($Offset >= $wildcardsCount) {
    $Offset = 0;
}
$wildcardList = eZURLWildcard::fetchList($Offset, $wildcardsLimit);
Ejemplo n.º 15
0
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.07.0
 * @package kernel
 */
$module = $Params['Module'];
$tpl = eZTemplate::factory();
$offset = $Params['Offset'];
$limit = 50;
if (eZPreferences::value('admin_archivelist_sortfield')) {
    $sortField = eZPreferences::value('admin_archivelist_sortfield');
}
if (!isset($sortField) || $sortField != 'created' && $sortField != 'user_name') {
    $sortField = 'created';
}
if (eZPreferences::value('admin_archivelist_sortorder')) {
    $sortOrder = eZPreferences::value('admin_archivelist_sortorder');
}
if (!isset($sortOrder) || $sortOrder != 'asc' && $sortOrder != 'desc') {
    $sortOrder = 'asc';
}
$http = eZHTTPTool::instance();
// Unarchive options.
if ($http->hasPostVariable('UnarchiveButton')) {
    if ($http->hasPostVariable('OrderIDArray')) {
        $orderIDArray = $http->postVariable('OrderIDArray');
        if ($orderIDArray !== null) {
            $http->setSessionVariable('OrderIDArray', $orderIDArray);
            $Module->redirectTo($Module->functionURI('unarchiveorder') . '/');
        }
    }
}
Ejemplo n.º 16
0
 static function generateViewCacheFile($user, $nodeID, $offset, $layout, $language, $viewMode, $viewParameters = false, $cachedViewPreferences = false, $viewCacheTweak = '')
 {
     $cacheNameExtra = '';
     $ini = eZINI::instance();
     if (!$language) {
         $language = false;
     }
     if (!$viewCacheTweak && $ini->hasVariable('ContentSettings', 'ViewCacheTweaks')) {
         $viewCacheTweaks = $ini->variable('ContentSettings', 'ViewCacheTweaks');
         if (isset($viewCacheTweaks[$nodeID])) {
             $viewCacheTweak = $viewCacheTweaks[$nodeID];
         } else {
             if (isset($viewCacheTweaks['global'])) {
                 $viewCacheTweak = $viewCacheTweaks['global'];
             }
         }
     }
     // should we use current siteaccess or let several siteaccesse share cache?
     if (strpos($viewCacheTweak, 'ignore_siteaccess_name') === false) {
         $currentSiteAccess = $GLOBALS['eZCurrentAccess']['name'];
     } else {
         $currentSiteAccess = $ini->variable('SiteSettings', 'DefaultAccess');
     }
     $cacheHashArray = array($nodeID, $viewMode, $language, $offset, $layout);
     // several user related cache tweaks
     if (strpos($viewCacheTweak, 'ignore_userroles') === false) {
         $cacheHashArray[] = implode('.', $user->roleIDList());
     }
     if (strpos($viewCacheTweak, 'ignore_userlimitedlist') === false) {
         $cacheHashArray[] = implode('.', $user->limitValueList());
     }
     if (strpos($viewCacheTweak, 'ignore_discountlist') === false) {
         $cacheHashArray[] = implode('.', eZUserDiscountRule::fetchIDListByUserID($user->attribute('contentobject_id')));
     }
     $cacheHashArray[] = eZSys::indexFile();
     // Add access type to cache hash if current access is uri type (so uri and host doesn't share cache)
     if (strpos($viewCacheTweak, 'ignore_siteaccess_type') === false && $GLOBALS['eZCurrentAccess']['type'] === eZSiteAccess::TYPE_URI) {
         $cacheHashArray[] = eZSiteAccess::TYPE_URI;
     }
     // Make the cache unique for every logged in user
     if (strpos($viewCacheTweak, 'pr_user') !== false and !$user->isAnonymous()) {
         $cacheNameExtra = $user->attribute('contentobject_id') . '-';
     }
     // Make the cache unique for every case of view parameters
     if (strpos($viewCacheTweak, 'ignore_viewparameters') === false && $viewParameters) {
         $vpString = '';
         ksort($viewParameters);
         foreach ($viewParameters as $key => $value) {
             if (!$key || $key === '_custom') {
                 continue;
             }
             $vpString .= 'vp:' . $key . '=' . $value;
         }
         $cacheHashArray[] = $vpString;
     }
     // Make the cache unique for every case of the preferences
     if ($cachedViewPreferences === false) {
         $depPreferences = $ini->variable('ContentSettings', 'CachedViewPreferences');
     } else {
         $depPreferences = $cachedViewPreferences;
     }
     if (strpos($viewCacheTweak, 'ignore_userpreferences') === false && isset($depPreferences[$viewMode])) {
         $depPreferences = explode(';', $depPreferences[$viewMode]);
         $pString = '';
         // Fetch preferences for the specified user
         $preferences = eZPreferences::values($user);
         foreach ($depPreferences as $pref) {
             $pref = explode('=', $pref);
             if (isset($pref[0])) {
                 if (isset($preferences[$pref[0]])) {
                     $pString .= 'p:' . $pref[0] . '=' . $preferences[$pref[0]] . ';';
                 } else {
                     if (isset($pref[1])) {
                         $pString .= 'p:' . $pref[0] . '=' . $pref[1] . ';';
                     }
                 }
             }
         }
         $cacheHashArray[] = $pString;
     }
     $cacheFile = $nodeID . '-' . $cacheNameExtra . md5(implode('-', $cacheHashArray)) . '.cache';
     $extraPath = eZDir::filenamePath($nodeID);
     $cacheDir = eZDir::path(array(eZSys::cacheDirectory(), $ini->variable('ContentSettings', 'CacheDir'), $currentSiteAccess, $extraPath));
     $cachePath = eZDir::path(array($cacheDir, $cacheFile));
     return array('cache_path' => $cachePath, 'cache_dir' => $cacheDir, 'cache_file' => $cacheFile);
 }
Ejemplo n.º 17
0
 static function setPreferredUserCountry($country)
 {
     eZPreferences::setValue('user_preferred_country', $country);
     return eZError::SHOP_OK;
 }
Ejemplo n.º 18
0
                                    $aliasOutputDestinationText = false;
                                }
                            }
                            if (preg_match("#^eznode:(.+)\$#", $action, $matches)) {
                                $infoData['node_id'] = $matches[1];
                            }
                        }
                    }
                }
            }
        }
    }
}
// User preferences
$limitList = array(array('id' => 1, 'value' => 10), array('id' => 2, 'value' => 25), array('id' => 3, 'value' => 50), array('id' => 4, 'value' => 100));
$limitID = eZPreferences::value('admin_urlalias_list_limit');
foreach ($limitList as $limitEntry) {
    $limitIDs[] = $limitEntry['id'];
    $limitValues[$limitEntry['id']] = $limitEntry['value'];
}
if (!in_array($limitID, $limitIDs)) {
    $limitID = 2;
}
// Fetch global custom aliases (excluding eznode)
$filter = new eZURLAliasQuery();
$filter->actionTypesEx = array('eznode', 'nop');
$filter->offset = $Offset;
$filter->limit = $limitValues[$limitID];
// Prime the internal data for the template, for PHP5 this is no longer needed since objects will not be copied anymore in the template code.
$count = $filter->count();
$aliasList = $filter->fetchAll();
Ejemplo n.º 19
0
    if( is_array( $collectionIDArray ) )
    {
        foreach( $collectionIDArray as $collectionID )
        {
            eZInformationCollection::removeCollection( $collectionID );
        }
    }

    $objectID = $http->sessionVariable( 'ObjectID' );
    $module->redirectTo( '/infocollector/collectionlist/' . $objectID );
}


if( eZPreferences::value( 'admin_infocollector_list_limit' ) )
{
    switch( eZPreferences::value( 'admin_infocollector_list_limit' ) )
    {
        case '2': { $limit = 25; } break;
        case '3': { $limit = 50; } break;
        default:  { $limit = 10; } break;
    }
}
else
{
    $limit = 10;
}

$object = false;

if( is_numeric( $objectID ) )
{
    foreach ($restoreIncludeArray as $element) {
        if ($element[2] === 'unset') {
            unset($vars[$element[0]][$element[1]]);
            continue;
        }
        $vars[$element[0]][$element[1]] = $element[2];
    }
    $restoreIncludeArray = $oldRestoreIncludeArray_d20717e07f71ae28b4af4bec0dfc6120;
}
unset($if_cond);
// if ends
$text .= '
';
// if begins
unset($if_cond);
$if_cond = eZPreferences::value("admin_navigation_class_temlates");
if (!isset($if_cond)) {
    $if_cond = NULL;
}
while (is_object($if_cond) and method_exists($if_cond, 'templateValue')) {
    $if_cond = $if_cond->templateValue();
}
if ($if_cond) {
    $text .= '    ';
    $oldRestoreIncludeArray_d20717e07f71ae28b4af4bec0dfc6120 = isset($restoreIncludeArray) ? $restoreIncludeArray : array();
    $restoreIncludeArray = array();
    if (!isset($dKeys)) {
        $resH = $tpl->resourceHandler("design");
        $dKeys = $resH->keys();
    }
    $resourceFound = false;
 function initializePackage($siteType, &$accessMap, $charset, &$extraLanguageCodes, &$allLanguages, &$primaryLanguage, &$admin, &$resultArray)
 {
     // Time limit #3:
     // We set the time limit to 5 minutes to ensure we have enough time
     // to initialize the site. However we only set if the current limit
     // is too small
     $maxTime = ini_get('max_execution_time');
     if ($maxTime != 0 and $maxTime < 5 * 60) {
         @set_time_limit(5 * 60);
     }
     switch ($siteType['access_type']) {
         case 'port':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['port'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['port'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'hostname':
             $userSiteaccessName = $siteType['identifier'] . '_' . 'user';
             $adminSiteaccessName = $siteType['identifier'] . '_' . 'admin';
             $accessMap['hostname'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['hostname'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
         case 'url':
         default:
             $userSiteaccessName = $siteType['access_type_value'];
             $adminSiteaccessName = $siteType['admin_access_type_value'];
             $accessMap['url'][$siteType['access_type_value']] = $userSiteaccessName;
             $accessMap['url'][$siteType['admin_access_type_value']] = $adminSiteaccessName;
             break;
     }
     $accessMap['accesses'][] = $userSiteaccessName;
     $accessMap['accesses'][] = $adminSiteaccessName;
     $accessMap['sites'][] = $userSiteaccessName;
     $userDesignName = $siteType['identifier'];
     $languageObjects = $allLanguages;
     $databaseMap = eZSetupDatabaseMap();
     $databaseInfo = $this->PersistenceList['database_info'];
     $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
     $dbServer = $databaseInfo['server'];
     $dbPort = $databaseInfo['port'];
     //        $dbName = $databaseInfo['dbname'];
     $dbSocket = $databaseInfo['socket'];
     $dbUser = $databaseInfo['user'];
     $dbPwd = $databaseInfo['password'];
     $dbCharset = $charset;
     $dbDriver = $databaseInfo['info']['driver'];
     $dbName = $siteType['database'];
     $dbParameters = array('server' => $dbServer, 'port' => $dbPort, 'user' => $dbUser, 'password' => $dbPwd, 'socket' => $dbSocket, 'database' => $dbName, 'charset' => $dbCharset);
     $db = eZDB::instance($dbDriver, $dbParameters, true);
     if (!$db->isConnected()) {
         $resultArray['errors'][] = array('code' => 'EZSW-005', 'text' => "Failed connecting to database {$dbName}\n" . $db->errorMessage());
         return false;
     }
     eZDB::setInstance($db);
     $result = true;
     // Initialize the database by inserting schema and data
     if (!isset($siteType['existing_database'])) {
         $siteType['existing_database'] = false;
     }
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_REMOVE) {
         eZDBTool::cleanup($db);
     }
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $result = true;
         $schemaArray = eZDbSchema::read('share/db_schema.dba', true);
         if (!$schemaArray) {
             $resultArray['errors'][] = array('code' => 'EZSW-001', 'message' => "Failed loading database schema file share/db_schema.dba");
             $result = false;
         }
         if ($result) {
             $result = true;
             $dataArray = eZDbSchema::read('share/db_data.dba', true);
             if (!$dataArray) {
                 $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed loading database data file share/db_data.dba");
                 $result = false;
             }
             if ($result) {
                 $schemaArray = array_merge($schemaArray, $dataArray);
                 $schemaArray['type'] = strtolower($db->databaseName());
                 $schemaArray['instance'] = $db;
                 $result = true;
                 $dbSchema = eZDbSchema::instance($schemaArray);
                 if (!$dbSchema) {
                     $resultArray['errors'][] = array('code' => 'EZSW-003', 'text' => "Failed loading " . $db->databaseName() . " schema handler");
                     $result = false;
                 }
                 if ($result) {
                     $result = true;
                     // This will insert the schema, then the data and
                     // run any sequence value correction SQL if required
                     $params = array('schema' => true, 'data' => true);
                     if ($db->databaseName() == 'mysql') {
                         $engines = $db->arrayQuery('SHOW ENGINES');
                         foreach ($engines as $engine) {
                             if ($engine['Engine'] == 'InnoDB' && in_array($engine['Support'], array('YES', 'DEFAULT'))) {
                                 $params['table_type'] = 'innodb';
                                 break;
                             }
                         }
                     }
                     if (!$dbSchema->insertSchema($params)) {
                         $resultArray['errors'][] = array('code' => 'EZSW-004', 'text' => "Failed inserting data to " . $db->databaseName() . "\n" . $db->errorMessage());
                         $result = false;
                     }
                 }
             }
         }
         if ($result) {
             // Inserting data from the dba-data files of the datatypes
             eZDataType::loadAndRegisterAllTypes();
             $registeredDataTypes = eZDataType::registeredDataTypes();
             foreach ($registeredDataTypes as $dataType) {
                 if (!$dataType->importDBDataFromDBAFile()) {
                     $resultArray['errors'][] = array('code' => 'EZSW-002', 'text' => "Failed importing datatype related data into database: \n" . 'datatype - ' . $dataType->DataTypeString . ", \n" . 'dba-data file - ' . $dataType->getDBAFilePath());
                 }
             }
         }
     }
     if (!$result) {
         return false;
     }
     // Database initialization done
     // Prepare languages
     $primaryLanguageLocaleCode = $primaryLanguage->localeCode();
     $primaryLanguageName = $primaryLanguage->languageName();
     $prioritizedLanguages = array_merge(array($primaryLanguageLocaleCode), $extraLanguageCodes);
     $installParameters = array('path' => '.');
     $installParameters['ini'] = array();
     $siteINIChanges = array();
     $url = $siteType['url'];
     if (preg_match("#^[a-zA-Z0-9]+://(.*)\$#", $url, $matches)) {
         $url = $matches[1];
     }
     $siteINIChanges['SiteAccessSettings'] = array('RelatedSiteAccessList' => $accessMap['accesses']);
     $siteINIChanges['ContentSettings'] = array('TranslationList' => implode(';', $extraLanguageCodes));
     $siteINIChanges['SiteSettings'] = array('SiteName' => $siteType['title'], 'SiteURL' => $url);
     $siteINIChanges['DatabaseSettings'] = array('DatabaseImplementation' => $dbDriver, 'Server' => $dbServer, 'Port' => $dbPort, 'Database' => $dbName, 'User' => $dbUser, 'Password' => $dbPwd, 'Charset' => false);
     $siteINIChanges['FileSettings'] = array('VarDir' => 'var/' . $siteType['identifier']);
     if (trim($dbSocket) != '') {
         $siteINIChanges['DatabaseSettings']['Socket'] = $dbSocket;
     } else {
         $siteINIChanges['DatabaseSettings']['Socket'] = 'disabled';
     }
     if ($admin['email']) {
         $siteINIChanges['InformationCollectionSettings'] = array('EmailReceiver' => false);
         $siteINIChanges['UserSettings'] = array('RegistrationEmail' => false);
         $siteINIChanges['MailSettings'] = array('AdminEmail' => $admin['email'], 'EmailSender' => false);
     }
     $siteINIChanges['RegionalSettings'] = array('Locale' => $primaryLanguage->localeFullCode(), 'ContentObjectLocale' => $primaryLanguage->localeCode(), 'SiteLanguageList' => $prioritizedLanguages);
     if ($primaryLanguage->localeCode() == 'eng-GB') {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'disabled';
     } else {
         $siteINIChanges['RegionalSettings']['TextTranslation'] = 'enabled';
     }
     $installParameters['ini']['siteaccess'][$adminSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini.append'] = $siteINIChanges;
     $installParameters['ini']['siteaccess'][$userSiteaccessName]['site.ini']['DesignSettings'] = array('SiteDesign' => $userDesignName);
     $installParameters['variables']['user_siteaccess'] = $userSiteaccessName;
     $installParameters['variables']['admin_siteaccess'] = $adminSiteaccessName;
     $installParameters['variables']['design'] = $userDesignName;
     $tmpSiteINI = eZINI::create('site.ini');
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $tmpSiteINI->setReadOnlySettingsCheck(false);
     $tmpSiteINI->setVariable('FileSettings', 'VarDir', $siteINIChanges['FileSettings']['VarDir']);
     // Change the current translation variables, before other parts start using them
     $tmpSiteINI->setVariable('RegionalSettings', 'Locale', $siteINIChanges['RegionalSettings']['Locale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'ContentObjectLocale', $siteINIChanges['RegionalSettings']['ContentObjectLocale']);
     $tmpSiteINI->setVariable('RegionalSettings', 'TextTranslation', $siteINIChanges['RegionalSettings']['TextTranslation']);
     $tmpSiteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     /*
     $typeFunctionality = eZSetupFunctionality( $siteType['identifier'] );
     $extraFunctionality = array_merge( isset( $this->PersistenceList['additional_packages'] ) ?
                                        $this->PersistenceList['additional_packages'] :
                                        array(),
                                        $typeFunctionality['required'] );
     $extraFunctionality = array_unique( $extraFunctionality );
     */
     // Add a policy to permit editors using OE
     eZPolicy::createNew(3, array('ModuleName' => 'ezoe', 'FunctionName' => '*'));
     // Install site package and it's required packages
     $sitePackageName = $this->chosenSitePackage();
     $sitePackage = eZPackage::fetch($sitePackageName);
     if (!is_object($sitePackage)) {
         $resultArray['errors'][] = array('code' => 'EZSW-041', 'text' => " Could not fetch site package: '{$sitePackageName}'");
         return false;
     }
     $dependecies = $sitePackage->attribute('dependencies');
     $requires = $dependecies['requires'];
     $requiredPackages = array();
     // Include setting files
     $settingsFiles = $sitePackage->attribute('settings-files');
     foreach ($settingsFiles as $settingsFileName) {
         if (file_exists($sitePackage->path() . '/settings/' . $settingsFileName)) {
             include_once $sitePackage->path() . '/settings/' . $settingsFileName;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePreInstall')) {
         eZSitePreInstall($siteType);
     }
     // Make sure objects use the selected main language instead of eng-GB
     if ($primaryLanguageLocaleCode != 'eng-GB') {
         $engLanguageObj = eZContentLanguage::fetchByLocale('eng-GB');
         $engLanguageID = (int) $engLanguageObj->attribute('id');
         $updateSql = "UPDATE ezcontent_language\nSET\nlocale='{$primaryLanguageLocaleCode}',\nname='{$primaryLanguageName}'\nWHERE\nid={$engLanguageID}";
         $db->query($updateSql);
         eZContentLanguage::expireCache();
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($primaryLanguageLocaleCode);
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($primaryLanguageLocaleCode, $primaryLanguageName);
         }
         $primaryLanguageID = (int) $primaryLanguageObj->attribute('id');
         // Find objects which are always available
         if ($db->databaseName() == 'oracle') {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nbitand( language_mask, 1 ) = 1";
         } else {
             $sql = "SELECT id\nFROM\nezcontentobject\nWHERE\nlanguage_mask & 1 = 1";
         }
         $objectList = array();
         $list = $db->arrayQuery($sql);
         foreach ($list as $row) {
             $objectList[] = (int) $row['id'];
         }
         $inSql = 'IN ( ' . implode(', ', $objectList) . ')';
         // Updates databases that have eng-GB data to the new locale.
         $updateSql = "UPDATE ezcontentobject_name\nSET\ncontent_translation='{$primaryLanguageLocaleCode}',\nreal_translation='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\ncontent_translation='eng-GB' OR\nreal_translation='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_name\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // attributes
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_code='{$primaryLanguageLocaleCode}',\nlanguage_id={$primaryLanguageID}\nWHERE\nlanguage_code='eng-GB'";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_attribute\nSET\nlanguage_id=language_id+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // version
         $updateSql = "UPDATE ezcontentobject_version\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject_version\nSET\nlanguage_mask=language_mask+1\nWHERE\ncontentobject_id {$inSql}";
         $db->query($updateSql);
         // object
         $updateSql = "UPDATE ezcontentobject\nSET\ninitial_language_id={$primaryLanguageID},\nlanguage_mask={$primaryLanguageID}\nWHERE\ninitial_language_id={$engLanguageID}";
         $db->query($updateSql);
         // Fix always available
         $updateSql = "UPDATE ezcontentobject\nSET\nlanguage_mask=language_mask+1\nWHERE\nid {$inSql}";
         $db->query($updateSql);
         // content object state groups & states
         $mask = $primaryLanguageID | 1;
         $db->query("UPDATE ezcobj_state_group\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state\n                         SET language_mask = {$mask}, default_language_id = {$primaryLanguageID}\n                         WHERE default_language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_group_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         $db->query("UPDATE ezcobj_state_language\n                         SET language_id = {$primaryLanguageID}\n                         WHERE language_id = {$engLanguageID}");
         // ezcontentclass_name
         $updateSql = "UPDATE ezcontentclass_name\nSET\nlanguage_locale='{$primaryLanguageLocaleCode}'\nWHERE\nlanguage_locale='eng-GB'";
         $db->query($updateSql);
         // use high-level api, because it's impossible to update serialized names with direct sqls.
         // use direct access to 'NameList' to avoid unnecessary sql-requests and because
         // we do 'replacement' of existing language(with some 'id') with another language code.
         $contentClassList = eZContentClass::fetchList();
         foreach ($contentClassList as $contentClass) {
             $classAttributes = $contentClass->fetchAttributes();
             foreach ($classAttributes as $classAttribute) {
                 $classAttribute->NameList->setName($classAttribute->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
                 $classAttribute->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
                 $classAttribute->NameList->removeName('eng-GB');
                 $classAttribute->store();
             }
             $contentClass->NameList->setName($contentClass->NameList->name('eng-GB'), $primaryLanguageLocaleCode);
             $contentClass->NameList->setAlwaysAvailableLanguage($primaryLanguageLocaleCode);
             $contentClass->NameList->removeName('eng-GB');
             $contentClass->NameList->setHasDirtyData(false);
             // to not update 'ezcontentclass_name', because we've already updated it.
             $contentClass->store();
         }
     }
     // Setup all languages
     foreach ($allLanguages as $languageObject) {
         $primaryLanguageObj = eZContentLanguage::fetchByLocale($languageObject->localeCode());
         // Add it if it is missing (most likely)
         if (!$primaryLanguageObj) {
             $primaryLanguageObj = eZContentLanguage::addLanguage($languageObject->localeCode(), $languageObject->internationalLanguageName());
         }
     }
     eZContentLanguage::expireCache();
     // Make sure priority list is changed to the new chosen languages
     eZContentLanguage::setPrioritizedLanguages($prioritizedLanguages);
     if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
         $user = eZUser::instance(14);
         // Must be initialized to make node assignments work correctly
         if (!is_object($user)) {
             $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
             return false;
         }
         // Make sure Admin is the currently logged in user
         // This makes sure all new/changed objects get this as creator
         $user->loginCurrent();
         // by default(if 'language_map' is not set) create all necessary languages
         $languageMap = isset($this->PersistenceList['package_info']) && isset($this->PersistenceList['package_info']['language_map']) ? $this->PersistenceList['package_info']['language_map'] : true;
         if (is_array($languageMap) && count($languageMap) > 0) {
             //
             // Create necessary languages and set them as "prioritized languages" to avoid
             // drawbacks in fetch functions, like eZContentObjectTreeNode::fetch().
             //
             $prioritizedLanguageObjects = eZContentLanguage::prioritizedLanguages();
             // returned objects
             foreach ($languageMap as $fromLanguage => $toLanguage) {
                 if ($toLanguage != 'skip') {
                     $prioritizedLanguageObjects[] = eZContentLanguage::fetchByLocale($toLanguage, true);
                 }
             }
             $prioritizedLanguageLocales = array();
             foreach ($prioritizedLanguageObjects as $language) {
                 $locale = $language->attribute('locale');
                 if (!in_array($locale, $prioritizedLanguageLocales)) {
                     $prioritizedLanguageLocales[] = $locale;
                 }
             }
             eZContentLanguage::setPrioritizedLanguages($prioritizedLanguageLocales);
         }
         foreach ($requires as $require) {
             if ($require['type'] != 'ezpackage') {
                 continue;
             }
             $packageName = $require['name'];
             $package = eZPackage::fetch($packageName, false, false, false);
             if (is_object($package)) {
                 $requiredPackages[] = $package;
                 if ($package->attribute('install_type') == 'install') {
                     $installParameters = array('use_dates_from_package' => true, 'site_access_map' => array('*' => $userSiteaccessName), 'top_nodes_map' => array('*' => 2), 'design_map' => array('*' => $userDesignName), 'language_map' => $languageMap, 'restore_dates' => true, 'user_id' => $user->attribute('contentobject_id'), 'non-interactive' => true);
                     $status = $package->install($installParameters);
                     if (!$status) {
                         $errorText = "Unable to install package '{$packageName}'";
                         if (isset($installParameters['error']['description'])) {
                             $errorText .= ": " . $installParameters['error']['description'];
                         }
                         $resultArray['errors'][] = array('code' => 'EZSW-051', 'text' => $errorText);
                         return false;
                     }
                 }
             } else {
                 $resultArray['errors'][] = array('code' => 'EZSW-050', 'text' => "Could not fetch required package: '{$packageName}'");
                 return false;
             }
             unset($package);
         }
     }
     $GLOBALS['eZContentObjectDefaultLanguage'] = $primaryLanguageLocaleCode;
     $nodeRemoteMap = array();
     $rows = $db->arrayQuery("SELECT node_id, remote_id FROM ezcontentobject_tree");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $nodeRemoteMap[$remoteID] = $row['node_id'];
         }
     }
     $objectRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, remote_id FROM ezcontentobject");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $objectRemoteMap[$remoteID] = $row['id'];
         }
     }
     $classRemoteMap = array();
     $rows = $db->arrayQuery("SELECT id, identifier, remote_id FROM ezcontentclass");
     foreach ($rows as $row) {
         $remoteID = $row['remote_id'];
         if (strlen(trim($remoteID)) > 0) {
             $classRemoteMap[$remoteID] = array('id' => $row['id'], 'identifier' => $row['identifier']);
         }
     }
     $siteCSS = false;
     $classesCSS = false;
     foreach ($requiredPackages as $package) {
         if ($package->attribute('type') == 'sitestyle') {
             $fileList = $package->fileList('default');
             foreach ($fileList as $file) {
                 $fileIdentifier = $file["variable-name"];
                 if ($fileIdentifier == 'sitecssfile') {
                     $siteCSS = $package->fileItemPath($file, 'default');
                 } else {
                     if ($fileIdentifier == 'classescssfile') {
                         $classesCSS = $package->fileItemPath($file, 'default');
                     }
                 }
             }
         }
     }
     $parameters = array('node_remote_map' => $nodeRemoteMap, 'object_remote_map' => $objectRemoteMap, 'class_remote_map' => $classRemoteMap, 'preview_design' => $userDesignName, 'design_list' => array($userDesignName, 'admin2', 'admin'), 'user_siteaccess' => $userSiteaccessName, 'admin_siteaccess' => $adminSiteaccessName, 'package_object' => $sitePackage, 'siteaccess_urls' => $this->siteaccessURLs(), 'access_map' => $accessMap, 'site_type' => $siteType, 'all_language_codes' => $prioritizedLanguages);
     $siteINIStored = false;
     $siteINIAdminStored = false;
     $designINIStored = false;
     if (function_exists('eZSiteINISettings')) {
         $extraSettings = eZSiteINISettings($parameters);
     } else {
         $extraSettings = array();
     }
     if (function_exists('eZSiteAdminINISettings')) {
         $extraAdminSettings = eZSiteAdminINISettings($parameters);
     } else {
         $extraAdminSettings = array();
     }
     if (function_exists('eZSiteCommonINISettings')) {
         $extraCommonSettings = eZSiteCommonINISettings($parameters);
     } else {
         $extraCommonSettings = array();
     }
     $isUntranslatedSettingAdded = false;
     foreach ($extraAdminSettings as $key => $extraAdminSetting) {
         if ($extraAdminSetting['name'] == 'site.ini') {
             $extraAdminSettings[$key]['settings']['RegionalSettings']['ShowUntranslatedObjects'] = 'enabled';
             $isUntranslatedSettingAdded = true;
             break;
         }
     }
     if (!$isUntranslatedSettingAdded) {
         $extraAdminSettings[] = array('name' => 'site.ini', 'settings' => array('RegionalSettings' => array('ShowUntranslatedObjects' => 'enabled')));
     }
     // Enable OE and ODF extensions by default
     $extensionsToEnable = array();
     // Included in "fat" install, needs to override $extraCommonSettings extensions
     $extensionsPrepended = array('ezjscore', 'ezoe', 'ezformtoken');
     foreach (array('ezie', 'ezodf', 'ezprestapiprovider', 'ezmultiupload', 'eztags', 'ezautosave', 'ez_network', 'ez_network_demo') as $extension) {
         if (file_exists("extension/{$extension}")) {
             $extensionsToEnable[] = $extension;
         }
     }
     $settingAdded = false;
     foreach ($extraCommonSettings as $key => $extraCommonSetting) {
         if ($extraCommonSetting['name'] == 'site.ini' && isset($extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'])) {
             $settingAdded = true;
             $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'] = array_merge($extensionsPrepended, $extraCommonSettings[$key]['settings']['ExtensionSettings']['ActiveExtensions'], $extensionsToEnable);
             break;
         }
     }
     if (!$settingAdded) {
         $extraCommonSettings[] = array('name' => 'site.ini', 'settings' => array('ExtensionSettings' => array('ActiveExtensions' => array_merge($extensionsPrepended, $extensionsToEnable))));
     }
     // Enable dynamic tree menu for the admin interface by default
     $enableDynamicTreeMenuAdded = false;
     foreach ($extraAdminSettings as $key => $extraSetting) {
         if ($extraSetting['name'] == 'contentstructuremenu.ini') {
             if (isset($extraSetting['settings']['TreeMenu'])) {
                 $extraAdminSettings[$key]['settings']['TreeMenu']['Dynamic'] = 'enabled';
             } else {
                 $extraAdminSettings[$key]['settings'] = array('TreeMenu' => array('Dynamic' => 'enabled'));
             }
             $enableDynamicTreeMenuAdded = true;
             break;
         }
     }
     if (!$enableDynamicTreeMenuAdded) {
         $extraAdminSettings[] = array('name' => 'contentstructuremenu.ini', 'settings' => array('TreeMenu' => array('Dynamic' => 'enabled')));
     }
     $resultArray['common_settings'] = $extraCommonSettings;
     foreach ($extraSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $tmpINI->setReadOnlySettingsCheck(false);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         } else {
             if ($iniName == 'design.ini') {
                 if ($siteCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
                 }
                 if ($classesCSS) {
                     $tmpINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
                 }
                 $designINIStored = true;
             }
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", $resetArray);
         if ($siteType['existing_database'] != eZStepInstaller::DB_DATA_KEEP) {
             // setting up appropriate data in look&feel object
             $templateLookClass = eZContentClass::fetchByIdentifier('template_look', true);
             if ($templateLookClass) {
                 $objectList = $templateLookClass->objectList();
                 if ($objectList and count($objectList) > 0) {
                     $templateLookObject = current($objectList);
                     $dataMap = $templateLookObject->fetchDataMap();
                     if (isset($dataMap['title'])) {
                         $dataMap['title']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteName']);
                         $dataMap['title']->store();
                     }
                     if (isset($dataMap['siteurl'])) {
                         $dataMap['siteurl']->setAttribute('data_text', $siteINIChanges['SiteSettings']['SiteURL']);
                         $dataMap['siteurl']->store();
                     }
                     if (isset($dataMap['email'])) {
                         $dataMap['email']->setAttribute('data_text', $siteINIChanges['MailSettings']['AdminEmail']);
                         $dataMap['email']->store();
                     }
                     $objectName = $templateLookClass->contentObjectName($templateLookObject);
                     $templateLookObject->setName($objectName);
                     $templateLookObject->store();
                 }
             }
         }
     }
     foreach ($extraAdminSettings as $extraSetting) {
         if ($extraSetting === false) {
             continue;
         }
         $iniName = $extraSetting['name'];
         $settings = $extraSetting['settings'];
         $resetArray = false;
         if (isset($extraSetting['reset_arrays'])) {
             $resetArray = $extraSetting['reset_arrays'];
         }
         $tmpINI = eZINI::create($iniName);
         $tmpINI->setVariables($settings);
         if ($iniName == 'site.ini') {
             $siteINIAdminStored = true;
             $tmpINI->setVariables($siteINIChanges);
             $tmpINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
             $tmpINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
             $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
             $tmpINI->setVariable('SiteSettings', 'LoginPage', 'custom');
             $tmpINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         }
         $tmpINI->save(false, '.append.php', false, true, "settings/siteaccess/{$adminSiteaccessName}", $resetArray);
     }
     if (!$siteINIAdminStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('SiteAccessSettings', 'RequireUserLogin', 'true');
         $siteINI->setVariable('DesignSettings', 'SiteDesign', 'admin2');
         $tmpINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('admin'));
         $siteINI->setVariable('SiteSettings', 'LoginPage', 'custom');
         $siteINI->setVariable('SiteSettings', 'DefaultPage', 'content/dashboard');
         $siteINI->save(false, '.append.php', false, false, "settings/siteaccess/{$adminSiteaccessName}", true);
     }
     if (!$siteINIStored) {
         $siteINI = eZINI::create('site.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $siteINI->setReadOnlySettingsCheck(false);
         $siteINI->setVariables($siteINIChanges);
         $siteINI->setVariable('DesignSettings', 'SiteDesign', $userDesignName);
         $siteINI->setVariable('DesignSettings', 'AdditionalSiteDesignList', array('base'));
         $siteINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}", true);
     }
     if (!$designINIStored) {
         $designINI = eZINI::create('design.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $designINI->setReadOnlySettingsCheck(false);
         if ($siteCSS) {
             $designINI->setVariable('StylesheetSettings', 'SiteCSS', $siteCSS);
         }
         if ($classesCSS) {
             $designINI->setVariable('StylesheetSettings', 'ClassesCSS', $classesCSS);
         }
         $designINI->save(false, '.append.php', false, true, "settings/siteaccess/{$userSiteaccessName}");
     }
     eZDir::mkdir("design/" . $userDesignName);
     eZDir::mkdir("design/" . $userDesignName . "/templates");
     eZDir::mkdir("design/" . $userDesignName . "/stylesheets");
     eZDir::mkdir("design/" . $userDesignName . "/images");
     eZDir::mkdir("design/" . $userDesignName . "/override");
     eZDir::mkdir("design/" . $userDesignName . "/override/templates");
     if ($siteType['existing_database'] == eZStepInstaller::DB_DATA_KEEP) {
         return true;
     }
     // Try and remove user/login without limitation from the anonymous user
     $anonRole = eZRole::fetchByName('Anonymous');
     if (is_object($anonRole)) {
         $anonPolicies = $anonRole->policyList();
         foreach ($anonPolicies as $anonPolicy) {
             if ($anonPolicy->attribute('module_name') == 'user' and $anonPolicy->attribute('function_name') == 'login') {
                 $anonPolicy->removeThis();
                 break;
             }
         }
     }
     // Setup all roles according to site chosen and addons
     if (function_exists('eZSiteRoles')) {
         $extraRoles = eZSiteRoles($parameters);
         foreach ($extraRoles as $extraRole) {
             if (!$extraRole) {
                 continue;
             }
             $extraRoleName = $extraRole['name'];
             $role = eZRole::fetchByName($extraRoleName);
             if (!is_object($role)) {
                 $role = eZRole::create($extraRoleName);
                 $role->store();
             }
             $roleID = $role->attribute('id');
             if (isset($extraRole['policies'])) {
                 $extraPolicies = $extraRole['policies'];
                 foreach ($extraPolicies as $extraPolicy) {
                     if (isset($extraPolicy['limitation'])) {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function'], $extraPolicy['limitation']);
                     } else {
                         $role->appendPolicy($extraPolicy['module'], $extraPolicy['function']);
                     }
                 }
             }
             if (isset($extraRole['assignments'])) {
                 $roleAssignments = $extraRole['assignments'];
                 foreach ($roleAssignments as $roleAssignment) {
                     $assignmentIdentifier = false;
                     $assignmentValue = false;
                     if (isset($roleAssignment['limitation'])) {
                         $assignmentIdentifier = $roleAssignment['limitation']['identifier'];
                         $assignmentValue = $roleAssignment['limitation']['value'];
                     }
                     $role->assignToUser($roleAssignment['user_id'], $assignmentIdentifier, $assignmentValue);
                 }
             }
         }
     }
     // Setup user preferences based on the site chosen and addons
     if (function_exists('eZSitePreferences')) {
         $prefs = eZSitePreferences($parameters);
         foreach ($prefs as $prefEntry) {
             if (!$prefEntry) {
                 continue;
             }
             $prefUserID = $prefEntry['user_id'];
             foreach ($prefEntry['preferences'] as $pref) {
                 $prefName = $pref['name'];
                 $prefValue = $pref['value'];
                 if (!eZPreferences::setValue($prefName, $prefValue, $prefUserID)) {
                     $resultArray['errors'][] = array('code' => 'EZSW-070', 'text' => "Could not create ezpreference '{$prefValue}' for {$prefUserID}");
                     return false;
                 }
             }
         }
     }
     $publishAdmin = false;
     $userAccount = eZUser::fetch(14);
     if (!is_object($userAccount)) {
         $resultArray['errors'][] = array('code' => 'EZSW-020', 'text' => "Could not fetch administrator user object");
         return false;
     }
     $userObject = $userAccount->attribute('contentobject');
     if (!is_object($userObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-021', 'text' => "Could not fetch administrator content object");
         return false;
     }
     $newUserObject = $userObject->createNewVersion(false, false);
     if (!is_object($newUserObject)) {
         $resultArray['errors'][] = array('code' => 'EZSW-022', 'text' => "Could not create new version of administrator content object");
         return false;
     }
     $dataMap = $newUserObject->attribute('data_map');
     $error = false;
     if (trim($admin['email'])) {
         if (!isset($dataMap['user_account'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'user_account' attribute");
             return false;
         }
         $userAccount->setInformation(14, 'admin', $admin['email'], $admin['password'], $admin['password']);
         $dataMap['user_account']->setContent($userAccount);
         $dataMap['user_account']->store();
         $publishAdmin = true;
         $userAccount->store();
     }
     if (trim($admin['first_name']) or trim($admin['last_name'])) {
         if (!isset($dataMap['first_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-023', 'text' => "Administrator content object does not have a 'first_name' field");
             $error = true;
         }
         if (!isset($dataMap['last_name'])) {
             $resultArray['errors'][] = array('code' => 'EZSW-024', 'text' => "Administrator content object does not have a 'last_name' field");
             $error = true;
         }
         if ($error) {
             return false;
         }
         $dataMap['first_name']->setAttribute('data_text', $admin['first_name']);
         $dataMap['first_name']->store();
         $dataMap['last_name']->setAttribute('data_text', $admin['last_name']);
         $dataMap['last_name']->store();
         $newUserObject->store();
         $publishAdmin = true;
     }
     if ($publishAdmin) {
         $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newUserObject->attribute('contentobject_id'), 'version' => $newUserObject->attribute('version')));
         if ($operationResult['status'] != eZModuleOperationInfo::STATUS_CONTINUE) {
             $resultArray['errors'][] = array('code' => 'EZSW-025', 'text' => "Failed to properly publish the administrator object");
             return false;
         }
     }
     // Call user function for additional setup tasks.
     if (function_exists('eZSitePostInstall')) {
         eZSitePostInstall($parameters);
     }
     // get all siteaccesses. do it via 'RelatedSiteAccessesList' settings.
     $adminSiteINI = eZINI::instance('site.ini' . '.append.php', "settings/siteaccess/{$adminSiteaccessName}");
     $relatedSiteAccessList = $adminSiteINI->variable('SiteAccessSettings', 'RelatedSiteAccessList');
     // Adding override for 'tiny_image' view for 'multi-option2' datatype
     foreach ($relatedSiteAccessList as $siteAccess) {
         $tmpOverrideINI = new eZINI('override.ini' . '.append.php', "settings/siteaccess/{$siteAccess}", null, null, null, true, true);
         $tmpOverrideINI->setVariable('tiny_image', 'Source', 'content/view/tiny.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'MatchFile', 'tiny_image.tpl');
         $tmpOverrideINI->setVariable('tiny_image', 'Subdir', 'templates');
         $tmpOverrideINI->setVariable('tiny_image', 'Match', array('class_identifier' => 'image'));
         $tmpOverrideINI->save();
     }
     $accessMap = $parameters['access_map'];
     // Call user function for some text which will be displayed at 'Finish' screen
     if (function_exists('eZSiteFinalText')) {
         $text = eZSiteFinalText($parameters);
         if (!isset($this->PersistenceList['final_text'])) {
             $this->PersistenceList['final_text'] = array();
         }
         $this->PersistenceList['final_text'][] = $text;
     }
     // ensure that evaluated policy wildcards in the user info cache
     // will be up to date with the currently activated modules
     eZCache::clearByID('user_info_cache');
     return true;
 }
Ejemplo n.º 22
0
<?php

$Module = $Params['Module'];
$tpl = eZTemplate::factory();
$newsletter_ini = eZINI::instance('jaj_newsletter.ini');
$newsletter_root_node_id = $newsletter_ini->variable('NewsletterSettings', 'RootFolderNodeId');
$node = eZContentObject::fetchByNodeID($newsletter_root_node_id);
if (!$node || !$node->canRead()) {
    return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
}
switch (eZPreferences::value('admin_jaj_newsletter_newsletters_limit')) {
    case '25':
        $limit = 25;
        break;
    case '50':
        $limit = 50;
        break;
    default:
        $limit = 10;
        break;
}
$newsletter_content_class = eZContentClass::fetchByIdentifier('jaj_newsletter');
if ($newsletter_content_class) {
    $tpl->setVariable('newsletter_content_class_id', $newsletter_content_class->ID);
}
$viewParameters = array('offset' => $Params['Offset']);
$tpl->setVariable('node', $node);
$tpl->setVariable('set_limit', $limit);
$tpl->setVariable('view_parameters', $viewParameters);
$Result = array('content' => $tpl->fetch('design:jaj_newsletter/newsletters/index.tpl'), 'path' => array(array('url' => 'jaj_newsletter/index', 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Newsletter')), array('url' => false, 'text' => ezpI18n::tr('jaj_newsletter/navigation', 'Newsletters'))));
unset($var1);
if (!isset($var)) {
    $var = NULL;
}
while (is_object($var) and method_exists($var, 'templateValue')) {
    $var = $var->templateValue();
}
if ($tpl->hasVariable('current_path', $rootNamespace)) {
    $tpl->warning('def', "Variable 'current_path' is already defined.", array(0 => array(0 => 4, 1 => 0, 2 => 87), 1 => array(0 => 16, 1 => 101, 2 => 816), 2 => 'design/admin2/templates/children.tpl'));
    $tpl->setVariable('current_path', $var, $rootNamespace);
} else {
    $tpl->setLocalVariable('current_path', $var, $rootNamespace);
}
// def $admin_children_viewmode
unset($var);
$var = eZPreferences::value("admin_children_viewmode");
if (!isset($var)) {
    $var = NULL;
}
while (is_object($var) and method_exists($var, 'templateValue')) {
    $var = $var->templateValue();
}
if ($tpl->hasVariable('admin_children_viewmode', $rootNamespace)) {
    $tpl->warning('def', "Variable 'admin_children_viewmode' is already defined.", array(0 => array(0 => 4, 1 => 0, 2 => 87), 1 => array(0 => 16, 1 => 101, 2 => 816), 2 => 'design/admin2/templates/children.tpl'));
    $tpl->setVariable('admin_children_viewmode', $var, $rootNamespace);
} else {
    $tpl->setLocalVariable('admin_children_viewmode', $var, $rootNamespace);
}
// def $children_count
unset($var);
unset($var1);
Ejemplo n.º 24
0
<?php

/**
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
 * @license For full copyright and license information view LICENSE file distributed with this source code.
 * @version 2014.07.0
 * @package kernel
 */
$http = eZHTTPTool::instance();
$module = $Params['Module'];
$cacheType = $module->actionParameter('CacheType');
eZPreferences::setValue('admin_clearcache_type', $cacheType);
if ($module->hasActionParameter('NodeID')) {
    $nodeID = $module->actionParameter('NodeID');
}
if ($module->hasActionParameter('ObjectID')) {
    $objectID = $module->actionParameter('ObjectID');
}
if ($cacheType == 'All') {
    eZCache::clearAll();
} elseif ($cacheType == 'Template') {
    eZCache::clearByTag('template');
} elseif ($cacheType == 'Content') {
    eZCache::clearByTag('content');
} elseif ($cacheType == 'TemplateContent') {
    eZCache::clearByTag('template');
    eZCache::clearByTag('content');
} elseif ($cacheType == 'Ini') {
    eZCache::clearByTag('ini');
} elseif ($cacheType == 'Static') {
    // get staticCacheHandler instance
Ejemplo n.º 25
0
 function instantiate($userID = false, $sectionID = 0, $versionNumber = false, $languageCode = false, $versionStatus = eZContentObjectVersion::STATUS_INTERNAL_DRAFT)
 {
     $attributes = $this->fetchAttributes();
     if ($userID === false) {
         $user = eZUser::currentUser();
         $userID = $user->attribute('contentobject_id');
     }
     if ($languageCode == false) {
         $languageCode = eZContentObject::defaultLanguage();
     }
     $object = eZContentObject::create(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), $this->attribute("id"), $userID, $sectionID, 1, $languageCode);
     if ($this->attribute('always_available')) {
         $object->setAttribute('language_mask', (int) $object->attribute('language_mask') | 1);
     }
     $db = eZDB::instance();
     $db->begin();
     $object->store();
     $object->assignDefaultStates();
     $object->setName(ezpI18n::tr("kernel/contentclass", "New %1", null, array($this->name($languageCode))), false, $languageCode);
     if (!$versionNumber) {
         $version = $object->createInitialVersion($userID, $languageCode);
     } else {
         $version = eZContentObjectVersion::create($object->attribute("id"), $userID, $versionNumber, $languageCode);
     }
     if ($versionStatus !== false) {
         $version->setAttribute('status', $versionStatus);
     }
     $version->store();
     foreach ($attributes as $attribute) {
         $attribute->instantiate($object->attribute('id'), $languageCode);
     }
     if (isset($user) && $user instanceof eZUser && $user->isAnonymous()) {
         $createdObjectIDList = eZPreferences::value('ObjectCreationIDList');
         if (!$createdObjectIDList) {
             $createdObjectIDList = array($object->attribute('id'));
         } else {
             $createdObjectIDList = unserialize($createdObjectIDList);
             $createdObjectIDList[] = $object->attribute('id');
         }
         eZPreferences::setValue('ObjectCreationIDList', serialize($createdObjectIDList));
     }
     $db->commit();
     return $object;
 }
Ejemplo n.º 26
0
<?php

/**
 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved.
 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2
 * @version  2012.6
 * @package kernel
 */
if (eZPreferences::value('admin_search_stats_limit')) {
    switch (eZPreferences::value('admin_search_stats_limit')) {
        case '2':
            $limit = 25;
            break;
        case '3':
            $limit = 50;
            break;
        default:
            $limit = 10;
            break;
    }
} else {
    $limit = 10;
}
$offset = $Params['Offset'];
if (!is_numeric($offset)) {
    $offset = 0;
}
$http = eZHTTPTool::instance();
$module = $Params['Module'];
if ($module->isCurrentAction('ResetSearchStats')) {
    eZSearchLog::removeStatistics();
Ejemplo n.º 27
0
 /**
  * Cleanup user related session values, for use by login / logout code
  *
  * @internal
  */
 static function cleanup()
 {
     $http = eZHTTPTool::instance();
     $http->removeSessionVariable('CanInstantiateClassList');
     $http->removeSessionVariable('ClassesCachedForUser');
     // Note: This must be done more generic with an internal
     //       callback system.
     eZPreferences::sessionCleanup();
 }
// Filename:  design/standard/templates/setup/clear_cache.tpl
// Timestamp: 1385723972 (Fri Nov 29 11:19:32 GMT 2013)
$oldSetArray_d40d1b1eb61f4fca642c0bb64af6d374 = isset($setArray) ? $setArray : array();
$setArray = array();
$tpl->Level++;
if ($tpl->Level > 40) {
    $text = $tpl->MaxLevelWarning;
    $tpl->Level--;
    return;
}
$eZTemplateCompilerCodeDate = 1074699607;
if (!defined('EZ_TEMPLATE_COMPILER_COMMON_CODE')) {
    include_once 'var/ezdemo_site/cache/template/compiled/common.php';
}
unset($var);
$var = eZPreferences::value("admin_clearcache_type");
if (!isset($var)) {
    $var = NULL;
}
while (is_object($var) and method_exists($var, 'templateValue')) {
    $var = $var->templateValue();
}
$vars[$currentNamespace]['selected_cache_type'] = $var;
unset($var);
unset($var);
unset($var1);
unset($var2);
$var2 = 'All caches';
if (!isset($var2)) {
    $var2 = NULL;
}
$setArray = array();
$tpl->Level++;
if ($tpl->Level > 40) {
    $text = $tpl->MaxLevelWarning;
    $tpl->Level--;
    return;
}
$eZTemplateCompilerCodeDate = 1074699607;
if (!defined('EZ_TEMPLATE_COMPILER_COMMON_CODE')) {
    include_once 'var/ezdemo_site/cache/template/compiled/common.php';
}
// def $page_limit
unset($var);
unset($var1);
unset($var2);
$var2 = eZPreferences::value("admin_list_limit");
if (!isset($var2)) {
    $var2 = NULL;
}
while (is_object($var2) and method_exists($var2, 'templateValue')) {
    $var2 = $var2->templateValue();
}
$var1 = min($var2, 3);
unset($var2);
if (!isset($var1)) {
    $var1 = NULL;
}
while (is_object($var1) and method_exists($var1, 'templateValue')) {
    $var1 = $var1->templateValue();
}
if ($var1 < 0 and $var1 >= 4) {
 function classListFromPolicy($policy, $allowedLanguageCodes = false)
 {
     $canCreateClassIDListPart = array();
     $hasClassIDLimitation = false;
     $user = eZUser::currentUser();
     $userID = $user->attribute('contentobject_id');
     $object = false;
     if (isset($policy['ParentOwner'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         // if limitation value == 2, anonymous limited to current session.
         if (in_array(2, $policy['ParentOwner']) && $user->isAnonymous()) {
             $createdObjectIDList = eZPreferences::value('ObjectCreationIDList');
             if (!$createdObjectIDList || !in_array($object->ID, unserialize($createdObjectIDList))) {
                 return array();
             }
         } else {
             if ($object->attribute('owner_id') != $userID && $object->ID != $userID) {
                 return array();
             }
         }
     }
     if (isset($policy['ParentGroup'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         $access = $object->checkGroupLimitationAccess($policy['ParentGroup'], $userID);
         if ($access !== 'allowed') {
             return array();
         }
     }
     if (isset($policy['Class'])) {
         $canCreateClassIDListPart = $policy['Class'];
         $hasClassIDLimitation = true;
     }
     if (isset($policy['User_Section'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         if (!in_array($object->attribute('section_id'), $policy['User_Section'])) {
             return array();
         }
     }
     if (isset($policy['User_Subtree'])) {
         $allowed = false;
         if ($object === false) {
             $object = $this->attribute('object');
         }
         $assignedNodes = $object->attribute('assigned_nodes');
         foreach ($assignedNodes as $assignedNode) {
             $path = $assignedNode->attribute('path_string');
             foreach ($policy['User_Subtree'] as $subtreeString) {
                 if (strstr($path, $subtreeString)) {
                     $allowed = true;
                     break;
                 }
             }
         }
         if (!$allowed) {
             return array();
         }
     }
     if (isset($policy['Section'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         if (!in_array($object->attribute('section_id'), $policy['Section'])) {
             return array();
         }
     }
     if (isset($policy['ParentClass'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         if (!in_array($object->attribute('contentclass_id'), $policy['ParentClass'])) {
             return array();
         }
     }
     if (isset($policy['ParentDepth']) && is_array($policy['ParentDepth'])) {
         $NodeDepth = $this->attribute('depth');
         if (!in_array('*', $policy['ParentDepth']) && !in_array($NodeDepth, $policy['ParentDepth'])) {
             return array();
         }
     }
     if (isset($policy['Assigned'])) {
         if ($object === false) {
             $object = $this->attribute('object');
         }
         if ($object->attribute('owner_id') != $userID) {
             return array();
         }
     }
     $allowedNode = false;
     if (isset($policy['Node'])) {
         $allowed = false;
         foreach ($policy['Node'] as $nodeID) {
             $mainNodeID = $this->attribute('main_node_id');
             $node = eZContentObjectTreeNode::fetch($nodeID, false, false);
             if ($mainNodeID == $node['main_node_id']) {
                 $allowed = true;
                 $allowedNode = true;
                 break;
             }
         }
         if (!$allowed && !isset($policy['Subtree'])) {
             return array();
         }
     }
     if (isset($policy['Subtree'])) {
         $allowed = false;
         if ($object === false) {
             $object = $this->attribute('object');
         }
         $assignedNodes = $object->attribute('assigned_nodes');
         foreach ($assignedNodes as $assignedNode) {
             $path = $assignedNode->attribute('path_string');
             foreach ($policy['Subtree'] as $subtreeString) {
                 if (strstr($path, $subtreeString)) {
                     $allowed = true;
                     break;
                 }
             }
         }
         if (!$allowed && !$allowedNode) {
             return array();
         }
     }
     if (isset($policy['Language'])) {
         if ($allowedLanguageCodes) {
             $allowedLanguageCodes = array_intersect($allowedLanguageCodes, $policy['Language']);
         } else {
             $allowedLanguageCodes = $policy['Language'];
         }
     }
     if ($hasClassIDLimitation) {
         return array('classes' => $canCreateClassIDListPart, 'language_codes' => $allowedLanguageCodes);
     }
     return array('classes' => '*', 'language_codes' => $allowedLanguageCodes);
 }