Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Added references to content object and author in statusUpdateEvent
Browse files Browse the repository at this point in the history
Changed: check status to verify a status results from an error or not
  • Loading branch information
dpobel committed Jun 30, 2011
1 parent 0a47a57 commit a218bb2
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 6 deletions.
1 change: 1 addition & 0 deletions extension/autostatus/classes/autostatusajaxfunctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ private static function retryAndUpdateStatus( eZWorkflowEvent $event, autostatus
}
$status->setAttribute( 'status', $r );
$status->setAttribute( 'error_msg', $errorMsg );
$status->setAttribute( 'user_id', eZUser::currentUserID();
$status->store();
return $status;
}
Expand Down
32 changes: 29 additions & 3 deletions extension/autostatus/classes/statusupdateevent.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class statusUpdateEvent extends eZPersistentObject

protected $ID;
protected $WorkflowEventID;
protected $UserID;
protected $ContentObjectID;
protected $StatusMessage;
protected $Created;
protected $Modified;
Expand All @@ -58,6 +60,14 @@ static function definition()
'datatype' => 'integer',
'default' => 0,
'required' => true ),
'user_id' => array( 'name' => 'UserID',
'datatype' => 'integer',
'default' => 0,
'required' => true ),
'contentobject_id' => array( 'name' => 'ContentObjectID',
'datatype' => 'integer',
'default' => 0,
'required' => true ),
'message' => array( 'name' => 'StatusMessage',
'datatype' => 'string',
'default' => '',
Expand All @@ -81,13 +91,25 @@ static function definition()
'keys' => array( 'id' ),
'increment_key' => 'id',
'function_attributes' => array( 'event' => 'fetchEvent',
'user' => 'fetchUser',
'object' => 'fetchContentObject',
'status_text' => 'statusText',
'is_error' => 'isError' ),
'class_name' => 'statusUpdateEvent',
'name' => 'statusupdateevent' );
return $definition;
}

function fetchUser()
{
return eZUser::fetch( $this->UserID );
}

function fetchContentObject()
{
return eZContentObject::fetch( $this->ContentObjectID );
}

function fetchEvent()
{
$eventID = $this->attribute( 'event_id' );
Expand All @@ -96,7 +118,7 @@ function fetchEvent()

function isError()
{
return ( $this->attribute( 'error_msg' ) !== '' );
return ( $this->Status !== self::NORMAL );
}

function statusText()
Expand All @@ -111,18 +133,22 @@ function statusText()
* @param string $message message used to update status
* @param string $errorMsg error message
* @param int $status status code
* @param int $userID user id that sends the update
* @param int $contentObjectID content object id
* @static
* @access public
* @return statusUpdateEvent
*/
static function create( $eventID, $message, $errorMsg, $status )
static function create( $eventID, $message, $errorMsg, $status, $userID, $contentObjectID )
{
$row = array( 'event_id' => $eventID,
'created' => time(),
'modified' => time(),
'message' => $message,
'error_msg' => (string) $errorMsg,
'status' => $status );
'status' => $status,
'user_id' => $userID,
'contentobject_id' => $contentObjectID );
return new statusUpdateEvent( $row );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@
* $Id$
* $HeadURL$
*}
{def $author = $event.user
$content = $event.object}
<td>{if $event.event.login|ne( '' )}{$event.event.login|wash}@{/if}{$event.event.social_network.name|wash}</td>
<td>{$event.message|wash|autolink}</td>
{if $content|is_object}
<td><a href={$content.main_node.url_alias|ezurl}>{$content.name|wash}</a></td>
{else}
<td>?</td>
{/if}
{if $author|is_object}
<td><a href={$author.contentobject.main_node.url_alias|ezurl}>{$author.contentobject.name|wash}</a></td>
{else}
<td>?</td>
{/if}
<td>{$event.created|l10n( 'shortdatetime' )}</td>
<td>{$event.modified|l10n( 'shortdatetime' )}</td>
<td class="message">{$event.error_msg|wash}</td>
<td class="message">{cond( and( $event.is_error, $event.error_msg|eq( '' ) ), '?', $event.error_msg|wash )}</td>
<td class="retry-button">
{if $event.is_error}
<input type="submit" class="button" name="Retry_{$event.id}" value="{'Retry'|i18n( 'autostatus/log' )}"{cond( $event.event|is_object, '', ' disabled="disabled"' )} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ $(document).ready(function() {
<tbody>
<tr>
<th>{'Social network'|i18n( 'autostatus/log' )}</th>
<th>{'Status to send'|i18n( 'autostatus/log' )}</th>
<th>{'Status message'|i18n( 'autostatus/log' )}</th>
<th>{'Content'|i18n( 'autostatus/log' )}</th>
<th>{'Author'|i18n( 'autostatus/log' )}</td>
<th class="modified">{'Created'|i18n( 'autostatus/log' )}</th>
<th class="modified">{'Modified'|i18n( 'autostatus/log' )}</th>
<th>{'Error message'|i18n( 'autostatus/log' )}</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,10 @@ function execute( $process, $event )
. $socialNetwork->attribute( 'name' ) . ' : '
. $e->getMessage(), 'Auto status workflow' );
}
$statusEvent = statusUpdateEvent::create( $event->attribute( 'id' ), $message, $errorMsg, $status );
$statusEvent = statusUpdateEvent::create(
$event->attribute( 'id' ), $message, $errorMsg, $status,
$parameters['user_id'], $parameters['contentobject_id']
);
$statusEvent->store();
}
return eZWorkflowEventType::STATUS_ACCEPTED;
Expand Down
2 changes: 2 additions & 0 deletions extension/autostatus/sql/statusupdateevent.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
CREATE TABLE statusupdateevent (
id int(11) NOT NULL auto_increment,
event_id int(11) NOT NULL default 0,
user_id int(11) NOT NULL default 0,
contentobject_id int(11) NOT NULL default 0,
message varchar(255) NOT NULL default '',
created int(11) NOT NULL default 0,
modified int(11) NOT NULL default 0,
Expand Down

0 comments on commit a218bb2

Please sign in to comment.