Location: PHPKode > projects > SiteX > admin/photo_album_add.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");

if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsAlbumsAdd']))  loginError($sxLang['LoginRequired']);

// Add new album
if($Submit)
{
	// Increment old album positions
	$position = 1;
	$query = "SELECT * FROM $DB_Photos_Albums ORDER BY position ASC";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		$position = $position + 1;
		$query2 = "UPDATE $DB_Photos_Albums SET position='$position' WHERE id='$ROW->id'";
		$result2 = mysql_query($query2, $Link) or queryError("38", mysql_error());
	}
	
	// Create new album at first position
	$query = "INSERT INTO $DB_Photos_Albums (name, description, timestamp, private, position) VALUES ('$name', '$description', '$NOW', '$private', '1')";
	$result = mysql_query($query, $Link) or queryError("38", mysql_error());
	
	$query = "SELECT * FROM $DB_Photos_Albums WHERE name='$name' AND timestamp='$NOW'";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	// Create perms
	if($private)
	{
		foreach ($user_types as $k => $v)
		{
			$query = "INSERT INTO $DB_Photos_Albums_Private (albumid, typeid) VALUES ('$ROW->id', '$k')";
			$result = mysql_query($query, $Link) or queryError("22", mysql_error());
		}
	}
	
	// Redirect
	header("Location: photo_albums.php?message=".str_replace(" ","_",$sxLang['MessagePhotoAlbumAdded']));
	die();
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
  <div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['PhotoAlbumHeadingAdd']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <a href="photo_albums.php"><?PHP echo $sxLang['PhotoAlbumHeadingManager']; ?></a> > <?PHP echo $sxLang['PhotoAlbumHeadingAdd']; ?></div>   
   <?PHP echoMessage($message); ?>
   <form name="sxFormPhotoAlbumAdd" action="<?PHP print $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
	<table border="0" cellspacing="3" cellpadding="5">
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemName']; ?></td>
		  <td><input name="name" type="text" id="name" /></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemDescription']; ?></td>
		  <td><textarea name="description" id="description" style="width:300px;height:100px;"></textarea></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPrivate']; ?></td>
		  <td><input type="checkbox" name="private" value="1" /> <?PHP echo $sxLang['GeneralMakePrivate']; ?><hr size="1" noshade="noshade" />
		  <?PHP
			$query = "SELECT * FROM $DB_Users_Types";
			$result = mysql_query($query, $Link) or queryError("22", mysql_error());
			while($ROW = mysql_fetch_object($result)){
				echo '<input name="user_types[' . $ROW->id . ']" type="checkbox" id="user_types" value="1"';
				//if($ROW->id == 1) echo ' onclick="document.form1.user_types.checked=true"';
				echo ' />' . $ROW->name . '<br />';
			}
			?></td>
		</tr>
		<tr> 
		  <td colspan="2" valign="top" align="right"><input type="submit" name="Submit" value="<?PHP echo $sxLang['PhotoAlbumButtonAdd']; ?>" class="sxButton" /></td>
		</tr>
	</table></form>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX