static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); eZGeneralDigestUserSettings::removeByUserId($userID); eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
static function removeUser($userID) { $user = eZUser::fetch($userID); if (!$user) { eZDebug::writeError("unable to find user with ID {$userID}", __METHOD__); return false; } eZUser::removeSessionData($userID); eZSubtreeNotificationRule::removeByUserID($userID); eZCollaborationNotificationRule::removeByUserID($userID); eZUserSetting::removeByUserID($userID); eZUserAccountKey::removeByUserID($userID); eZForgotPassword::removeByUserID($userID); eZWishList::removeByUserID($userID); // only remove general digest setting if there are no other users with the same e-mail $email = $user->attribute('email'); $usersWithEmailCount = eZPersistentObject::count(eZUser::definition(), array('email' => $email)); if ($usersWithEmailCount == 1) { eZGeneralDigestUserSettings::removeByAddress($email); } eZPersistentObject::removeObject(eZUser::definition(), array('contentobject_id' => $userID)); return true; }
static function removeByUserID( $userID ) { eZPersistentObject::removeObject( eZCollaborationNotificationRule::definition(), array( 'user_id' => $userID ) ); }
function cleanup() { eZCollaborationNotificationRule::cleanup(); }
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; }