Adds a user to the list of user IDs that should be explicitly enabled for this feature
@param integer $userId
@return RolloutableInterface $this
548188
public function addUser($userId)
    {
        if (true === is_numeric($userId) && false === in_array($userId, $this->users)) {
            $this->users[] = (int)$userId;
        }
        return $this;
    }
1182155
public function getUserCapabilities(string $userId): array
    {
        if (empty($this->userCapabilities)) {
            $this->userCapabilities = Utils::fetchUserCapabilities($userId);
        }

        return $this->userCapabilities;
    }
1197714
public function disableUser($uid): ResponseInterface
    {
        return $this->updateUser(
            Request\UpdateUser::new()
                ->withUid($uid)
                ->markAsDisabled()
        );
    }
770109
public function addAvailableFilters($userId, $archivedAllowed = false, $cancelledAvailable = false)
    {
        if (!$archivedAllowed) {
            $this->neq(TaskLogBrokerInterface::COLUMN_STATUS, TaskLogInterface::STATUS_ARCHIVED);
        }

        if (!$cancelledAvailable) {
            $this->neq(TaskLogBrokerInterface::COLUMN_STATUS, TaskLogInterface::STATUS_CANCELLED);
        }

        if ($userId !== TaskLogInterface::SUPER_USER) {
            $this->eq(TaskLogBrokerInterface::COLUMN_OWNER, $userId);
        }

        return $this;
    }
865604
static public function sendActivationEmail( $userID )
    {
        eZDebugSetting::writeNotice( 'kernel-user',  'Sending activation email.', 'user register' );
        $ini = eZINI::instance();

        $tpl = eZTemplate::factory();
        $user = eZUser::fetch( $userID );
        $tpl->setVariable( 'user', $user );
        $object= eZContentObject::fetch( $userID );
        $tpl->setVariable( 'object', $object );
        $hostname = eZSys::hostname();
        $tpl->setVariable( 'hostname', $hostname );

        // Check whether account activation is required.
        $verifyUserType = $ini->variable( 'UserSettings', 'VerifyUserType' );
        $sendUserMail = !!$verifyUserType;

        if ( $verifyUserType === 'email' ) // and if it is email type
        {
            // Disable user account and send verification mail to the user

            // Create enable account hash and send it to the newly registered user
            $hash = md5( mt_rand() . time() . $userID );

            if ( eZOperationHandler::operationIsAvailable( 'user_activation' ) )
            {
                $operationResult = eZOperationHandler::execute( 'user',
                                                                'activation', array( 'user_id'    => $userID,
                                                                                     'user_hash'  => $hash,
                                                                                     'is_enabled' => false ) );
            }
            else
            {
                eZUserOperationCollection::activation( $userID, $hash, false );
            }

            $tpl->setVariable( 'hash', $hash );

            $sendUserMail = true;
        }
        else if ( $verifyUserType )// custom account activation
        {
            $verifyUserTypeClass = false;
            // load custom verify user settings
            if ( $ini->hasGroup( 'VerifyUserType_' . $verifyUserType ) )
            {
                if ( $ini->hasVariable( 'VerifyUserType_' . $verifyUserType, 'File' ) )
                    include_once( $ini->variable( 'VerifyUserType_' . $verifyUserType, 'File' ) );
                $verifyUserTypeClass = $ini->variable( 'VerifyUserType_' . $verifyUserType, 'Class' );
            }
            // try to call the verify user class with function verifyUser
            $user = eZContentObject::fetch( $userID );
            if ( $verifyUserTypeClass && method_exists( $verifyUserTypeClass, 'verifyUser' ) )
                $sendUserMail  = call_user_func( array( $verifyUserTypeClass, 'verifyUser' ), $user, $tpl );
            else
                eZDebug::writeWarning( "Unknown VerifyUserType '$verifyUserType'", 'user/register' );
        }

        // send verification mail to user if email type or custum verify user type returned true
        if ( $sendUserMail )
        {
            $templateResult = $tpl->fetch( 'design:user/registrationinfo.tpl' );
            if ( $tpl->hasVariable( 'content_type' ) )
                $contentType = $tpl->variable( 'content_type' );
            else
                $contentType = $ini->variable( 'MailSettings', 'ContentType' );

            $emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
            if ( $tpl->hasVariable( 'email_sender' ) )
                $emailSender = $tpl->variable( 'email_sender' );
            else if ( !$emailSender )
                $emailSender = $ini->variable( 'MailSettings', 'AdminEmail' );

            if ( $tpl->hasVariable( 'subject' ) )
                $subject = $tpl->variable( 'subject' );
            else
                $subject = ezpI18n::tr( 'kernel/user/register', 'Registration info' );

            $mail = new eZMail();
            $mail->setSender( $emailSender );
            $mail->setContentType( $contentType );
            $user = eZUser::fetch( $userID );
            $receiver = $user->attribute( 'email' );
            $mail->setReceiver( $receiver );
            $mail->setSubject( $subject );
            $mail->setBody( $templateResult );
            $mailResult = eZMailTransport::send( $mail );
        }
        return array( 'status' => eZModuleOperationInfo::STATUS_CONTINUE );
    }
