Location: PHPKode > projects > Kwalbum > kwalbum/ajax/editLocationValue.php
<?php
/* 2.0.3: 2008-10-03
 * 2.0 created: 2008-09-04
 */
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/DBConnection.php';
$DB = new DBConnection();
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/verifyLogin.php';
require_once pathinfo(__FILE__, PATHINFO_DIRNAME).'/../include/funcChangeLocation.php';
$errorMsg = '<span class="error">Change Not Saved!</span>';

$id = (int)$P['id'];
if (empty($P['loc']))
	$loc = '';
else
	$loc = trim($DB->FilterString($P['loc']));

if (USER_IS_ADMIN and 0 < $id)
{
	if (!empty($loc))
	{
		$row = $DB->Query('SELECT LocationId FROM '.LOCATION_TABLE.
			" WHERE Location='unknown location'")->fetch_array();
		$unknownId = $row[0];
		if ($id == $unknownId)
			$loc = 'unknown location';
		elseif ('-----' != $loc)
		{
			$DB->UpdateSingle(LOCATION_TABLE, 'Location',
				"'$loc'", "LocationId='$id'");
		}
		else
		{
			$result = $DB->Query('SELECT ItemId FROM '.ITEM_TABLE.
			" WHERE ItemLocationIdFk='$id'");
			if (0 < $result->num_rows)
			{
				while ($row = $result->fetch_array())
					ChangeLocation($row[0], null, false);
			}
			$DB->Delete(LOCATION_TABLE, "LocationId='$id'");
			echo '';
			exit();
		}
	}
	else
	{
		$row = $DB->Query('SELECT Location FROM '.LOCATION_TABLE.
			' WHERE LocationId='.$id)->fetch_array();
		$loc = $row[0];
	}
	echo $loc;
}
else
	if (TEST_MODE)
		echo '<span class="error">Invalid Permissions.</span>';
	else
		echo $errorMsg;

Return current item: Kwalbum