Delete an email given its ID.

@param string $userId
@param string $emailId

@return \Google_Service_Gmail_Message|null
323927
public function trash(string $userId, string $emailId): ?\Google_Service_Gmail_Message
    {
        if ($this->get($userId, $emailId)) {
            return null;
        }

        return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->trash($userId, $emailId);
    }
751469
public static function delete_stale_subscriptions($userid = 0) {
        global $DB;
        // Get the expiry duration, in days.
        $cutofftime = strtotime("-" . self::INACTIVE_SUBSCRIPTION_LIFESPAN_IN_DAYS . " days", time());

        if (!empty($userid)) {
            // Remove any stale subscriptions for the desired user only.
            $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                  'userid = ? AND inactivedate < ? AND inactivedate <> 0',
                                                  array($userid, $cutofftime));

        } else {
            // Remove all stale subscriptions.
            $success = $DB->delete_records_select('tool_monitor_subscriptions',
                                                  'inactivedate < ? AND inactivedate <> 0',
                                                  array($cutofftime));
        }
        return $success;
    }
536113
public function deleteEmail( $email_id = null ) {
		if ( ! $email_id ) {
			$this->assertNotEmpty( $this->_current_email, 'The current email is not selected' );
			$email_id = $this->_current_email['id'];
		}

		$this->_send_delete_request( '/messages/' . $email_id );
	}
252270
public function deleteUser($userid){
	    if (!$this->access_token && !$this->checkAuth()) return false;
	    $result = $this->http_get(self::API_URL_PREFIX.self::USER_DELETE_URL.'access_token='.$this->access_token.'&userid='.$userid);
	    if ($result)
	    {
	        $json = json_decode($result,true);
	        if (!$json || !empty($json['errcode']) || $json['errcode']!=0) {
	            $this->errCode = $json['errcode'];
	            $this->errMsg = $json['errmsg'];
	            return false;
	        }
	        return $json;
	    }
	    return false;
	}
1181601
public function delete($messageId, $documentId = null)
    {
        return $this->diadocApi->delete($this->boxId, $messageId, $documentId);
    }
484667
public function deleteUserQuery($userId)
    {
        $qb = $this->createQueryBuilder();
        $qb->delete($this->getTableName());

        if (is_numeric($userId)) {
            $qb->where('id = :userId');
        } else {
            $qb->where('username = :userId')->orWhere('email = :userId');
        }
        $qb->setParameter('userId', $userId);

        return $qb;
    }
119160
public static function delete_contacts($userids, $userid = 0) {
        global $CFG, $USER;

        // Check if messaging is enabled.
        if (empty($CFG->messaging)) {
            throw new moodle_exception('disabled', 'message');
        }

        if (empty($userid)) {
            $userid = $USER->id;
        }

        // Validate context.
        $context = context_system::instance();
        self::validate_context($context);

        $params = array('userids' => $userids, 'userid' => $userid);
        $params = self::validate_parameters(self::delete_contacts_parameters(), $params);

        $capability = 'moodle/site:manageallmessaging';
        if (($USER->id != $params['userid']) && !has_capability($capability, $context)) {
            throw new required_capability_exception($context, $capability, 'nopermissions', '');
        }

        foreach ($params['userids'] as $id) {
            \core_message\api::remove_contact($params['userid'], $id);
        }

        return null;
    }
1079251
public static function can_create_data_deletion_request_for_self(int $userid = null): bool {
        global $USER;
        $userid = $userid ?: $USER->id;
        return has_capability('tool/dataprivacy:requestdelete', \context_user::instance($userid), $userid);
    }
150256
public function deleteUser($userId)
    {
        $result = $this->httpGet(self::WECHAT_USER_DELETE_PREFIX, [
            'access_token' => $this->getAccessToken(),
            'userid' => $userId
        ]);
        return isset($result['errcode']) && ($result['errcode'] ? $this->dump([$result,$this->getAccessToken()]) : !$result['errcode']);
    }
322837
public function delete_message($messageId, $boxId)
    {
        try {
            $manager = $this->container->get('symbb.extension.tapatalk.manager.user');
            return $manager->deleteMessage($messageId, $boxId);
        } catch (\Exception $exc) {
            return $this->errorResponse($exc);
        }
    }
1200273
public function resolveEmailsFromUserId(string $userId, int $mode)
    {
        $gmailUser = $this->getGmailDomain()->findGmailUserById($userId);

        if (!($gmailUser instanceof GmailUserInterface)) {
            return [];
        }

        switch ($mode) {
            case self::MODE_RESOLVE_PRIMARY_ONLY:
                return [$gmailUser->getPrimaryEmailAddress()];

            case self::MODE_RESOLVE_ALIASES_ONLY:
                return $gmailUser->getEmailAliases();

            case self::MODE_RESOLVE_PRIMARY_PLUS_ALIASES:
                return $gmailUser->getAllEmailAddresses();

            default:
                throw new \InvalidArgumentException();
        }
    }
858720
public function send(string $userId, \Google_Service_Gmail_Message $message): \Google_Service_Gmail_Message
    {
        return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->send($userId, $message);
    }
267862
public function removeMember($id, $userId)
    {
        try {
            $result = $this->service->remove(Auth::user(), $id, $userId);

            if ($result) {
                return back()->with('message', 'Successfully removed member');
            }

            return back()->with('message', 'Failed to remove member');
        } catch (Exception $e) {
            return back()->withErrors($e->getMessage());
        }
    }
1027833
public static function deletePatient($id, $userId = 0) {
		$entityManager = ( object ) DoctrineBootstrap::getEntityManager ();
		$type = 'Hospitalplugin\Entities\Patient';
		$patient = $entityManager->getRepository ( $type )->findOneBy ( array (
				'id' => $id 
		) );
		$entityManager->remove ( $patient );
		$log = strval($patient);
		$audit = new PatientDeleted();
		$audit->deletedAt = new \DateTime ();
		$audit->deletedByUserId = $userId;
		$audit->log = $log;
		$entityManager->persist ( $audit );
		$entityManager->flush ();
	}
993731
protected static function delete_user_evidence_of_prior_learning($userid) {
        global $DB;

        $usercontext = context_user::instance($userid);
        $ueids = $DB->get_fieldset_select(user_evidence::TABLE, 'id', 'userid = :userid', ['userid' => $userid]);
        if (empty($ueids)) {
            return;
        }
        list($insql, $inparams) = $DB->get_in_or_equal($ueids, SQL_PARAMS_NAMED);

        // Delete competencies associated with user evidence.
        $DB->delete_records_select(user_evidence_competency::TABLE, "userevidenceid $insql", $inparams);

        // Delete the user evidence.
        $DB->delete_records_select(user_evidence::TABLE, "id $insql", $inparams);

        // Delete the user evidence files.
        $fs = get_file_storage();
        $fs->delete_area_files($usercontext->id, 'core_competency', 'userevidence');
    }
237787
public function delete($appUserId, $id)
    {
        $url = sprintf('users/%s/bankaccounts/%s', $appUserId, $id);
        return $this->deleteObject($url);
    }
355326
public function list(string $userId, array $options = []): \Google_Service_Gmail_ListMessagesResponse
    {
        return $this->googleServices->getGoogleServiceGmailForUserId($userId)->users_messages->listUsersMessages($userId, $options);
    }