Create page for Kyc document
@param string $userId User Id
@param string $kycDocumentId KYC Document Id
@param \MangoPay\KycPage $kycPage KYC Page
@return bool `true` if the upload was successful, `false` otherwise
@throws \MangoPay\Libraries\Exception
7837
public function CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey = null)
    {
        $uploaded = false;
        try {
            $response = $this->CreateObject('kyc_page_create', $kycPage, null, $userId, $kycDocumentId, $idempotencyKey);
            $uploaded = true;
        } catch (\MangoPay\Libraries\ResponseException $exc) {
            if ($exc->getCode() != 204) {
                throw $exc;
            } else {
                $uploaded = true;
            }
        }
        return $uploaded;
    }
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);
    }
886705
public function CreateKycPageFromFile($userId, $kycDocumentId, $filePath, $idempotencyKey = null)
    {
        if (empty($filePath)) {
            throw new \MangoPay\Libraries\Exception('Path of file cannot be empty');
        }

        if (!file_exists($filePath)) {
            throw new \MangoPay\Libraries\Exception('File not exist');
        }

        $kycPage = new \MangoPay\KycPage();
        $kycPage->File = base64_encode(file_get_contents($filePath));

        if (empty($kycPage->File)) {
            throw new \MangoPay\Libraries\Exception('Content of the file cannot be empty');
        }

        return $this->CreateKycPage($userId, $kycDocumentId, $kycPage, $idempotencyKey);
    }
921219
public function userKey($user_id, $key_id)
    {
        return $this->get('users/'.$this->encodePath($user_id).'/keys/'.$this->encodePath($key_id));
    }
575474
public function create($appUserId, CardPayment $cardPayment)
    {
        $url = sprintf('users/%s/payins/cardpayments/', $appUserId);
        return $this->createObject($url, $cardPayment);
    }
544143
public function findTokenByParams($userId, $code, $type)
    {
        return $this->findToken([
            'user_id' => $userId,
            'code'    => $code,
            'type'    => $type,
        ])->one();
    }
1173345
public static function is_contact(int $userid, int $contactid) : bool {
        global $DB;

        $sql = "SELECT id
                  FROM {message_contacts} mc
                 WHERE (mc.userid = ? AND mc.contactid = ?)
                    OR (mc.userid = ? AND mc.contactid = ?)";
        return $DB->record_exists_sql($sql, [$userid, $contactid, $contactid, $userid]);
    }
636432
protected function attachPermissionToUser($permission, $userId)
    {
        // Check if user exists
        if ($user = $this->userRepository->findById($userId)) {
            $user->attachPermission($permission);
            $this->info('Permission attached successfully to user');
        } else {
            $this->error('Not possible to attach permission. User not found');
        }
    }
1011648
public function userCopy($userId, $options=array()){

        $data = array();
        
        $data['user_id'] = $userId;

        $data = array_merge($data, $options);

        return $this->request($this->userCopyUrl, $data);
    }
1317092
public function findAllKYC($appUserId)
    {
        $url = sprintf('users/%s/kyc/', $appUserId);

        return $this->getAll($url, $this->KYCEntityClassName);
    }
714988
public static function create($userId, $params = null, $options = null)
    {
        return self::_userBasedCreate($userId, $params, $options);
    }
523207
public function existstUserCountryCodeAndPhoneNumber($userId) {
        $countryCode = DB::table('users')
            ->where('id', '=', $userId)
            ->value('phone_country_code')
        ;

        $phoneNumber =  DB::table('users')
            ->where('id', '=', $userId)
            ->value('phone_number')
        ;

        if ((!$countryCode) || (!$phoneNumber)) {
            return false;
        }

        return true;
    }
195264
protected static function add_session_record($userid) {
        global $DB;
        $record = new \stdClass();
        $record->state       = 0;
        $record->sid         = session_id();
        $record->sessdata    = null;
        $record->userid      = $userid;
        $record->timecreated = $record->timemodified = time();
        $record->firstip     = $record->lastip = getremoteaddr();

        $record->id = $DB->insert_record('sessions', $record);

        return $record;
    }
482067
private function createRateLimitData($applicationId, $userId)
	{
		// data needed to create record
		$ipAddress    = \Request::ip();
		$countShort   = 0;
		$countLong    = 0;
		$limitShort   = $this->config['short']['limit'];
		$limitLong    = $this->config['long']['limit'];
		$created      = with(new Date('now'))->toSql();
		$expiresShort = $this->getNewExpiresDateString('short');
		$expiresLong  = $this->getNewExpiresDateString('long');

		// create initial limit record
		return $this->storage->createRateLimitData(
			$applicationId,
			$userId,
			$ipAddress,
			$limitShort,
			$limitLong,
			$countShort,
			$countLong,
			$expiresShort,
			$expiresLong,
			$created
		);
	}
1297941
public static function user_competency_request_review($userid, $competencyid) {
        $params = self::validate_parameters(self::user_competency_request_review_parameters(), array(
            'userid' => $userid,
            'competencyid' => $competencyid,
        ));

        $context = context_user::instance($params['userid']);
        self::validate_context($context);

        return api::user_competency_request_review($userid, $competencyid);
    }
172894
public function create($userId, $name, $redirect, $personalAccess = false, $password = false)
    {
        $client = Passport::client()->forceFill([
            'user_id' => $userId,
            'name' => $name,
            'secret' => Str::random(40),
            'redirect' => $redirect,
            'personal_access_client' => $personalAccess,
            'password_client' => $password,
            'revoked' => false,
        ]);

        $client->save();

        return $client;
    }
615800
public static final function create_from_user_evidence(user_evidence $userevidence) {
        if (!$userevidence->get('id')) {
            throw new \coding_exception('The evidence of prior learning ID must be set.');
        }
        $event = static::create(array(
            'contextid'  => $userevidence->get_context()->id,
            'objectid' => $userevidence->get('id'),
            'relateduserid' => $userevidence->get('userid')
        ));
        $event->add_record_snapshot(user_evidence::TABLE, $userevidence->to_record());
        return $event;
    }