Skip to content

Commit

Permalink
Revert "Fix EZP-21966: eZUser now supports basic drafts"
Browse files Browse the repository at this point in the history
Introduces a regression in the setup wizard.
See https://jira.ez.no/browse/EZP-22267.
  • Loading branch information
Bertrand Dunogier committed Jan 29, 2014
1 parent f3dc566 commit ece8c52
Showing 1 changed file with 0 additions and 85 deletions.
85 changes: 0 additions & 85 deletions kernel/classes/datatypes/ezuser/ezusertype.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )

function storeObjectAttribute( $contentObjectAttribute )
{
/** @var eZContentObjectAttribute $contentObjectAttribute */
/** @var eZUser $user */
$user = $contentObjectAttribute->content();
if ( !( $user instanceof eZUser ) )
{
Expand All @@ -244,83 +242,11 @@ function storeObjectAttribute( $contentObjectAttribute )
$isEnabled = 1;
$userSetting = eZUserSetting::create( $userID, $isEnabled );
$userSetting->store();

$user->store();
$contentObjectAttribute->setContent( $user );
}
else
{
// saving information in the object attribute data_text field to simulate a draft
$contentObjectAttribute->setAttribute( 'data_text', $this->serializeDraft( $user ) );
}
}

function onPublish( $contentObjectAttribute, $contentObject, $publishedNodes )
{
/** @var eZContentObjectAttribute $contentObjectAttribute */
/** @var eZUser $user */
$user = $contentObjectAttribute->content();

// Publishing draft's content
$serializedDraft = $contentObjectAttribute->attribute( 'data_text' );

if ( !empty( $serializedDraft ) )
{
$user = $this->updateUserDraft( $user, $serializedDraft );
}

$user->store();
$contentObjectAttribute->setContent( $user );
}

/**
* Generates a serialized draft of the ezuser content
*
* @param eZUser $user
* @return string
*/
private function serializeDraft( eZUser $user )
{
return json_encode(
array(
'login' => $user->attribute( 'login' ),
'password_hash' => $user->attribute( 'password_hash' ),
'email' => $user->attribute( 'email' ),
'password_hash_type' => $user->attribute( 'password_hash_type' )
)
);
}

/**
* Unserialize draft data generated with serializeDraft()
*
* @param $serializedDraft
* @return mixed
*/
private function unserializeDraft( $serializedDraft )
{
return json_decode( $serializedDraft );
}

/**
* Updates ezuser with data generated with getSerializedDraft()
*
* @param eZUser $user
* @param $serializedDraft
* @return eZUser updated user
*/
private function updateUserDraft( eZUser $user, $serializedDraft )
{
$draft = $this->unserializeDraft( $serializedDraft );

$user->setAttribute( 'login', $draft->login );
$user->setAttribute( 'password_hash', $draft->password_hash );
$user->setAttribute( 'email', $draft->email );
$user->setAttribute( 'password_hash_type', $draft->password_hash_type );

return $user;
}

/*!
Returns the object title.
*/
Expand Down Expand Up @@ -352,19 +278,8 @@ function objectAttributeContent( $contentObjectAttribute )
{
$GLOBALS['eZUserObject_' . $userID] = eZUser::fetch( $userID );
}

/** @var eZUser $user */
$user = eZUser::fetch( $userID );
eZDebugSetting::writeDebug( 'kernel-user', $user, 'user' );

// Looking for a "draft" and loading it's content
$serializedDraft = $contentObjectAttribute->attribute( 'data_text' );

if ( !empty( $serializedDraft ) )
{
$user = $this->updateUserDraft( $user, $serializedDraft );
}

return $user;
}

Expand Down

0 comments on commit ece8c52

Please sign in to comment.