Location: PHPKode > projects > MyNotebook > mynotebook/notes.dispatcher.php
<?php
function CheckPermissions ()
{
	if (!is_writable("useruploads/images/_thumbs"))
	{
		echo "<div style=\"font-weight: bold;\">";
		echo "Warning: It seems like the \"directory\" useruploads is not writable<br>";
		echo "Please ensure that \"useruploads\" and all it's subfolders are writeable or image upload won't work.";
		echo "</div>";
	}
}

// Whatever is set in $action this function decides what to do next and calls the necessary function
function dispatch ()
{
	global $action;
	global $pwd;
	global $note;
	global $tags;
	global $id;
	global $module;

	switch ($action)
	{
	case "Logout":
		logout();
		break;
		
	case "Login":
		if (isset ($pwd))
		{
			if (isLoggedIn ())
			{
				displayNotes ();
			}
			else
			{
				login ();
			}
		}
		break;
		
	case "Edit":
		if (isset ($note))
		{
			editNote ();
		}
		if ($module == "Tags")
		{
			$oldTag = $_REQUEST["OldTag"];
			$newTag = $_REQUEST["NewTag"];
			if (isset ($oldTag) && isset ($newTag))
			RenameTag ($oldTag, $newTag);
		}
		break;

	case "NewNote":
		
		if (isset ($note) && isset ($id))
		{
			createNote ();
		}
		break;

	case "View":
		if (isset ($tags))
		{
			echo getNotesJSON ();
		}
		break;

	case "Delete":
		if (isset ($id))
		{
			deleteNote ();
		}
		if ($module == "Tags")
		{
			$tag = $_REQUEST["Tag"];
			if (isset ($tag))
			DeleteTag ($tag);
		}
		break;

	default:
		if (isLoggedIn ())
		{
			displayNotes ();
		}
		else
		{
			showLoginForm ();
			CheckPermissions();
			exit;
		}
		break;
	}
}
?>
Return current item: MyNotebook