kernel/private/classes/ezcontentobjectstate.php
public function store( $fieldFilters = null )
    {
        if ( $fieldFilters === null )
        {
            $db = eZDB::instance();

            $db->begin();

            $languageMask = 1;
            // set language mask and always available bits
            foreach ( $this->AllTranslations() as $translation )
            {
                if ( $translation->hasData() )
                {
                    $languageID = $translation->attribute( 'language_id' );
                    if ( empty( $this->DefaultLanguageID ) )
                    {
                        $this->DefaultLanguageID = $languageID & ~1;
                    }
                    // if default language, set always available flag
                    if ( $languageID & $this->DefaultLanguageID )
                    {
                        $translation->setAttribute( 'language_id', $languageID | 1 );
                    }
                    // otherwise, remove always available flag if it's set
                    else if ( $languageID & 1 )
                    {
                        $translation->setAttribute( 'language_id',  $languageID & ~1 );
                    }

                    $languageMask = $languageMask | $languageID;
                }
            }

            $assignToObjects = false;
            if ( !isset( $this->ID ) )
            {
                $rows = $db->arrayQuery( "SELECT MAX(priority) AS max_priority FROM ezcobj_state WHERE group_id=" . $this->GroupID );

                if ( count( $rows ) > 0 && $rows[0]['max_priority'] !== null )
                {
                    $this->setAttribute( 'priority', $rows[0]['max_priority'] + 1 );
                }
                else
                {
                    // this is the first state created in the state group
                    // make all content objects use this state
                    $assignToObjects = true;
                }
            }

            $this->setAttribute( 'language_mask', $languageMask );

            // store state
            eZPersistentObject::storeObject( $this, $fieldFilters );

            // store or remove translations
            foreach ( $this->AllTranslations as $translation )
            {
                if ( !$translation->hasData() )
                {
                    // the name and description are empty
                    // so the translation needs to be removed if it was stored before
                    if ( $translation->attribute( 'contentobject_state_id' ) !== null )
                    {
                        $translation->remove();
                    }
                }
                else
                {
                    if ( $translation->attribute( 'contentobject_state_id' ) != $this->ID )
                    {
                        $translation->setAttribute( 'contentobject_state_id', $this->ID );
                    }

                    $translation->store();
                }
            }

            if ( $assignToObjects )
            {
                $stateID = $this->ID;
                $db->query( "INSERT INTO ezcobj_state_link (contentobject_id, contentobject_state_id) SELECT id, $stateID FROM ezcontentobject" );
            }

            $db->commit();
        }
        else
        {
            parent::store( $fieldFilters );
        }
    }
public function store( $fieldFilters = null )
    {
        if ( $fieldFilters === null )
        {
            $db = eZDB::instance();

            $db->begin();

            $languageMask = 1;
            // set language mask and always available bits
            foreach ( $this->AllTranslations() as $translation )
            {
                if ( $translation->hasData() )
                {
                    $languageID = $translation->attribute( 'language_id' );
                    if ( empty( $this->DefaultLanguageID ) )
                    {
                        $this->DefaultLanguageID = $languageID & ~1;
                    }
                    // if default language, set always available flag
                    if ( $languageID & $this->DefaultLanguageID )
                    {
                        $translation->setAttribute( 'language_id', $languageID | 1 );
                    }
                    // otherwise, remove always available flag if it's set
                    else if ( $languageID & 1 )
                    {
                        $translation->setAttribute( 'language_id',  $languageID & ~1 );
                    }

                    $languageMask = $languageMask | $languageID;
                }
            }

            $assignToObjects = false;
            if ( !isset( $this->ID ) )
            {
                $rows = $db->arrayQuery( "SELECT MAX(priority) AS max_priority FROM ezcobj_state WHERE group_id=" . $this->GroupID );

                if ( count( $rows ) > 0 && $rows[0]['max_priority'] !== null )
                {
                    $this->setAttribute( 'priority', $rows[0]['max_priority'] + 1 );
                }
                else
                {
                    // this is the first state created in the state group
                    // make all content objects use this state
                    $assignToObjects = true;
                }
            }

            $this->setAttribute( 'language_mask', $languageMask );

            // store state
            eZPersistentObject::storeObject( $this, $fieldFilters );

            // store or remove translations
            foreach ( $this->AllTranslations as $translation )
            {
                if ( !$translation->hasData() )
                {
                    // the name and description are empty
                    // so the translation needs to be removed if it was stored before
                    if ( $translation->attribute( 'contentobject_state_id' ) !== null )
                    {
                        $translation->remove();
                    }
                }
                else
                {
                    if ( $translation->attribute( 'contentobject_state_id' ) != $this->ID )
                    {
                        $translation->setAttribute( 'contentobject_state_id', $this->ID );
                    }

                    $translation->store();
                }
            }

            if ( $assignToObjects )
            {
                $stateID = $this->ID;
                $db->query( "INSERT INTO ezcobj_state_link (contentobject_id, contentobject_state_id) SELECT id, $stateID FROM ezcontentobject" );
            }

            $db->commit();
        }
        else
        {
            parent::store( $fieldFilters );
        }
    }
