Gets the User instance.
@param bool $force If true, forces to load User from storage.
@return CNabuUser|null Returns the User instance if setted or null if not.
433889
public function getUser($force = false)
    {
        if ($this->nb_user === null || $force) {
            $this->nb_user = null;
            if ($this instanceof CNabuDataObject &&
                $this->contains(NABU_USER_FIELD_ID) &&
                $this->isValueNumeric(NABU_USER_FIELD_ID)
            ) {
                $nb_user = new CNabuUser($this->getValue(NABU_USER_FIELD_ID));
                if ($nb_user->isFetched()) {
                    $this->nb_user = $nb_user;
                }
            }
        }

        return $this->nb_user;
    }
515929
public static function loadConfiguration($force = false)
    {
        if ($force === false && static::$isConfigurationLoaded === true)
        {
            return true;
        }

        if (class_exists('\Bitrix\Main\Config\Configuration'))
        {
            $config = Configuration::getInstance()->get('monolog');

            if (is_array($config) && !empty($config))
            {
                Cascade::fileConfig($config);

                return true;
            }
        }

        return false;
    }
824347
public function getRole($force = false)
     {
         if ($this->nb_role === null || $force) {
             $this->nb_role = null;
             if ($this->isValueNumeric('nb_role_id')) {
                 $nb_role = new CNabuRole($this);
                 if ($nb_role->isFetched()) {
                     $this->nb_role = $nb_role;
                 }
             }
         }

         return $this->nb_role;
     }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
706172
function getManager($force=false)
    {
        // Extract the YadisServiceManager for this object's URL and
        // suffix from the session.

        $manager_str = $this->session->get($this->getSessionKey());
        /** @var Auth_Yadis_Manager $manager */
        $manager = null;

        if ($manager_str !== null) {
            $loader = new Auth_Yadis_ManagerLoader();
            $manager = $loader->fromSession(unserialize($manager_str));
        }

        if ($manager && ($manager->forURL($this->url) || $force)) {
            return $manager;
        }
        return null;
    }
914801
public function user($user = null)
    {
        if ($user !== null) {
            $this->user = $user;
        }

        return $this->user;
    }
1040351
public function get_tokens( $force = false ) {
		Hooks::runHook( 'GetTokens', array( &$this->tokens ) );

		if( !$force && !empty( $this->tokens ) ) return $this->tokens;

		$tokens = $this->apiQuery(
			array(
				'action' => 'tokens',
				'type'   => 'block|delete|deleteglobalaccount|edit|email|import|move|options|patrol|protect|setglobalaccountstatus|unblock|watch'
			)
		);

		foreach( $tokens['tokens'] as $y => $z ){
			if( in_string( 'token', $y ) ) {
				$this->tokens[str_replace( 'token', '', $y )] = $z;
			}
		}

		$token = $this->apiQuery(
			array(
				'action'  => 'query',
				'list'    => 'users',
				'ususers' => $this->username,
				'ustoken' => 'userrights'
			)
		);

		if( isset( $token['query']['users'][0]['userrightstoken'] ) ) {
			$this->tokens['userrights'] = $token['query']['users'][0]['userrightstoken'];
		} else {
			pecho( "Error retrieving userrights token...\n\n", PECHO_FATAL );
			return array();
		}

		return $this->tokens;

	}
666360
public function getCommerces($force = false)
    {
        if ($this->nb_commerce_list->isEmpty() || $force) {
            $this->nb_commerce_list->clear();
            $this->nb_commerce_list->merge(CNabuCommerce::getAllCommerces($this));
        }

        return $this->nb_commerce_list->getItems();
    }
452548
public function getUser()
    {
        if ( ! $this->container->has('security')) {
            return false;
        }

        $security = $this->container->get('security');

        if ( ! $token = $security->getToken()) {
            return false;
        }

        $user = $token->getUser();
        if ( ! $user instanceof UserInterface) {
            return false;
        }

        return $user;
    }
602599
protected function touch($force = false)
    {
        if (true === $this->getState()->is('deleted')) {
            return $this;
        }
        if (true === $this->getState()->is('empty') || true === $force) {
            $record = $this->store->retrieveRecord($this->getType(), $this->getId());
            $this->initialize($record['properties']);
            $this->getState()->setLoaded();
        }
        return $this;
    }
222652
public function getSiteRoles(bool $force = false) : CNabuSiteRoleList
    {
        if ($this->nb_site_role_list->isEmpty() || $force) {
            $this->nb_site_role_list->clear();
            $this->nb_site_role_list->merge(CNabuSiteRole::getSiteRolesForSite($this));
        }

        return $this->nb_site_role_list;
    }
785679
public function getItems($force = false)
    {
        if (!$this->isBuiltIn() && ($this->nb_medioteca_item_list->isEmpty() || $force)) {
            $this->nb_medioteca_item_list = CNabuMediotecaItem::getItemsForMedioteca($this);
        }

        return $this->nb_medioteca_item_list;
    }
