Remove any data from the current submission.

@param int $userid
@return boolean
329641
public function remove_submission($userid) {
        global $USER;

        if (!$this->can_edit_submission($userid, $USER->id)) {
            print_error('nopermission');
        }

        if ($this->get_instance()->teamsubmission) {
            $submission = $this->get_group_submission($userid, 0, false);
        } else {
            $submission = $this->get_user_submission($userid, false);
        }

        if (!$submission) {
            return false;
        }

        // Tell each submission plugin we were saved with no data.
        $plugins = $this->get_submission_plugins();
        foreach ($plugins as $plugin) {
            if ($plugin->is_enabled() && $plugin->is_visible()) {
                $plugin->remove($submission);
            }
        }

        if ($submission->userid != 0) {
            \mod_assign\event\submission_status_updated::create_from_submission($this, $submission)->trigger();
        }
        return true;
    }
427085
public static function can_create_data_deletion_request_for_children(int $userid, int $requesterid = null): bool {
        global $USER;
        $requesterid = $requesterid ?: $USER->id;
        return has_capability('tool/dataprivacy:makedatadeletionrequestsforchildren', \context_user::instance($userid),
            $requesterid);
    }
872650
public function batchDelete(array $UserID)
    {
        $params = array(
                   'useridlist' => $UserID,
                  );
        return $this->http->jsonPost(self::API_BATCH_DELETE, $params);

    }
798600
public function DeleteUserData($UserID, $Options = array(), &$Data = NULL) {
      $SQL = Gdn::SQL();
      
      // Remove discussion watch records and drafts.
		$SQL->Delete('UserDiscussion', array('UserID' => $UserID));
      
		Gdn::UserModel()->GetDelete('Draft', array('InsertUserID' => $UserID), $Data);
      
      // Comment deletion depends on method selected
      $DeleteMethod = GetValue('DeleteMethod', $Options, 'delete');
      if ($DeleteMethod == 'delete') {
         // Clear out the last posts to the categories.
         $SQL
            ->Update('Category c')
            ->Join('Discussion d', 'd.DiscussionID = c.LastDiscussionID')
            ->Where('d.InsertUserID', $UserID)
            ->Set('c.LastDiscussionID', NULL)
            ->Set('c.LastCommentID', NULL)
            ->Put();
         
         $SQL
            ->Update('Category c')
            ->Join('Comment d', 'd.CommentID = c.LastCommentID')
            ->Where('d.InsertUserID', $UserID)
            ->Set('c.LastDiscussionID', NULL)
            ->Set('c.LastCommentID', NULL)
            ->Put();
         
         // Grab all of the discussions that the user has engaged in.
         $DiscussionIDs = $SQL
            ->Select('DiscussionID')
            ->From('Comment')
            ->Where('InsertUserID', $UserID)
            ->GroupBy('DiscussionID')
            ->Get()->ResultArray();
         $DiscussionIDs = ConsolidateArrayValuesByKey($DiscussionIDs, 'DiscussionID');

         
         Gdn::UserModel()->GetDelete('Comment', array('InsertUserID' => $UserID), $Data);
         
         // Update the comment counts.
         $CommentCounts = $SQL
            ->Select('DiscussionID')
            ->Select('CommentID', 'count', 'CountComments')
            ->Select('CommentID', 'max', 'LastCommentID')
            ->WhereIn('DiscussionID', $DiscussionIDs)
            ->GroupBy('DiscussionID')
            ->Get('Comment')->ResultArray();
         
         foreach ($CommentCounts as $Row) {
            $SQL->Put('Discussion',
               array('CountComments' => $Row['CountComments'] + 1, 'LastCommentID' => $Row['LastCommentID']),
               array('DiscussionID' => $Row['DiscussionID']));
         }
         
         // Update the last user IDs.
         $SQL->Update('Discussion d')
            ->Join('Comment c', 'd.LastCommentID = c.CommentID', 'left')
            ->Set('d.LastCommentUserID', 'c.InsertUserID', FALSE, FALSE)
            ->Set('d.DateLastComment', 'c.DateInserted', FALSE, FALSE)
            ->WhereIn('d.DiscussionID', $DiscussionIDs)
            ->Put();
         
         // Update the last posts.
         $Discussions = $SQL
            ->WhereIn('DiscussionID', $DiscussionIDs)
            ->Where('LastCommentUserID', $UserID)
            ->Get('Discussion');
         
         // Delete the user's dicussions 
         Gdn::UserModel()->GetDelete('Discussion', array('InsertUserID' => $UserID), $Data);
         
         // Update the appropriat recent posts in the categories.
         $CategoryModel = new CategoryModel();
         $Categories = $CategoryModel->GetWhere(array('LastDiscussionID' => NULL))->ResultArray();
         foreach ($Categories as $Category) {
            $CategoryModel->SetRecentPost($Category['CategoryID']);
         }
      } else if ($DeleteMethod == 'wipe') {
         // Erase the user's dicussions
         $SQL->Update('Discussion')
            ->Set('Body', T('The user and all related content has been deleted.'))
            ->Set('Format', 'Deleted')
            ->Where('InsertUserID', $UserID)
            ->Put();

         $SQL->Update('Comment')
            ->Set('Body', T('The user and all related content has been deleted.'))
            ->Set('Format', 'Deleted')
            ->Where('InsertUserID', $UserID)
            ->Put();
      } else {
         // Leave comments
      }

      // Remove the user's profile information related to this application
      $SQL->Update('User')
         ->Set(array(
				'CountDiscussions' => 0,
				'CountUnreadDiscussions' => 0,
				'CountComments' => 0,
				'CountDrafts' => 0,
				'CountBookmarks' => 0
			))
         ->Where('UserID', $UserID)
         ->Put();
   }
