예제 #1
0
 function sendMessages($userId)
 {
     if ($userId == 0) {
         $userList = $this->_db->listUsers("", 0, 9999999);
     } else {
         $thisUser = $this->_db->getUser($userId);
         $userList['list'] = array($thisUser);
     }
     # else
     foreach ($userList['list'] as $user) {
         # Omdat we vanuit listUsers() niet alle velden meekrijgen
         # vragen we opnieuw het user record op
         $user = $this->_db->getUser($user['userid']);
         $security = new SpotSecurity($this->_db, $this->_settings, $user);
         # Om e-mail te kunnen versturen hebben we iets meer data nodig
         $adminUsr = $this->_db->getUser(SPOTWEB_ADMIN_USERID);
         $user['prefs']['notifications']['email']['sender'] = $adminUsr['mail'];
         $user['prefs']['notifications']['email']['receiver'] = $user['mail'];
         # Twitter heeft ook extra settings nodig
         $user['prefs']['notifications']['twitter']['consumer_key'] = $this->_settings->get('twitter_consumer_key');
         $user['prefs']['notifications']['twitter']['consumer_secret'] = $this->_settings->get('twitter_consumer_secret');
         $newMessages = $this->_db->getUnsentNotifications($user['userid']);
         foreach ($newMessages as $newMessage) {
             $objectId = $newMessage['objectid'];
             $spotweburl = $this->_settings->get('spotweburl') == 'http://mijnuniekeservernaam/spotweb/' ? '' : $this->_settings->get('spotweburl');
             $notifProviders = Notifications_Factory::getActiveServices();
             foreach ($notifProviders as $notifProvider) {
                 if ($user['prefs']['notifications'][$notifProvider]['enabled'] && $user['prefs']['notifications'][$notifProvider]['events'][$objectId]) {
                     if ($security->allowed(SpotSecurity::spotsec_send_notifications_services, $notifProvider)) {
                         $this->_notificationServices[$notifProvider] = Notifications_Factory::build('Spotweb', $notifProvider, $user['prefs']['notifications'][$notifProvider]);
                     }
                     # if
                 }
                 # if
             }
             # foreach
             # nu wordt het bericht pas echt verzonden
             foreach ($this->_notificationServices as $notificationService) {
                 $notificationService->sendMessage($newMessage['type'], $newMessage['title'], $newMessage['body'], $spotweburl);
             }
             # foreach
             # Alle services resetten, deze mogen niet hergebruikt worden
             $this->_notificationServices = array();
             # Als dit bericht ging over het aanmaken van een nieuwe user, verwijderen we
             # het plaintext wachtwoord uit de database uit veiligheidsoverwegingen.
             if ($objectId == SpotNotifications::notifytype_user_added) {
                 $body = explode(" ", $newMessage['body']);
                 $body[4] = '[deleted]';
                 $newMessage['body'] = implode(" ", $body);
             }
             # if
             $newMessage['sent'] = 1;
             $this->_db->updateNotification($newMessage);
         }
         # foreach message
     }
     # foreach user
 }
예제 #2
0
	function sendMessages($userId) {
		if ($userId == 0) {
			$userList = $this->_db->listUsers("", 0, 9999999);
		} else {
			$thisUser = $this->_db->getUser($userId);
			$userList['list'] = array($thisUser);
		} # else

		foreach ($userList['list'] as $user) {
			# Omdat we vanuit listUsers() niet alle velden meekrijgen
			# vragen we opnieuw het user record op
			$user = $this->_db->getUser($user['userid']);
			$security = new SpotSecurity($this->_db, $this->_settings, $user);

			$newMessages = $this->_db->getUnsentNotifications($user['userid']);
			foreach ($newMessages as $newMessage) {
				
				$objectId = $newMessage['objectid'];
				$spotweburl = ($this->_settings->get('spotweburl') == 'http://mijnuniekeservernaam/spotweb/') ? '' : $this->_settings->get('spotweburl');

				$notifProviders = Notifications_Factory::getActiveServices();
				foreach ($notifProviders as $notifProvider) {
					if ($user['prefs']['notifications'][$notifProvider]['enabled'] && $user['prefs']['notifications'][$notifProvider]['events'][$objectId]) {
						if ($security->allowed(SpotSecurity::spotsec_send_notifications_services, $notifProvider)) {
							$this->_notificationServices[$notifProvider] = Notifications_Factory::build('Spotweb', $notifProvider, $user['prefs']['notifications'][$notifProvider]);
						} # if
					} # if
				} # foreach

				# nu wordt het bericht pas echt verzonden
				foreach($this->_notificationServices as $notificationService) {
					$notificationService->sendMessage($newMessage['type'], $newMessage['title'], $newMessage['body'], $spotweburl);
				} # foreach

				# Alle services resetten, deze mogen niet hergebruikt worden
				$this->_notificationServices = array();

				$this->_db->markNotificationSent($newMessage['id']);
			} # foreach message
		} # foreach user
	} # sendMessages
