function fetchParticipantList($itemID, $sortBy, $offset, $limit) { $itemParameters = array('item_id' => $itemID, 'offset' => $offset, 'limit' => $limit, 'sort_by' => $sortBy); $children = eZCollaborationItemParticipantLink::fetchParticipantList($itemParameters); if ($children === null) { $resultArray = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND)); } else { $resultArray = array('result' => $children); } return $resultArray; }
function participantList() { return eZCollaborationItemParticipantLink::fetchParticipantList(array('item_id' => $this->ID)); }
static function handleCollaborationEvent($event, $item, &$parameters) { $participantList = eZCollaborationItemParticipantLink::fetchParticipantList(array('item_id' => $item->attribute('id'), 'participant_type' => eZCollaborationItemParticipantLink::TYPE_USER, 'as_object' => false)); $userIDList = array(); $participantMap = array(); foreach ($participantList as $participant) { $userIDList[] = $participant['participant_id']; $participantMap[$participant['participant_id']] = $participant; } // $collaborationIdentifier = $event->attribute( 'collaboration_identifier' ); $collaborationIdentifier = $event->attribute('data_text1'); $ruleList = eZCollaborationNotificationRule::fetchItemTypeList($collaborationIdentifier, $userIDList, false); $userIDList = array(); foreach ($ruleList as $rule) { $userIDList[] = $rule['user_id']; } $userList = array(); if (count($userIDList) > 0) { $db = eZDB::instance(); $userIDListText = $db->generateSQLINStatement($userIDList, 'contentobject_id', false, false, 'int'); $userList = $db->arrayQuery("SELECT contentobject_id, email FROM ezuser WHERE {$userIDListText}"); } else { return eZNotificationEventHandler::EVENT_SKIPPED; } $itemHandler = $item->attribute('handler'); $collectionHandling = $itemHandler->notificationCollectionHandling(); $db = eZDB::instance(); $db->begin(); if ($collectionHandling == self::NOTIFICATION_COLLECTION_ONE_FOR_ALL) { $tpl = eZTemplate::factory(); $tpl->resetVariables(); $tpl->setVariable('collaboration_item', $item); $result = $tpl->fetch('design:notification/handler/ezcollaboration/view/plain.tpl'); $subject = $tpl->variable('subject'); if ($tpl->hasVariable('message_id')) { $parameters['message_id'] = $tpl->variable('message_id'); } if ($tpl->hasVariable('references')) { $parameters['references'] = $tpl->variable('references'); } if ($tpl->hasVariable('reply_to')) { $parameters['reply_to'] = $tpl->variable('reply_to'); } if ($tpl->hasVariable('from')) { $parameters['from'] = $tpl->variable('from'); } if ($tpl->hasVariable('content_type')) { $parameters['content_type'] = $tpl->variable('content_type'); } $collection = eZNotificationCollection::create($event->attribute('id'), eZCollaborationNotificationHandler::NOTIFICATION_HANDLER_ID, eZCollaborationNotificationHandler::TRANSPORT); $collection->setAttribute('data_subject', $subject); $collection->setAttribute('data_text', $result); $collection->store(); foreach ($userList as $subscriber) { $collection->addItem($subscriber['email']); } } else { if ($collectionHandling == self::NOTIFICATION_COLLECTION_PER_PARTICIPATION_ROLE) { $userCollection = array(); foreach ($userList as $subscriber) { $contentObjectID = $subscriber['contentobject_id']; $participant = $participantMap[$contentObjectID]; $participantRole = $participant['participant_role']; $userItem = array('participant' => $participant, 'email' => $subscriber['email']); if (!isset($userCollection[$participantRole])) { $userCollection[$participantRole] = array(); } $userCollection[$participantRole][] = $userItem; } $tpl = eZTemplate::factory(); $tpl->resetVariables(); foreach ($userCollection as $participantRole => $collectionItems) { $templateName = $itemHandler->notificationParticipantTemplate($participantRole); if (!$templateName) { $templateName = eZCollaborationItemHandler::notificationParticipantTemplate($participantRole); } $itemInfo = $itemHandler->attribute('info'); $typeIdentifier = $itemInfo['type-identifier']; $tpl->setVariable('collaboration_item', $item); $tpl->setVariable('collaboration_participant_role', $participantRole); $result = $tpl->fetch('design:notification/handler/ezcollaboration/view/' . $typeIdentifier . '/' . $templateName); $subject = $tpl->variable('subject'); if ($tpl->hasVariable('message_id')) { $parameters['message_id'] = $tpl->variable('message_id'); } if ($tpl->hasVariable('references')) { $parameters['references'] = $tpl->variable('references'); } if ($tpl->hasVariable('reply_to')) { $parameters['reply_to'] = $tpl->variable('reply_to'); } if ($tpl->hasVariable('from')) { $parameters['from'] = $tpl->variable('from'); } if ($tpl->hasVariable('content_type')) { $parameters['content_type'] = $tpl->variable('content_type'); } $collection = eZNotificationCollection::create($event->attribute('id'), eZCollaborationNotificationHandler::NOTIFICATION_HANDLER_ID, eZCollaborationNotificationHandler::TRANSPORT); $collection->setAttribute('data_subject', $subject); $collection->setAttribute('data_text', $result); $collection->store(); foreach ($collectionItems as $collectionItem) { $collection->addItem($collectionItem['email']); } } } else { if ($collectionHandling == self::NOTIFICATION_COLLECTION_PER_USER) { } else { eZDebug::writeError("Unknown collaboration notification collection handling type '{$collectionHandling}', skipping notification", __METHOD__); } } } $db->commit(); return eZNotificationEventHandler::EVENT_HANDLED; }
static function fetchParticipantMap($originalParameters = array()) { $parameters = array_merge(array('sort_field' => 'role'), $originalParameters); $itemID = $parameters['item_id']; $sortField = $parameters['sort_field']; $list = eZCollaborationItemParticipantLink::fetchParticipantList($originalParameters); if ($list === null) { $listMap = null; return $listMap; } $listMap = array(); foreach ($list as $listItem) { $sortKey = null; if ($sortField == 'role') { $sortKey = $listItem->attribute('participant_role'); } if ($sortKey !== null) { if (!isset($listMap[$sortKey])) { if ($sortField == 'role') { $sortName = eZCollaborationItemParticipantLink::roleName($itemID, $sortKey); } $listMap[$sortKey] = array('name' => $sortName, 'items' => array()); } $listMap[$sortKey]['items'][] = $listItem; } } return $listMap; }
function handleCustomAction($module, $collaborationItem) { $redirectView = 'item'; $redirectParameters = array('full', $collaborationItem->attribute('id')); $addComment = false; if ($this->isCustomAction('Comment')) { $addComment = true; } else { if ($this->isCustomAction('Accept') or $this->isCustomAction('Deny') or $this->isCustomAction('Defer')) { // check user's rights to approve $user = eZUser::currentUser(); $userID = $user->attribute('contentobject_id'); $participantList = eZCollaborationItemParticipantLink::fetchParticipantList(array('item_id' => $collaborationItem->attribute('id'))); $approveAllowed = false; foreach ($participantList as $participant) { if ($participant->ParticipantID == $userID && $participant->ParticipantRole == eZCollaborationItemParticipantLink::ROLE_APPROVER) { $approveAllowed = true; break; } } if (!$approveAllowed) { return $module->redirectToView($redirectView, $redirectParameters); } $contentObjectVersion = $this->contentObjectVersion($collaborationItem); $status = self::STATUS_DENIED; if ($this->isCustomAction('Accept')) { $status = self::STATUS_ACCEPTED; } else { if ($this->isCustomAction('Defer') or $this->isCustomAction('Deny')) { $status = self::STATUS_DENIED; } } $collaborationItem->setAttribute('data_int3', $status); $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_INACTIVE); $timestamp = time(); $collaborationItem->setAttribute('modified', $timestamp); $collaborationItem->setIsActive(false); $redirectView = 'view'; $redirectParameters = array('summary'); $addComment = true; } } if ($addComment) { $messageText = $this->customInput('ApproveComment'); if (trim($messageText) != '') { $message = eZCollaborationSimpleMessage::create('ezapprove_comment', $messageText); $message->store(); eZCollaborationItemMessageLink::addMessage($collaborationItem, $message, self::MESSAGE_TYPE_APPROVE); } } $collaborationItem->sync(); return $module->redirectToView($redirectView, $redirectParameters); }
static function activateApproval($approvalID) { $collaborationItem = eZCollaborationItem::fetch($approvalID); if ($collaborationItem !== null) { $collaborationItem->setAttribute('data_int3', eZCollaborationApprove2::STATUS_WAITING); $collaborationItem->setAttribute('status', eZCollaborationItem::STATUS_ACTIVE); $timestamp = time(); $collaborationItem->setAttribute('modified', $timestamp); $collaborationItem->store(); $participantList = eZCollaborationItemParticipantLink::fetchParticipantList(array('item_id' => $approvalID)); foreach ($participantList as $participantLink) { $collaborationItem->setIsActive(true, $participantLink->attribute('participant_id')); } return true; } return false; }