پروفایل کاربر را تعیین می‌کند.

Retrieve the profile of the current user. If not profile in the
database a Pluf_Exception_DoesNotExist exception is thrown,
just catch it and create a profile.

@return Pluf_Model User profile
350742
function getProfile()
    {
        $pclass = Pluf::f('user_profile_class', false);
        if (false === $pclass) {
            throw new Pluf_Exception_SettingError('"user_profile_class" setting not defined.');
        }
        $db = $this->getDbConnection();
        $sql = new Pluf_SQL(sprintf('%s=%%s', $db->qn('user')), array(
            $this->id
        ));
        $users = Pluf::factory($pclass)->getList(array(
            'filter' => $sql->gen()
        ));
        if ($users->count() != 1) {
            throw new Pluf_Exception_DoesNotExist(sprintf('No profiles available for user: %s', (string) $this));
        }
        return $users[0];
    }
795065
public function getUser()
    {
        if (! $this->_user) {
            $request = $this->getRequest();

            $this->_user = $this->loader->getUser($request->getParam($this->usernameFieldName), $request->getParam($this->organizationFieldName));
        }
        return $this->_user;
    }
159482
protected function getProfile(): CrawlProfile
    {
        if (! is_null($this->option('profile'))) {
            return app($this->option('profile'));
        }

        if (config('laravel-link-checker.default_profile') != '') {
            return app(config('laravel-link-checker.default_profile'));
        }

        throw new Exception('Could not determine the profile to be used');
    }
1095013
public function getActiveProfile()
    {
        $profiles = $this->getProfiles();
        $profileId = $this->getProfileId();

        if (!is_array($profiles)) {
            throw new \Exception('<fg=red>The config is invalid</fg=red>');
        }

        foreach ($profiles as $profile) {
            if ($profile['profileId'] == $profileId) {
                return $profile;
            }
        }
    }
437767
public function getOwnerUser()
    {
        $reflection = ClassUtils::newReflectionObject($this);

        if ($reflection->hasMethod('getUser')) {
            return $this->getUser();
        }
        elseif ($reflection->hasMethod('getUserProfile')) {
            return $this->getUserProfile() ? $this->getUserProfile()->getUser() : null;
        }

        return null;
    }
376481
protected function getActiveUser()
    {
        if (!Config::has('culpa.users.active_user')) {
            return Auth::check() ? Auth::user() : null;
        }

        $fn = Config::get('culpa.users.active_user');
        if (!is_callable($fn)) {
            throw new \Exception('culpa.users.active_user should be a closure');
        }

        return $fn();
    }
588123
public function actionBindMobile()
    {
        $model = new UserBindMobileForm();
        $model->load(Yii::$app->getRequest()->getBodyParams(), '');
        if (($user = $model->bind()) != false) {
            Yii::$app->getResponse()->setStatusCode(200);
            return $user;
        } elseif (!$model->hasErrors()) {
            throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
        }
        return $model;
    }
