Returns an array of constructed rules.

@param User       $user
@param Model|null $model

@return array
194601
protected function rules(User $user, Model $model = null)
    {
        $rules = [];

        foreach ($this->getRules() as $rule) {
            $rules[] = new $rule($user, $model);
        }

        return $rules;
    }
468381
public function includeAbilities(User $user)
    {
        $abilities = isset($user->selected_context_id) ? $user->selected_context->abilities : [];

        return $this->collection($abilities, new AbilityTransformer, 'ability');
    }
928370
protected function loadRecordData(User $user)
    {
        $this->setData($user->getData());

        // 清空更改状态
        $this->isChanged = false;
        $this->changedData = [];
    }
732972
public static function getNonBlameds($user = null)
    {
        $noInit = static::buildNoInitModel();
        /* @var $noInit static */
        $createdByAttribute = $noInit->createdByAttribute;
        if (!$user) {
            $user = \Yii::$app->user->identity;
        }
        $cond = [
            $createdByAttribute => $user->getGUID(),
            $noInit->multiBlamesAttribute => ''
        ];
        return static::find()->where($cond)->all();
    }
1055231
public function userPendingItems(Member $user)
    {
        // Don't restrict anything for ADMIN users
        $userInstances = DataList::create(WorkflowInstance::class)
            ->where('"WorkflowStatus" != \'Complete\'')
            ->sort('LastEdited DESC');

        if (Permission::checkMember($user, 'ADMIN')) {
            return $userInstances;
        }
        $instances = new ArrayList();
        foreach ($userInstances as $inst) {
            $instToArray = $inst->getAssignedMembers();
            if (!count($instToArray)>0 || !in_array($user->ID, $instToArray->column())) {
                continue;
            }
            $instances->push($inst);
        }

        return $instances;
    }
397210
private function withConfirmationSpecification($user)
    {
        (new EnableUserCommandBuilder($this->container, $this->persistence))->build($user);

        return [
            'command'          => WithConfirmationSignUpUserCommand::class,
            'handler'          => WithConfirmationSignUpUserHandler::class,
            'handlerArguments' => $this->handlerArguments($user),
        ];
    }
1319775
public function getRegistrationsSummaryForUser(User $user)
    {
        $data = [];
        $rsm = $this->createResultSetMappingBuilder('d');
        $rsm->addScalarResult('sbas_id','sbas_id');
        $rsm->addScalarResult('base_id','base_id');
        $rsm->addScalarResult('dbname','dbname');
        $rsm->addScalarResult('time_limited', 'time_limited');
        $rsm->addScalarResult('limited_from', 'limited_from');
        $rsm->addScalarResult('limited_to', 'limited_to');
        $rsm->addScalarResult('actif', 'actif');

        $sql = "
        SELECT dbname, sbas.sbas_id, time_limited,
               UNIX_TIMESTAMP( limited_from ) AS limited_from,
               UNIX_TIMESTAMP( limited_to ) AS limited_to,
               bas.server_coll_id, Users.id, basusr.actif,
               bas.base_id, " . $rsm->generateSelectClause(['d' => 'd',]) . "
        FROM (Users, bas, sbas)
          LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )
          LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )
        WHERE basusr.actif = 1 AND bas.sbas_id = sbas.sbas_id
        AND Users.id = ?";

        $query = $this->_em->createNativeQuery($sql, $rsm);
        $query->setParameter(1, $user->getId());

        foreach ($query->getResult() as $row) {
            $registrationEntity = $row[0];
            $data[$row['sbas_id']][$row['base_id']] = [
                'base-id' => $row['base_id'],
                'db-name' => $row['dbname'],
                'active' => (Boolean) $row['actif'],
                'time-limited' => (Boolean) $row['time_limited'],
                'in-time' => $row['time_limited'] && ! ($row['limited_from'] >= time() && $row['limited_to'] <= time()),
                'registration' => $registrationEntity
            ];
        }

        return $data;
    }
534340
private function listUserAuthorizedCollections(User $user)
    {
        $acl = $this->getAclForUser($user);
        $rights = $acl->get_bas_rights();
        $bases = $acl->get_granted_base();

        $grants = [];

        $statusMapper = new RestrictedStatusExtractor($acl, $this->getApplicationBox());

        foreach ($bases as $base) {
            $baseGrants = [];

            foreach ($rights as $right) {
                if (!$acl->has_right_on_base($base->get_base_id(), $right)) {
                    continue;
                }

                $baseGrants[] = $right;
            }

            $grants[] = [
                'databox_id'    => $base->get_sbas_id(),
                'base_id'       => $base->get_base_id(),
                'collection_id' => $base->get_coll_id(),
                'name'          => $base->get_name(),
                'logo'          => $base->get_binary_minilogos() ? base64_encode($base->get_binary_minilogos()) : '',
                'labels'        => [
                    'fr' => $base->get_label('fr'),
                    'en' => $base->get_label('en'),
                    'de' => $base->get_label('de'),
                    'nl' => $base->get_label('nl'),
                ],
                'rights'        => $baseGrants,
                'statuses'      => $statusMapper->getRestrictedStatuses($base->get_base_id())
            ];
        }

        return $grants;
    }