예제 #3
0
 function validateUserPreferences($prefs, $currentPrefs)
 {
     $errorList = array();
     # Definieer een aantal arrays met valid settings
     $validDateFormats = array('human', '%a, %d-%b-%Y (%H:%M)', '%d-%m-%Y (%H:%M)');
     $validTemplates = array('we1rdo');
     # Controleer de per page setting
     $prefs['perpage'] = (int) $prefs['perpage'];
     if ($prefs['perpage'] < 2 || $prefs['perpage'] > 250) {
         $errorList[] = array('validateuser_invalidpreference', array('perpage'));
     }
     # if
     # Controleer basis settings
     if (in_array($prefs['date_formatting'], $validDateFormats) === false) {
         $errorList[] = array('validateuser_invalidpreference', array('date_formatting'));
     }
     # if
     if (in_array($prefs['template'], $validTemplates) === false) {
         $errorList[] = array('validateuser_invalidpreference', array('template'));
     }
     # if
     # Als nzbhandling instellingen totaal niet opgegeven zijn, defaulten we naar disable
     if (!isset($prefs['nzbhandling'])) {
         $prefs['nzbhandling'] = array('action' => 'disable', 'prepare_action' => 'merge');
     }
     # if
     # als er een sabnzbd host opgegeven is, moet die geldig zijn
     if ($prefs['nzbhandling']['action'] == 'client-sabnzbd' || $prefs['nzbhandling']['action'] == 'push-sabnzbd') {
         $tmpHost = parse_url($prefs['nzbhandling']['sabnzbd']['url']);
         if ($tmpHost === false | !isset($tmpHost['scheme']) || $tmpHost['scheme'] != 'http' && $tmpHost['scheme'] != 'https') {
             $errorList[] = array('validateuser_invalidpreference', array('sabnzbd url'));
         }
         # if
         # SABnzbd URL moet altijd eindigen met een slash
         if (substr($prefs['nzbhandling']['sabnzbd']['url'], -1) !== '/') {
             $prefs['nzbhandling']['sabnzbd']['url'] .= '/';
         }
         # if
     }
     # if
     # converteer overige settings naar boolean zodat we gewoon al weten wat er uitkomt
     $prefs['count_newspots'] = isset($prefs['count_newspots']) ? true : false;
     $prefs['keep_seenlist'] = isset($prefs['keep_seenlist']) ? true : false;
     $prefs['auto_markasread'] = isset($prefs['auto_markasread']) ? true : false;
     $prefs['keep_downloadlist'] = isset($prefs['keep_downloadlist']) ? true : false;
     $prefs['keep_watchlist'] = isset($prefs['keep_watchlist']) ? true : false;
     $prefs['show_filesize'] = isset($prefs['show_filesize']) ? true : false;
     $prefs['show_multinzb'] = isset($prefs['show_multinzb']) ? true : false;
     $notifProviders = Notifications_Factory::getActiveServices();
     foreach ($notifProviders as $notifProvider) {
         $prefs['notifications'][$notifProvider]['enabled'] = isset($prefs['notifications'][$notifProvider]['enabled']) ? true : false;
         $prefs['notifications'][$notifProvider]['events']['watchlist_handled'] = isset($prefs['notifications'][$notifProvider]['events']['watchlist_handled']) ? true : false;
         $prefs['notifications'][$notifProvider]['events']['nzb_handled'] = isset($prefs['notifications'][$notifProvider]['events']['nzb_handled']) ? true : false;
         $prefs['notifications'][$notifProvider]['events']['retriever_finished'] = isset($prefs['notifications'][$notifProvider]['events']['retriever_finished']) ? true : false;
         $prefs['notifications'][$notifProvider]['events']['user_added'] = isset($prefs['notifications'][$notifProvider]['events']['user_added']) ? true : false;
     }
     # Twitter tokens komen niet binnen via het form, maar mogen perse niet weggegooid worden.
     $prefs['notifications']['twitter']['screen_name'] = $currentPrefs['notifications']['twitter']['screen_name'];
     $prefs['notifications']['twitter']['access_token'] = $currentPrefs['notifications']['twitter']['access_token'];
     $prefs['notifications']['twitter']['access_token_secret'] = $currentPrefs['notifications']['twitter']['access_token_secret'];
     $prefs['notifications']['twitter']['request_token'] = $currentPrefs['notifications']['twitter']['request_token'];
     $prefs['notifications']['twitter']['request_token_secret'] = $currentPrefs['notifications']['twitter']['request_token_secret'];
     # We willen geen megabytes aan custom CSS opslaan, dus controleer dat dit niet te groot is
     if (strlen($prefs['customcss'] > 1024 * 10)) {
         $errorList[] = array('validateuser_invalidpreference', array('customcss'));
     }
     # if
     # als men runcommand of save wil, moet er een local_dir opgegeven worden
     if ($prefs['nzbhandling']['action'] == 'save' || $prefs['nzbhandling']['action'] == 'runcommand') {
         if (empty($prefs['nzbhandling']['local_dir'])) {
             $errorList[] = array('validateuser_invalidpreference', array('local_dir'));
         }
         # if
     }
     # if
     # als men Growl wil gebruiken, moet er een host opgegeven worden
     if ($prefs['notifications']['growl']['enabled']) {
         if (empty($prefs['notifications']['growl']['host'])) {
             $errorList[] = array('validateuser_invalidpreference', array('growl host'));
         }
         # if
     }
     # if
     # als men Notifo wil gebruiken, moet er een username & apikey opgegeven worden
     if ($prefs['notifications']['notifo']['enabled']) {
         if (empty($prefs['notifications']['notifo']['username'])) {
             $errorList[] = array('validateuser_invalidpreference', array('notifo username'));
         }
         # if
         if (empty($prefs['notifications']['notifo']['api'])) {
             $errorList[] = array('validateuser_invalidpreference', array('notifo api'));
         }
         # if
     }
     # if
     # als men Prowl wil gebruiken, moet er een apikey opgegeven worden
     if ($prefs['notifications']['prowl']['enabled']) {
         if (empty($prefs['notifications']['prowl']['apikey'])) {
             $errorList[] = array('validateuser_invalidpreference', array('prowl apikey'));
         }
         # if
     }
     # if
     # als men Twitter wil gebruiken, moet er er een account zijn geverifieerd
     if ($prefs['notifications']['twitter']['enabled']) {
         if (empty($prefs['notifications']['twitter']['access_token']) || empty($prefs['notifications']['twitter']['access_token_secret'])) {
             $errorList[] = array('validateuser_invalidpreference', array('Er is geen account geverifi&euml;erd voor Twitter notificaties.'));
         }
         # if
     }
     # if
     return array($errorList, $prefs);
 }
