/**
     * Sets the state of a content object.
     *
     * Changes are stored immediately in the database, does not require a store() of the content object.
     * Should only be called on instances of eZContentObject that have a ID (that were stored already before).
     *
     * @param eZContentObjectState $state
     * @return boolean true when the state was set, false if the state equals the current state
     */
    function assignState( eZContentObjectState $state )
    {
        $groupID = $state->attribute( 'group_id' );
        $stateID = $state->attribute( 'id' );
        $contentObjectID = $this->ID;

        $currentStateIDArray = $this->stateIDArray( true );
        $currentStateID = $currentStateIDArray[$groupID];

        if ( $currentStateID == $stateID )
        {
            return false;
        }

        $sql = "UPDATE ezcobj_state_link
                SET contentobject_state_id=$stateID
                WHERE contentobject_state_id=$currentStateID AND
                      contentobject_id=$contentObjectID";
        eZDB::instance()->query( $sql );

        $this->StateIDArray[$groupID] = $stateID;

        return true;
    }
Пример #2
0
 /**
  * Sets the state of a content object.
  *
  * Changes are stored immediately in the database, does not require a store() of the content object.
  * Should only be called on instances of eZContentObject that have a ID (that were stored already before).
  *
  * @param eZContentObjectState $state
  * @return boolean true when the state was set, false if the state equals the current state
  */
 function assignState(eZContentObjectState $state)
 {
     $groupID = $state->attribute('group_id');
     $stateID = $state->attribute('id');
     $contentObjectID = $this->ID;
     $db = eZDB::instance();
     $db->begin();
     $currentStateIDArray = $this->stateIDArray(true);
     $currentStateID = $currentStateIDArray[$groupID];
     if ($currentStateID == $stateID) {
         $db->rollback();
         return false;
     }
     $sql = "UPDATE ezcobj_state_link\n                SET contentobject_state_id={$stateID}\n                WHERE contentobject_state_id={$currentStateID} AND\n                      contentobject_id={$contentObjectID}";
     $db->query($sql);
     $db->commit();
     $this->StateIDArray[$groupID] = $stateID;
     return true;
 }