diff -Naur -b participants_orig/blocks/participants/ReadMe.txt participants_mod/blocks/participants/ReadMe.txt --- participants_orig/blocks/participants/ReadMe.txt 1970-01-01 01:00:00.000000000 +0100 +++ participants_mod/blocks/participants/ReadMe.txt 2009-06-11 09:00:22.000000000 +0100 @@ -0,0 +1,5 @@ +To get the block to show different icons for different roles, create an icon in the i directory of the theme being used and call it roleX.gif, where X is the roleid. + +e.g. Where Teachers are role 3 and the theme flashywhizzy is being used, which has custom icons, the path would be moodle/theme/flashywhizzy/pix/i/role3.gif + +Where custom icons aren't used, you'll need to add it to /moodle/pix/i \ No newline at end of file diff -Naur -b participants_orig/blocks/participants/block_participants.php participants_mod/blocks/participants/block_participants.php --- participants_orig/blocks/participants/block_participants.php 2008-03-03 20:10:00.000000000 +0000 +++ participants_mod/blocks/participants/block_participants.php 2009-06-11 09:00:22.000000000 +0100 @@ -1,11 +1,13 @@ -title = get_string('people'); - $this->version = 2007101509; + $this->version = 2009050810; } + function has_config() {return true;} + function get_content() { global $CFG, $COURSE; @@ -43,9 +45,40 @@ } } + if ($CFG->block_participants_useroles == 1 && $CFG->block_participants_rolestouse != '') { + // Use the option to select the roles to show + $rolestoshow = $CFG->block_participants_rolestouse.','; + $roles = array(); + if ($allroles = get_all_roles()) { + foreach ($allroles as $role) { + $rolename = strip_tags(format_string($role->name, true)); + if (substr($rolename, -1, 1) != 's') { + // Pluralise any roles that don't already end with an s + // It's a bit of a bodge until someone suggests a more reliable method + $rolename .= 's'; + } + $roletofind = $role->id.','; + if (strpos($rolestoshow, $roletofind) !== false) { + $roles[$role->id] = $rolename; + $this->content->items[] = ''.$rolename.''; + + // Check for the existance of an icon with the name roleX.gif, where X is the roleid + if(file_exists($CFG->dirroot.'/theme/'.$CFG->theme.'/pix/i/role'.$role->id.'.gif')) { + $this->content->icons[] = ''; + } else { + // If it can't be found, use the default icon + $this->content->icons[] = ''; + } + } + } + } + } else { + // Use the default items to show $this->content->items[] = ''.get_string('participants').''; $this->content->icons[] = ''; + } return $this->content; } diff -Naur -b participants_orig/blocks/participants/settings.php participants_mod/blocks/participants/settings.php --- participants_orig/blocks/participants/settings.php 1970-01-01 01:00:00.000000000 +0100 +++ participants_mod/blocks/participants/settings.php 2009-06-11 09:00:22.000000000 +0100 @@ -0,0 +1,22 @@ +libdir.'/dmllib.php'; + +$settings->add(new admin_setting_configcheckbox('block_participants_useroles', get_string('useroles', 'block_participants'), + get_string('configuseroles', 'block_participants'), 0)); + +// Get a list of non-guest roles +$nonguestroles = array(); +if ($roles = get_all_roles()) { + foreach ($roles as $role) { + $rolename = strip_tags(format_string($role->name, true)); + if (!isset($guestroles[$role->id])) { + $nonguestroles[$role->id] = $rolename; + } + } +} + +$settings->add(new admin_setting_configmultiselect('block_participants_rolestouse', get_string('useroles', 'block_participants'), + get_string('configuseroles', 'block_participants'), array(), $nonguestroles)); + +?> \ No newline at end of file diff -Naur -b participants_orig/lang/en_utf8/block_participants.php participants_mod/lang/en_utf8/block_participants.php --- participants_orig/lang/en_utf8/block_participants.php 1970-01-01 01:00:00.000000000 +0100 +++ participants_mod/lang/en_utf8/block_participants.php 2009-06-11 09:00:22.000000000 +0100 @@ -0,0 +1,8 @@ +