320450
protected function delete(User $user, Model $model)
    {
        if (
            $this->isUsingSoftDeletes($model) &&
            ! $model->trashed() &&
            $user->isDisabled()
        ) {
            // If deleting is enabled, the model supports soft deletes, the model
            // isn't already deleted, and the LDAP user is disabled, we'll
            // go ahead and delete the users model.
            $model->delete();

            if ($this->isLogging()) {
                $type = get_class($user->getSchema());

                logger()->info("Soft-deleted user {$user->getCommonName()}. Their {$type} user account is disabled.");
            }
        }
    }
501909
public function loginByRecord(User $user)
    {
        $this->loadRecordData($user);
        $this->session['user'] = $user->toArray($this->sessionFields);
        wei()->event->trigger('userLogin', [$user]);

        return ['code' => 1, 'message' => '登录成功'];
    }
842922
public function scopeOfUser(Builder $builder, Model $user): Builder
    {
        return $builder->where('user_type', $user->getMorphClass())->where('user_id', $user->getKey());
    }
1162958
public function manageRoles(User $user)
    {
        $this->authorize('roles', $user);

        $roles = Role::all();

        return view('laralum_users::roles', ['user' => $user, 'roles' => $roles]);
    }
761122
private function serializeRestrictions(User $user)
    {
        return [
            'disabled' => !$user->isEnabled(),
            'removed' => $user->isRemoved(),
            'dates' => DateRangeNormalizer::normalize($user->getInitDate(), $user->getExpirationDate()),
        ];
    }
52167
public function rules(): array
    {
        $user = $this->route('role') ?? new Role();
        $user->updateRulesUniques();
        $rules = $user->getRules();
        $rules['abilities'] = 'nullable|array';

        return $rules;
    }
547019
public function sendCreationMessage(User $user)
    {
        $locale = $this->container->get('claroline.manager.locale_manager')->getLocale($user);
        $url = $this->router->generate(
            'claro_security_validate_email',
            ['hash' => $user->getEmailValidationHash()],
            UrlGeneratorInterface::ABSOLUTE_URL
        );
        $placeholders = [
            'first_name' => $user->getFirstName(),
            'last_name' => $user->getLastName(),
            'username' => $user->getUsername(),
            'password' => $user->getPlainPassword(),
            'validation_mail' => $url,
        ];
        $subject = $this->templateManager->getTemplate('claro_mail_registration', $placeholders, $locale, 'title');
        $body = $this->templateManager->getTemplate('claro_mail_registration', $placeholders, $locale);

        return $this->send($subject, $body, [$user], null, [], true);
    }
1238953
private function getPermissionTable(User $user) {
		$userId = $user->getId();
		if ($this->permissionTable->has($userId)) {
			return $this->permissionTable->get($userId);
		}

		// always allow what guests can do
		$guestGroup = GroupQuery::create()->findOneByIsGuest(true);

		// collect groups from user
		$groups = GroupQuery::create()->filterByUser($user)->find();
		$userGroup = GroupQuery::create()->filterByOwnerId(($userId))->findOne();
		if ($userGroup) {
			$groups[] = $userGroup;
		}
		$groups[] = $guestGroup;

		// ... structure them
		$permissionTable = new Set();
		foreach ($groups as $group) {
			foreach ($group->getActions() as $action) {
				$permissionTable->add($action->getId());
			}
		}

		$this->permissionTable->set($userId, $permissionTable);

		return $this->permissionTable->get($userId);
	}
366560
public function getResumableDeliveries(User $user)
    {
        $deliveryExecutionService = ServiceProxy::singleton();
        $resumable = array();
        foreach ($this->getResumableStates() as $state) {
            foreach ($deliveryExecutionService->getDeliveryExecutionsByStatus($user->getIdentifier(), $state) as $execution) {
                $delivery = $execution->getDelivery();
                if ($delivery->exists()) {
                    $resumable[] = $execution;
                }
            }
        }
        return $resumable;
    }