<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -148,9 +148,6 @@
 	#     &lt;Session&gt;
 	require_once INCLUDES_DIR.&quot;/class/Session.php&quot;;
 
-	if (!JAVASCRIPT)
-		session();
-
 	# File: Flash
 	# See Also:
 	#     &lt;Flash&gt;
@@ -205,13 +202,17 @@
 	#     &lt;Feather&gt;
 	require_once INCLUDES_DIR.&quot;/interface/Feather.php&quot;;
 
+	session();
 	timer_start();
+	set_locale($config-&gt;locale);
 
 	$flash = Flash::current();
 
-	set_locale($config-&gt;locale);
-
-	# Require feathers/modules and load their translations.
+	/**
+	 * Array: $feathers
+	 * Contains all of the enabled Feather's Classes.
+	 */
+	$feathers = array();
 	foreach ($config-&gt;enabled_feathers as $index =&gt; $feather) {
 		if (!file_exists(FEATHERS_DIR.&quot;/&quot;.$feather.&quot;/&quot;.$feather.&quot;.php&quot;)) {
 			unset($config-&gt;enabled_feathers[$index]);
@@ -222,8 +223,26 @@
 			load_translator($feather, FEATHERS_DIR.&quot;/&quot;.$feather.&quot;/locale/&quot;.$config-&gt;locale.&quot;.mo&quot;);
 
 		require FEATHERS_DIR.&quot;/&quot;.$feather.&quot;/&quot;.$feather.&quot;.php&quot;;
+
+		$camelized = camelize($feather);
+		if (!class_exists($camelized))
+			continue;
+
+		$feathers[$feather] = new $camelized;
+		$feathers[$feather]-&gt;safename = $feather;
+
+		if (!ADMIN and $route-&gt;action != &quot;feed&quot;)
+			continue;
+
+		foreach (YAML::load(FEATHERS_DIR.&quot;/&quot;.$feather.&quot;/info.yaml&quot;) as $key =&gt; $val)
+			$feathers[$feather]-&gt;$key = (is_string($val)) ? __($val, $feather) : $val ;
 	}
 
+	/**
+	 * Array: $modules
+	 * Contains all of the enabled Module's Classes.
+	 */
+	$modules = array();
 	foreach ($config-&gt;enabled_modules as $index =&gt; $module) {
 		if (!file_exists(MODULES_DIR.&quot;/&quot;.$module.&quot;/&quot;.$module.&quot;.php&quot;)) {
 			unset($config-&gt;enabled_modules[$index]);
@@ -234,11 +253,31 @@
 			load_translator($module, MODULES_DIR.&quot;/&quot;.$module.&quot;/locale/&quot;.$config-&gt;locale.&quot;.mo&quot;);
 
 		require MODULES_DIR.&quot;/&quot;.$module.&quot;/&quot;.$module.&quot;.php&quot;;
+
+		$camelized = camelize($module);
+		if (!class_exists($camelized))
+			continue;
+
+		$modules[$module] = new $camelized;
+		$modules[$module]-&gt;safename = $module;
+
+		if (!ADMIN)
+			continue;
+
+		foreach (YAML::load(MODULES_DIR.&quot;/&quot;.$module.&quot;/info.yaml&quot;) as $key =&gt; $val)
+			$modules[$module]-&gt;$key = (is_string($val)) ? __($val, $module) : $val ;
 	}
 
-	# Load the /clean/urls into their correct $_GET values.
-	if (INDEX or ADMIN)
-		$route-&gt;determine_action();
+	# Now that they're all instantiated, call __init().
+	foreach ($feathers as $feather)
+		if (method_exists($feather, &quot;__init&quot;))
+			$feather-&gt;__init();
+
+	foreach ($modules as $module)
+		if (method_exists($module, &quot;__init&quot;))
+			$module-&gt;__init();
+
+	$route-&gt;determine_action();
 
 	# Variable: $visitor
 	# Holds the current user and their group.
@@ -251,11 +290,11 @@
 	$theme = PREVIEWING ? $_GET['theme'] : $config-&gt;theme;
 
 	# Constant: THEME_DIR
-	# Absolute path to /themes/(current theme)
+	# Absolute path to /themes/(current/previewed theme)
 	define('THEME_DIR', MAIN_DIR.&quot;/themes/&quot;.$theme);
 
 	# Constant: THEME_URL
-	# URL to /themes/(current theme)
+	# URL to /themes/(current/previewed theme)
 	define('THEME_URL', $config-&gt;chyrp_url.&quot;/themes/&quot;.$theme);
 
 	$theme = Theme::current();
@@ -263,56 +302,7 @@
 	foreach (YAML::load(THEME_DIR.&quot;/info.yaml&quot;) as $key =&gt; $val)
 		$theme-&gt;$key = $val;
 
-	if (INDEX)
-		header(&quot;Content-type: &quot;.fallback($theme-&gt;type, &quot;text/html&quot;).&quot;; charset=UTF-8&quot;);
-	elseif (AJAX)
-		header(&quot;Content-type: text/html; charset=UTF-8&quot;);
-
-	# These are down here so that the modules are
-	# initialized after the $_GET values are filled.
-	/**
-	 * Array: $feathers
-	 * Contains all of the enabled Feather's Classes.
-	 */
-	$feathers = array();
-	foreach ($config-&gt;enabled_feathers as $feather) {
-		$camelized = camelize($feather);
-		if (!class_exists($camelized)) continue;
-
-		$feathers[$feather] = new $camelized;
-		$feathers[$feather]-&gt;safename = $feather;
-
-		if (!ADMIN and $route-&gt;action != &quot;feed&quot;) continue;
-
-		foreach (YAML::load(FEATHERS_DIR.&quot;/&quot;.$feather.&quot;/info.yaml&quot;) as $key =&gt; $val)
-			$feathers[$feather]-&gt;$key = (is_string($val)) ? __($val, $feather) : $val ;
-	}
-
-	/**
-	 * Array: $modules
-	 * Contains all of the enabled Module's Classes.
-	 */
-	$modules = array();
-	foreach ($config-&gt;enabled_modules as $module) {
-		$camelized = camelize($module);
-		if (!class_exists($camelized)) continue;
-
-		$modules[$module] = new $camelized;
-		$modules[$module]-&gt;safename = $module;
-
-		if (!ADMIN) continue;
-
-		foreach (YAML::load(MODULES_DIR.&quot;/&quot;.$module.&quot;/info.yaml&quot;) as $key =&gt; $val)
-			$modules[$module]-&gt;$key = (is_string($val)) ? __($val, $module) : $val ;
-	}
-
-	# Now that they're all instantiated, call __init().
-	foreach ($feathers as $feather)
-		if (method_exists($feather, &quot;__init&quot;))
-			$feather-&gt;__init();
-	foreach ($modules as $module)
-		if (method_exists($module, &quot;__init&quot;))
-			$module-&gt;__init();
+	header(&quot;Content-type: &quot;.(INDEX ? fallback($theme-&gt;type, &quot;text/html&quot;) : &quot;text/html&quot;).&quot;; charset=UTF-8&quot;);
 
 	if (INDEX) {
 		$route-&gt;check_custom_routes();
@@ -322,12 +312,12 @@
 			$route-&gt;check_viewing_page();
 			$route-&gt;check_viewing_post(true);
 		} else {
-			$route-&gt;check_viewing_post();
 			$route-&gt;check_viewing_page(true);
+			$route-&gt;check_viewing_post();
 		}
-	}
 
-	if (INDEX or ADMIN)
+		$trigger-&gt;call(&quot;runtime&quot;);
+	} elseif (ADMIN)
 		$trigger-&gt;call(&quot;runtime&quot;);
 
 	# Array: $statuses