public function store ( $ fieldFilters = null ) { if ( $ fieldFilters === null ) { $ db = eZDB :: instance ( ) ; $ db -> begin ( ) ; $ languageMask = 1 ; // set language mask and always available bits foreach ( $ this -> AllTranslations ( ) as $ translation ) { if ( $ translation -> hasData ( ) ) { $ languageID = $ translation -> attribute ( 'language_id' ) ; if ( empty ( $ this -> DefaultLanguageID ) ) { $ this -> DefaultLanguageID = $ languageID & ~ 1 ; } // if default language, set always available flag if ( $ languageID & $ this -> DefaultLanguageID ) { $ translation -> setAttribute ( 'language_id' , $ languageID | 1 ) ; } // otherwise, remove always available flag if it's set else if ( $ languageID & 1 ) { $ translation -> setAttribute ( 'language_id' , $ languageID & ~ 1 ) ; } $ languageMask = $ languageMask | $ languageID ; } } $ assignToObjects = false ; if ( ! isset ( $ this -> ID ) ) { $ rows = $ db -> arrayQuery ( "SELECT MAX(priority) AS max_priority FROM ezcobj_state WHERE group_id=" . $ this -> GroupID ) ; if ( count ( $ rows ) > 0 && $ rows [ 0 ] [ 'max_priority' ] !== null ) { $ this -> setAttribute ( 'priority' , $ rows [ 0 ] [ 'max_priority' ] + 1 ) ; } else { // this is the first state created in the state group // make all content objects use this state $ assignToObjects = true ; } } $ this -> setAttribute ( 'language_mask' , $ languageMask ) ; // store state eZPersistentObject :: storeObject ( $ this , $ fieldFilters ) ; // store or remove translations foreach ( $ this -> AllTranslations as $ translation ) { if ( ! $ translation -> hasData ( ) ) { // the name and description are empty // so the translation needs to be removed if it was stored before if ( $ translation -> attribute ( 'contentobject_state_id' ) !== null ) { $ translation -> remove ( ) ; } } else { if ( $ translation -> attribute ( 'contentobject_state_id' ) != $ this -> ID ) { $ translation -> setAttribute ( 'contentobject_state_id' , $ this -> ID ) ; } $ translation -> store ( ) ; } } if ( $ assignToObjects ) { $ stateID = $ this -> ID ; $ db -> query ( "INSERT INTO ezcobj_state_link (contentobject_id, contentobject_state_id) SELECT id, $stateID FROM ezcontentobject" ) ; } $ db -> commit ( ) ; } else { parent :: store ( $ fieldFilters ) ; } }
Stores the content object state and its translations.

Before storing a content object state, you should use
{@link eZContentObjectState::isValid()} to check its validness.

@param array $fieldFilters
Stores the content object state and its translations .