예제 #4
0
 function updateUserPreferences()
 {
     $userList = $this->_db->listUsers("", 0, 9999999);
     # loop through every user and fix it
     foreach ($userList['list'] as $user) {
         # Omdat we vanuit listUsers() niet alle velden meekrijgen
         # vragen we opnieuw het user record op
         $user = $this->_db->getUser($user['userid']);
         # set the users' preferences
         $this->setSettingIfNot($user['prefs'], 'perpage', 25);
         $this->setSettingIfNot($user['prefs'], 'date_formatting', 'human');
         $this->setSettingIfNot($user['prefs'], 'template', 'we1rdo');
         $this->setSettingIfNot($user['prefs'], 'count_newspots', true);
         $this->setSettingIfNot($user['prefs'], 'keep_seenlist', true);
         $this->setSettingIfNot($user['prefs'], 'auto_markasread', true);
         $this->setSettingIfNot($user['prefs'], 'keep_downloadlist', true);
         $this->setSettingIfNot($user['prefs'], 'keep_watchlist', true);
         $this->setSettingIfNot($user['prefs'], 'nzb_search_engine', 'nzbindex');
         $this->setSettingIfNot($user['prefs'], 'show_filesize', true);
         $this->setSettingIfNot($user['prefs'], 'show_reportcount', true);
         $this->setSettingIfNot($user['prefs'], 'show_multinzb', true);
         $this->setSettingIfNot($user['prefs'], 'customcss', '');
         $this->setSettingIfNot($user['prefs'], 'newspotdefault_tag', $user['username']);
         $this->setSettingIfNot($user['prefs'], 'newspotdefault_body', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'action', 'disable');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'local_dir', '/tmp');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'prepare_action', 'merge');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'command', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'url', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'host', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'port', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'username', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'password', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'timeout', 15);
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'host', '');
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'password', '');
         $this->setSettingIfNot($user['prefs']['notifications']['nma'], 'api', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'username', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'api', '');
         $this->setSettingIfNot($user['prefs']['notifications']['prowl'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'screen_name', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token_secret', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token_secret', '');
         $notifProviders = Notifications_Factory::getActiveServices();
         foreach ($notifProviders as $notifProvider) {
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider], 'enabled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'watchlist_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'nzb_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'retriever_finished', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'spot_posted', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'user_added', false);
         }
         // foreach
         # make sure a sort preference is defined. An empty field means relevancy
         $this->setSettingIfNot($user['prefs'], 'defaultsortfield', '');
         # oude settings verwijderen
         $this->unsetSetting($user['prefs'], 'search_url');
         $this->unsetSetting($user['prefs']['notifications'], 'libnotify');
         # controleren dat de user een geldige RSA key heeft
         if ($user['userid'] > 2) {
             $rsaKey = $this->_db->getUserPrivateRsaKey($user['userid']);
             if (empty($rsaKey)) {
                 # Creer een private en public key paar voor deze user
                 $spotSigning = new SpotSigning();
                 $userKey = $spotSigning->createPrivateKey($this->_settings->get('openssl_cnf_path'));
                 $this->_db->setUserRsaKeys($user['userid'], $userKey['public'], $userKey['private']);
             }
             # if
         }
         # if
         # update the user record in the database
         $this->_db->setUser($user);
     }
     # foreach
 }
