original_string: public static function instance($userid, $strictness = MUST_EXIST) {
          global $DB;
  
          if ($context = context::cache_get(CONTEXT_USER, $userid)) {
              return $context;
          }
  
          if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_USER, 'instanceid' => $userid))) {
              if ($user = $DB->get_record('user', array('id' => $userid, 'deleted' => 0), 'id', $strictness)) {
                  $record = context::insert_context_record(CONTEXT_USER, $user->id, '/'.SYSCONTEXTID, 0);
              }
          }
  
          if ($record) {
              $context = new context_user($record);
              context::cache_add($context);
              return $context;
          }
  
          return false;
      }
code: public static function instance($userid, $strictness = MUST_EXIST) {
          global $DB;
  
          if ($context = context::cache_get(CONTEXT_USER, $userid)) {
              return $context;
          }
  
          if (!$record = $DB->get_record('context', array('contextlevel' => CONTEXT_USER, 'instanceid' => $userid))) {
              if ($user = $DB->get_record('user', array('id' => $userid, 'deleted' => 0), 'id', $strictness)) {
                  $record = context::insert_context_record(CONTEXT_USER, $user->id, '/'.SYSCONTEXTID, 0);
              }
          }
  
          if ($record) {
              $context = new context_user($record);
              context::cache_add($context);
              return $context;
          }
  
          return false;
      }
code_tokens: public static function instance ( $ userid , $ strictness = MUST_EXIST ) { global $ DB ; if ( $ context = context :: cache_get ( CONTEXT_USER , $ userid ) ) { return $ context ; } if ( ! $ record = $ DB -> get_record ( 'context' , array ( 'contextlevel' => CONTEXT_USER , 'instanceid' => $ userid ) ) ) { if ( $ user = $ DB -> get_record ( 'user' , array ( 'id' => $ userid , 'deleted' => 0 ) , 'id' , $ strictness ) ) { $ record = context :: insert_context_record ( CONTEXT_USER , $ user -> id , '/' . SYSCONTEXTID , 0 ) ; } } if ( $ record ) { $ context = new context_user ( $ record ) ; context :: cache_add ( $ context ) ; return $ context ; } return false ; }
docstring: Returns user context instance.
  
  @static
  @param int $userid id from {user} table
  @param int $strictness
  @return context_user context instance
docstring_tokens: Returns user context instance .