1000429
public function profileAction()
    {
      // fix new implementation of servicelocator
        try {
            $translator = $this->getServiceLocator()->get('MvcTranslator');
        } catch (\Exception $e) {
          //echo ($e->getMessage());
        }
        if (! $this->zfcUserAuthentication()->hasIdentity()) {
            return $this->redirect()->toUrl(
                $this->url()->fromRoute(
                    $this->getOptions()->getLoginRedirectRoute(),
                    array(),
                    array('force_canonical' => true)
                )
            );
        }
        $formEmail     = $this->getChangeEmailForm();
        $formEmail->get('credential')
                  ->setLabel($translator->translate('Your password', 'playgrounduser'))
                  ->setAttributes(array(
                      'type'            => 'password',
                      'class'        => 'large-input',
                      'placeholder'    => $translator->translate('Your password', 'playgrounduser')
                  ));
        $formEmail->get('newIdentity')
                  ->setLabel($translator->translate('Your new email', 'playgrounduser'))
                  ->setAttributes(array(
                      'type'            => 'email',
                      'class'        => 'large-input',
                      'placeholder'    => $translator->translate('Your new email', 'playgrounduser')
                  ));
        $formEmail->get('newIdentityVerify')
                  ->setLabel($translator->translate('Confirm the new email', 'playgrounduser'))
                  ->setAttributes(array(
                      'type'            => 'email',
                      'class'        => 'large-input',
                      'placeholder'    => $translator->translate('Confirm the new email', 'playgrounduser')
                  ));
        $formPassword  = $this->getChangePasswordForm();
        $formPassword->get('credential')
                     ->setLabel($translator->translate('Your current password', 'playgrounduser'))
                     ->setAttributes(array(
                         'class'    => 'large-input',
                         'type'        => 'password',
                         'placeholder' => $translator->translate('Your current password', 'playgrounduser')
                     ));
        $formPassword->get('newCredential')
                     ->setLabel($translator->translate('New Password', 'playgrounduser'))
                     ->setAttributes(array(
                         'class'    => 'large-input',
                         'type'        => 'password',
                         'placeholder' => $translator->translate('New Password', 'playgrounduser')
                     ));
        $formPassword->get('newCredentialVerify')
                     ->setLabel($translator->translate('Verify New Password', 'playgrounduser'))
                     ->setAttributes(array(
                         'class'    => 'large-input',
                         'type'        => 'password',
                         'placeholder' => $translator->translate('Verify New Password', 'playgrounduser')
                     ));
        ;
        $formInfo      = $this->getChangeInfoForm();
        $formPrize     = $this->getPrizeCategoryForm();
        $formBlock     = $this->getBlockAccountForm();
        if ($this->zfcUserAuthentication()->getIdentity()->getState() == 2) {
            $formBlock->get('activate')->setAttribute('value', 1);
            $formBlock->get('submit')->setAttribute('value', $translator->translate('Reactivate my account', 'playgrounduser'));
            $formBlock->get('confirm_submit')->setAttribute('value', $translator->translate('Confirm account reactivation', 'playgrounduser'));
        }

        $categoryService = $this->getServiceLocator()->get('playgroundgame_prizecategoryuser_service');
        $categoriesUser = $categoryService->getPrizeCategoryUserMapper()->findBy(array('user' => $this->zfcUserAuthentication()->getIdentity()));
        $existingCategories = array();

        foreach ($categoriesUser as $categoryUser) {
            $existingCategories[] = $categoryUser->getPrizeCategory()->getId();
        }

        $formPrize->get('prizeCategory')->setAttribute('value', $existingCategories);

        $request = $this->getRequest();
        // I don't want to rely on the browser's info for these key datas
        $request->getPost()->set(
            'identity',
            $this->getUserService()->getAuthService()->getIdentity()->getEmail()
        );
        $request->getPost()->set(
            'email',
            $this->getUserService()->getAuthService()->getIdentity()->getEmail()
        );
        $userId = $this->getUserService()->getAuthService()->getIdentity()->getId();

        $user = $this->getUserService()->getUserMapper()->findById($userId);
        $formInfo->bind($user);

        $username = $formInfo->get('username')->getValue();
        $userFirstLastName = $user->getFirstName().' '.substr($user->getLastName(), 0, 1);
        if (empty($username) || $username == $userFirstLastName) {
            $usernamePoint = '+ 150 pts';
        } else {
            $usernamePoint = '';
        }

        $fmPassword = $this->flashMessenger()->setNamespace('change-password')->getMessages();

        if (isset($fmPassword[0])) {
            $statusPassword = $fmPassword[0];
        } else {
            $statusPassword = null;
        }

        $fmEmail = $this->flashMessenger()->setNamespace('change-email')->getMessages();
        if (isset($fmEmail[0])) {
            $statusEmail = $fmEmail[0];
        } else {
            $statusEmail = null;
        }

        $fmInfo = $this->flashMessenger()->setNamespace('change-info')->getMessages();
        if (isset($fmInfo[0])) {
            $statusInfo = $fmInfo[0];
        } else {
            $statusInfo = null;
        }

        if ($request->isPost() && array_key_exists('firstname', $this->params()->fromPost())) {
            $result = false;
            $data = $request->getPost()->toArray();

            $file = $this->params()->fromFiles('avatar');
            if ($file['name']) {
                $data = array_merge(
                    $data,
                    ['avatar' => $file['name']]
                );
            }

            $result = $this->getUserService()->updateInfo($data, $user);

            if (! $result) {
                return array(
                    'statusPassword' => null,
                    'changePasswordForm' => $formPassword,
                    'statusEmail' => null,
                    'changeEmailForm' => $formEmail,
                    'statusInfo' => false,
                    'changeInfoForm' => $formInfo,
                    'prizeCategoryForm' => $formPrize,
                    'blockAccountForm' => $formBlock,
                    'usernamePoint' => $usernamePoint,
                );
            }

            $this->flashMessenger()->setNamespace('change-info')->addMessage(true);

            $redirect = (!empty($this->params()->fromQuery('redirect')))?
                $this->params()->fromQuery('redirect'):
                $this->getRequest()->getUri();

            return $this->redirect()->toUrl($redirect);
        }

        $redirectUrl = $this->getRequest()->getUri();

        $prg = $this->prg($redirectUrl, true);

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
            'statusPassword' => $statusPassword,
            'changePasswordForm' => $formPassword,
            'statusEmail' => $statusEmail,
            'changeEmailForm' => $formEmail,
            'statusInfo' => $statusInfo,
            'changeInfoForm' => $formInfo,
            'prizeCategoryForm' => $formPrize,
            'blockAccountForm' => $formBlock,
            'usernamePoint' => $usernamePoint,
            );
        }

        if (isset($prg['newCredential'])) {
            $formPassword->setData($prg);
            if (! $formPassword->isValid()) {
                $messages = $formPassword->getMessages();
                if (isset($messages['credential']) && isset($messages['credential']['isEmpty'])) {
                    $messages['credential']['isEmpty'] = 'Saisissez votre mot de passe actuel';
                }
                if (isset($messages['newCredential']) && isset($messages['newCredential']['isEmpty'])) {
                    $messages['newCredential']['isEmpty'] = 'Saisissez votre nouveau mot de passe';
                }
                if (isset($messages['newCredentialVerify']) && isset($messages['newCredentialVerify']['isEmpty'])) {
                    $messages['newCredentialVerify']['isEmpty'] = 'Confirmation du mot de passe ';
                }
                $formPassword->setMessages($messages);

                return array(
                    'statusPassword' => false,
                    'changePasswordForm' => $formPassword,
                    'statusEmail' => null,
                    'changeEmailForm' => $formEmail,
                    'statusInfo' => null,
                    'changeInfoForm' => $formInfo,
                    'prizeCategoryForm' => $formPrize,
                    'blockAccountForm' => $formBlock,
                    'usernamePoint' => $usernamePoint,
                    );
            }

            if (! $this->getUserService()->changePassword($formPassword->getData())) {
                return array(
                'statusPassword' => false,
                'changePasswordForm' => $formPassword,
                'statusEmail' => null,
                'changeEmailForm' => $formEmail,
                'statusInfo' => null,
                'changeInfoForm' => $formInfo,
                'prizeCategoryForm' => $formPrize,
                'blockAccountForm' => $formBlock,
                'usernamePoint' => $usernamePoint,
                );
            }

            $this->flashMessenger()
                ->setNamespace('change-password')
                ->addMessage(true);

            return $this->redirect()->toUrl($this->getRequest()->getUri());
        } elseif (isset($prg['newIdentity'])) {
            $formEmail->setData($prg);

            if (! $formEmail->isValid()) {
                $messages = $formEmail->getMessages();
                if (isset($messages['newIdentity']) && isset($messages['newIdentity']['isEmpty'])) {
                    $messages['newIdentity']['isEmpty'] = 'Saisissez votre nouvel email';
                }
                if (isset($messages['newIdentity']) && isset($messages['newIdentity']['recordFound'])) {
                    $messages['newIdentity']['recordFound'] = 'Cet email existe déjà';
                }
                if (isset($messages['newIdentityVerify']) && isset($messages['newIdentityVerify']['isEmpty'])) {
                    $messages['newIdentityVerify']['isEmpty'] = 'Confirmer votre nouvel email';
                }
                if (isset($messages['newIdentityVerify']) && isset($messages['newIdentityVerify']['notSame'])) {
                    $messages['newIdentityVerify']['notSame'] = 'Les deux emails ne correspondent pas';
                }
                $formEmail->setMessages($messages);

                return array(
                    'statusPassword' => null,
                    'changePasswordForm' => $formPassword,
                    'statusEmail' => false,
                    'changeEmailForm' => $formEmail,
                    'statusInfo' => null,
                    'changeInfoForm' => $formInfo,
                    'prizeCategoryForm' => $formPrize,
                    'blockAccountForm' => $formBlock,
                    'usernamePoint' => $usernamePoint,
                );
            }

            $change = $this->getUserService()->changeEmail($prg);

            if (! $change) {
                $this->flashMessenger()
                ->setNamespace('change-email')
                ->addMessage(false);

                return array(
                    'statusPassword' => null,
                    'changePasswordForm' => $formPassword,
                    'statusEmail' => false,
                    'changeEmailForm' => $formEmail,
                    'statusInfo' => null,
                    'changeInfoForm' => $formInfo,
                    'prizeCategoryForm' => $formPrize,
                    'blockAccountForm' => $formBlock,
                    'usernamePoint' => $usernamePoint,
                );
            }

            $this->flashMessenger()
            ->setNamespace('change-email')
            ->addMessage(true);

            return $this->redirect()->toUrl($this->getRequest()->getUri());
        }

        return array(
            'statusPassword' => null,
            'changePasswordForm' => $formPassword,
            'statusEmail' => null,
            'changeEmailForm' => $formEmail,
            'statusInfo' => null,
            'changeInfoForm' => $formInfo,
            'prizeCategoryForm' => $formPrize,
            'blockAccountForm' => $formBlock,
            'usernamePoint' => $usernamePoint,
            );
    }