예제 #5
0
 function updateUserPreferences()
 {
     $userList = $this->_userDao->getUserList();
     # loop through every user and fix it
     foreach ($userList as $user) {
         /*
          * Because we do not get all users' properties from
          * getUserList, retrieve the users' settings from scratch
          */
         $user = $this->_userDao->getUser($user['userid']);
         # set the users' preferences
         $this->setSettingIfNot($user['prefs'], 'perpage', 25);
         $this->setSettingIfNot($user['prefs'], 'date_formatting', 'human');
         $this->setSettingIfNot($user['prefs'], 'normal_template', 'we1rdo');
         $this->setSettingIfNot($user['prefs'], 'mobile_template', 'mobile');
         $this->setSettingIfNot($user['prefs'], 'tablet_template', 'we1rdo');
         $this->setSettingIfNot($user['prefs'], 'count_newspots', true);
         $this->setSettingIfNot($user['prefs'], 'mouseover_subcats', true);
         $this->setSettingIfNot($user['prefs'], 'keep_seenlist', true);
         $this->setSettingIfNot($user['prefs'], 'auto_markasread', true);
         $this->setSettingIfNot($user['prefs'], 'keep_downloadlist', true);
         $this->setSettingIfNot($user['prefs'], 'keep_watchlist', true);
         $this->setSettingIfNot($user['prefs'], 'nzb_search_engine', 'nzbindex');
         $this->setSettingIfNot($user['prefs'], 'show_filesize', true);
         $this->setSettingIfNot($user['prefs'], 'show_reportcount', true);
         $this->setSettingIfNot($user['prefs'], 'minimum_reportcount', 1);
         $this->setSettingIfNot($user['prefs'], 'show_nzbbutton', true);
         $this->setSettingIfNot($user['prefs'], 'show_multinzb', true);
         $this->setSettingIfNot($user['prefs'], 'customcss', '');
         $this->setSettingIfNot($user['prefs'], 'newspotdefault_tag', $user['username']);
         $this->setSettingIfNot($user['prefs'], 'newspotdefault_body', '');
         $this->setSettingIfNot($user['prefs'], 'user_language', 'en_US');
         $this->setSettingIfNot($user['prefs'], 'show_avatars', true);
         $this->setSettingIfNot($user['prefs'], 'usemailaddress_for_gravatar', true);
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'action', 'disable');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'local_dir', '/tmp');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'prepare_action', 'merge');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'command', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'url', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'username', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'password', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'host', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'port', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'username', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'password', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'timeout', 15);
         $this->setSettingIfNot($user['prefs']['notifications']['boxcar'], 'email', '');
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'host', '');
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'password', '');
         $this->setSettingIfNot($user['prefs']['notifications']['nma'], 'api', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'username', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'api', '');
         $this->setSettingIfNot($user['prefs']['notifications']['prowl'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'screen_name', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token_secret', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token_secret', '');
         $notifProviders = Notifications_Factory::getActiveServices();
         foreach ($notifProviders as $notifProvider) {
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider], 'enabled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'watchlist_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'nzb_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'retriever_finished', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'report_posted', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'spot_posted', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'user_added', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'newspots_for_filter', false);
         }
         // foreach
         # make sure a sort preference is defined. An empty field means relevancy
         $this->setSettingIfNot($user['prefs'], 'defaultsortfield', '');
         # Remove deprecated preferences
         $this->unsetSetting($user['prefs'], 'search_url');
         $this->unsetSetting($user['prefs'], 'template');
         $this->unsetSetting($user['prefs']['notifications'], 'libnotify');
         # Make sure the user has a valid RSA key
         if ($user['userid'] > 2) {
             $rsaKey = $this->_userDao->getUserPrivateRsaKey($user['userid']);
             if (empty($rsaKey)) {
                 # Creer een private en public key paar voor deze user
                 $spotSigning = Services_Signing_Base::factory();
                 $userKey = $spotSigning->createPrivateKey($this->_settings->get('openssl_cnf_path'));
                 $this->_userDao->setUserRsaKeys($user['userid'], $userKey['public'], $userKey['private']);
             }
             # if
         }
         # if
         /*
          * In earlier versions, we always appended "sabnzbd/" to the URL, so we do this once
          * manually
          */
         if ($this->_settings->get('securityversion') < 0.31) {
             if (!empty($user['prefs']['nzbhandling']['sabnzbd']['url'])) {
                 $user['prefs']['nzbhandling']['sabnzbd']['url'] = $user['prefs']['nzbhandling']['sabnzbd']['url'] . 'sabnzbd/';
             }
             # if
         }
         # if
         # update the user record in the database
         $this->_userDao->setUser($user);
     }
     # foreach
 }
