static function fetchForUser( $address, $asObject = true ) { return eZPersistentObject::fetchObject( eZGeneralDigestUserSettings::definition(), null, array( 'address' => $address ), $asObject ); }
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; }
function handlePublishEvent($event, &$parameters) { $versionObject = $event->attribute('content'); if (!$versionObject) { return eZNotificationEventHandler::EVENT_SKIPPED; } $contentObject = $versionObject->attribute('contentobject'); if (!$contentObject) { return eZNotificationEventHandler::EVENT_SKIPPED; } $contentNode = $contentObject->attribute('main_node'); if (!$contentNode) { return eZNotificationEventHandler::EVENT_SKIPPED; } // Notification should only be sent out when the object is published (is visible) if ($contentNode->attribute('is_invisible') == 1) { return eZNotificationEventHandler::EVENT_SKIPPED; } $contentClass = $contentObject->attribute('content_class'); if (!$contentClass) { return eZNotificationEventHandler::EVENT_SKIPPED; } if ($versionObject->attribute('version') != $contentObject->attribute('current_version')) { return eZNotificationEventHandler::EVENT_SKIPPED; } $tpl = eZTemplate::factory(); $tpl->resetVariables(); $parentNode = $contentNode->attribute('parent'); if (!$parentNode instanceof eZContentObjectTreeNode) { eZDebug::writeError('DB corruption: Node id ' . $contentNode->attribute('node_id') . ' is missing parent node.', __METHOD__); return eZNotificationEventHandler::EVENT_SKIPPED; } $parentContentObject = $parentNode->attribute('object'); if (!$parentContentObject instanceof eZContentObject) { eZDebug::writeError('DB corruption: Node id ' . $parentNode->attribute('node_id') . ' is missing object.', __METHOD__); return eZNotificationEventHandler::EVENT_SKIPPED; } $parentContentClass = $parentContentObject->attribute('content_class'); if (!$parentContentClass instanceof eZContentClass) { eZDebug::writeError('DB corruption: Object id ' . $parentContentObject->attribute('id') . ' is missing class object.', __METHOD__); return eZNotificationEventHandler::EVENT_SKIPPED; } $res = eZTemplateDesignResource::instance(); $res->setKeys(array(array('object', $contentObject->attribute('id')), array('node', $contentNode->attribute('node_id')), array('class', $contentObject->attribute('contentclass_id')), array('class_identifier', $contentClass->attribute('identifier')), array('parent_node', $contentNode->attribute('parent_node_id')), array('parent_class', $parentContentObject->attribute('contentclass_id')), array('parent_class_identifier', $parentContentClass != null ? $parentContentClass->attribute('identifier') : 0), array('depth', $contentNode->attribute('depth')), array('url_alias', $contentNode->attribute('url_alias')))); $tpl->setVariable('object', $contentObject); $notificationINI = eZINI::instance('notification.ini'); $emailSender = $notificationINI->variable('MailSettings', 'EmailSender'); $ini = eZINI::instance(); if (!$emailSender) { $emailSender = $ini->variable('MailSettings', 'EmailSender'); } if (!$emailSender) { $emailSender = $ini->variable("MailSettings", "AdminEmail"); } $tpl->setVariable('sender', $emailSender); $result = $tpl->fetch('design:notification/handler/ezsubtree/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'), self::NOTIFICATION_HANDLER_ID, self::TRANSPORT); $collection->setAttribute('data_subject', $subject); $collection->setAttribute('data_text', $result); $collection->store(); $assignedNodes = $contentObject->parentNodes(true); $nodeIDList = array(); foreach ($assignedNodes as $node) { if ($node) { $pathString = $node->attribute('path_string'); $pathString = ltrim(rtrim($pathString, '/'), '/'); $nodeIDListPart = explode('/', $pathString); $nodeIDList = array_merge($nodeIDList, $nodeIDListPart); } } $nodeIDList[] = $contentNode->attribute('node_id'); $nodeIDList = array_unique($nodeIDList); $userList = eZSubtreeNotificationRule::fetchUserList($nodeIDList, $contentObject); $locale = eZLocale::instance(); $weekDayNames = $locale->attribute('weekday_name_list'); $weekDaysByName = array_flip($weekDayNames); foreach ($userList as $subscriber) { $item = $collection->addItem($subscriber['address']); if ($subscriber['use_digest'] == 0) { $settings = eZGeneralDigestUserSettings::fetchByUserId($subscriber['user_id']); if ($settings !== null && $settings->attribute('receive_digest') == 1) { $time = $settings->attribute('time'); $timeArray = explode(':', $time); $hour = $timeArray[0]; if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_DAILY) { eZNotificationSchedule::setDateForItem($item, array('frequency' => 'day', 'hour' => $hour)); } else { if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_WEEKLY) { $weekday = $weekDaysByName[$settings->attribute('day')]; eZNotificationSchedule::setDateForItem($item, array('frequency' => 'week', 'day' => $weekday, 'hour' => $hour)); } else { if ($settings->attribute('digest_type') == eZGeneralDigestUserSettings::TYPE_MONTHLY) { eZNotificationSchedule::setDateForItem($item, array('frequency' => 'month', 'day' => $settings->attribute('day'), 'hour' => $hour)); } } } $item->store(); } } } return eZNotificationEventHandler::EVENT_HANDLED; }
function cleanup() { eZGeneralDigestUserSettings::cleanup(); }