244463
function getProfile() {

		$profile['users_id'] = $this->userId;
		foreach ( $this->profileMetaKeys as $key => $type ) {
			$profile[ $key ] = get_user_meta( $this->userId, $key, true );
		}

		return $profile;
	}
942105
public final function getCurrentUser()
    {
        if (! self::$currentUser) {
            if ($this->session->__isset('__user_definition')) {
                $defName = $this->session->__get('__user_definition');

                // Check for during upgrade. Remove for version 1.6
                if (substr($defName, -10, 10) != 'Definition') {
                    $defName .= 'Definition';
                }

                self::$currentUser = $this->_loadClass('User', true, array($this->session, $this->_getClass($defName)));

            } else {
                if (\MUtil_Console::isConsole()) {
                    if (! $this->project->isConsoleAllowed()) {
                        echo "Accessing " . GEMS_PROJECT_NAME . " from the command line is not allowed.\n";
                        exit;
                    }


                    $request = \Zend_Controller_Front::getInstance()->getRequest();

                    if (($request instanceof \MUtil_Controller_Request_Cli) && $request->hasUserLogin()) {
                        $user = $this->getUser($request->getUserName(), $request->getUserOrganization());

                        $authResult = $user->authenticate($request->getUserPassword());
                        if (! $authResult->isValid()) {
                            echo "Invalid user login data.\n";
                            echo implode("\n", $authResult->getMessages());
                            exit;
                        }
                        self::$currentUser = $user;

                    } elseif ($this->project->getConsoleRole()) {
                        // \MUtil_Echo::track($this->request->getUserName(), $this->request->getUserOrganization());
                        self::$currentUser = $this->loadUser(self::USER_CONSOLE, 0, '(system)');
                    }

                }
                if (! self::$currentUser) {
                    self::$currentUser = $this->getUser(null, self::SYSTEM_NO_ORG);
                }
                self::$currentUser->setAsCurrentUser();
           }
        }

        return self::$currentUser;
    }
