original_string: public static function delete_data_for_user(approved_contextlist $contextlist) {
          global $DB;
  
          // Don't remove data from role_capabilities.
          // Because this data affects the whole Moodle, there are override capabilities.
          // Don't belong to the modifier user.
  
          // Remove data from role_assignments.
          if (empty($contextlist->count())) {
              return;
          }
          $userid = $contextlist->get_user()->id;
          $contextids = $contextlist->get_contextids();
  
          list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
          $params = ['userid' => $userid] + $contextparams;
  
          // Only delete the roles assignments where the user is assigned in all contexts.
          $DB->delete_records_select('role_assignments',
              "userid = :userid AND contextid {$contextsql}", $params);
      }
code: public static function delete_data_for_user(approved_contextlist $contextlist) {
          global $DB;
  
          // Don't remove data from role_capabilities.
          // Because this data affects the whole Moodle, there are override capabilities.
          // Don't belong to the modifier user.
  
          // Remove data from role_assignments.
          if (empty($contextlist->count())) {
              return;
          }
          $userid = $contextlist->get_user()->id;
          $contextids = $contextlist->get_contextids();
  
          list($contextsql, $contextparams) = $DB->get_in_or_equal($contextids, SQL_PARAMS_NAMED);
          $params = ['userid' => $userid] + $contextparams;
  
          // Only delete the roles assignments where the user is assigned in all contexts.
          $DB->delete_records_select('role_assignments',
              "userid = :userid AND contextid {$contextsql}", $params);
      }
code_tokens: public static function delete_data_for_user ( approved_contextlist $ contextlist ) { global $ DB ; // Don't remove data from role_capabilities. // Because this data affects the whole Moodle, there are override capabilities. // Don't belong to the modifier user. // Remove data from role_assignments. if ( empty ( $ contextlist -> count ( ) ) ) { return ; } $ userid = $ contextlist -> get_user ( ) -> id ; $ contextids = $ contextlist -> get_contextids ( ) ; list ( $ contextsql , $ contextparams ) = $ DB -> get_in_or_equal ( $ contextids , SQL_PARAMS_NAMED ) ; $ params = [ 'userid' => $ userid ] + $ contextparams ; // Only delete the roles assignments where the user is assigned in all contexts. $ DB -> delete_records_select ( 'role_assignments' , "userid = :userid AND contextid {$contextsql}" , $ params ) ; }
docstring: Delete all user data for this user only.
  
  @param  approved_contextlist $contextlist The list of approved contexts for a user.
docstring_tokens: Delete all user data for this user only .