예제 #6
0
 function updateUserPreferences()
 {
     $userList = $this->_db->listUsers("", 0, 9999999);
     # loop through every user and fix it
     foreach ($userList['list'] as $user) {
         # Omdat we vanuit listUsers() niet alle velden meekrijgen
         # vragen we opnieuw het user record op
         $user = $this->_db->getUser($user['userid']);
         # set the users' preferences
         $this->setSettingIfNot($user['prefs'], 'perpage', 25);
         $this->setSettingIfNot($user['prefs'], 'date_formatting', 'human');
         $this->setSettingIfNot($user['prefs'], 'template', 'we1rdo');
         $this->setSettingIfNot($user['prefs'], 'count_newspots', true);
         $this->setSettingIfNot($user['prefs'], 'keep_seenlist', true);
         $this->setSettingIfNot($user['prefs'], 'auto_markasread', true);
         $this->setSettingIfNot($user['prefs'], 'keep_downloadlist', true);
         $this->setSettingIfNot($user['prefs'], 'keep_watchlist', true);
         $this->setSettingIfNot($user['prefs'], 'nzb_search_engine', 'nzbindex');
         $this->setSettingIfNot($user['prefs'], 'show_filesize', true);
         $this->setSettingIfNot($user['prefs'], 'show_multinzb', true);
         $this->setSettingIfNot($user['prefs'], 'customcss', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'action', 'disable');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'local_dir', '/tmp');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'prepare_action', 'merge');
         $this->setSettingIfNot($user['prefs']['nzbhandling'], 'command', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'url', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['sabnzbd'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'host', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'port', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'username', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'password', '');
         $this->setSettingIfNot($user['prefs']['nzbhandling']['nzbget'], 'timeout', 15);
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'host', '');
         $this->setSettingIfNot($user['prefs']['notifications']['growl'], 'password', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'username', '');
         $this->setSettingIfNot($user['prefs']['notifications']['notifo'], 'api', '');
         $this->setSettingIfNot($user['prefs']['notifications']['prowl'], 'apikey', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'screen_name', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'request_token_secret', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token', '');
         $this->setSettingIfNot($user['prefs']['notifications']['twitter'], 'access_token_secret', '');
         $notifProviders = Notifications_Factory::getActiveServices();
         foreach ($notifProviders as $notifProvider) {
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider], 'enabled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'watchlist_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'nzb_handled', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'retriever_finished', false);
             $this->setSettingIfNot($user['prefs']['notifications'][$notifProvider]['events'], 'user_added', false);
         }
         // foreach
         # oude settings verwijderen
         $this->unsetSetting($user['prefs'], 'search_url');
         $this->unsetSetting($user['prefs']['notifications'], 'libnotify');
         # update the user record in the database
         $this->_db->setUser($user);
     }
     # foreach
 }
