Location: PHPKode > projects > Kwalbum > kwalbum/include/funcChangeDescription.php
<?php
// 2.0
function ChangeDescription($id, $newDescription, $echo = true)
{
	global $DB, $P, $errorMsg;

	$query = 'SELECT ItemId, ItemUserIdFk FROM ' . ITEM_TABLE .
	" WHERE ItemId='$id'" .
	" LIMIT 1";
	$result = $DB->Query($query);
	if (0 == $result->num_rows)
	{
		if (TEST_MODE)
			echo '<p class="error">Item ID ('.$id.') was not found in the DB.</p>';
		else if ($echo)
			echo $errorMsg;
		return;
	}
	$row = $result->fetch_array();
	if (!USER_CAN_ADD or (USER_ID != $row[1] and !USER_IS_ADMIN))
	{
		if (TEST_MODE)
			echo '<p class="error">Invalid Permissions</p>';
		else if ($echo)
			echo $errorMsg;
		return;
	}

	$DB->UpdateSingle(ITEM_TABLE, 'ItemDescription', "'$newDescription', ItemUpdateDt=NOW()", "ItemId='$id'");

	if ($echo)
		echo stripslashes($newDescription);
}
?>
Return current item: Kwalbum