357820
public function getClient() {
		if ($this->client === null) {
			$connectionString  = $this->getConnectionString();
			$connectionOptions = $this->getConnectionOptions();

			if ($this->_profilerEnabled) {
				$event = $this->getProfiler()->startInfo('Connect: ' . $connectionString);
			}

			$attempts = $this->connectionAttempts;

			do {
				try {
					$this->client = new MongoClient($connectionString, $connectionOptions);
				}
				catch (MongoConnectionException $exception) {
					sleep($this->connectionTimeout);
				}
				catch (Exception $exception) {
					if ($this->_profilerEnabled) {
						$event->stopError();
					}
				}
			} while ($this->client === null && -- $attempts > 0);

			if ($this->client === null) {
				if ($this->_profilerEnabled) {
					$event->stopError();
				}

				if (isset($exception)) {
					throw new Exceptions\ConnectionError('Unable to connect to the database', $exception->getCode(), $exception);
				} else {
					$exception = new Exceptions\ConnectionError('Unable to connect to the database, after ' . $this->connectionAttempts . ' attempts');
				}

				throw $exception;
			}

			if ($this->_profilerEnabled) {
				if (isset($exception)) {
					$event->stopNotice();
				} else {
					$event->stopSuccess();
				}

				$this->putDetailInfoIntoProfiler();
			}
		}

		return $this->client;
	}
