<?

/*
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
*/



	// ========================================================================================
	// photo galleries administration
	// ========================================================================================
	
	$PageTitle = '<img src="'.$ImagesURL.'/admin/admincp_photo.gif" width="28" height="22"> '.$MsgText[3][3];
	$BrowserTitle = $MsgText[3][3];
	$LocationBar = '<a href="'.$IndexURL.'">'.$MsgText[0][1].'</a> > <a href="' . $MainURL . '/options.html">'.$MsgText[0][4].'</a> > '.$MsgText[3][3];
	
	if ($LoggedIn == 'y') {
		
		ReadPermissions();
		Global $Permissions;
		
		if ($Permissions[301] == 'y') {
		
			$query = "select Level,Description from `".$Settings['DBPrefix']."core-Permissions` where Level<=".$UserLevel;
	   		$result = mysql_query($query) or die (mysql_error());
			while ($row = mysql_fetch_array($result)) {
				$LevelDescriptions[$row['Level']] = $row['Description'];
			}
		
			$PermissionsDropdown = '<option value="0" selected> 0 - '.$MsgText[0][162].'</option>';
			for ($i = 1; $i <= $UserLevel; $i++) {
				if ($LevelDescriptions[$i] != '') {
					$PermissionsDropdown .= '<option value="'.$i.'"> '.$i.' - '.$LevelDescriptions[$i].'</option>';
				}
				else {
					$PermissionsDropdown .= '<option value="'.$i.'"> '.$i.'</option>';
				}
			}
			
	
	
		$query = "select * from `".$Settings['DBPrefix']."pg-Galleries` where MinLevel<='".$UserLevel."' and MinEditLevel<='".$UserLevel."' ORDER BY Priority ASC, GalleryTitle ASC, RecordNumber ASC";
		$result = mysql_query($query) or die (mysql_error());
		
		if (mysql_num_rows($result) > 0) {
			
			$PageContents = '<br><a href="'.$MainURL.'/admin/photos.html"><b>'.$MsgText[3][2].'</b></a><br><br><a href="#new">'.$MsgText[3][29].'</a><br><br><br><b>'.$MsgText[3][30].':</b><br><table width="95%" border="0" cellpadding="3" cellspacing="0"><tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][31].'</b></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][13].'</b></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][46].'</b></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][199].'</b></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][33].'</b></td></tr>';
		
			while ($row = mysql_fetch_array($result)) { 
				
				//$query2 = "select sum(FileSize) as TotalSize from `".$Settings['DBPrefix']."pg-Images` where GalleryNumber=".$row['RecordNumber'];
				//$result2 = mysql_query($query2) or die (mysql_error());
				//$row2 = mysql_fetch_array($result2);
			
        
				$PageContents .= '<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/photos/'.$row['RecordNumber'].'.html" target="_blank">'.$row['GalleryTitle'].'</a></td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['GalleryImages'].'</td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['MinLevel'].'</td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'">'.$row['Priority'].'</td><td align="center"><font face="'.$FontFace.'" size="'.$FontSize.'"><a href="'.$MainURL.'/admin/photos_gallery_edit/'.$row['RecordNumber'].'">'.$MsgText[0][155].'</a> / <a href="'.$MainURL.'/admin/photos_gallery_delete/'.$row['RecordNumber'].'">'.$MsgText[0][156].'</a></td></tr>';
							
			}
			
			$PageContents .= '</table>';
		}
		else {
			$PageContents = '<br><br>['.$MsgText[3][34].']';
		}
		
		
		$PageContents .= '<br><br><br><br><a name="new"></a><b>'.$MsgText[3][29].':</b><br><br><form action="'.$MainURL.'/admin/photos_new_gallery" method="post">

<table width="500" border="0" cellpadding="3" cellspacing="3">

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][35].':</b></td><td><input type="text" name="Title" size="30" maxlength="255" value=""></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][36].':</b></td><td><textarea name="Description" cols="40" rows="3"></textarea><br><font face="'.$FontFace.'" size="'.($FontSize-1).'">'.$MsgText[3][37].'</td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][38].':</b></td><td>
<select name="Format"><option value="1"> '.$MsgText[3][39].'</option><option value="2"> '.$MsgText[3][40].'</option><option value="3"> '.$MsgText[3][41].'</option><option value="4"> '.$MsgText[3][42].'</option><option value="5"> '.$MsgText[3][43].'</option><option value="6"> '.$MsgText[3][44].'</option><option value="7"> '.$MsgText[3][45].'</option></select></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[3][46].':</b></td><td><select name="MinLevel">'.$PermissionsDropdown.'</select><br><font face="'.$FontFace.'" size="'.($FontSize-1).'"></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][542].':</b></td><td><select name="MinEditLevel">'.$PermissionsDropdown.'</select><br><font face="'.$FontFace.'" size="'.($FontSize-1).'"></td></tr>

<tr><td><font face="'.$FontFace.'" size="'.$FontSize.'"><b>'.$MsgText[0][199].':</b></td><td><input type="text" name="Priority" size="3" value=""></td></tr>

</table><br><br><input name="SubmitButton" type="submit" value="'.$MsgText[3][47].'"></form>';
		
		
		}
		else {
		
			$PageContents = $MsgText[0][97];
		
		}

	}
	else {
	
		RedirectToLogin();
	
	}

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




?>