480805
public function reset($force = false)
    {
        $this->isBroadcast = false;
        $this->to = [];

        if ($force) {
            $this->sender = null;
            $this->userId = null;
        }

        return $this;
    }
1261380
public function user($user = null)
    {
        if ($user !== null) {
            $this->_user = $user;

            return;
        }

        if ($this->_user === false) {
            if (($session = $this->getSession()) && $session->id) {
                $this->_user = auth()->who($session);
            } else {
                $this->_user = null;
            }
        }

        return $this->_user;
    }
646169
public function get($force = false)
    {
        if (is_null($this->settings) || $force) {
            $_settings = $this->db->select()
                ->from($this->getTable())
                ->get();
            $settings = array();
            foreach ($_settings as $setting) {
                // decrypt the value if needed
                if (in_array($setting['setting_key'], $this->getEncrypted()) && ! empty($setting['setting_value'])) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = $this->getEncrypt()->decode($setting['setting_value']);
                }
                
                // unserialize the value
                if (in_array($setting['setting_key'], $this->getSerialized()) && ! empty($setting['setting_value'])) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = unserialize($setting['setting_value']);
                    foreach ($settings[$setting['setting_key']] as $key => $value) {
                        if ($value == '') {
                            unset($settings[$setting['setting_key']][$key]); // remove blank entries
                        }
                    }
                }
                
                // sort out new line values
                if (in_array($setting['setting_key'], $this->getNewLines())) {
                    $settings[$setting['setting_key']] = $setting['setting_value'] = explode("\n", $setting['setting_value']);
                    foreach ($settings[$setting['setting_key']] as $key => $value) {
                        $value = trim($value);
                        if ($value == '') {
                            unset($settings[$setting['setting_key']][$key]); // remove blank entries
                        } else {
                            $settings[$setting['setting_key']][$key] = $value;
                        }
                    }
                }
                
                $settings[$setting['setting_key']] = $setting['setting_value'];
            }
            
            $ignore = array(
                'license_check',
                'license_status'
            );
            foreach ($this->getDefaults() as $key => $value) {
                // setup the override check
                if (isset($this->overrides[$key]) && ! in_array($key, $ignore)) {
                    $settings[$key] = $this->overrides[$key];
                }
                
                if (! isset($settings[$key])) {
                    $settings[$key] = $value;
                }
            }
            
            $this->settings = $settings;
            
            if($this->settings['api_key'] == '')
            {
                $this->settings['api_key'] = $this->getEncrypt()->guid();
            }
            
            if($this->settings['api_secret'] == '')
            {
                $this->settings['api_secret'] = $this->getEncrypt()->guid();
            }            
        }
        
        return $this->settings;
    }
1003591
public function persist($force = false) {
        global $DB;

        if (!$this->dirty && !$force) {
            return $this;
        }

        if ($this->id) {
            $record = $this->to_record();
            $DB->update_record('tool_usertours_steps', $record);
        } else {
            $this->calculate_sortorder();
            $record = $this->to_record();
            unset($record->id);
            $this->id = $DB->insert_record('tool_usertours_steps', $record);
            $this->get_tour()->reset_step_sortorder();
        }

        $this->reload();

        // Notify of a change to the step configuration.
        // This must be done separately to tour change notifications.
        cache::notify_step_change($this->get_tourid());

        // Notify the cache that a tour has changed.
        // Tours are only stored in the cache if there are steps.
        // If there step count has changed for some reason, this will change the potential cache results.
        cache::notify_tour_change();

        return $this;
    }
692607
public function init($force = false)
    {
        $flockFactory = new Factory(new FlockStore());

        $lock = $flockFactory->createLock('propel-cache-generation');

        // Acquire a blocking cache generation lock
        $lock->acquire(true);

        try {
            if ($force) {
                (new Filesystem())->remove($this->getPropelCacheDir());
            }

            if (!file_exists($this->getTheliaDatabaseConfigFile())) {
                return false;
            }

            $this->buildPropelConfig();

            $this->buildPropelInitFile();
            require $this->getPropelInitFile();

            $theliaDatabaseConnection = Propel::getConnection('thelia');
            $this->schemaLocator->setTheliaDatabaseConnection($theliaDatabaseConnection);

            $this->buildPropelGlobalSchema();

            $this->buildPropelModels();
            $this->registerPropelModelLoader();

            $theliaDatabaseConnection->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);

            if ($this->debug) {
                // In debug mode, we have to initialize Tlog at this point, as this class uses Propel
                Tlog::getInstance()->setLevel(Tlog::DEBUG);

                Propel::getServiceContainer()->setLogger('defaultLogger', Tlog::getInstance());
                $theliaDatabaseConnection->useDebug(true);
            }
        } catch (\Throwable $th) {
            $fs = new Filesystem();
            $fs->remove(THELIA_CACHE_DIR . $this->environment);
            $fs->remove($this->getPropelModelDir());
            throw $th;
        } finally {
            // Release cache generation lock
            $lock->release();
        }

        return true;
    }