<?

/*
FlexCMS (http://www.flexcms.com)
Flexible, Powerful, Affordable.

Contents of this file are protected by the copyright
notice found at http://www.flexcms.com/flex/pages/copyright.html,
and its usage is subject to the terms of the licensing agreement 
available at http://www.flexcms.com/flex/pages/license.html
*/



	// ========================================================================================
	// Save Notification Preferences
	// ========================================================================================

	$PageTitle = $MsgText[2][11];
	$BrowserTitle = $MsgText[2][11];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="'.$MainURL.'/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[2][11];
	
	
	if ($LoggedIn == 'y') {
	
	
		ReadFormArguments();
		Global $FormArguments;
			
		if (count($FormArguments) > 0) {
			
			
			$query = "select * from `".$Settings['DBPrefix']."core-Users` where Username='".$CookieUsername."' limit 1";
		   	$result = mysql_query($query) or die (mysql_error());
			$row = mysql_fetch_array($result);
			
			
			$BoardsWorkingString = substr($row['NotifyBoards'],1,strlen($row['NotifyBoards'])-2);
			$ThreadsWorkingString = substr($row['NotifyThreads'],1,strlen($row['NotifyThreads'])-2);
				
						
			
			$NotifyBoardsArray = explode('-',$BoardsWorkingString);
					
			for ($i = 0; $i < count($NotifyBoardsArray); $i++) {
			
				if (intval($NotifyBoardsArray[$i]) > 0) {
				
					if ($FormArguments['b-'.intval($NotifyBoardsArray[$i])] == 'yes') {
						$NotifyBoardsString .= '-'.intval($NotifyBoardsArray[$i]);
					}
					
				}
			}
							
			if ($NotifyBoardsString != '') {
				$NotifyBoardsString .= '-';
			}
			
			
			
			
			
			$NotifyThreadsArray = explode('-',$ThreadsWorkingString);
					
			for ($i = 0; $i < count($NotifyThreadsArray); $i++) {
			
				if (intval($NotifyThreadsArray[$i]) > 0) {
				
					if ($FormArguments['t-'.intval($NotifyThreadsArray[$i])] == 'yes') {
						$NotifyThreadsString .= '-'.intval($NotifyThreadsArray[$i]);
					}
					
				}
			}
							
			if ($NotifyThreadsString != '') {
				$NotifyThreadsString .= '-';
			}
			
			
			
			if ($FormArguments['MonitorAllMessages'] == 'yes') {
				$MonitorAllMessages = 'y';
			}
			
				
			
			
			$query = "update `".$Settings['DBPrefix']."core-Users` set NotifyThreads='".$NotifyThreadsString."', NotifyBoards='".$NotifyBoardsString."', NotifyAllBoards='".$MonitorAllMessages."' where Username='".$CookieUsername."' limit 1";
			$result = mysql_query($query) or die (mysql_error());
				
					
				
			header('Location: ' . $MainURL . '/notifications.html');
			
			
			
			
		}
		else {
		
			$PageContents = $MsgText[0][98];
		
		}	
	}
	else {
	
		RedirectToLogin();
		
	}				

	

	// ========================================================================================




?>
