/** * Test regression for issue #13952: Workflow cronjob gives fatal error if * node is moved to different location before approval. * * Test Outline * ------------ * 1. Create a folder * 2. Approve folder * 3. Create child of folder * 4. Approve child * 5. Create a new version and re-publish the child * 6. Move child to root * 7. Approve child * 8. Run approval cronjob * * @result: Fatal error: Call to a member function attribute() on a non-object in * /www/trunk/kernel/content/ezcontentoperationcollection.php on line 313 * @expected: No fatal error * @link http://issues.ez.no/13952 */ public function testApprovalFatalErrorWhenMoving() { $anonymousObjectID = eZUser::fetchByName('anonymous')->attribute('contentobject_id'); // STEP 1: Create a folder $folder = new ezpObject("folder", 2, $anonymousObjectID); $folder->name = "Parent folder (needs approval)"; $folder->publish(); // STEP 2: Approve folder $collaborationItem = eZCollaborationItem::fetch(1); $this->approveCollaborationItem($collaborationItem); $this->runWorkflow(); // STEP 3: Create child of folder $child = new ezpObject("folder", $folder->mainNode->node_id, $anonymousObjectID); $child->name = "Child folder (needs approval)"; $child->publish(); // STEP 4: Approve child $collaborationItem = eZCollaborationItem::fetch(2); $this->approveCollaborationItem($collaborationItem); $this->runWorkflow(); // STEP 5: Re-publish child $newVersion = $child->createNewVersion(); ezpObject::publishContentObject($child->object, $newVersion); // STEP 6: Move child to root $child->mainNode->move(2); // STEP 7: Approve child again $collaborationItem = eZCollaborationItem::fetch(3); $this->approveCollaborationItem($collaborationItem); // STEP 8: Run approval cronjob $this->runWorkflow(); }
function collaborationItem() { if (isset($this->CollaborationID) and $this->CollaborationID) { return eZCollaborationItem::fetch($this->CollaborationID, $this->UserID); } return null; }
function fetchItemCount($isRead, $isActive, $parentGroupID, $status) { $itemParameters = array('is_read' => $isRead, 'is_active' => $isActive, 'parent_group_id' => $parentGroupID); if ($status !== false) { $itemParameters['status'] = $status; } $count = eZCollaborationItem::fetchListCount($itemParameters); return array('result' => $count); }
function checkApproveCollaboration( $process, $event ) { $db = eZDb::instance(); $taskResult = $db->arrayQuery( 'select workflow_process_id, collaboration_id from ezapprove_items where workflow_process_id = ' . $process->attribute( 'id' ) ); $collaborationID = $taskResult[0]['collaboration_id']; $collaborationItem = eZCollaborationItem::fetch( $collaborationID ); $contentObjectVersion = eZApproveCollaborationHandler::contentObjectVersion( $collaborationItem ); $approvalStatus = eZApproveCollaborationHandler::checkApproval( $collaborationID ); if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_WAITING ) { eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval still waiting' ); return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT; } else if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_ACCEPTED ) { eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval was accepted' ); $status = eZWorkflowType::STATUS_ACCEPTED; } else if ( $approvalStatus == eZApproveCollaborationHandler::STATUS_DENIED or $approvalStatus == eZApproveCollaborationHandler::STATUS_DEFERRED ) { eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, 'approval was denied' ); $contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_DRAFT ); $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } else { eZDebugSetting::writeDebug( 'kernel-workflow-approve', $event, "approval unknown status '$approvalStatus'" ); $contentObjectVersion->setAttribute( 'status', eZContentObjectVersion::STATUS_REJECTED ); $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } $contentObjectVersion->sync(); if ( $approvalStatus != eZApproveCollaborationHandler::STATUS_DEFERRED ) $db->query( 'DELETE FROM ezapprove_items WHERE workflow_process_id = ' . $process->attribute( 'id' ) ); return $status; }
static function fetchList($parameters = array()) { return eZCollaborationItem::fetchListTool($parameters, false); }
{ $cli->output( "Removing all forgot password requests" ); eZForgotPassword::cleanup(); } if ( $clean['workflow'] ) { $cli->output( "Removing all workflow processes and operation mementos" ); eZOperationMemento::cleanup(); eZWorkflowProcess::cleanup(); } if ( $clean['collaboration'] ) { $cli->output( "Removing all collaboration elements" ); eZCollaborationItem::cleanup(); } if ( $clean['collectedinformation'] ) { $cli->output( "Removing all collected information" ); eZInformationCollection::cleanup(); } if ( $clean['notification'] ) { $cli->output( "Removing all notifications events" ); eZNotificationEvent::cleanup(); eZNotificationCollection::cleanup(); eZNotificationEventFilter::cleanup(); }
function eventContent($event) { return eZCollaborationItem::fetch($event->attribute('data_int1')); }
/** * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. * @license http://ez.no/Resources/Software/Licenses/eZ-Business-Use-License-Agreement-eZ-BUL-Version-2.1 eZ Business Use License Agreement eZ BUL Version 2.1 * @version 4.7.0 * @package kernel */ $Module = $Params['Module']; $ViewMode = $Params['ViewMode']; $ItemID = $Params['ItemID']; $Offset = $Params['Offset']; if ( !is_numeric( $Offset ) ) $Offset = 0; $collabItem = eZCollaborationItem::fetch( $ItemID ); if ( $collabItem === null ) return $Module->handleError( eZError::KERNEL_NOT_AVAILABLE, 'kernel' ); $collabHandler = $collabItem->handler(); $collabItem->handleView( $ViewMode ); $template = $collabHandler->template( $ViewMode ); $collabTitle = $collabItem->title(); $viewParameters = array( 'offset' => $Offset ); $tpl = eZTemplate::factory(); $tpl->setVariable( 'view_parameters', $viewParameters ); $tpl->setVariable( 'collab_item', $collabItem );
function participantRoleString() { if ($this->ParticipantRole < self::ROLE_CUSTOM) { return eZCollaborationItemParticipantLink::roleString($this->ParticipantRole); } $item = eZCollaborationItem::fetch($this->CollaborationID); return $item->attribute('type_identifier') . '_' . $item->handler()->participantRoleString($this->ParticipantRole); }
function itemList($parameters = array()) { return eZCollaborationItem::fetchList(array_merge(array('parent_group_id' => $this->ID), $parameters)); }
static function createApproval($contentObjectID, $contentObjectVersion, $authorID, $approverIDArray) { $collaborationItem = eZCollaborationItem::create('ezapprove', $authorID); $collaborationItem->setAttribute('data_int1', $contentObjectID); $collaborationItem->setAttribute('data_int2', $contentObjectVersion); $collaborationItem->setAttribute('data_int3', false); $collaborationItem->store(); $collaborationID = $collaborationItem->attribute('id'); $participantList = array(array('id' => array($authorID), 'role' => eZCollaborationItemParticipantLink::ROLE_AUTHOR), array('id' => $approverIDArray, 'role' => eZCollaborationItemParticipantLink::ROLE_APPROVER)); foreach ($participantList as $participantItem) { foreach ($participantItem['id'] as $participantID) { $participantRole = $participantItem['role']; $link = eZCollaborationItemParticipantLink::create($collaborationID, $participantID, $participantRole, eZCollaborationItemParticipantLink::TYPE_USER); $link->store(); $profile = eZCollaborationProfile::instance($participantID); $groupID = $profile->attribute('main_group'); eZCollaborationItemGroupLink::addItem($groupID, $collaborationID, $participantID); } } // Create the notification $collaborationItem->createNotificationEvent(); return $collaborationItem; }
function attribute($attr, $noFunction = false) { $retVal = false; switch ($attr) { case 'approve_status_name': $nameMap = $this->statusNameMap(); $retVal = $nameMap[$this->attribute('approve_status')]; break; case 'num_approvers': $retVal = count($this->approveUserList()); break; case 'collaboration_item': #include_once( 'kernel/classes/ezcollaborationitem.php' ); $retVal = eZCollaborationItem::fetch($this->attribute('collaborationitem_id')); break; case 'workflow_process': #include_once( 'kernel/classes/ezworkflowprocess.php' ); $retVal = eZWorkflowProcess::fetch($this->attribute('workflowprocess_id')); break; case 'user_approve_status': $retVal = eZXApproveStatusUserLink::fetchByUserID(eZUser::currentUserID(), $this->attribute('id'), eZXApproveStatusUserLink::RoleApprover); break; case 'num_approve_required': $eventData = $this->attribute('approve2_event'); if ($eventData) { $retVal = $eventData->attribute('require_all_approve') ? $this->attribute('num_approvers') : 1; } break; case 'contentobject': $retVal = eZContentObject::fetch($this->attribute('contentobject_id')); break; default: $retVal = eZPersistentObject::attribute($attr); break; } return $retVal; }
function checkApproveCollaboration($process, $event, $collaborationID = 0) { $db = eZDb::instance(); if ($collaborationID > 0) { $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id, target_node_ids from ezxapprovelocation_items where collaboration_id = ' . $collaborationID); } else { $taskResult = $db->arrayQuery('select workflow_process_id, collaboration_id, target_node_ids from ezxapprovelocation_items where workflow_process_id = ' . $process->attribute('id')); } $collaborationID = $taskResult[0]['collaboration_id']; $collaborationItem = eZCollaborationItem::fetch($collaborationID); $approvalStatus = approveLocationCollaborationHandler::checkApproval($collaborationID); $targetNodeIDs = json_decode($taskResult[0]['target_node_ids']); if ($approvalStatus == approveLocationCollaborationHandler::STATUS_WAITING) { eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval still waiting'); return eZWorkflowType::STATUS_DEFERRED_TO_CRON_REPEAT; } elseif ($approvalStatus == approveLocationCollaborationHandler::STATUS_ACCEPTED) { eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval was accepted'); eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $targetNodeIDs, 'add new location(s)'); return eZWorkflowType::STATUS_ACCEPTED; } elseif ($approvalStatus == approveLocationCollaborationHandler::STATUS_DENIED or $approvalStatus == approveLocationCollaborationHandler::STATUS_DEFERRED) { eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, 'approval was denied'); $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } else { eZDebugSetting::writeDebug('ezworkflowcollection-workflow-approve-location', $event, "approval unknown status '{$approvalStatus}'"); $status = eZWorkflowType::STATUS_WORKFLOW_CANCELLED; } if ($approvalStatus != approveLocationCollaborationHandler::STATUS_DEFERRED) { $db->query('DELETE FROM ezxapprovelocation_items WHERE workflow_process_id = ' . $process->attribute('id')); } return $status; }