user = (string)$currentUser->getUID(); } /** * @NoAdminRequired * * @param int $notify_setting_batchtime * @param bool $notify_setting_self * @param bool $notify_setting_selfemail * @param bool $activity_digest * @return DataResponse */ public function personal( $notify_setting_batchtime = UserSettings::EMAIL_SEND_HOURLY, $notify_setting_self = false, $notify_setting_selfemail = false, $activity_digest = false, ) { $settings = $this->manager->getSettings(); foreach ($settings as $setting) { $this->config->setUserValue( $this->user, 'activity', 'notify_notification_' . $setting->getIdentifier(), (string)(int)$this->request->getParam($setting->getIdentifier() . '_notification', false) ); if ($setting->canChangeMail()) { $this->config->setUserValue( $this->user, 'activity', 'notify_email_' . $setting->getIdentifier(), (string)(int)$this->request->getParam($setting->getIdentifier() . '_email', false) ); } } $email_batch_time = 3600; if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_DAILY) { $email_batch_time = 3600 * 24; } elseif ($notify_setting_batchtime === UserSettings::EMAIL_SEND_WEEKLY) { $email_batch_time = 3600 * 24 * 7; } elseif ($notify_setting_batchtime === UserSettings::EMAIL_SEND_ASAP) { $email_batch_time = 0; } $this->config->setUserValue( $this->user, 'activity', 'notify_setting_batchtime', (string)$email_batch_time ); $this->config->setUserValue( $this->user, 'activity', 'notify_setting_self', (string)(int)$notify_setting_self ); $this->config->setUserValue( $this->user, 'activity', 'notify_setting_selfemail', (string)(int)$notify_setting_selfemail ); $this->config->setUserValue( $this->user, 'activity', 'notify_setting_activity_digest', (string)(int)$activity_digest ); return new DataResponse([ 'data' => [ 'message' => $this->l10n->t('Your settings have been updated.'), ], ]); } /** * @param int $notify_setting_batchtime * @param bool $notify_setting_self * @param bool $notify_setting_selfemail * @return DataResponse */ public function admin( $notify_setting_batchtime = UserSettings::EMAIL_SEND_HOURLY, $notify_setting_self = false, $notify_setting_selfemail = false) { $settings = $this->manager->getSettings(); foreach ($settings as $setting) { $this->config->setAppValue( 'activity', 'notify_notification_' . $setting->getIdentifier(), (string)(int)$this->request->getParam($setting->getIdentifier() . '_notification', false) ); if ($setting->canChangeMail()) { $this->config->setAppValue( 'activity', 'notify_email_' . $setting->getIdentifier(), (string)(int)$this->request->getParam($setting->getIdentifier() . '_email', false) ); } } $email_batch_time = 3600; if ($notify_setting_batchtime === UserSettings::EMAIL_SEND_DAILY) { $email_batch_time = 3600 * 24; } elseif ($notify_setting_batchtime === UserSettings::EMAIL_SEND_WEEKLY) { $email_batch_time = 3600 * 24 * 7; } elseif ($notify_setting_batchtime === UserSettings::EMAIL_SEND_ASAP) { $email_batch_time = 0; } $this->config->setAppValue( 'activity', 'notify_setting_batchtime', (string)$email_batch_time ); $this->config->setAppValue( 'activity', 'notify_setting_self', (string)(int)$notify_setting_self ); $this->config->setAppValue( 'activity', 'notify_setting_selfemail', (string)(int)$notify_setting_selfemail ); return new DataResponse([ 'data' => [ 'message' => $this->l10n->t('Settings have been updated.'), ], ]); } /** * @NoAdminRequired * * @param bool $enable true if the feed is enabled * @return DataResponse */ public function feed(bool $enable) { $token = $tokenUrl = ''; if ($enable === true) { $conflicts = true; // Check for collisions while (!empty($conflicts)) { $token = $this->random->generate(30, ISecureRandom::CHAR_UPPER . ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS); $conflicts = $this->config->getUsersForUserValue('activity', 'rsstoken', $token); } $tokenUrl = $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show', ['token' => $token]); } $this->config->setUserValue($this->user, 'activity', 'rsstoken', $token); return new DataResponse([ 'data' => [ 'message' => $this->l10n->t('Your settings have been updated.'), 'rsslink' => trim($tokenUrl), ], ]); } }