Browse Source

Make current_user_id global

Yentl Van Tendeloo 8 years ago
parent
commit
1a31a79974
1 changed files with 122 additions and 120 deletions
  1. 122 120
      bootstrap/core_algorithm.alc

+ 122 - 120
bootstrap/core_algorithm.alc

@@ -17,6 +17,7 @@ include "typing.alh"
 String core_model_location = "models/core"
 
 Element core = ?
+String current_user_id
 Element caches
 
 Void function initialize_core():
@@ -278,7 +279,7 @@ String function get_group_id(name : String):
 	
 	return ""!
 
-String function export_typing(model : Element, name : String, user_id : String):
+String function export_typing(model : Element, name : String):
 	String result
 	result = instantiate_node(core, "TypeMapping", "")
 
@@ -291,14 +292,14 @@ String function export_typing(model : Element, name : String, user_id : String):
 	instantiate_attribute(core, result, "name", "TM_" + name)
 	instantiate_attribute(core, result, "location", location)
 	instantiate_attribute(core, result, "permissions", "200")
-	instantiate_link(core, "owner", "", result, user_id)
+	instantiate_link(core, "owner", "", result, current_user_id)
 	instantiate_link(core, "group", "", result, get_group_id("nobody"))
 	instance_of = instantiate_link(core, "instanceOf", "", result, get_model_id("TypeMapping"))
 	instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
 
 	return result!
 
-Void function model_create(model : Element, name : String, user_id : String, type_id : String, kind : String):
+Void function model_create(model : Element, name : String, type_id : String, kind : String):
 	String location
 	String model_id
 	String instance_of