458355
public static function can_read_user($userid) {
        $capability = 'moodle/competency:usercompetencyview';
        return has_capability($capability, context_user::instance($userid))
            || plan::can_read_user($userid);
    }
311351
public function generateToken($userId)
    {
        $user = $this->users->find($userId);

        if (! is_null($user)) {
            $user->generateInvitationToken();
            $user->trackTime('invited_at');
            $user->setStatus(Status::INACTIVE);
        }
    }
72547
public function like($userId = null)
    {
        app(LikeableServiceContract::class)->addLikeTo($this, LikeType::LIKE, $userId);
    }
614814
private function createBatch($userId)
    {
        $entity = new EBatch();
        $entity->setUserRef($userId);
        $result = $this->daoBatch->create($entity);
        return $result;
    }
986356
public function enableUser($uid): ResponseInterface
    {
        return $this->updateUser(
            Request\UpdateUser::new()
                ->withUid($uid)
                ->markAsEnabled()
        );
    }
1112291
public function toOpenId($userId, $agentId)
    {
        $params = array(
                'userid' => $userId,
                'agentid' => $agentId,
            );

        return $this->http->jsonPost(self::API_TO_OPENID, $params);
    }
827438
public function enableUser($id)
    {
        /** @var UserInterface $user */
        $user = $this->userRepository->findUserById($id);
        $user->setEnabled(true);
        $this->em->persist($user);
        $this->em->flush();

        return $user;
    }
1088661
public function activateUser($featureName, $userId)
    {
        $feature = $this->getFeature($featureName);
        $feature->addUser($userId);
        $this->saveFeature($feature);
    }
646343
public function generateToken($userId)
    {
        $user = $this->users->find($userId);

        if (! is_null($user)) {
            $user->generateActivationToken();
            $user->setStatus(Status::INACTIVE);
        }
    }
390539
public function activeForUser($userId)
    {
        return $this->forUser($userId)->reject(function ($client) {
            return $client->revoked;
        })->values();
    }
916824
public function removeUser($userId)
    {
        if (true === is_numeric($userId) && true === in_array($userId, $this->users)) {
            foreach (array_keys($this->users, (int)$userId, true) as $key) {
                unset($this->users[$key]);
            }
        }
        return $this;
    }
357
public static function add_contact(int $userid, int $contactid) {
        global $DB;

        $messagecontact = new \stdClass();
        $messagecontact->userid = $userid;
        $messagecontact->contactid = $contactid;
        $messagecontact->timecreated = time();
        $messagecontact->id = $DB->insert_record('message_contacts', $messagecontact);

        $eventparams = [
            'objectid' => $messagecontact->id,
            'userid' => $userid,
            'relateduserid' => $contactid,
            'context' => \context_user::instance($userid)
        ];
        $event = \core\event\message_contact_added::create($eventparams);
        $event->add_record_snapshot('message_contacts', $messagecontact);
        $event->trigger();
    }