private function sectionIDbyName( $name )
 {
     $sectionID = false;
     $sectionList = eZSection::fetchFilteredList( array( 'name' => $name ), false, false, true );
     if( is_array( $sectionList ) && count( $sectionList ) > 0 )
     {
         $section = $sectionList[0];
         if( is_object( $section ) )
         {
             $sectionID = $section->attribute( 'id' );
         }
     }
     return $sectionID;
 }
 * @version  2013.11
 * @package update
 */
require 'autoload.php';
$script = eZScript::instance(array('description' => 'eZ Publish section identifier update script. ' . 'This script will update existing sections with missing identifiers.', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true));
$script->startup();
$options = $script->getOptions('', '', array('-q' => 'Quiet mode'));
$script->initialize();
$cli = eZCLI::instance();
$trans = eZCharTransform::instance();
// Fetch 50 items per iteration
$limit = 50;
$offset = 0;
do {
    // Fetch items with empty identifier
    $rows = eZSection::fetchFilteredList(null, $offset, $limit);
    if (!$rows) {
        break;
    }
    foreach ($rows as $row) {
        if ($row->attribute('identifier') == '') {
            // Create a new section identifier with NAME_ID pattern
            $name = $row->attribute('name');
            $identifier = $trans->transformByGroup($name, 'identifier') . '_' . $row->attribute('id');
            // Set new section identifier and store it
            $row->setAttribute('identifier', $identifier);
            $row->store();
            $cli->output("Setting identifier '{$identifier}' for section '{$name}'");
        }
    }
    $offset += $limit;
Beispiel #3
0
}
if ($http->hasPostVariable("StoreButton")) {
    if ($SectionID == 0) {
        $section = new eZSection(array());
    }
    $section->setAttribute('name', $http->postVariable('Name'));
    $sectionIdentifier = trim($http->postVariable('SectionIdentifier'));
    $errorMessage = '';
    if ($sectionIdentifier === '') {
        $errorMessage = ezpI18n::tr('design/admin/section/edit', 'Identifier can not be empty');
    } else {
        if (preg_match('/(^[^A-Za-z])|\\W/', $sectionIdentifier)) {
            $errorMessage = ezpI18n::tr('design/admin/section/edit', 'Identifier should consist of letters, numbers or \'_\' with letter prefix.');
        } else {
            $conditions = array('identifier' => $sectionIdentifier, 'id' => array('!=', $SectionID));
            $existingSection = eZSection::fetchFilteredList($conditions);
            if (count($existingSection) > 0) {
                $errorMessage = ezpI18n::tr('design/admin/section/edit', 'The identifier has been used in another section.');
            }
        }
    }
    $section->setAttribute('identifier', $sectionIdentifier);
    $section->setAttribute('navigation_part_identifier', $http->postVariable('NavigationPartIdentifier'));
    if ($http->hasPostVariable('Locale')) {
        $section->setAttribute('locale', $http->postVariable('Locale'));
    }
    if ($errorMessage === '') {
        $section->store();
        eZContentCacheManager::clearContentCacheIfNeededBySectionID($section->attribute('id'));
        $Module->redirectTo($Module->functionURI('list'));
        return;
    /**
     * @return eZSection[]|null
     */
    function allowedAssignSectionList()
    {
        $currentUser = eZUser::currentUser();
        $sectionIDList = $currentUser->canAssignToObjectSectionList( $this );

        $sectionList = array();
        if ( in_array( '*', $sectionIDList ) )
        {
            $sectionList = eZSection::fetchList( false );
        }
        else
        {
            $sectionIDList[] = $this->attribute( 'section_id' );
            $sectionList = eZSection::fetchFilteredList( array( 'id' => array( $sectionIDList ) ), false, false, false );
        }
        return $sectionList;
    }
 * @package update
 */
require 'autoload.php';
$script = eZScript::instance(array('description' => 'eZ Publish section identifier update script. ' . 'This script will update existing sections with missing identifiers.', 'use-session' => false, 'use-modules' => false, 'use-extension' => false));
$script->startup();
$options = $script->getOptions('', '', array('-q' => 'Quiet mode'));
$script->initialize();
$isQuiet = $script->isQuiet();
$cli = eZCLI::instance();
$trans = eZCharTransform::instance();
// Fetch 50 items per iteration
$limit = 50;
$offset = 0;
do {
    // Fetch items with empty identifier
    $rows = eZSection::fetchFilteredList(array('identifier' => ''), $offset, $limit);
    if (!$rows) {
        break;
    }
    foreach ($rows as $row) {
        if ($row->attribute('identifier') == '') {
            // Create a new section identifier with NAME_ID pattern
            $name = $row->attribute('name');
            $identifier = $trans->transformByGroup($name, 'identifier') . '_' . $row->attribute('id');
            // Set new section identifier and store it
            $row->setAttribute('identifier', $identifier);
            $row->store();
            if (!$isQuiet) {
                $cli->output("Setting identifier '{$identifier}' for section '{$name}'");
            }
        }