Skip to content

Commit

Permalink
Merge branch 'unstable' of github.com:vanillaforums/Garden into unstable
Browse files Browse the repository at this point in the history
Conflicts:
	bootstrap.php
	index.php
	library/core/class.auth.php
	library/core/class.session.php
  • Loading branch information
kaecyra committed Jun 28, 2011
2 parents 69af5d9 + 3343382 commit 8b561f0
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 65 deletions.
1 change: 1 addition & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@
// Start Authenticators
Gdn::Authenticator()->StartAuthenticator();


// Include a user-defined bootstrap.
if (file_exists(PATH_ROOT.'/conf/bootstrap.after.php'))
require_once(PATH_ROOT.'/conf/bootstrap.after.php');
Expand Down
8 changes: 3 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,20 @@
// 2. Include the bootstrap to configure the framework.
require_once(PATH_ROOT.'/bootstrap.php');

// 3. Run authenticators.
// 3. Create and configure the dispatcher.
// TIM: Removed this change temporarily for .com hosting
// Gdn::Authenticator()->StartAuthenticator();

// 4. Create and configure the dispatcher.
$Dispatcher = Gdn::Dispatcher();

$EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders();
$Dispatcher->EnabledApplicationFolders($EnabledApplications);
$Dispatcher->PassProperty('EnabledApplications', $EnabledApplications);

// 5. Process the request.
// 4. Process the request.
$Dispatcher->Dispatch();
$Dispatcher->Cleanup();

// 6. Finish profiling and save results to disk, if requested
// 5. Finish profiling and save results to disk, if requested
if (defined('PROFILER') && PROFILER) {
$xhprof_data = xhprof_disable();

Expand Down
3 changes: 1 addition & 2 deletions library/core/class.auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ public function __construct() {
parent::__construct();
}

public function StartAuthenticator($ForceStart = FALSE) {
public function StartAuthenticator() {
if (!C('Garden.Installed', FALSE) && !$ForceStart) return;

// Start the 'session'
Gdn::Session()->Start(FALSE, FALSE);

Expand Down
96 changes: 38 additions & 58 deletions library/core/class.session.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,7 @@ class Gdn_Session {
*/
protected $_Preferences;


/**
* Whether the session has been started
*
* @var bool
*/
protected $_Started = FALSE;



/**
* The current user's transient key.
*
Expand Down Expand Up @@ -268,46 +260,6 @@ public function IsValid() {
return $this->UserID > 0;
}

/**
* Sets a value in the $this->_Attributes array. This setting will persist
* only to the end of the page load. It is not intended for making permanent
* changes to user attributes.
*
* @param string|array $Name
* @param mixed $Value
* @todo check argument type
*/
public function SetAttribute($Name, $Value = '') {
if (!is_array($Name))
$Name = array($Name => $Value);

foreach($Name as $Key => $Val) {
$this->_Attributes[$Key] = $Val;
}
}

/**
* Sets a value in the $this->_Preferences array. This setting will persist
* changes to user prefs.
*
* @param string|array $Name
* @param mixed $Value
* @todo check argument type
*/
public function SetPreference($Name, $Value = '', $SaveToDatabase = TRUE) {
if (!is_array($Name))
$Name = array($Name => $Value);

foreach($Name as $Key => $Val) {
$this->_Preferences[$Key] = $Val;
}

if ($SaveToDatabase && $this->UserID > 0) {
$UserModel = Gdn::UserModel();
$UserModel->SavePreference($this->UserID, $Name);
}
}

/**
* Authenticates the user with the provided Authenticator class.
*
Expand All @@ -316,7 +268,6 @@ public function SetPreference($Name, $Value = '', $SaveToDatabase = TRUE) {
*/
public function Start($UserID = FALSE, $SetIdentity = TRUE, $Persist = FALSE) {
if (!C('Garden.Installed', FALSE)) return;

// Retrieve the authenticated UserID from the Authenticator module.
$UserModel = Gdn::Authenticator()->GetUserModel();
$this->UserID = $UserID ? $UserID : Gdn::Authenticator()->GetIdentity();
Expand Down Expand Up @@ -364,17 +315,46 @@ public function Start($UserID = FALSE, $SetIdentity = TRUE, $Persist = FALSE) {
// Load guest permissions if necessary
if ($this->UserID == 0)
$this->_Permissions = Gdn_Format::Unserialize($UserModel->DefinePermissions(0));

$this->_Started = TRUE;
}


/**
* Sets a value in the $this->_Attributes array. This setting will persist
* only to the end of the page load. It is not intended for making permanent
* changes to user attributes.
*
* @param string|array $Name
* @param mixed $Value
* @todo check argument type
*/
public function SetAttribute($Name, $Value = '') {
if (!is_array($Name))
$Name = array($Name => $Value);

foreach($Name as $Key => $Val) {
$this->_Attributes[$Key] = $Val;
}
}

/**
* Whether the session has been started yet.
*
* @return bool
* Sets a value in the $this->_Preferences array. This setting will persist
* changes to user prefs.
*
* @param string|array $Name
* @param mixed $Value
* @todo check argument type
*/
public function Started() {
return $this->_Started;
public function SetPreference($Name, $Value = '', $SaveToDatabase = TRUE) {
if (!is_array($Name))
$Name = array($Name => $Value);

foreach($Name as $Key => $Val) {
$this->_Preferences[$Key] = $Val;
}

if ($SaveToDatabase && $this->UserID > 0) {
$UserModel = Gdn::UserModel();
$UserModel->SavePreference($this->UserID, $Name);
}
}

/**
Expand Down

0 comments on commit 8b561f0

Please sign in to comment.