|
@@ -173,9 +173,10 @@ Void function user_function_skip_init(user_id : String)
|
|
|
output("Group operations")
|
|
|
output(" group_create -- TODO")
|
|
|
output(" group_delete -- TODO")
|
|
|
- output(" group_owner -- TODO")
|
|
|
- output(" group_join -- TODO")
|
|
|
- output(" group_kick -- TODO")
|
|
|
+ output(" group_owner -- Change group owner")
|
|
|
+ output(" group_join -- Add someone to your group")
|
|
|
+ output(" group_kick -- Kick someone from your group")
|
|
|
+ output(" group_list -- List all groups you are a member of")
|
|
|
output("")
|
|
|
output("Admin operations")
|
|
|
output(" admin_promote -- Promote a user to admin status")
|
|
@@ -283,6 +284,80 @@ Void function user_function_skip_init(user_id : String)
|
|
|
type = read_attribute(core, set_pop(allAssociationDestinations(core, m, "instanceOf")), "name")
|
|
|
output(((((((((((" " + permissions) + " ") + owner) + " ") + group) + " ") + size) + " ") + name) + " : ") + type)
|
|
|
|
|
|
+ elif (cmd == "group_join"):
|
|
|
+ // Add someone to your group
|
|
|
+ String group_id
|
|
|
+
|
|
|
+ output("Which group do you want to add someone to?")
|
|
|
+ group_id = get_group_id(input())
|
|
|
+ if (group_id != ""):
|
|
|
+ if (allow_group_modify(user_id, group_id)):
|
|
|
+ output("Which user do you want to add?")
|
|
|
+ other_user_id = get_user_id(input())
|
|
|
+ if (other_user_id != ""):
|
|
|
+ Element overlap
|
|
|
+
|
|
|
+ overlap = set_overlap(allOutgoingAssociationInstances(core, user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
|
|
|
+ if (read_nr_out(overlap) == 0):
|
|
|
+ instantiate_link(core, "belongsTo", "", user_id, group_id)
|
|
|
+ output("User added to the group!")
|
|
|
+ else:
|
|
|
+ output("User is already a member of the group!")
|
|
|
+ else:
|
|
|
+ output("No such user")
|
|
|
+ else:
|
|
|
+ output("Permission denied!")
|
|
|
+ else:
|
|
|
+ output("No such group")
|
|
|
+
|
|
|
+ elif (cmd == "group_kick"):
|
|
|
+ // Remove someone from your group
|
|
|
+ String group_id
|
|
|
+
|
|
|
+ output("Which group do you want to kick someone from?")
|
|
|
+ group_id = get_group_id(input())
|
|
|
+ if (group_id != ""):
|
|
|
+ if (allow_group_modify(user_id, group_id)):
|
|
|
+ output("Which user do you want to kick?")
|
|
|
+ other_user_id = get_user_id(input())
|
|
|
+ if (other_user_id != ""):
|
|
|
+ Element overlap
|
|
|
+
|
|
|
+ overlap = set_overlap(allOutgoingAssociationInstances(core, user_id, "belongsTo"), allIncomingAssociationInstances(core, group_id, "belongsTo"))
|
|
|
+ if (read_nr_out(overlap) > 0):
|
|
|
+ model_delete_element(core, set_pop(overlap))
|
|
|
+
|
|
|
+ // Check if user was an owner as well
|
|
|
+ overlap = set_overlap(allIncomingAssociationInstances(core, user_id, "owner"), allOutgoingAssociationInstances(core, group_id, "owner"))
|
|
|
+ if (read_nr_out(overlap) > 0):
|
|
|
+ model_delete_element(core, set_pop(overlap))
|
|
|
+
|
|
|
+ output("User kicked!")
|
|
|
+ else:
|
|
|
+ output("User is not even a member of the group!")
|
|
|
+ else:
|
|
|
+ output("No such user")
|
|
|
+ else:
|
|
|
+ output("Permission denied!")
|
|
|
+ else:
|
|
|
+ output("No such group")
|
|
|
+
|
|
|
+ elif (cmd == "group_list"):
|
|
|
+ // List all groups you are a member of (and whether you are admin or not!)
|
|
|
+ Element groups
|
|
|
+ String group_id
|
|
|
+ String admin
|
|
|
+
|
|
|
+ groups = allAssociationDestinations(core, user_id, "belongsTo")
|
|
|
+ while (True):
|
|
|
+ group_id = set_pop(groups)
|
|
|
+ if (set_in(allAssociation(core, group_id, "owner"), user_id)):
|
|
|
+ admin = " A "
|
|
|
+ else:
|
|
|
+ admin = " "
|
|
|
+
|
|
|
+ output(admin + read_attribute(core, group_id, "name"))
|
|
|
+
|
|
|
elif (cmd == "admin_promote"):
|
|
|
// Promote a user to admin status
|
|
|
if (is_admin(user_id)):
|