original_string: public function user_roles_and_actions($userid, $roles, $assignableroles, $canassign, $pageurl) {
  
          // Get list of roles.
          $rolesoutput = '';
          foreach ($roles as $roleid=>$role) {
              if ($canassign and (is_siteadmin() or isset($assignableroles[$roleid])) and !$role['unchangeable']) {
                  $strunassign = get_string('unassignarole', 'role', $role['text']);
                  $icon = $this->output->pix_icon('t/delete', $strunassign);
                  $url = new moodle_url($pageurl, array('action'=>'unassign', 'roleid'=>$roleid, 'user'=>$userid));
                  $rolesoutput .= html_writer::tag('div', $role['text'] . html_writer::link($url, $icon, array('class'=>'unassignrolelink', 'rel'=>$roleid, 'title'=>$strunassign)), array('class'=>'role role_'.$roleid));
              } else {
                  $rolesoutput .= html_writer::tag('div', $role['text'], array('class'=>'role unchangeable', 'rel'=>$roleid));
              }
          }
          $output = '';
          if (!empty($assignableroles) && $canassign) {
              $roleids = array_keys($roles);
              $hasallroles = true;
              foreach (array_keys($assignableroles) as $key) {
                  if (!in_array($key, $roleids)) {
                      $hasallroles = false;
                      break;
                  }
              }
              if (!$hasallroles) {
                  $url = new moodle_url($pageurl, array('action' => 'assign', 'user' => $userid));
                  $roleicon = $this->output->pix_icon('i/assignroles', get_string('assignroles', 'role'));
                  $link = html_writer::link($url, $roleicon, array('class' => 'assignrolelink'));
                  $output = html_writer::tag('div', $link, array('class'=>'addrole'));
              }
          }
          $output .= html_writer::tag('div', $rolesoutput, array('class'=>'roles'));
          return $output;
      }
code: public function user_roles_and_actions($userid, $roles, $assignableroles, $canassign, $pageurl) {
  
          // Get list of roles.
          $rolesoutput = '';
          foreach ($roles as $roleid=>$role) {
              if ($canassign and (is_siteadmin() or isset($assignableroles[$roleid])) and !$role['unchangeable']) {
                  $strunassign = get_string('unassignarole', 'role', $role['text']);
                  $icon = $this->output->pix_icon('t/delete', $strunassign);
                  $url = new moodle_url($pageurl, array('action'=>'unassign', 'roleid'=>$roleid, 'user'=>$userid));
                  $rolesoutput .= html_writer::tag('div', $role['text'] . html_writer::link($url, $icon, array('class'=>'unassignrolelink', 'rel'=>$roleid, 'title'=>$strunassign)), array('class'=>'role role_'.$roleid));
              } else {
                  $rolesoutput .= html_writer::tag('div', $role['text'], array('class'=>'role unchangeable', 'rel'=>$roleid));
              }
          }
          $output = '';
          if (!empty($assignableroles) && $canassign) {
              $roleids = array_keys($roles);
              $hasallroles = true;
              foreach (array_keys($assignableroles) as $key) {
                  if (!in_array($key, $roleids)) {
                      $hasallroles = false;
                      break;
                  }
              }
              if (!$hasallroles) {
                  $url = new moodle_url($pageurl, array('action' => 'assign', 'user' => $userid));
                  $roleicon = $this->output->pix_icon('i/assignroles', get_string('assignroles', 'role'));
                  $link = html_writer::link($url, $roleicon, array('class' => 'assignrolelink'));
                  $output = html_writer::tag('div', $link, array('class'=>'addrole'));
              }
          }
          $output .= html_writer::tag('div', $rolesoutput, array('class'=>'roles'));
          return $output;
      }
code_tokens: public function user_roles_and_actions ( $ userid , $ roles , $ assignableroles , $ canassign , $ pageurl ) { // Get list of roles. $ rolesoutput = '' ; foreach ( $ roles as $ roleid => $ role ) { if ( $ canassign and ( is_siteadmin ( ) or isset ( $ assignableroles [ $ roleid ] ) ) and ! $ role [ 'unchangeable' ] ) { $ strunassign = get_string ( 'unassignarole' , 'role' , $ role [ 'text' ] ) ; $ icon = $ this -> output -> pix_icon ( 't/delete' , $ strunassign ) ; $ url = new moodle_url ( $ pageurl , array ( 'action' => 'unassign' , 'roleid' => $ roleid , 'user' => $ userid ) ) ; $ rolesoutput .= html_writer :: tag ( 'div' , $ role [ 'text' ] . html_writer :: link ( $ url , $ icon , array ( 'class' => 'unassignrolelink' , 'rel' => $ roleid , 'title' => $ strunassign ) ) , array ( 'class' => 'role role_' . $ roleid ) ) ; } else { $ rolesoutput .= html_writer :: tag ( 'div' , $ role [ 'text' ] , array ( 'class' => 'role unchangeable' , 'rel' => $ roleid ) ) ; } } $ output = '' ; if ( ! empty ( $ assignableroles ) && $ canassign ) { $ roleids = array_keys ( $ roles ) ; $ hasallroles = true ; foreach ( array_keys ( $ assignableroles ) as $ key ) { if ( ! in_array ( $ key , $ roleids ) ) { $ hasallroles = false ; break ; } } if ( ! $ hasallroles ) { $ url = new moodle_url ( $ pageurl , array ( 'action' => 'assign' , 'user' => $ userid ) ) ; $ roleicon = $ this -> output -> pix_icon ( 'i/assignroles' , get_string ( 'assignroles' , 'role' ) ) ; $ link = html_writer :: link ( $ url , $ roleicon , array ( 'class' => 'assignrolelink' ) ) ; $ output = html_writer :: tag ( 'div' , $ link , array ( 'class' => 'addrole' ) ) ; } } $ output .= html_writer :: tag ( 'div' , $ rolesoutput , array ( 'class' => 'roles' ) ) ; return $ output ; }
docstring: Generates HTML to display the users roles and any available actions
  
  @param int $userid
  @param array $roles
  @param array $assignableroles
  @param moodle_url $pageurl
  @return string
docstring_tokens: Generates HTML to display the users roles and any available actions