Location: PHPKode > projects > SiteX > admin/photo_album_edit.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['EditorRightsAlbumsManage']))  loginError($sxLang['LoginRequired']);

if ($Submit)
{
	$query = "UPDATE $DB_Photos_Albums SET name='$name', description='$description', picture='$picture', private='$private' WHERE id='$editid'";
	$result = mysql_query($query, $Link) or queryError("38", mysql_error());
	
	$query = "DELETE FROM $DB_Photos_Albums_Private WHERE albumid='$editid'";
	$result = mysql_query($query, $Link) or queryError("38", mysql_error());
	
	if (($private) AND (count($user_types) > 0))
	{
		foreach ($user_types as $k => $v)
		{
			$query = "INSERT INTO $DB_Photos_Albums_Private (albumid, typeid) VALUES ('$editid', '$k')";
			$result = mysql_query($query, $Link) or queryError("38", mysql_error());
		}
	}
	
	if($sxPrevURL)
	{
		header("Location: ".urldecode($sxPrevURL));
		die();
	}
	else
	{
		header("Location: photo_albums.php?message=".urlencode($sxLang['MessagePhotoAlbumUpdated']));
		die();
	}
}

$query = "SELECT * FROM $DB_Photos_Albums WHERE id='$editid'";
$result = mysql_query($query, $Link) or queryError("27", mysql_error());
$ROW = mysql_fetch_object($result);

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
  <div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['PhotoAlbumHeadingEdit']; ?></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['PhotoAlbumHeadingEdit']; ?></div>   
   <?PHP echoMessage($message); ?>
	<table border="0" cellspacing="3" cellpadding="5">
	  <form name="sxFormPhotoAlbumEdit" action="<?PHP print $PHP_SELF; ?>" method="post" enctype="multipart/form-data">
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemName']; ?></td>
		  <td><input name="name" type="text" id="name" value="<?PHP echo htmlspecialchars($ROW->name); ?>" /></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['PhotoAlbumItemPhoto']; ?></td>
		  <td><select name="picture">
		  <option value="" selected><?PHP echo $sxLang['OptionNoneSelected']; ?></option>
			<?PHP
			$query2 = "SELECT * FROM $DB_Photos, $DB_Photos_Assoc
					   WHERE $DB_Photos.id=$DB_Photos_Assoc.photoid AND
							 $DB_Photos_Assoc.albumid='$editid'";
			$result2 = mysql_query($query2, $Link) or queryError("27", mysql_error());
			while($ROW2 = mysql_fetch_object($result2)){
				if($ROW2->filename == $ROW->picture) $selected = " selected";
				else $selected = "";
				echo '<option value="' . $ROW2->filename . '"' . $selected . '>' . $ROW2->name . '</option>';
			}
			?>
			</select></td>
		</tr>
		<tr> 
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemDescription']; ?></td>
		  <td><textarea name="description" id="description" style="width:300px;height:100px;"><?PHP echo $ROW->description; ?></textarea></td>
		</tr>
		<tr>
		  <td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPrivate']; ?></td>
		  <td>
		<?PHP
		$checked = "";
		$query3 = "SELECT * FROM $DB_Photos_Albums_Private WHERE albumid='$ROW->id'";
		$result3 = mysql_query($query3, $Link) or queryError("38", mysql_error());
		if(mysql_num_rows($result3)) $checked = " checked";
		?>
		<input type="checkbox" name="private" value="1"<?PHP echo $checked; ?> /> <?PHP echo $sxLang['GeneralMakePrivate']; ?><hr size="1" noshade="noshade" /><?PHP
		$query2 = "SELECT * FROM $DB_Users_Types";
		$result2 = mysql_query($query2, $Link) or queryError("38", mysql_error());
		while($ROW2 = mysql_fetch_object($result2)){
			
			$checked = "";
			$query3 = "SELECT * FROM $DB_Photos_Albums_Private WHERE albumid='$ROW->id'";
			$result3 = mysql_query($query3, $Link) or queryError("38", mysql_error());
			while($ROW3 = mysql_fetch_object($result3)){
				if($ROW3->typeid == $ROW2->id) $checked = " checked";
			}
			
			echo '<input name="user_types[' . $ROW2->id . ']" type="checkbox" id="user_types" value="1"' . $checked;
			echo ' />' . $ROW2->name . '<br />';
		}
		?></td>
	  </tr>
		<tr> 
		  <td colspan="2" valign="top" align="right"> 
			<input type="hidden" name="editid" value="<?PHP echo $editid; ?>" />
		    <input type="hidden" name="sxPrevURL" value="<?PHP echo $sxPrevURL; ?>" />
			<input type="submit" name="Submit" value="<?PHP echo $sxLang['PhotoAlbumButtonEdit']; ?>" class="sxButton" /></td>
		</tr>
	  </form>
	</table>
  </div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX