Index: app/app_controller.php
===================================================================
--- app/app_controller.php	(revision 0)
+++ app/app_controller.php	(revision 0)
@@ -0,0 +1,127 @@
+<?php
+
+class AppController extends Controller {
+
+	var $components = array('Acl', 'Auth');
+ 
+	function beforeFilter() {
+    	//Configure AuthComponent
+	    $this->Auth->authorize = 'actions';
+    	$this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
+	    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');
+    	$this->Auth->loginRedirect = array('controller' => 'projects', 'action' => 'index');
+	}
+
+
+	function admin_add() {
+		  
+	  	if (!empty($this->data)) {
+	      if ($this->{$this->modelClass}->save($this->data)) {
+    	    # no errors were encountered
+        	# put some type of flash message here - to display on the next page
+	        $this->redirect(array('action' => 'index'));
+    	  } else {
+        	# errors were encountered
+	        # put some type of flash message here - to display on POST'd broke-ass page!
+    	  }
+	    }
+  	}
+
+	function add() {
+		if (!empty($this->data)) {
+      		if ($this->{$this->modelClass}->save($this->data)) {
+	        # no errors were encountered
+    	    # put some type of flash message here - to display on the next page
+        	$this->redirect(array('action' => 'index'));
+	    	} else {
+    	    	# errors were encountered
+	        	# put some type of flash message here - to display on POST'd broke-ass page!
+		    }
+		}
+	}
+
+	function delete($pid) {
+		$this->{$this->modelClass}->del($pid);
+		$this->redirect(array('action' => 'index'));
+	}
+	function edit($id = null) {
+		$this->{$this->modelClass}->id = $id;
+		if (empty($this->data)) {
+			$this->data = $this->{$this->modelClass}->read();
+			$this->redirect(array('action' => 'index'));
+		} else {
+			if ($this->{$this->modelClass}->save($this->data)) {
+			$this->redirect(array('action' => 'index'));
+			}
+		}
+	}
+	
+	/**
+	 * Rebuild the Acl based on the current controllers in the application
+	 *
+	 * @return void
+	*/
+    function buildAcl() {
+        $log = array();
+ 
+        $aco =& $this->Acl->Aco;
+        $root = $aco->node('controllers');
+        if (!$root) {
+            $aco->create(array('parent_id' => null, 'model' => null, 'alias' => 'controllers'));
+            $root = $aco->save();
+            $root['Aco']['id'] = $aco->id; 
+            $log[] = 'Created Aco node for controllers';
+        } else {
+            $root = $root[0];
+        }   
+ 
+        App::import('Core', 'File');
+        $Controllers = Configure::listObjects('controller');
+        $appIndex = array_search('App', $Controllers);
+        if ($appIndex !== false ) {
+            unset($Controllers[$appIndex]);
+        }
+        $baseMethods = get_class_methods('Controller');
+        $baseMethods[] = 'buildAcl';
+ 
+        // look at each controller in app/controllers
+        foreach ($Controllers as $ctrlName) {
+            App::import('Controller', $ctrlName);
+            $ctrlclass = $ctrlName . 'Controller';
+            $methods = get_class_methods($ctrlclass);
+ 
+            // find / make controller node
+            $controllerNode = $aco->node('controllers/'.$ctrlName);
+            if (!$controllerNode) {
+                $aco->create(array('parent_id' => $root['Aco']['id'], 'model' => null, 'alias' => $ctrlName));
+                $controllerNode = $aco->save();
+                $controllerNode['Aco']['id'] = $aco->id;
+                $log[] = 'Created Aco node for '.$ctrlName;
+            } else {
+                $controllerNode = $controllerNode[0];
+            }
+ 
+            //clean the methods. to remove those in Controller and private actions.
+            foreach ($methods as $k => $method) {
+                if (strpos($method, '_', 0) === 0) {
+                    unset($methods[$k]);
+                    continue;
+                }
+                if (in_array($method, $baseMethods)) {
+                    unset($methods[$k]);
+                    continue;
+                }
+                $methodNode = $aco->node('controllers/'.$ctrlName.'/'.$method);
+                if (!$methodNode) {
+                    $aco->create(array('parent_id' => $controllerNode['Aco']['id'], 'model' => null, 'alias' => $method));
+                    $methodNode = $aco->save();
+                    $log[] = 'Created Aco node for '. $method;
+                }
+            }
+        }
+        debug($log);
+    }
+
+}
+
+?>
\ No newline at end of file
