Load default profiles

@return void
182370
protected function loadDefaultProfiles()
    {
        $defaultProfiles = [];

        if (isset($this->profiles['default'])) {
            $defaultProfiles = $this->getArrayFromValue(
                $this->profiles['default']
            );
        }

        array_map([$this, 'loadProfileByKey'], $defaultProfiles);
    }
664671
private function load()
    {
        // Load default settings
        if (!$this->load_from_file('defaults.inc.php')) {
            $this->errors[] = 'defaults.inc.php was not found.';
        }

        // load main config file
        if (!$this->load_from_file('config.inc.php')) {
            // Old configuration files
            if (!$this->load_from_file('main.inc.php') || !$this->load_from_file('db.inc.php')) {
                $this->errors[] = 'config.inc.php was not found.';
            }
            else if (rand(1,100) == 10) {  // log warning on every 100th request (average)
                trigger_error("config.inc.php was not found. Please migrate your config by running bin/update.sh", E_USER_WARNING);
            }
        }

        // load host-specific configuration
        $this->load_host_config();

        // set skin (with fallback to old 'skin_path' property)
        if (empty($this->prop['skin'])) {
            if (!empty($this->prop['skin_path'])) {
                $this->prop['skin'] = str_replace('skins/', '', unslashify($this->prop['skin_path']));
            }
            else {
                $this->prop['skin'] = self::DEFAULT_SKIN;
            }
        }

        // larry is the new default skin :-)
        if ($this->prop['skin'] == 'default') {
            $this->prop['skin'] = self::DEFAULT_SKIN;
        }

        // fix paths
        foreach (array('log_dir' => 'logs', 'temp_dir' => 'temp') as $key => $dir) {
            foreach (array($this->prop[$key], '../' . $this->prop[$key], RCUBE_INSTALL_PATH . $dir) as $path) {
                if ($path && ($realpath = realpath(unslashify($path)))) {
                    $this->prop[$key] = $realpath;
                    break;
                }
            }
        }

        // fix default imap folders encoding
        foreach (array('drafts_mbox', 'junk_mbox', 'sent_mbox', 'trash_mbox') as $folder) {
            $this->prop[$folder] = rcube_charset::convert($this->prop[$folder], RCUBE_CHARSET, 'UTF7-IMAP');
        }

        // set PHP error logging according to config
        if ($this->prop['debug_level'] & 1) {
            ini_set('log_errors', 1);

            if ($this->prop['log_driver'] == 'syslog') {
                ini_set('error_log', 'syslog');
            }
            else {
                ini_set('error_log', $this->prop['log_dir'].'/errors');
            }
        }

        // enable display_errors in 'show' level, but not for ajax requests
        ini_set('display_errors', intval(empty($_REQUEST['_remote']) && ($this->prop['debug_level'] & 4)));

        // remove deprecated properties
        unset($this->prop['dst_active']);

        // export config data
        $GLOBALS['CONFIG'] = &$this->prop;
    }
182666
public function LoadDefaults()
	{
		$fms = $this->_phreezer->GetFieldMaps(get_class($this));

		foreach ($fms as $fm)
		{
			$prop = $fm->PropertyName;
			$this->$prop = $fm->DefaultValue;
		}
	}
174680
private Set<String> doGetDefaultProfiles() {
        synchronized (defaultProfiles) {
            if (defaultProfiles.isEmpty()) {
                String[] profiles = getProfilesFromSystemProperty(DEFAULT_PROFILES_PROPERTY_NAME);
                if (profiles != null) {
                    setDefaultProfiles(profiles);
                    String[] defaultProfiles = getDefaultProfiles();
                    if (defaultProfiles.length > 0) {
                        log.info("Default profiles [" + StringUtils.joinCommaDelimitedList(defaultProfiles) + "]");
                    }
                }
            }
            return defaultProfiles;
        }
    }
