/** * Authorises an otherwise unauthorised active object against the given user and the current controller. * (NOTE: the object must previously have been registered using {@link register_object()}). * <b>Must not be called statically.</b> * @param string $uuid The UUID of the object being updated * @param SloodleUser $user The user to authorise the object against * @param string $type (Optional). Specifies the type to store for this object. Ignored if null. * @return bool True if successful, or false if not */ function authorise_object($uuid, $user, $type = null) { // Attempt to find an unauthorised entry for the object $entry = get_record('sloodle_active_object', 'uuid', $uuid); if (!$entry) { return false; } // Update the controller, user and time $entry->controllerid = $this->get_id(); $entry->userid = $user->get_user_id(); if (!empty($type)) { $entry->type = $type; } $entry->timeupdated = time(); if (!update_record('sloodle_active_object', $entry)) { return false; } return true; }
/** * Add a new submission (or replace an existing one). * Ignores all submission checks, such as permissions and time. * @param SloodleUser $user The user making the submission * @param string $obj_name Name of the object being submitted * @param int $num_prims Number of prims in the object being submitted * @param string $primdrop_name Name of the PrimDrop being submitted to * @param string $primdrop_uuid UUID of the PrimDrop being submitted to * @param string $primdrop_region Region of the PrimDrop being submitted to * @param string $primdrop_pos Position vector (<x,y,z>) of the PrimDrop being submitted to * @return bool True if successful, or false otherwise */ function submit($user, $obj_name, $num_prims, $primdrop_name, $primdrop_uuid, $primdrop_region, $primdrop_pos) { // Make sure the user is loaded if (!$user->is_user_loaded()) { return false; } // Construct a submission object $sloodle_submission = new assignment_sloodleobject_submission(); $sloodle_submission->obj_name = $obj_name; $sloodle_submission->num_prims = $num_prims; $sloodle_submission->primdrop_name = $primdrop_name; $sloodle_submission->primdrop_uuid = $primdrop_uuid; $sloodle_submission->primdrop_region = $primdrop_region; $sloodle_submission->primdrop_pos = $primdrop_pos; // Update the submission return $this->assignment->update_submission($user->get_user_id(), $sloodle_submission); }
/** * Deletes any loginzone allocations for the given user * If there are multiple for the same user (which there should never be) it will delete them all. * @param SloodleUser $user The user whose allocation is to be deleted * @return void */ function delete_loginzone_allocation($user) { delete_records('sloodle_loginzone_allocation', 'userid', $user->get_user_id()); }