Location: PHPKode > projects > NCD Toolkit > ncdtoolkit1.2/ncd/variables.inc.php
<?php
	require_once ("authentification.inc.php");
	require_once ("language.inc.php");
	$currentdate = date("Y-m-d");
	
	// Specific variables that should not be erased
	if (isset($_REQUEST["step"]))
		$step = $_REQUEST["step"];
	else
		$step = "";
	
	if (isset($_REQUEST["summary"]))
		$summary = $_REQUEST["summary"];
	else
		$summary = "";
		
	// Process variables
	$institution_variables = array ("acronym", "subunit_uk", "name_uk", "abstract_uk",
					"postalstreet", "postaladdressext", "postalpostbox", "postalzip", "postallocality", "postalregion", "country_id",
					"visitorstreet", "visitoraddressext", "visitorzip", "visitortown", "visitorregion",
					"telephone", "fax", "email", "logourl", "websiteurl",
					"organisationid", "parentid", "organisation_access_rights", "organisation_usage_restrictions", "organisation_rights");
	if ($second_language != "")
		array_push($institution_variables, "subunit_nl", "name_nl", "abstract_nl");
	foreach ($institution_variables as $variable)
	{
		if (isset($_REQUEST[$variable]))
		{
			$$variable = trim(str_replace("\"", "&quot;", $_REQUEST[$variable]));
			if (get_magic_quotes_gpc())
				$$variable = stripslashes($$variable);
			$_SESSION[$variable] = $$variable;
		}
		else if (isset($_SESSION[$variable]))
			$$variable = $_SESSION[$variable];
		else
			$$variable = "";
	}
	
	$person_variables = array ("personid",
						"prefix", "suffix", "givenname", "additionalnames", "familyname", "title", "role_uk",
						"personstreet", "personaddressext", "personpostbox", "personzip", "persontown", "personregion", "country_id", 
						"persontelephone", "personfax", "personemail", "personwebsiteurl", "privatecollector");
	if ($second_language != "")
		array_push($person_variables, "role_nl");
	foreach ($person_variables as $variable)
	{
		if (isset($_REQUEST[$variable]))
		{
			$$variable = trim(str_replace("\"", "&quot;", $_REQUEST[$variable]));
			if (get_magic_quotes_gpc())
				$$variable = stripslashes($$variable);
			$_SESSION[$variable] = $$variable;
		}
		else if (isset($_SESSION[$variable]))
			$$variable = $_SESSION[$variable];
		else
			$$variable = "";
	}
	
	$collection_variables = array ("collectionname_uk", "collection_alt_name_uk", "collectionabstract_uk", "collection_spec_abstract_uk", "primary_grouping_principle_id", "primary_purpose_id", "notes_uk", "conservationstatus_uk", "collection_access_rights", "collection_rights", "collection_usage_restrictions", "includetypes", "cite_uk", "provenance_uk", "collection_parentid", "development_status_id", "conservation_status_date", "conservation_status_year", "conservation_status_month", "conservation_status_day", "related_collections");
	if ($second_language != "")
		array_push($collection_variables, "collectionname_nl", "collection_alt_name_nl", "collectionabstract_nl", "collection_spec_abstract_nl", "cite_nl", "notes_nl", "provenance_nl");
	foreach ($collection_variables as $variable)
	{
		if (isset($_REQUEST[$variable]))
		{
			$$variable = trim(str_replace("\"", "&quot;", $_REQUEST[$variable]));
			if (get_magic_quotes_gpc())
				$$variable = stripslashes($$variable);
			$_SESSION[$variable] = $$variable;
		}
		else if (isset($_SESSION[$variable]))
			$$variable = $_SESSION[$variable];
		else
			$$variable = "";
	}
	
	$multi_value_variables = array ("selected_classes" => "selected_class",
									"selected_collection_types" => "selected_collection_type",
									"selected_conservation_statuses" => "selected_conservation_status",
									"selected_expeditions" => "selected_expedition",
									"selected_formation_periods" => "selected_formation_period",
									"selected_collectors" => "selected_collector",
									"selected_kingdoms" => "selected_kingdom",
									"selected_taxa" => "selected_taxon",
									"selected_common_names" => "selected_common_name",
									"selected_geo_coverages" => "selected_geo_coverage",
									"selected_time_periods" => "selected_time_period",
									"selected_preservation_methods" => "selected_preservation_method",
									"selected_media" => "selected_medium",
									"selected_formats" => "selected_format",
									"selected_items" => "selected_item",
									"selected_relations" => "selected_relation",
									"selected_curators" => "selected_curator");
	foreach ($multi_value_variables as $this_array => $this_value)
	{
		if (isset($_POST[$this_value]))
		{
			$action = $_POST["action"];
			$$this_value = trim($_POST[$this_value]);
			if (get_magic_quotes_gpc())
				$$this_value = stripslashes($$this_value);
			if (isset($_POST["selected_language_id"]))
			{
				$selected_language_id = $_POST["selected_language_id"];
				if (get_magic_quotes_gpc())
					$selected_language_id = stripslashes($selected_language_id);
				$$this_value = $selected_language_id."@@@".$$this_value;
			}
			else
				$selected_language_id = "";

			if (isset($_POST["strength"]))
			{
				$strength = $_POST["strength"];
				$$this_value = $$this_value."@@@".$_POST["strength"];
			}
			else
				$strength = "";

			if ($action == "add")
			{
				if (isset($_SESSION[$this_array]) && $_SESSION[$this_array] != "")
					$$this_array = array_unique($_SESSION[$this_array]);
				else
					$$this_array = array();
				if ($$this_value != "" && 
					$$this_value != $selected_language_id."@@@" && 
					$$this_value != $selected_language_id."@@@@@@".$strength && 
					$$this_value != "@@@".$strength && 
					!in_array($$this_value, $$this_array))
					array_push($$this_array, $$this_value);
			}
			else if ($action == "remove")
			{
				$remove_array = $_SESSION[$this_array];
				unset($remove_array[$$this_value]);
				$$this_array = $remove_array;
 			}
			$_SESSION[$this_array] = $$this_array;
		}
		else if (isset($_SESSION[$this_array]))
			$$this_array = $_SESSION[$this_array];
		else
			$$this_array = array();
	}
?>
Return current item: NCD Toolkit