original_string: function sync_roles($user) {
          global $DB;
  
          $roles = get_ldap_assignable_role_names(2); // Admin user.
  
          foreach ($roles as $role) {
              $isrole = $this->is_role($user->username, $role);
              if ($isrole === null) {
                  continue; // Nothing to sync - role/LDAP contexts not configured.
              }
  
              // Sync user.
              $systemcontext = context_system::instance();
              if ($isrole) {
                  // Following calls will not create duplicates.
                  role_assign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
              } else {
                  // Unassign only if previously assigned by this plugin.
                  role_unassign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
              }
          }
      }
code: function sync_roles($user) {
          global $DB;
  
          $roles = get_ldap_assignable_role_names(2); // Admin user.
  
          foreach ($roles as $role) {
              $isrole = $this->is_role($user->username, $role);
              if ($isrole === null) {
                  continue; // Nothing to sync - role/LDAP contexts not configured.
              }
  
              // Sync user.
              $systemcontext = context_system::instance();
              if ($isrole) {
                  // Following calls will not create duplicates.
                  role_assign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
              } else {
                  // Unassign only if previously assigned by this plugin.
                  role_unassign($role['id'], $user->id, $systemcontext->id, $this->roleauth);
              }
          }
      }
code_tokens: function sync_roles ( $ user ) { global $ DB ; $ roles = get_ldap_assignable_role_names ( 2 ) ; // Admin user. foreach ( $ roles as $ role ) { $ isrole = $ this -> is_role ( $ user -> username , $ role ) ; if ( $ isrole === null ) { continue ; // Nothing to sync - role/LDAP contexts not configured. } // Sync user. $ systemcontext = context_system :: instance ( ) ; if ( $ isrole ) { // Following calls will not create duplicates. role_assign ( $ role [ 'id' ] , $ user -> id , $ systemcontext -> id , $ this -> roleauth ) ; } else { // Unassign only if previously assigned by this plugin. role_unassign ( $ role [ 'id' ] , $ user -> id , $ systemcontext -> id , $ this -> roleauth ) ; } } }
docstring: Sync roles for this user.
  
  @param object $user The user to sync (without system magic quotes).
docstring_tokens: Sync roles for this user .