@@ -335,6 +325,7 @@
 	$statuses = array(&quot;public&quot;);
 	if (logged_in())
 		$statuses[] = &quot;registered_only&quot;;
+
 	if ($visitor-&gt;group()-&gt;can(&quot;view_private&quot;))
 		$statuses[] = &quot;private&quot;;
 </diff>
      <filename>includes/common.php</filename>
    </modified>
    <modified>
      <diff>@@ -223,6 +223,11 @@
 			fallback($_POST['login']);
 			fallback($_POST['password']);
 
+			$trigger = Trigger::current();
+
+			if ($trigger-&gt;exists(&quot;authenticate&quot;))
+				return $trigger-&gt;call(&quot;authenticate&quot;);
+
 			if (!User::authenticate($_POST['login'], md5($_POST['password'])))
 				if (!count(User::find(array(&quot;where&quot; =&gt; array(&quot;login&quot; =&gt; $_POST['login'])))))
 					Flash::warning(__(&quot;There is no user with that login name.&quot;));</diff>
      <filename>includes/controller/Main.php</filename>
    </modified>
    <modified>
      <diff>@@ -602,6 +602,9 @@
 	 *
 	 * Returns:
 	 *     A CamelCased string.
+	 *
+	 * See Also:
+	 *     &lt;decamelize&gt;
 	 */
 	function camelize($string, $keep_spaces = false) {
 		$lower = strtolower($string);
@@ -626,7 +629,7 @@
 	 *     A de_camel_cased string.
 	 *
 	 * See Also:
-	 * &lt;camelize&gt;
+	 *     &lt;camelize&gt;
 	 */
 	function decamelize($string) {
 		return strtolower(preg_replace(&quot;/([a-z])([A-Z])/&quot;, &quot;\\1_\\2&quot;, $string));
@@ -1032,6 +1035,11 @@
 	 function cancel_module($target) {
 		$this_disabled = array();
 
+		global $modules;
+
+		if (isset($modules[$target]))
+			$modules[$target]-&gt;cancelled = true;
+
 		$config = Config::current();
 		foreach ($config-&gt;enabled_modules as $module)
 			if ($module != $target)</diff>
      <filename>includes/helpers.php</filename>
    </modified>
    <modified>
      <diff>@@ -219,7 +219,7 @@ $(this).parent().find(&quot;ul:first&quot;).append(ui.draggable);self.element.data(&quot;sortab
 			var self = this;
 			this.interval = window.setInterval(function() { self.checkExpand() }, 400);
 			// this.textarea.keydown(function() {
-			// 	self.checkExpand()
+			//     self.checkExpand()
 			// })
 		},
 		stopExpand: function() {</diff>
      <filename>includes/lib/plugins.js</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@
 	/**
 	 * Class: Group
 	 * The Group model.
+	 *
 	 * See Also:
 	 *     &lt;Model&gt;
 	 */</diff>
      <filename>includes/model/Group.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 	/**
 	 * Class: Page
 	 * The Page model.
+	 *
 	 * See Also:
 	 *     &lt;Model&gt;
 	 */</diff>
      <filename>includes/model/Page.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 	/**
 	 * Class: Post
 	 * The Post model.
+	 *
 	 * See Also:
 	 *     &lt;Model&gt;
 	 */</diff>
      <filename>includes/model/Post.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 	/**
 	 * Class: User
 	 * The User model.
+	 *
 	 * See Also:
 	 *     &lt;Model&gt;
 	 */</diff>
      <filename>includes/model/User.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,7 @@
 	/**
 	 * Class: Visitor
 	 * The model for the currently browsing &lt;User&gt;. Group falls back to whatever group is set as the &quot;Guest Group&quot;.
+	 *
 	 * See Also:
 	 *     &lt;User&gt;
 	 */
@@ -15,9 +16,13 @@
 		 * Checks if a valid user is logged in.
 		 */
 		public function __construct() {
-			if (isset($_SESSION['login']) and isset($_SESSION['password']))
-				parent::__construct(null, array(&quot;where&quot;  =&gt; array(&quot;login&quot;    =&gt; $_SESSION['login'],
-				                                                  &quot;password&quot; =&gt; $_SESSION['password'])));
+			$trigger = Trigger::current();
+
+			if (!$trigger-&gt;exists(&quot;authenticate&quot;) and isset($_SESSION['login']) and isset($_SESSION['password']))
+				parent::__construct(null, array(&quot;where&quot; =&gt; array(&quot;login&quot;    =&gt; $_SESSION['login'],
+				                                                 &quot;password&quot; =&gt; $_SESSION['password'])));
+
+			$trigger-&gt;filter($this, &quot;visitor&quot;);
 		}
 
 		/**</diff>
      <filename>includes/model/Visitor.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,16 @@
 &lt;?php
 	class Cacher extends Modules {
-		public function __init() {
+		static function __install() {
+			$config = Config::current();
+			$config-&gt;set(&quot;cache_expire&quot;, 1800);
+		}
+
+		static function __uninstall() {
+			$config = Config::current();
+			$config-&gt;remove(&quot;cache_expire&quot;);
+		}
+
+		public function prepare() {
 			$this-&gt;user = (logged_in()) ? Visitor::current()-&gt;login : &quot;guest&quot; ;
 			$this-&gt;caches = INCLUDES_DIR.&quot;/caches&quot;;
 			$this-&gt;path = INCLUDES_DIR.&quot;/caches/&quot;.sanitize($this-&gt;user);
@@ -18,18 +28,10 @@
 			$this-&gt;remove_expired();
 		}
 
-		static function __install() {
-			$config = Config::current();
-			$config-&gt;set(&quot;cache_expire&quot;, 1800);
-		}
-
-		static function __uninstall() {
-			$config = Config::current();
-			$config-&gt;remove(&quot;cache_expire&quot;);
-		}
-
 		public function runtime() {
-			if (!file_exists($this-&gt;file) or Flash::exists())
+			$this-&gt;prepare();
+
+			if ($this-&gt;cancelled or !file_exists($this-&gt;file) or Flash::exists())
 				return;
 
 			$action = Route::current()-&gt;action;</diff>
      <filename>modules/cacher/cacher.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,6 +2,9 @@
 	/**
 	 * Class: Comment
 	 * The model for the Comments SQL table.
+	 *
+	 * See Also:
+	 *     &lt;Model&gt;
 	 */
 	class Comment extends Model {
 		public $no_results = false;</diff>
      <filename>modules/comments/model.Comment.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7b38ea6d900434a89a0511e2c660bd2d893ab5c8</id>
    </parent>
  </parents>
  <author>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </author>
  <url>http://github.com/vito/chyrp/commit/a3d1c5c28f03588ac451190abd4957e766f56a19</url>
  <id>a3d1c5c28f03588ac451190abd4957e766f56a19</id>
  <committed-date>2008-09-06T12:28:46-07:00</committed-date>
  <authored-date>2008-09-06T12:28:46-07:00</authored-date>
  <message>* Extensible authentication system. [#135 state:resolved]
  * Added a &quot;visitor&quot; filter that modifies the Visitor.
  * If an &quot;authenticate&quot; trigger exists...
    * Its functionality will be used instead of the standard log-in functionality.
    * The Visitor::__construct() will not load a User object.
* Cleaned up the sequence of execution in common.php.
  * Visitor, Theme, and Route-parsed URL values are no longer available to __init functions.
    Use the more appropriate &quot;runtime&quot; trigger instead.
  * Merged those two feather/module preparing loops into one.
* Documentation cleanups.</message>
  <tree>74490c7f50ceb1fec22f2c327e34497a25995abd</tree>
  <committer>
    <name>Alex Suraci</name>
    <email>i.am@toogeneric.com</email>
  </committer>
</commit>