457766
public function Clear($UserID = '') {
      if (empty($_POST))
         throw PermissionException('Javascript');
      
      $UserID = is_numeric($UserID) ? $UserID : 0;
      $Session = Gdn::Session();
      if ($UserID != $Session->UserID && !$Session->CheckPermission('Garden.Moderation.Manage'))
         throw PermissionException('Garden.Moderation.Manage');

      if ($UserID > 0)
         $this->UserModel->SaveAbout($UserID, '');

      if ($this->DeliveryType() == DELIVERY_TYPE_ALL)
         Redirect('/profile');
      else {
         $this->JsonTarget('#Status', '', 'Remove');
         $this->Render('Blank', 'Utility');
      }
   }
54777
public function check_examples_assessed_before_submission($userid) {

        if ($this->useexamples and $this->examplesmode == self::EXAMPLES_BEFORE_SUBMISSION
            and !has_capability('mod/workshop:manageexamples', $this->context)) {

            // Check that all required examples have been assessed by the user.
            $examples = $this->get_examples_for_reviewer($userid);
            foreach ($examples as $exampleid => $example) {
                if (is_null($example->assessmentid)) {
                    $examples[$exampleid]->assessmentid = $this->add_allocation($example, $userid, 0);
                }
                if (is_null($example->grade)) {
                    return false;
                }
            }
        }
        return true;
    }
961693
public function removeParticipant($userId)
    {
        $userIds = is_array($userId) ? $userId : (array) func_get_args();

        Models::participant()->where('thread_id', $this->id)->whereIn('user_id', $userIds)->delete();
    }
