unset($users[$loc->userid]); } } } // if all users have been removed or no users in course if (count($users) == 0) { print_box(get_string("nolocationsupdated", "map")); } else { //for the user left(don't already have a location) foreach ($users as $user) { require_once $CFG->dirroot . '/user/profile/lib.php'; profile_load_data($user); $context = get_context_instance(CONTEXT_COURSE, $COURSE->id); // only display students on the map (nadavkav patch) if (!has_capability('moodle/legacy:admin', $context)) { $user->userid = $user->id; $user->state = map_get_user_state($user); $user->action = "insertlocation"; $user->mapid = $map->id; $user->id = $id; if ($resultLocation = map_save_location($user) === true) { //was able to set users location print_box("User: {$user->firstname} {$user->lastname} - " . get_string("locationset", "map")); } else { //was not able to set user location print_box("User: {$user->firstname} {$user->lastname} - " . get_string("errorsetlocation", "map") . " - " . $resultLocation); } } } } print_single_button("view.php?id=" . $id, null, "View Map", "post");
$timenow = time(); $action = required_param('action', PARAM_ALPHA); if ($action == "resetlocation") { $form = new mod_map_reset_location_form(); } else { $form = new mod_map_user_location_form(); } if ($form->is_cancelled()) { redirect("view.php?id={$cm->id}", get_string("actioncanceled", "map")); exit; } if (!$form->is_validated()) { redirect("view.php?id={$cm->id}", get_string("submiterror", "map")); exit; } $locationSuccess = map_save_location($form->get_data()); if ($locationSuccess === true) { redirect("view.php?id={$cm->id}", get_string("actionsuccessfull", "map")); exit; } else { redirect("view.php?id={$cm->id}", get_string("actionfailed", "map") . " - " . $locationSuccess); exit; } } /// Display the map and locations //print_header_simple(format_string($map->name), "","<a href=\"index.php?id=$course->id\">$strmaps</a> -> ".format_string($map->name), "", "", true, //update_module_button($cm->id, $course->id, $strmap), navmenu($course, $cm)); $navigation = build_navigation('', $cm); print_header_simple(format_string($map->name), "", $navigation, "", "", true, update_module_button($cm->id, $course->id, $strmap), navmenu($course, $cm)); add_to_log($course->id, "map", "view", "view.php?id={$cm->id}", $map->id, $cm->id); require_once "handle_groups.php";