浏览代码

Allow access to model owner and group for admin

Yentl Van Tendeloo 8 年之前
父节点
当前提交
27ca765b6a
共有 1 个文件被更改,包括 5 次插入14 次删除
  1. 5 14
      core/core_algorithm.alc

+ 5 - 14
core/core_algorithm.alc

@@ -83,13 +83,9 @@ Void function main():
 	Element prev
 	root = read_root()
 	root = root["__hierarchy"]["__IP"]
-	log("Found " + cast_e2s(root))
 	while (value_neq(root, !call)):
-		log("Found " + cast_e2s(root))
 		prev = root
 		root = root["next"]
-	log("End at " + cast_e2s(root))
-	log("to: " + cast_e2s(root["func"]["var"]["var"]))
 	dict_delete(prev, "next")
 	dict_add(prev, "next", user_function["body"])
 
@@ -174,7 +170,6 @@ Boolean function check_login(user_id : String):
 	return False!
 
 Element function user_function():
-	log("Got to user_function")
 	String username
 	String user_id
 
@@ -361,7 +356,7 @@ Void function user_function_skip_init(user_id : String):
 					else:
 						output("Model with that name already exists!")
 				else:
-					output("You are not allowed to read this type model!")
+					output("Permission denied")
 			else:
 				output("Could not find type model!")
 
@@ -530,9 +525,9 @@ Void function user_function_skip_init(user_id : String):
 					if (allow_read(user_id, type_id)):
 						modify(import_node(read_attribute(core, model_id, "location")), allow_write(user_id, model_id))
 					else:
-						output("You are not allowed to read the type model!")
+						output("Permission denied")
 				else:
-					output("You are not allowed to read this model!")
+					output("Permission denied")
 			else:
 				output("Could not find model!")
 
@@ -557,10 +552,6 @@ Void function user_function_skip_init(user_id : String):
 			models = allInstances(core, "Model")
 			while (read_nr_out(models) > 0):
 				m = set_pop(models)
-				log("at " + cast_e2s(m))
-				log("Name: " + cast_v2s(read_attribute(core, m, "name")))
-				log("Instance of " + cast_e2s(set_pop(followAssociation(core, m, "instanceOf"))))
-				log("Name: " + cast_e2s(read_attribute(core, set_pop(followAssociation(core, m, "instanceOf")), "name")))
 				output(string_join((string_join("  ", read_attribute(core, m, "name")) + " : "), read_attribute(core, set_pop(followAssociation(core, m, "instanceOf")), "name")))
 
 		elif (cmd == "model_list_full"):
@@ -845,7 +836,7 @@ Void function user_function_skip_init(user_id : String):
 			output("Which model do you want to change owner of?")
 			model_id = get_model_id(input())
 			if (model_id != ""):
-				if (get_relation_to_model(user_id, model_id) == 0):
+				if (bool_or(get_relation_to_model(user_id, model_id) == 0, is_admin(user_id))):
 					output("New owner?")
 					user_id = get_user_id(input())
 					if (user_id != ""):
@@ -866,7 +857,7 @@ Void function user_function_skip_init(user_id : String):
 			output("Which model do you want to change permissions of?")
 			model_id = get_model_id(input())
 			if (model_id != ""):
-				if (get_relation_to_model(user_id, model_id) == 0):
+				if (bool_or(get_relation_to_model(user_id, model_id) == 0, is_admin(user_id))):
 					output("New group?")
 					group_id = get_group_id(input())
 					if (group_id != ""):