959110
public function loadDefaults()
    {
        // Obtain Default and Current Site Config:
        
        $default = SiteConfig::create();
        $current = SiteConfig::current_site_config();
        
        // Check App Title:
        
        if (!is_null($this->config()->title)) {
            
            // Update Site Title:
            
            if ($current->Title == $default->Title) {
                $current->Title = $this->config()->title;
            }
            
        }
        
        // Check App Tagline:
        
        if (!is_null($this->config()->tagline)) {
            
            // Update Site Tagline:
            
            if ($current->Tagline == $default->Tagline) {
                $current->Tagline = $this->config()->tagline;
            }
            
        }
        
        // Save Site Config Changes:
        
        if ($current->isChanged('Title') || $current->isChanged('Tagline')) {
            
            if ($current->isChanged('Title')) {
                
                DB::alteration_message(
                    sprintf(
                        'Updating App Title to "%s"',
                        $current->Title
                    ),
                    'changed'
                );
                
            }
            
            if ($current->isChanged('Tagline')) {
                
                DB::alteration_message(
                    sprintf(
                        'Updating App Tagline to "%s"',
                        $current->Tagline
                    ),
                    'changed'
                );
                
            }
            
            $current->write();
            
        }
        
    }
508969
public static function loadAll()
  {
    $list = [];
    foreach (self::getProfileList() as $definition) {
      $list[$definition['name']] = self::loadProfileByName($definition['name']);
    }
    return $list;
  }
101285
def load(self):
        
        self.minimum_needs = self.settings.value('MinimumNeeds')

        if not self.minimum_needs or self.minimum_needs == '':
            # Load the most relevant minimum needs
            # If more than one profile exists, just use defaults so
            # the user doesn't get confused.
            profiles = self.get_profiles()
            if len(profiles) == 1:
                profile = self.get_profiles()[0]
                self.load_profile(profile)
            else:
                self.minimum_needs = self._defaults()
942706
protected function findProfile()
	{
		$adapter_profile = $this->getAdapterProfile();
		$ProfileModel = $this->config['db']['profilemodel'];
		$UserModel = $this->config['db']['usermodel'];
		$user = NULL;

		//check if the provider profile already exists
		$profile_builder = call_user_func_array(
			"$ProfileModel::where",
			array('provider', $this->provider)
		);

		if ($profile = $profile_builder->where('identifier', $adapter_profile->identifier)->first())
		{
			//we found an existing user
			$user = $profile->user()->first();
		}
		elseif ($adapter_profile->email)
		{
			//it's a new profile, but it may not be a new user, so check the users by email
			$user_builder = call_user_func_array(
				"$UserModel::where",
				array('email', $adapter_profile->email)
			);

			$user = $user_builder->first();
		}

		//if we haven't found a user, we need to create a new one
		if (!$user)
		{
			$user = new $UserModel();

			//map in anything from the profile that we want in the User
			$map = $this->config['db']['profiletousermap'];

			foreach ($map as $apkey => $ukey)
			{
				$user->$ukey = $adapter_profile->$apkey;
			}

			$values = $this->config['db']['uservalues'];

			foreach ($values as $key=>$value)
			{
				if (is_callable($value))
				{
					$user->$key = $value($user, $adapter_profile);
				}
				else
				{
					$user->$key = $value;
				}
			}

			//$user->username = $adapter_profile->email;
			$user->email = $adapter_profile->email;

			if (!$user->save($this->config['db']['userrules']))
			{
				return NULL;
			}
		}

		//if we didn't find the profile, we need to create a new one
		if (!$profile)
		{
			$profile = $this->createProfileFromAdapterProfile($adapter_profile, $user);
		}
		//if we did find a profile, make sure we update any changes to the source
		else
		{
			$profile = $this->applyAdapterProfileToExistingProfile($adapter_profile, $profile);
		}

		if (!$profile->save())
		{
			return NULL;
		}

		return $profile;
	}
722135
public function bootstrap()
    {

        // setup autoloader
        require SERVER_AUTOLOADER;

        // make the application available and register the class loaders
        $application = $this->getApplication();
        $application->registerClassLoaders();

        // register the applications annotation registries
        $application->registerAnnotationRegistries();

        // try to load the profile logger
        if (isset($this->loggers[LoggerUtils::PROFILE])) {
            $this->profileLogger = $this->loggers[LoggerUtils::PROFILE];
            $this->profileLogger->appendThreadContext('timer-factory');
        }
    }