1221615
public function getProfiles(){
        if($this->loadProfiles != 'ALL'){
            $this->connection->select('name');
            $this->connection->from($this->tableProfile);
            $profiles= $this->connection->get()->fetchAll(\PDO::FETCH_ASSOC);
            foreach ($profiles as $profile) {
                $this->getProfile($profile['name']);
            }
            $this->loadModules= 'ALL';
        }
        return $this->profiles;
    }
181284
public function getProfiler() {
		if ($this->_profiler === null) {
			$this->_profiler = new Profiler();
			$this->onProfilerInit($this->_profiler);
		}
		
		return $this->_profiler;
	}
1284545
public function user()
    {
        // If we've already retrieved the user for the current request we can just
        // return it back immediately. We do not want to fetch the user data on
        // every call to this method because that would be tremendously slow.
        if (! is_null($this->user)) {
            return $this->user;
        }

        $user = null;

        // If a user ID was provided in the JWT, then
        // we should attempt to fetch their profile.
        if (! empty($this->id())) {
            $user = $this->provider->retrieveById($this->id());
        }

        return $this->user = $user;
    }
829035
public function actionPassword()
    {
        $model = new UserSettingsForm();
        $model->load(Yii::$app->request->post(), '');
        if ($model->save()) {
            Yii::$app->getResponse()->setStatusCode(200);
            return $model;
        } elseif (!$model->hasErrors()) {
            throw new ServerErrorHttpException('Failed to create the object for unknown reason.');
        }
        return $model;
    }
689771
public function getCurrentUser()
    {
        if (Towel::isCli()) {
          return false; //Cli is not logged.
        }

        $userRecord = $this->session()->get('user', false);
        if (!$userRecord) {
            return false;
        }

        $userModel = $this->getInstance('user_model');
        $userModel->setRecord($userRecord);

        return $userModel;
    }
1249764
public function getCurrentUser()
    {
        if ($token = $this->tokenStorage->getToken()) {
            if (($user = $token->getUser()) && is_object($user)) {
                return $user;
            }
        }

        throw new \Exception('Authorization needed', ErrorCode::CODE_UNAUTHORIZED);
    }