@@ -311,13 +312,13 @@ Void function model_create(model : Element, name : String, user_id : String, typ
 	instantiate_attribute(core, model_id, "name", name)
 	instantiate_attribute(core, model_id, "location", location)
 	instantiate_attribute(core, model_id, "permissions", "200")
-	instantiate_link(core, "owner", "", model_id, user_id)
+	instantiate_link(core, "owner", "", model_id, current_user_id)
 	instantiate_link(core, "group", "", model_id, get_group_id("nobody"))
 	instance_of = instantiate_link(core, "instanceOf", "", model_id, type_id)
 	instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
 
 	// Create type mapping model
-	instantiate_link(core, "typing", "", instance_of, export_typing(model, name, user_id))
+	instantiate_link(core, "typing", "", instance_of, export_typing(model, name))
 
 	return!
 
@@ -345,7 +346,7 @@ Void function model_overwrite(model : Element, model_id : String, metamodel_id :
 	String instance_of
 	instance_of = instantiate_link(core, "instanceOf", "", model_id, metamodel_id)
 	instantiate_link(core, "semantics", "", instance_of, get_model_id("conformance_mv"))
-	instantiate_link(core, "typing", "", instance_of, export_typing(model, read_attribute(core, model_id, "name"), get_user_id("admin")))
+	instantiate_link(core, "typing", "", instance_of, export_typing(model, read_attribute(core, model_id, "name")))
 
 	return!
 
@@ -534,7 +535,7 @@ Element function execute_operation(operation_id : String, input_models : Element
 		log("Negative result of execution")
 		return read_root()!
 
-Boolean function enact_action(pm : Element, element : String, prefix : String, user_id : String):
+Boolean function enact_action(pm : Element, element : String, prefix : String):
 	Boolean result
 	String transformation_id
 	Element lst
@@ -600,12 +601,12 @@ Boolean function enact_action(pm : Element, element : String, prefix : String, u
 			key = set_pop(keys)
 			if (get_model_id(output_map[key]) == ""):
 				// New model
-				model_create(result[key], output_map[key], user_id, get_model_id(key), "Model")
+				model_create(result[key], output_map[key], get_model_id(key), "Model")
 			else:
 				model_overwrite(result[key], get_model_id(output_map[key]), get_model_id(outputs[key]))
 		return True!
 
-Void function enact_PM(pm : Element, prefix : String, user_id : String):
+Void function enact_PM(pm : Element, prefix : String):
 	Element worklist
 	String element
 	String start
@@ -669,7 +670,7 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 			// Execute a transformation
 			// This the difficult part!
 
-			result = enact_action(pm, element, prefix, user_id)
+			result = enact_action(pm, element, prefix)
 
 		elif (type == "Decision"):
 			// If the previous result is true, we add the normal one, otherwise the false one
@@ -695,7 +696,7 @@ Void function enact_PM(pm : Element, prefix : String, user_id : String):
 	output("Success")
 	return !
 
-String function cmd_help(user_id : String):
+String function cmd_help():
 	String result
 
 	result = ""
@@ -736,7 +737,7 @@ String function cmd_help(user_id : String):
 	result = result + ("    group_list                      -- List all groups you are a member of\n")
 	result = result + ("\n")
 
-	if (is_admin(user_id)):
+	if (is_admin(current_user_id)):
 		result = result + ("Admin operations\n")
 		result = result + ("    admin_promote                   -- Promote a user to admin status\n")
 		result = result + ("    admin_demote                    -- Demote a user to normal status\n")
@@ -748,7 +749,7 @@ String function cmd_help(user_id : String):
 
 	return result!
 
-String function cmd_model_add(user_id : String, type : String, name : String):
+String function cmd_model_add(type : String, name : String):
 	// Model addition operation, which uses model upload commands of the compiler
 	String location
 	String type_id
@@ -758,7 +759,7 @@ String function cmd_model_add(user_id : String, type : String, name : String):
 	type_id = get_model_id(type)
 	if (type_id != ""):
 		// Type exists
-		if (allow_read(user_id, type_id)):
+		if (allow_read(current_user_id, type_id)):
 			// And is readable
 			if (get_model_id(name) == ""):
 				// Model doesn't exist yet
@@ -769,7 +770,7 @@ String function cmd_model_add(user_id : String, type : String, name : String):
 
 				output("Waiting for model constructors...")
 				new_model = construct_model_raw(mm)
-				model_create(new_model, name, user_id, type_id, "Model")
+				model_create(new_model, name, type_id, "Model")
 				return "Success"!
 			else:
 				return "Model exists: " + name!
@@ -778,26 +779,26 @@ String function cmd_model_add(user_id : String, type : String, name : String):
 	else:
 		return "Model not found: " + type!
 
-String function cmd_process_execute(user_id : String, process : String, prefix : String):
+String function cmd_process_execute(process : String, prefix : String):
 	// Execute a process model until it reaches termination
 	String process_id
 
 	process_id = get_model_id(process)
 	if (process_id != ""):
-		if (allow_read(user_id, process_id)):
+		if (allow_read(current_user_id, process_id)):
 			Element pm
 			pm = get_full_model(process_id, get_model_id("ProcessModel"))
 			if (element_eq(pm, read_root())):
 				return "Specified model cannot be interpreted as a ProcessModel: " + process!
 
-			enact_PM(pm, prefix, user_id)
+			enact_PM(pm, prefix)
 			return "Success"!
 		else:
 			return "Permission denied to model: " + process!
 	else:
 		return "Model not found: " + process!
 
-String function cmd_transformation_between(user_id : String, source_name : String, target_name : String):
+String function cmd_transformation_between(source_name : String, target_name : String):
 	String source_id
 	String target_id
 	Element onSource
@@ -819,7 +820,7 @@ String function cmd_transformation_between(user_id : String, source_name : Strin
 			r = "Success: "
 			while (set_len(result) > 0):
 				transformation = set_pop(result)
-				if (allow_read(user_id, transformation)):
+				if (allow_read(current_user_id, transformation)):
 					r = r + string_join(read_attribute(core, transformation, "name"), "\n")
 			return r!
 		else:
@@ -827,7 +828,7 @@ String function cmd_transformation_between(user_id : String, source_name : Strin
 	else:
 		return "Model not found: " + source_name!
 
-String function cmd_model_render(user_id : String, model_name : String, mapper_name : String):
+String function cmd_model_render(model_name : String, mapper_name : String):
 	String model_ID
 	String mapper_ID
 	String rendered_name
@@ -845,9 +846,9 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 	if (model_ID != ""):
 		mapper_ID = get_model_id(mapper_name)
 
-		if (allow_read(user_id, model_ID)):
+		if (allow_read(current_user_id, model_ID)):
 			if (mapper_ID != ""):
-				if (allow_read(user_id, mapper_ID)):
+				if (allow_read(current_user_id, mapper_ID)):
 					// Everything is fine; start the actual operation
 					// Find metamodel to render to
 					rendered_name = (("__RENDERED_" + model_name) + "__") + mapper_name
@@ -873,11 +874,11 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 							return "Rendered metamodel cannot conform to SimpleClassDiagrams"!
 
 						rendered_model = instantiate_model(rendered)
-						model_create(rendered_model, rendered_name, user_id, get_model_id(output_map["rendered"]), "Model")
+						model_create(rendered_model, rendered_name, get_model_id(output_map["rendered"]), "Model")
 						
 						// Tracability model won't exist either
 						tracability_model = instantiate_model(get_full_model(get_model_id("Tracability"), get_model_id("SimpleClassDiagrams")))
-						model_create(tracability_model, tracability_name, user_id, get_model_id("Tracability"), "Model")
+						model_create(tracability_model, tracability_name, get_model_id("Tracability"), "Model")
 
 					else:
 						// Read out tracability model
@@ -909,7 +910,7 @@ String function cmd_model_render(user_id : String, model_name : String, mapper_n
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_transformation_execute(user_id : String, transformation_name : String, source_models : Element, target_models : Element):
+String function cmd_transformation_execute(transformation_name : String, source_models : Element, target_models : Element):
 	// Execute a transformation, whatever type it is
 	// First we detect the type, so we know how to prepare for invocation
 	String transformation_id
@@ -932,7 +933,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 
 	transformation_id = get_model_id(transformation_name)
 	if (transformation_id != ""):
-		if (allow_read(user_id, transformation_id)):
+		if (allow_read(current_user_id, transformation_id)):
 			if (is_nominal_instance(core, transformation_id, "Transformation")):
 				// Read out source and target links
 				inputs = dict_create()
@@ -948,7 +949,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 
 					source_model_ID = get_model_id(source_model_name)
 					if (source_model_ID != ""):
-						if (allow_read(user_id, source_model_ID)):
+						if (allow_read(current_user_id, source_model_ID)):
 							// Check for conformance to the requested metamodel
 							dict_add(inputs, assoc_name, source_model_name)
 							continue!
@@ -974,7 +975,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 						dict_add(outputs, assoc_name, target_model_name)
 					else:
 						// Already exists, so we need to check for write access
-						if (allow_write(user_id, get_model_id(target_model_name))):
+						if (allow_write(current_user_id, get_model_id(target_model_name))):
 							dict_add(output_map, assoc_name, read_attribute(core, readAssociationDestination(core, target), "name"))
 							dict_add(outputs, assoc_name, target_model_name)
 						else:
@@ -1000,7 +1001,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 						
 						if (get_model_id(outputs[key]) == ""):
 							// New model
-							model_create(result[key], outputs[key], user_id, get_model_id(key), "Model")
+							model_create(result[key], outputs[key], get_model_id(key), "Model")
 						else:
 							model_overwrite(result[key], get_model_id(outputs[key]), get_model_id(output_map[key]))
 
@@ -1012,7 +1013,7 @@ String function cmd_transformation_execute(user_id : String, transformation_name
 	else:
 		return "Model not found: " + transformation_name!
 
-String function cmd_verify(user_id : String, model_name : String, metamodel_name : String):
+String function cmd_verify(model_name : String, metamodel_name : String):
 	// Check whether a model conforms to its specification (with the selected type mapping)
 	String model_id
 	String result
@@ -1020,7 +1021,7 @@ String function cmd_verify(user_id : String, model_name : String, metamodel_name
 
 	model_id = get_model_id(model_name)
 	if (model_id != ""):
-		if (allow_read(user_id, model_id)):
+		if (allow_read(current_user_id, model_id)):
 			Element m
 			m = get_full_model(get_model_id(model_name), get_model_id(metamodel_name))
 			if (element_eq(m, read_root())):
@@ -1032,7 +1033,7 @@ String function cmd_verify(user_id : String, model_name : String, metamodel_name
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_model_overwrite(user_id : String, model_name : String, metamodel_name : String):
+String function cmd_model_overwrite(model_name : String, metamodel_name : String):
 	// Overwrites an existing model without changing any metadata
 	String model_id
 	String type_id
@@ -1040,9 +1041,9 @@ String function cmd_model_overwrite(user_id : String, model_name : String, metam
 
 	model_id = get_model_id(model_name)
 	if (model_id != ""):
-		if (allow_write(user_id, model_id)):
+		if (allow_write(current_user_id, model_id)):
 			type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
-			if (allow_read(user_id, type_id)):
+			if (allow_read(current_user_id, type_id)):
 				Element mm
 				mm = get_full_model(get_model_id(metamodel_name), get_model_id("SimpleClassDiagrams"))
 				if (element_eq(mm, read_root())):
@@ -1059,7 +1060,7 @@ String function cmd_model_overwrite(user_id : String, model_name : String, metam
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_model_modify(user_id : String, model_name : String, metamodel_name : String):
+String function cmd_model_modify(model_name : String, metamodel_name : String):
 	// Model modify operation, which uses the mini_modify.alc operations, though with extensions for access control
 	String model_id
 	String type_id
@@ -1067,16 +1068,16 @@ String function cmd_model_modify(user_id : String, model_name : String, metamode
 	model_id = get_model_id(model_name)
 
 	if (model_id != ""):
-		if (allow_read(user_id, model_id)):
+		if (allow_read(current_user_id, model_id)):
 			type_id = set_pop(allAssociationDestinations(core, model_id, "instanceOf"))
-			if (allow_read(user_id, type_id)):
+			if (allow_read(current_user_id, type_id)):
 				Element new_model
 				new_model = get_full_model(model_id, get_model_id(metamodel_name))
 				if (element_eq(new_model, read_root())):
 					return "No conformance relation can be found between these models"!
 				output("Success")
-				modify(new_model, allow_write(user_id, model_id))
-				if (allow_write(user_id, model_id)):
+				modify(new_model, allow_write(current_user_id, model_id))
+				if (allow_write(current_user_id, model_id)):
 					// Overwrite the modified model
 					model_overwrite(new_model, model_id, metamodel_name)
 				return "Success"!
@@ -1087,12 +1088,12 @@ String function cmd_model_modify(user_id : String, model_name : String, metamode
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_model_delete(user_id : String, model_name : String):
+String function cmd_model_delete(model_name : String):
 	String model_id
 	model_id = get_model_id(model_name)
 
 	if (model_id != ""):
-		if (allow_write(user_id, model_id)):
+		if (allow_write(current_user_id, model_id)):
 			model_delete_element(core, model_id)
 			return "Success"!
 		else:
@@ -1145,13 +1146,13 @@ String function cmd_model_list_full():
 
 	return result!
 
-String function cmd_transformation_add_MANUAL(user_id : String, source_models : Element, target_models : Element, operation_name : String):
-	return transformation_add(user_id, source_models, target_models, operation_name, "manual")!
+String function cmd_transformation_add_MANUAL(source_models : Element, target_models : Element, operation_name : String):
+	return transformation_add(source_models, target_models, operation_name, "manual")!
 
-String function cmd_transformation_add_AL(user_id : String, source_models : Element, target_models : Element, operation_name : String):
-	return transformation_add(user_id, source_models, target_models, operation_name, "actionlanguage")!
+String function cmd_transformation_add_AL(source_models : Element, target_models : Element, operation_name : String):
+	return transformation_add(source_models, target_models, operation_name, "actionlanguage")!
 
-String function transformation_add(user_id : String, source_models : Element, target_models : Element, operation_name : String, operation_type : String):
+String function transformation_add(source_models : Element, target_models : Element, operation_name : String, operation_type : String):
 	// Add a manual transformation model
 	String model_id
 	Element models
@@ -1181,7 +1182,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 		name = source_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
-			if (allow_read(user_id, model_id)):
+			if (allow_read(current_user_id, model_id)):
 				if (bool_not(dict_in(source, key))):
 					dict_add(source, key, model_id)
 					mm = get_full_model(model_id, get_model_id("SimpleClassDiagrams"))
@@ -1207,7 +1208,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 		name = target_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
-			if (allow_read(user_id, model_id)):
+			if (allow_read(current_user_id, model_id)):
 				if (bool_not(dict_in(target, key))):
 					dict_add(target, key, model_id)
 					mm = get_full_model(model_id, get_model_id("SimpleClassDiagrams"))
@@ -1241,18 +1242,18 @@ String function transformation_add(user_id : String, source_models : Element, ta
 			if (element_eq(m, read_root())):
 				log("Error when opening ManualOperation: no conformance relation found")
 				return "Error when opening ManualOperation: no conformance relation found"!
-			model_create(instantiate_model(m), operation_name, user_id, get_model_id("ManualOperation"), "ManualOperation")
+			model_create(instantiate_model(m), operation_name, get_model_id("ManualOperation"), "ManualOperation")
 			model_id = get_model_id(operation_name)
 
 		elif (operation_type == "actionlanguage"):
 			// Finished with all information, now create the model itself!
 			output("Waiting for code constructors...")
 			add_code_model(get_full_model(get_model_id("ActionLanguage"), get_model_id("SimpleClassDiagrams")), "AL/" + operation_name, construct_function())
-			model_create(import_node("AL/" + operation_name), operation_name, user_id, get_model_id("ActionLanguage"), "ActionLanguage")
+			model_create(import_node("AL/" + operation_name), operation_name, get_model_id("ActionLanguage"), "ActionLanguage")
 			model_id = get_model_id(operation_name)
 
 		if (bool_not(bool_and(dict_len(source_models) == 0, dict_len(target_models) == 0))):
-			model_create(merged_formalism, "__merged_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
+			model_create(merged_formalism, "__merged_" + operation_name, get_model_id("SimpleClassDiagrams"), "Model")
 			merged_formalism_id = get_model_id("__merged_" + operation_name)
 
 			// Add tracability links at this level
@@ -1284,7 +1285,7 @@ String function transformation_add(user_id : String, source_models : Element, ta
 	else:
 		return "Model exists: " + operation_name!
 
-String function cmd_transformation_add_MT(user_id : String, source_models : Element, target_models : Element, operation_name : String):
+String function cmd_transformation_add_MT(source_models : Element, target_models : Element, operation_name : String):
 	// Add a model transformation model
 	// Just a usual model instantiation, but need to add the source and target links based on user info
 	String ramified_metamodel_id
@@ -1319,7 +1320,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		name = source_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
-			if (allow_read(user_id, name)):
+			if (allow_read(current_user_id, name)):
 				// Check whether or not it is SimpleClassDiagrams
 				if (is_typed_by(model_id, get_model_id("SimpleClassDiagrams"))):
 					if (bool_not(dict_in(source, key))):
@@ -1343,7 +1344,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		name = target_models[key]
 		model_id = get_model_id(name)
 		if (model_id != ""):
-			if (allow_read(user_id, name)):
+			if (allow_read(current_user_id, name)):
 				if (is_typed_by(model_id, get_model_id("SimpleClassDiagrams"))):
 					if (bool_not(dict_in(target, key))):
 						if (dict_in(source, key)):
@@ -1371,7 +1372,7 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 	modify(merged_formalism, True)
 
 	ramified_metamodel = ramify(merged_formalism)
-	model_create(ramified_metamodel, "__RAM_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
+	model_create(ramified_metamodel, "__RAM_" + operation_name, get_model_id("SimpleClassDiagrams"), "Model")
 	ramified_metamodel_id = get_model_id("__RAM_" + operation_name)
 	
 	// Now use the RAMified model to create the instance
@@ -1380,12 +1381,12 @@ String function cmd_transformation_add_MT(user_id : String, source_models : Elem
 		// Finished with all information, now create the model itself!
 		output("Waiting for model constructors...")
 		new_model = construct_model_raw(get_full_model(ramified_metamodel_id, get_model_id("SimpleClassDiagrams")))
-		model_create(new_model, operation_name, user_id, ramified_metamodel_id, "ModelTransformation")
+		model_create(new_model, operation_name, ramified_metamodel_id, "ModelTransformation")
 		model_id = get_model_id(operation_name)
 
 		// Write out a merged metamodel containing all these models: this is the MM for the manual operation
 		// New location is available, so write
-		model_create(merged_formalism, "__merged_" + operation_name, user_id, get_model_id("SimpleClassDiagrams"), "Model")
+		model_create(merged_formalism, "__merged_" + operation_name, get_model_id("SimpleClassDiagrams"), "Model")
 		merged_formalism_id = get_model_id("__merged_" + operation_name)
 
 		// Add tracability links at this level
@@ -1457,13 +1458,13 @@ String function cmd_transformation_list_full():
 
 	return result!
 
-String function cmd_permission_modify(user_id : String, model_name : String, permissions : String):
+String function cmd_permission_modify(model_name : String, permissions : String):
 	Integer permission
 	String model_id
 
 	model_id = get_model_id(model_name)
 	if (model_id != ""):
-		if (get_relation_to_model(user_id, model_id) == 0):
+		if (get_relation_to_model(current_user_id, model_id) == 0):
 			Boolean fail
 			Integer i
 			i = 0
@@ -1488,13 +1489,13 @@ String function cmd_permission_modify(user_id : String, model_name : String, per
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_permission_owner(user_id : String, model_name : String, new_user_name : String):
+String function cmd_permission_owner(model_name : String, new_user_name : String):
 	String model_id
 	String new_user_id
 
 	model_id = get_model_id(model_name)
 	if (model_id != ""):
-		if (bool_or(get_relation_to_model(user_id, model_id) == 0, is_admin(user_id))):
+		if (bool_or(get_relation_to_model(current_user_id, model_id) == 0, is_admin(current_user_id))):
 			new_user_id = get_user_id(new_user_name)
 			if (new_user_id != ""):
 				model_delete_element(core, set_pop(allOutgoingAssociationInstances(core, model_id, "owner")))
@@ -1507,13 +1508,13 @@ String function cmd_permission_owner(user_id : String, model_name : String, new_
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_permission_group(user_id : String, model_name : String, new_group_name : String):
+String function cmd_permission_group(model_name : String, new_group_name : String):
 	String model_id
 	String group_id
 
 	model_id = get_model_id(model_name)
 	if (model_id != ""):
-		if (bool_or(get_relation_to_model(user_id, model_id) == 0, is_admin(user_id))):
+		if (bool_or(get_relation_to_model(current_user_id, model_id) == 0, is_admin(current_user_id))):
 			group_id = get_group_id(new_group_name)
 			if (group_id != ""):
 				model_delete_element(core, set_pop(allOutgoingAssociationInstances(core, model_id, "group")))
@@ -1526,7 +1527,7 @@ String function cmd_permission_group(user_id : String, model_name : String, new_
 	else:
 		return "Model not found: " + model_name!
 
-String function cmd_group_create(user_id : String, group_name : String):
+String function cmd_group_create(group_name : String):
 	// Create a new group and become its owner
 	String group_id
 	String name
@@ -1535,19 +1536,19 @@ String function cmd_group_create(user_id : String, group_name : String):
 	if (group_id == ""):
 		group_id = instantiate_node(core, "Group", "")
 		instantiate_attribute(core, group_id, "name", group_name)
-		instantiate_link(core, "belongsTo", "", user_id, group_id)
-		instantiate_link(core, "owner", "", group_id, user_id)
+		instantiate_link(core, "belongsTo", "", current_user_id, group_id)
+		instantiate_link(core, "owner", "", group_id, current_user_id)
 		return "Success"!
 	else:
 		return "Group exists: " + group_name!
 
-String function cmd_group_delete(user_id : String, group_name : String):
+String function cmd_group_delete(group_name : String):
 	// Delete an existing group
 	String group_id
 
 	group_id = get_group_id(group_name)
 	if (group_id != ""):
-		if (allow_group_modify(user_id, group_id)):
+		if (allow_group_modify(current_user_id, group_id)):
 			model_delete_element(core, group_id)
 			return "Success"!
 		else:
@@ -1555,14 +1556,14 @@ String function cmd_group_delete(user_id : String, group_name : String):
 	else:
 		return "Group not found: " + group_name!
 
-String function cmd_group_owner_add(user_id : String, group_name : String, other_user_name : String):
+String function cmd_group_owner_add(group_name : String, other_user_name : String):
 	// Add an owner to your group
 	String group_id
 	String other_user_id
 
 	group_id = get_group_id(group_name)
 	if (group_id != ""):
-		if (allow_group_modify(user_id, group_id)):
+		if (allow_group_modify(current_user_id, group_id)):
 			other_user_id = get_user_id(other_user_name)
 			if (other_user_id != ""):
 				if (set_in(allAssociationDestinations(core, group_id, "owner"), other_user_id)):
@@ -1581,14 +1582,14 @@ String function cmd_group_owner_add(user_id : String, group_name : String, other
 	else:
 		return "Group not found: " + group_name!
 
-String function cmd_group_owner_delete(user_id : String, group_name : String, other_user_name : String):
+String function cmd_group_owner_delete(group_name : String, other_user_name : String):
 	// Remove an owner from your group
 	String group_id
 	String other_user_id
 
 	group_id = get_group_id(group_name)
 	if (group_id != ""):
-		if (allow_group_modify(user_id, group_id)):
+		if (allow_group_modify(current_user_id, group_id)):
 			other_user_id = get_user_id(other_user_name)
 			if (other_user_id != ""):
 				if (set_in(allAssociationDestinations(core, other_user_id, "belongsTo"), group_id)):
@@ -1608,14 +1609,14 @@ String function cmd_group_owner_delete(user_id : String, group_name : String, ot
 	else:
 		return "Group not found: " + group_name!
 
-String function cmd_group_join(user_id : String, group_name : String, other_user_name : String):
+String function cmd_group_join(group_name : String, other_user_name : String):
 	// Add someone to your group
 	String group_id
 	String other_user_id
 
 	group_id = get_group_id(group_name)
 	if (group_id != ""):
-		if (allow_group_modify(user_id, group_id)):
+		if (allow_group_modify(current_user_id, group_id)):
 			other_user_id = get_user_id(other_user_name)
 			if (other_user_id != ""):
 				if (set_in(allOutgoingAssociationInstances(core, other_user_id, "belongsTo"), group_id)):
@@ -1630,14 +1631,14 @@ String function cmd_group_join(user_id : String, group_name : String, other_user
 	else:
 		return "Group not found: " + group_name!
 
-String function cmd_group_kick(user_id : String, group_name : String, other_user_name : String):
+String function cmd_group_kick(group_name : String, other_user_name : String):
 	// Remove someone from your group
 	String group_id
 	String other_user_id
 
 	group_id = get_group_id(group_name)
 	if (group_id != ""):
-		if (allow_group_modify(user_id, group_id)):
+		if (allow_group_modify(current_user_id, group_id)):
 			other_user_id = get_user_id(other_user_name)
 			if (other_user_id != ""):
 				Element overlap
@@ -1660,7 +1661,7 @@ String function cmd_group_kick(user_id : String, group_name : String, other_user
 	else:
 		return "Group not found: " + group_name!
 
-String function cmd_group_list(user_id : String):
+String function cmd_group_list():
 	// List all groups you are a member of (and whether you are admin or not!)
 	Element groups
 	String group_id
@@ -1668,10 +1669,10 @@ String function cmd_group_list(user_id : String):
 	String result
 	
 	result = ""
-	groups = allAssociationDestinations(core, user_id, "belongsTo")
+	groups = allAssociationDestinations(core, current_user_id, "belongsTo")
 	while (set_len(groups) > 0):
 		group_id = set_pop(groups)
-		if (set_in(allAssociationDestinations(core, group_id, "owner"), user_id)):
+		if (set_in(allAssociationDestinations(core, group_id, "owner"), current_user_id)):
 			admin = " A "
 		else:
 			admin = "   "
@@ -1680,9 +1681,9 @@ String function cmd_group_list(user_id : String):
 
 	return result!
 
-String function cmd_admin_promote(user_id : String, other_user_name : String):
+String function cmd_admin_promote(other_user_name : String):
 	// Promote a user to admin status
-	if (is_admin(user_id)):
+	if (is_admin(current_user_id)):
 		String other_user_id
 
 		other_user_id = get_user_id(other_user_name)
@@ -1695,9 +1696,9 @@ String function cmd_admin_promote(user_id : String, other_user_name : String):
 	else:
 		return "Permission denied to administrate: " + other_user_name!
 
-String function cmd_admin_demote(user_id : String, other_user_name : String):
+String function cmd_admin_demote(other_user_name : String):
 	// Demote a user to normal status
-	if (is_admin(user_id)):
+	if (is_admin(current_user_id)):
 		String other_user_id
 
 		other_user_id = get_user_id(other_user_name)
@@ -1710,7 +1711,7 @@ String function cmd_admin_demote(user_id : String, other_user_name : String):
 	else:
 		return "Permission denied to administrate: " + other_user_name!
 
-String function cmd_service_register(user_id : String, service_name : String):
+String function cmd_service_register(service_name : String):
 	// Active a service for this specific user
 	if (get_service_id(service_name) == ""):
 		String service
@@ -1732,8 +1733,8 @@ String function cmd_service_register(user_id : String, service_name : String):
 	else:
 		return "Service already exists: " + service_name!
 
-String function cmd_user_password(user_id : String, user_name : String, new_password : String):
-	if (bool_or(user_id == get_user_id(user_name), is_admin(user_id))):
+String function cmd_user_password(user_name : String, new_password : String):
+	if (bool_or(current_user_id == get_user_id(user_name), is_admin(current_user_id))):
 		if (get_user_id(user_name) != ""):
 			instantiate_attribute(core, get_user_id(user_name), "password", hash(new_password))
 			return "Success"!
@@ -1742,13 +1743,13 @@ String function cmd_user_password(user_id : String, user_name : String, new_pass
 	else:
 		return "Permission denied to user: " + user_name!
 
-String function cmd_transformation_signature(user_id : String, transformation_name : String):
+String function cmd_transformation_signature(transformation_name : String):
 	String model_id
 	model_id = get_model_id(transformation_name)
 
 	if (model_id != ""):
 		if (is_nominal_instance(core, model_id, "Transformation")):
-			if (allow_read(user_id, transformation_name)):
+			if (allow_read(current_user_id, transformation_name)):
 				String result
 				String elem
 				Element inputs
@@ -1773,9 +1774,9 @@ String function cmd_transformation_signature(user_id : String, transformation_na
 	else:
 		return "No such transformation: " + transformation_name!
 	
-String function cmd_element_list_nice(user_id : String, model_name : String, metamodel_name : String):
+String function cmd_element_list_nice(model_name : String, metamodel_name : String):
 	if (get_model_id(model_name) != ""):
-		if (allow_read(user_id, get_model_id(model_name))):
+		if (allow_read(current_user_id, get_model_id(model_name))):
 			Element mm
 			mm = get_full_model(get_model_id(model_name), get_model_id(metamodel_name))
 			if (element_eq(mm, read_root())):
@@ -1793,6 +1794,7 @@ Void function user_function_skip_init(user_id : String):
 	caches = dict_create()
 	dict_add_fast(caches, "models", dict_create())
 	dict_add_fast(caches, "users", dict_create())
+	current_user_id = user_id
 
 	output("Welcome to the Model Management Interface v2.0!")
 	output("Use the 'help' command for a list of possible commands")
@@ -1800,73 +1802,73 @@ Void function user_function_skip_init(user_id : String):
 	while (True):
 		cmd = input()
 		if (cmd == "help"):
-			output(cmd_help(user_id))
+			output(cmd_help())
 		elif (cmd == "model_add"):
-			output(cmd_model_add(user_id, single_input("Model type?"), single_input("Model name?")))
+			output(cmd_model_add(single_input("Model type?"), single_input("Model name?")))
 		elif (cmd == "process_execute"):
-			output(cmd_process_execute(user_id, single_input("Process to execute?"), single_input("Model prefix to use?")))
+			output(cmd_process_execute(single_input("Process to execute?"), single_input("Model prefix to use?")))
 		elif (cmd == "transformation_between"):
-			output(cmd_transformation_between(user_id, single_input("Source type?"), single_input("Target type?")))
+			output(cmd_transformation_between(single_input("Source type?"), single_input("Target type?")))
 		elif (cmd == "model_render"):
-			output(cmd_model_render(user_id, single_input("Model name?"), single_input("Mapper name?")))
+			output(cmd_model_render(single_input("Model name?"), single_input("Mapper name?")))
 		elif (cmd == "transformation_execute"):
-			output(cmd_transformation_execute(user_id, single_input("Transformation name?"), dict_input("Source models?"), dict_input("Target models?")))
+			output(cmd_transformation_execute(single_input("Transformation name?"), dict_input("Source models?"), dict_input("Target models?")))
 		elif (cmd == "verify"):
-			result = cmd_verify(user_id, single_input("Model name?"), single_input("Metamodel name?"))
+			result = cmd_verify(single_input("Model name?"), single_input("Metamodel name?"))
 			if (result != ""):
 				output(result)
 		elif (cmd == "model_overwrite"):
-			output(cmd_model_overwrite(user_id, single_input("Model name?"), single_input("Metamodel name?")))
+			output(cmd_model_overwrite(single_input("Model name?"), single_input("Metamodel name?")))
 		elif (cmd == "model_modify"):
-			output(cmd_model_modify(user_id, single_input("Model name?"), single_input("Metamodel name?")))
+			output(cmd_model_modify(single_input("Model name?"), single_input("Metamodel name?")))
 		elif (cmd == "model_delete"):
-			output(cmd_model_delete(user_id, single_input("Model name?")))
+			output(cmd_model_delete(single_input("Model name?")))
 		elif (cmd == "model_list"):
 			output(cmd_model_list())
 		elif (cmd == "model_list_full"):
 			output(cmd_model_list_full())
 		elif (cmd == "transformation_add_MANUAL"):
-			output(cmd_transformation_add_MANUAL(user_id, dict_input("Source model names?"), dict_input("Target model names?"), single_input("Operation name?")))
+			output(cmd_transformation_add_MANUAL(dict_input("Source model names?"), dict_input("Target model names?"), single_input("Operation name?")))
 		elif (cmd == "transformation_add_AL"):
-			output(cmd_transformation_add_AL(user_id, dict_input("Source model names?"), dict_input("Target model names?"), single_input("Operation name?")))
+			output(cmd_transformation_add_AL(dict_input("Source model names?"), dict_input("Target model names?"), single_input("Operation name?")))
 		elif (cmd == "transformation_add_MT"):
-			output(cmd_transformation_add_MT(user_id, dict_input("Source model names?"), dict_input("Target models?"), single_input("Operation name?")))
+			output(cmd_transformation_add_MT(dict_input("Source model names?"), dict_input("Target models?"), single_input("Operation name?")))
 		elif (cmd == "transformation_list"):
 			output(cmd_transformation_list())
 		elif (cmd == "transformation_list_full"):
 			output(cmd_transformation_list_full())
 		elif (cmd == "permission_modify"):
-			output(cmd_permission_modify(user_id, single_input("Model name?"), single_input("Permissions?")))
+			output(cmd_permission_modify(single_input("Model name?"), single_input("Permissions?")))
 		elif (cmd == "permission_owner"):
-			output(cmd_permission_owner(user_id, single_input("Model name?"), single_input("New owning user?")))
+			output(cmd_permission_owner(single_input("Model name?"), single_input("New owning user?")))
 		elif (cmd == "permission_group"):
-			output(cmd_permission_group(user_id, single_input("Model name?"), single_input("New owning group?")))
+			output(cmd_permission_group(single_input("Model name?"), single_input("New owning group?")))
 		elif (cmd == "group_create"):
-			output(cmd_group_create(user_id, single_input("New group name?")))
+			output(cmd_group_create(single_input("New group name?")))
 		elif (cmd == "group_delete"):
-			output(cmd_group_delete(user_id, single_input("Group name?")))
+			output(cmd_group_delete(single_input("Group name?")))
 		elif (cmd == "group_owner_add"):
-			output(cmd_group_owner_add(user_id, single_input("Group name?"), single_input("User name?")))
+			output(cmd_group_owner_add(single_input("Group name?"), single_input("User name?")))
 		elif (cmd == "group_owner_delete"):
-			output(cmd_group_owner_delete(user_id, single_input("Group name?"), single_input("User name?")))
+			output(cmd_group_owner_delete(single_input("Group name?"), single_input("User name?")))
 		elif (cmd == "group_join"):
-			output(cmd_group_join(user_id, single_input("Group name?"), single_input("User name?")))
+			output(cmd_group_join(single_input("Group name?"), single_input("User name?")))
 		elif (cmd == "group_kick"):
-			output(cmd_group_kick(user_id, single_input("Group name?"), single_input("User name?")))
+			output(cmd_group_kick(single_input("Group name?"), single_input("User name?")))
 		elif (cmd == "group_list"):
-			output(cmd_group_list(user_id))
+			output(cmd_group_list())
 		elif (cmd == "admin_promote"):
-			output(cmd_admin_promote(user_id, single_input("User name?")))
+			output(cmd_admin_promote(single_input("User name?")))
 		elif (cmd == "admin_demote"):
-			output(cmd_admin_demote(user_id, single_input("User name?")))
+			output(cmd_admin_demote(single_input("User name?")))
 		elif (cmd == "service_register"):
-			output(cmd_service_register(user_id, single_input("Service name?")))
+			output(cmd_service_register(single_input("Service name?")))
 		elif (cmd == "user_password"):
-			output(cmd_user_password(user_id, single_input("User name?"), single_input("New password?")))
+			output(cmd_user_password(single_input("User name?"), single_input("New password?")))
 		elif (cmd == "transformation_read_signature"):
-			output(cmd_transformation_signature(user_id, single_input("Transformation name?")))
+			output(cmd_transformation_signature(single_input("Transformation name?")))
 		elif (cmd == "element_list_nice"):
-			output(cmd_element_list_nice(user_id, single_input("Model name?"), single_input("Metamodel name?")))
+			output(cmd_element_list_nice(single_input("Model name?"), single_input("Metamodel name?")))
 		elif (cmd == "verbose"):
 			set_verbose(True)
 		elif (cmd == "quiet"):