133144
private function loadSettings()
	{
    	// Set initial settings base on the initial config
		$userdefinedsettings = $this->initialConfig->get('settings')?: [];

		$this->initialSettings = new Settings();
		$this->initialSettings->loadSettings($userdefinedsettings);

    	// Set settings
        $userdefinedsettings = $this->config->get('settings')?: [];

		$this->settings = new Settings();
		$this->settings->loadSettings($userdefinedsettings);
    }
197159
protected function load()
    {
        if (!$this->isConfigurationLoaded) {
            $this->values = $this->getDefaults();
            $values = $this->getConfigStore()->load();
            if (is_array($values)) {
                $this->values = array_merge($this->getDefaults(), $values);
            }
            $this->values = $this->castValues($this->values);
            $this->isConfigurationLoaded = true;
        }
    }
358380
def load_default(self):
        ''' 
        '''
        appdir = AppDirs(self.application_name, self.application_author,
                version=self.application_version)
        file_name = os.path.join(appdir.site_data_dir, "{0}.conf".format(
                self.application_name.lower()))
        if os.path.exists(file_name):
            self.load(file_name)
        if os.name is not 'posix' or os.getuid() > 0:
            config_file = os.path.join(appdir.user_data_dir, '{0}.conf'.format(
                    self.application_name.lower()))
            if os.path.exists(config_file):
                self.load(config_file)
265036
public function bootstrap()
    {

        // register the default autoloader
        require SERVER_AUTOLOADER;

        // synchronize the application instance and register the class loaders
        $application = $this->application;
        $application->registerClassLoaders();

        // register the applications annotation registries
        $application->registerAnnotationRegistries();

        // add the application instance to the environment
        Environment::singleton()->setAttribute(EnvironmentKeys::APPLICATION, $application);

        // create s simulated request/session ID whereas session equals request ID
        Environment::singleton()->setAttribute(EnvironmentKeys::SESSION_ID, $sessionId = SessionUtils::generateRandomString());
        Environment::singleton()->setAttribute(EnvironmentKeys::REQUEST_ID, $sessionId);

        // try to load the profile logger
        if ($this->profileLogger = $application->getInitialContext()->getLogger(\AppserverIo\Logger\LoggerUtils::PROFILE)) {
            $this->profileLogger->appendThreadContext(sprintf('queue-worker-%s', $this->priorityKey));
        }
    }
554871
protected function buildProfile() {
		$sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id";
		if ($user = $this->executeQuery($sql,array(":id"=>$this->getSessionUserId()))[0]) {
			unset($user['password']);
			foreach ($user as $field=>$value) {
				$this->profile[$field] = $value;
			}
		}
	}
386740
protected function setupDefaults()
    {
        $defaults = (isset($this->config['defaults'])) ?
            $this->config['defaults'] :
            [];

        foreach ($defaults as $key => $value) {
            if ($key == 'images') {
                if (empty($this->images)) {
                    $this->images = $value;
                }
            } elseif ($key == 'url' && $value === null) {
                $this->setUrl(app('url')->current());
            } elseif (! empty($value) && ! array_key_exists($key, $this->properties)) {
                $this->addProperty($key, $value);
            }
        }
    }
1198782
public function loadConfig() {
        $this->allLocales = config('app.all_locales');
        $this->defaultLocales = config('app.fallback_locale');
        $this->usePrefixForDefault = config('routelocale.default_prefix');
    }
46589
public function getActiveProfiles()
    {
        if ($this->cache->contains($this->activeProfilesSettingName)) {
            $profiles = $this->cache->fetch($this->activeProfilesSettingName);
        } else {
            $profiles = [];
            $allProfiles = $this->getAllProfiles();

            foreach ($allProfiles as $profile) {
                if (!$profile['active']) {
                    continue;
                }

                $profiles[] = $profile['name'];
            }

            $this->cache->save($this->activeProfilesSettingName, $profiles);
        }

        $profiles = array_merge($profiles, $this->activeProfilesList);

        return $profiles;
    }