Skip to content

Commit

Permalink
Fix EZP-23607: display actual published version in versionview
Browse files Browse the repository at this point in the history
  • Loading branch information
Joao Inacio committed Nov 13, 2014
1 parent c91fac3 commit 5c42732
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Expand Up @@ -40,7 +40,7 @@
<p>
<label>{'Published version'|i18n( 'design/admin/content/history' )}:</label>
{if $object.published}
{$object.current_version}
{$object.published_version}
{else}
{'Not yet published'|i18n( 'design/admin/content/history' )}
{/if}
Expand Down
22 changes: 22 additions & 0 deletions kernel/classes/ezcontentobject.php
Expand Up @@ -151,6 +151,7 @@ static function definition()
'multiplicity' => '1..*' ) ),
"keys" => array( "id" ),
"function_attributes" => array( "current" => "currentVersion",
"published_version" => "publishedVersion",
'versions' => 'versions',
'author_array' => 'authorArray',
"class_name" => "className",
Expand Down Expand Up @@ -1202,6 +1203,27 @@ function currentVersion( $asObject = true )
return eZContentObjectVersion::fetchVersion( $this->attribute( "current_version" ), $this->ID, $asObject );
}

/**

This comment has been minimized.

Copy link
@guillaumelecerf

guillaumelecerf Nov 14, 2014

Contributor

This comment is now wrong :( "or null if not published yet."

This comment has been minimized.

Copy link
@guillaumelecerf

guillaumelecerf Dec 3, 2014

Contributor

See #1121

* Returns the published version of the object, or false if not published yet.
*
* @return int|null
*/
public function publishedVersion()
{
$params = array(
'conditions' => array(
'status' => eZContentObjectVersion::STATUS_PUBLISHED
)
);
$versions = $this->versions( false, $params );

if ( !empty( $versions ) )
{
return $versions[0]['version'];
}
return null;
}

/**
* Returns the given object version. False is returned if the versions does not exist.
*
Expand Down

0 comments on commit 5c42732

Please sign in to comment.