691319
protected static function delete_user_data(int $userid, \context $context) {
        global $DB;

        // Delete password history.
        $DB->delete_records('user_password_history', ['userid' => $userid]);
        // Delete last access.
        $DB->delete_records('user_lastaccess', ['userid' => $userid]);
        // Delete password resets.
        $DB->delete_records('user_password_resets', ['userid' => $userid]);
        // Delete user devices.
        $DB->delete_records('user_devices', ['userid' => $userid]);
        // Delete user course requests.
        $DB->delete_records('course_request', ['requester' => $userid]);
        // Delete sessions.
        $DB->delete_records('sessions', ['userid' => $userid]);
        // Do I delete user preferences? Seems like the right place to do it.
        $DB->delete_records('user_preferences', ['userid' => $userid]);

        // Delete all of the files for this user.
        $fs = get_file_storage();
        $fs->delete_area_files($context->id, 'user');

        // For the user record itself we only want to remove unnecessary data. We still need the core data to keep as a record
        // that we actually did follow the request to be forgotten.
        $user = \core_user::get_user($userid);
        // Update fields we wish to change to nothing.
        $user->deleted = 1;
        $user->idnumber = '';
        $user->emailstop = 0;
        $user->icq = '';
        $user->skype = '';
        $user->yahoo = '';
        $user->aim = '';
        $user->msn = '';
        $user->phone1 = '';
        $user->phone2 = '';
        $user->institution = '';
        $user->department = '';
        $user->address = '';
        $user->city = '';
        $user->country = '';
        $user->lang = '';
        $user->calendartype = '';
        $user->theme = '';
        $user->timezone = '';
        $user->firstaccess = 0;
        $user->lastaccess = 0;
        $user->lastlogin = 0;
        $user->currentlogin = 0;
        $user->lastip = 0;
        $user->secret = '';
        $user->picture = '';
        $user->url = '';
        $user->description = '';
        $user->descriptionformat = 0;
        $user->mailformat = 0;
        $user->maildigest = 0;
        $user->maildisplay = 0;
        $user->autosubscribe = 0;
        $user->trackforums = 0;
        $user->timecreated = 0;
        $user->timemodified = 0;
        $user->trustbitmask = 0;
        $user->imagealt = '';
        $user->lastnamephonetic = '';
        $user->firstnamephonetic = '';
        $user->middlename = '';
        $user->alternatename = '';
        $DB->update_record('user', $user);
    }
1196344
public function revoke($itemName,$userId)
	{
		return $this->db->createCommand()
			->delete($this->assignmentTable, 'itemname=:itemname AND userid=:userid', array(
				':itemname'=>$itemName,
				':userid'=>$userId
			)) > 0;
	}
934005
public function login(string $userID): bool
    {
        $data = Internal\Server::call('login', ['userID' => $userID], true);
        if (isset($data['result'])) {
            return $data['result'] === 'ok';
        }
        return false;
    }
335304
public function isOwnedBy($recordId, $userId = null)
    {
        return (bool)$this->find()
            ->where(['id' => $recordId, 'user_id' => $userId])
            ->first();
    }
1113163
public function removeNode($nodeId)
    {
        if (isset($this->nodeSet[$nodeId]))
            unset($this->nodeSet[$nodeId]);
        return true;
    }
435558
public function unlinkRichMenu($userId)
    {
        $url = sprintf('%s/v2/bot/user/%s/richmenu', $this->endpointBase, urlencode($userId));
        return $this->httpClient->delete($url);
    }
651281
public function deleteSoft(array $userIds): void
    {
        $deleted = $this->getRepository()->deleteSoft($userIds);

        event(new HCUserSoftDeleted($deleted));
    }
1135400
protected static function delete_data(\context $context, int $userid = null) {
        global $DB;

        $cohortids = $DB->get_fieldset_select('cohort', 'id', 'contextid = :contextid', ['contextid' => $context->id]);
        foreach ($cohortids as $cohortid) {
            $params = ['cohortid' => $cohortid];
            if (!empty($userid)) {
                $params['userid'] = $userid;
            }
            $DB->delete_records('cohort_members', $params);
        }
    }
969799
public function hasParticipant($userId)
    {
        $participants = $this->participants()->where('user_id', '=', $userId);
        if ($participants->count() > 0) {
            return true;
        }

        return false;
    }
996311
protected function process_lock_submission($userid = 0) {

        require_sesskey();

        if (!$userid) {
            $userid = required_param('userid', PARAM_INT);
        }

        return $this->lock_submission($userid);
    }