/** * @see \wcf\system\SingletonFactory::init() */ protected function init() { // get available object types $this->objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.notification.objectType'); foreach ($this->objectTypes as $typeName => $object) { $this->availableObjectTypes[$typeName] = $object->getProcessor(); } // get available events $this->availableEvents = UserNotificationEventCacheBuilder::getInstance()->getData(); }
/** * @see \wcf\form\IForm::save() */ public function save() { parent::save(); foreach ($this->events as $objectType => $events) { foreach ($events as $event) { $preset = 0; $presetMailNotificationType = 'none'; if (!empty($this->settings[$event->eventID]['enabled'])) { $preset = 1; if (isset($this->settings[$event->eventID]['mailNotificationType'])) { $presetMailNotificationType = $this->settings[$event->eventID]['mailNotificationType']; } } if ($event->preset != $preset || $event->presetMailNotificationType != $presetMailNotificationType) { $editor = new UserNotificationEventEditor(new UserNotificationEvent(null, array('eventID' => $event->eventID))); $editor->update(array('preset' => $preset, 'presetMailNotificationType' => $presetMailNotificationType)); if ($this->applyChangesToExistingUsers) { if (!$preset) { $sql = "DELETE FROM\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\t\t\t\t\tWHERE\t\teventID = ?"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($event->eventID)); } else { $sql = "REPLACE INTO\twcf" . WCF_N . "_user_notification_event_to_user\n\t\t\t\t\t\t\t\t\t\t(userID, eventID, mailNotificationType)\n\t\t\t\t\t\t\t\tSELECT\t\tuserID, ?, ?\n\t\t\t\t\t\t\t\tFROM\t\twcf" . WCF_N . "_user"; $statement = WCF::getDB()->prepareStatement($sql); $statement->execute(array($event->eventID, $presetMailNotificationType)); } } } } } UserNotificationEventCacheBuilder::getInstance()->reset(); $this->saved(); // show success message WCF::getTPL()->assign('success', true); }