/** * count all the uncertified pts assigned to mts, assigned to the given user * * @param mixed $user optional, defaults to null, can be int or object. if not supplied, currently logged in user is used. * @param object $course stdclass object of course to fetch role assignment on (optional, defaults to SITE) * * @return int count */ function tao_count_uncertified_pts_of_mts($user = null, $course = null) { $user = tao_user_parameter($user); $childrole = get_record('role', 'shortname', ROLE_MT); $grandchildrole = get_record('role', 'shortname', ROLE_PT); return tao_count_grandchildren_by_courserole($user, $grandchildrole, $course, $childrole, null); }
function tao_message_get_recipients_by_target($target, $course, $user = null) { $user = tao_user_parameter($user); $context = get_context_instance(CONTEXT_COURSE, $course->id); if (!empty($target->recipientrole) || !empty($target->recipientroles)) { if (!empty($target->recipientcontext)) { $context = get_context_instance_by_id($target->recipientcontext); } if (!empty($target->recipientrole)) { $roleid = get_field('role', 'id', 'shortname', $target->recipientrole); } else { $rolesql = " IN ( '" . implode("','", $target->recipientroles) . "' ) "; $roleid = array_keys(get_records_select('role', 'shortname ' . $rolesql, '', 'id, id')); } return get_role_users($roleid, $context); } else { if (is_array($target->recipientfunction)) { // recipientfunction $function = $target->recipientfunction['users']; $users = $function($user, $course); if (empty($target->recipienttransform)) { return $users; } switch ($target->recipienttransform) { case 'nested': // these are the grandchild ones $newu = array(); foreach ($users as $key => $children) { $newu = array_merge($newu, $children); } return $newu; } } } }
* along with this program. If not, see <http://www.gnu.org/licenses/>. * * @package moodle * @subpackage local * @author Penny Leach <*****@*****.**> * @license http://www.gnu.org/copyleft/gpl.html GNU GPL * @copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com * * show a list of users who are assigned to you */ require_once dirname(dirname(dirname(__FILE__))) . '/config.php'; require_login(); $page = optional_param('page', 0, PARAM_INT); $perpage = optional_param('perpage', 10, PARAM_INT); $userid = optional_param('user', 0, PARAM_INT); $user = tao_user_parameter($userid); $sitecontext = get_context_instance(CONTEXT_COURSE, SITEID); if ($user->id == $USER->id) { $strheading = get_string('responsiblefor', 'local'); require_capability('moodle/local:viewresponsibleusers', $sitecontext); } else { $strheading = get_string('responsibleforbehalfof', 'local', fullname($user)); $usercontext = get_context_instance(CONTEXT_USER, $user->id); require_capability('moodle/local:viewresponsibleusersbehalfof', $usercontext); } print_header($strheading, $strheading, build_navigation($strheading)); $users = array(); $children = array(); // for STS only if (has_capability('moodle/local:isst', $sitecontext, $user->id)) { $count = tao_count_mts($user);