/** * Determine whether the current user can unassign the user from the track. * @param int $userid The ID of the user (the assignee). * @param int $trackid The ID of the track. * @return bool Whether the current can unassign (true) or not (false) */ protected function can_unassign($userid, $trackid) { return usertrack::can_manage_assoc($userid, $trackid); }
function can_do_delete() { global $USER; $association_id = 0; if (!empty($this->params['association_id'])) { $association_id = $this->params['association_id']; } else { $association_id = $this->optional_param('association_id', '', PARAM_INT); } $usrtrk = new usertrack($association_id); return usertrack::can_manage_assoc($usrtrk->userid, $usrtrk->trackid); }
$dir = 'ASC'; } $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 30, PARAM_INT); $context = get_context_instance(context_level_base::get_custom_context_level('track', 'block_curr_admin'), $trackid); //todo: integrate this better with user-track page? //this checks permissions at the track level if (!trackpage::can_enrol_into_track($trackid)) { //standard failure message require_capability('block/curr_admin:track:enrol', $context); } // add user to track if ($userid) { //todo: integrate this better with user-track page? //this checks permissions at the user-track association level if (!usertrack::can_manage_assoc($userid, $trackid)) { //standard failure message require_capability('block/curr_admin:track:enrol', $context); } usertrack::enrol($userid, $trackid); // reload the main page with the new assignments $target = new trackuserpage(array('id' => $trackid)); ?> <script type="text/javascript"> //<![CDATA[ window.opener.location = "<?php echo htmlspecialchars_decode($target->get_url()); ?> "; //]]> </script>