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;

		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);
		Config::set('fullscreen', $this->fullscreen);

		// Inherit permissions
		$always = array('alexf');
		$depends = array('modules', 'themes', 'pagemounts', 'alpty', 'filemounts', 'fop', 'forms', 'formp', 'imageSizes', 'amg');

		// 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');
			}
		}

		// Hide the "admin" field if the user is not an admin (see #184)
		if (!$this->isAdmin && ($index = array_search('tl_user::admin', $this->alexf)) !== false)
		{
			unset($this->alexf[$index]);
		}
	}
protected function setUserFromDb()
	{
		$this->intId = $this->id;

		
		foreach ($this->arrData as $k=>$v)
		{
			if (!is_numeric($v))
			{
				$this->$k = StringUtil::deserialize($v);
			}
		}

		$GLOBALS['TL_USERNAME'] = $this->username;

		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);
		Config::set('fullscreen', $this->fullscreen);

		
		$always = array('alexf');
		$depends = array('modules', 'themes', 'pagemounts', 'alpty', 'filemounts', 'fop', 'forms', 'formp', 'imageSizes', 'amg');

		
		if (!empty($GLOBALS['TL_PERMISSIONS']) && \is_array($GLOBALS['TL_PERMISSIONS']))
		{
			$depends = array_merge($depends, $GLOBALS['TL_PERMISSIONS']);
		}

		
		if ($this->inherit == 'group')
		{
			foreach ($depends as $field)
			{
				$this->$field = array();
			}
		}

		
		$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);

					
					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);
					}
				}
			}
		}

		
		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);
		}

		
		$this->arrFilemountIds = $this->filemounts;

		
		if (!$this->isAdmin && !empty($this->filemounts))
		{
			$objFiles = FilesModel::findMultipleByUuids($this->filemounts);

			if ($objFiles !== null)
			{
				$this->filemounts = $objFiles->fetchEach('path');
			}
		}

		
		if (!$this->isAdmin && ($index = array_search('tl_user::admin', $this->alexf)) !== false)
		{
			unset($this->alexf[$index]);
		}
	}
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 ; 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 ) ; Config :: set ( 'fullscreen' , $ this -> fullscreen ) ; // Inherit permissions $ always = array ( 'alexf' ) ; $ depends = array ( 'modules' , 'themes' , 'pagemounts' , 'alpty' , 'filemounts' , 'fop' , 'forms' , 'formp' , 'imageSizes' , 'amg' ) ; // 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' ) ; } } // Hide the "admin" field if the user is not an admin (see #184) if ( ! $ this -> isAdmin && ( $ index = array_search ( 'tl_user::admin' , $ this -> alexf ) ) !== false ) { unset ( $ this -> alexf [ $ index ] ) ; } }
Set all user properties from a database record
Set all user properties from a database record