예제 #7
0
 function cleanseUserPreferences($prefs, $anonSkel, $tmplSkel)
 {
     /*
      * We do not want any user preferences to be submitted which aren't in the anonuser preferences,
      * as this would allow garbage preferences or invalid settings for non-existing preferences.
      *
      * A simple recursive merge with the anonuser preferences is not possible because some browsers
      * just don't submit the values of a checkbox when the checkbox is deselected, in that case the
      * anonuser's settings would be set instead of the false setting as it should be.
      *
      * We solve this by simply setting the values of all the checkboxes and then performing
      * a recursive merge
      */
     $anonSkel['count_newspots'] = isset($prefs['count_newspots']) ? true : false;
     $anonSkel['mouseover_subcats'] = isset($prefs['mouseover_subcats']) ? true : false;
     $anonSkel['keep_seenlist'] = isset($prefs['keep_seenlist']) ? true : false;
     $anonSkel['auto_markasread'] = isset($prefs['auto_markasread']) ? true : false;
     $anonSkel['keep_downloadlist'] = isset($prefs['keep_downloadlist']) ? true : false;
     $anonSkel['keep_watchlist'] = isset($prefs['keep_watchlist']) ? true : false;
     $anonSkel['show_filesize'] = isset($prefs['show_filesize']) ? true : false;
     $anonSkel['show_reportcount'] = isset($prefs['show_reportcount']) ? true : false;
     $anonSkel['show_nzbbutton'] = isset($prefs['show_nzbbutton']) ? true : false;
     $anonSkel['show_multinzb'] = isset($prefs['show_multinzb']) ? true : false;
     $anonSkel['show_avatars'] = isset($prefs['show_avatars']) ? true : false;
     $notifProviders = Notifications_Factory::getActiveServices();
     foreach ($notifProviders as $notifProvider) {
         $anonSkel['notifications'][$notifProvider]['enabled'] = isset($prefs['notifications'][$notifProvider]['enabled']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['watchlist_handled'] = isset($prefs['notifications'][$notifProvider]['events']['watchlist_handled']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['nzb_handled'] = isset($prefs['notifications'][$notifProvider]['events']['nzb_handled']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['retriever_finished'] = isset($prefs['notifications'][$notifProvider]['events']['retriever_finished']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['report_posted'] = isset($prefs['notifications'][$notifProvider]['events']['report_posted']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['spot_posted'] = isset($prefs['notifications'][$notifProvider]['events']['spot_posted']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['user_added'] = isset($prefs['notifications'][$notifProvider]['events']['user_added']) ? true : false;
         $anonSkel['notifications'][$notifProvider]['events']['newspots_for_filter'] = isset($prefs['notifications'][$notifProvider]['events']['newspots_for_filter']) ? true : false;
     }
     # foreach
     # When nzbhandling settings are not entered at all, we default to disable
     if (!isset($prefs['nzbhandling'])) {
         $anonSkel['nzbhandling'] = array('action' => 'disable', 'prepare_action' => 'merge');
     }
     # if
     /*
      * We add the users' template specific settings to the basic
      * skeleton of settings so those settings aren't removed.
      */
     unset($anonSkel['template_specific']);
     $tmplSkel = array('template_specific' => $tmplSkel);
     $anonSkel = $this->array_merge_recursive_overwrite($tmplSkel, $anonSkel);
     /*
      * Unset any keys in the preferences which aren't available 
      * in the preferences template (anonyuser)
      */
     foreach (array_diff_key($prefs, $anonSkel) as $keys => $values) {
         unset($prefs[$keys]);
     }
     # foreach
     /* 
      * Of course array_merge_recursive doesn't do what one would
      * expect it to do and merge embedded arrays by combining them
      * instead of overwriting key values...
      */
     $prefs = $this->array_merge_recursive_overwrite($anonSkel, $prefs);
     return $prefs;
 }