protected function setUserFromDb()
{
$this->intId = $this->id;
// Unserialize values
foreach ($this->arrData as $k => $v) {
if (!is_numeric($v)) {
$this->{$k} = \StringUtil::deserialize($v);
}
}
$GLOBALS['TL_USERNAME'] = $this->username;
\System::getContainer()->get('request_stack')->getCurrentRequest()->setLocale($this->language);
\System::getContainer()->get('translator')->setLocale($this->language);
// Deprecated since Contao 4.0, to be removed in Contao 5.0
$GLOBALS['TL_LANGUAGE'] = str_replace('_', '-', $this->language);
\Config::set('showHelp', $this->showHelp);
\Config::set('useRTE', $this->useRTE);
\Config::set('useCE', $this->useCE);
\Config::set('thumbnails', $this->thumbnails);
\Config::set('backendTheme', $this->backendTheme);
// Inherit permissions
$always = array('alexf');
$depends = array('modules', 'themes', 'pagemounts', 'alpty', 'filemounts', 'fop', 'forms', 'formp', 'imageSizes');
// HOOK: Take custom permissions
if (!empty($GLOBALS['TL_PERMISSIONS']) && is_array($GLOBALS['TL_PERMISSIONS'])) {
$depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
}
// Overwrite user permissions if only group permissions shall be inherited
if ($this->inherit == 'group') {
foreach ($depends as $field) {
$this->{$field} = array();
}
}
// Merge permissions
$inherit = in_array($this->inherit, array('group', 'extend')) ? array_merge($always, $depends) : $always;
$time = \Date::floorToMinute();
foreach ((array) $this->groups as $id) {
$objGroup = $this->Database->prepare("SELECT * FROM tl_user_group WHERE id=? AND disable!='1' AND (start='' OR start<='{$time}') AND (stop='' OR stop>'" . ($time + 60) . "')")->limit(1)->execute($id);
if ($objGroup->numRows > 0) {
foreach ($inherit as $field) {
$value = \StringUtil::deserialize($objGroup->{$field}, true);
// The new page/file picker can return integers instead of arrays, so use empty() instead of is_array() and StringUtil::deserialize(true) here
if (!empty($value)) {
$this->{$field} = array_merge(is_array($this->{$field}) ? $this->{$field} : ($this->{$field} != '' ? array($this->{$field}) : array()), $value);
$this->{$field} = array_unique($this->{$field});
}
}
}
}
// Make sure pagemounts and filemounts are set!
if (!is_array($this->pagemounts)) {
$this->pagemounts = array();
} else {
$this->pagemounts = array_filter($this->pagemounts);
}
if (!is_array($this->filemounts)) {
$this->filemounts = array();
} else {
$this->filemounts = array_filter($this->filemounts);
}
// Store the numeric file mounts
$this->arrFilemountIds = $this->filemounts;
// Convert the file mounts into paths
if (!$this->isAdmin && !empty($this->filemounts)) {
$objFiles = \FilesModel::findMultipleByUuids($this->filemounts);
if ($objFiles !== null) {
$this->filemounts = $objFiles->fetchEach('path');
}
}
}