Merge branch 'master' of http://private.akbkhome.com/Pman.Base
authorAlan Knowles <alan@akbkhome.com>
Mon, 14 Mar 2011 04:03:59 +0000 (12:03 +0800)
committerAlan Knowles <alan@akbkhome.com>
Mon, 14 Mar 2011 04:03:59 +0000 (12:03 +0800)
Pman.php
Pman/Login.php
Pman/Roo.php

index 44759cb..f16ee9b 100644 (file)
--- a/Pman.php
+++ b/Pman.php
@@ -34,6 +34,8 @@ class Pman extends HTML_FlexyFramework_Page
     var $appModules = '';
     
     
+    var $authUser; // always contains the authenticated user..
+    
    
     
     /**
@@ -169,22 +171,44 @@ class Pman extends HTML_FlexyFramework_Page
         return $au->hasPerm($name,$lvl);
         
     }
+    
+    function modules()
+    {
+        // appModules/appDisable contain a comma limited list of
+        // both modules and components that can be enabled/disabled..
+         $boot = HTML_FlexyFramework::get();
+
+        // the modules call just lists the modules
+        $enabled =  array('Core' => true);
+         $am = !empty($boot->enable) ? explode(',',  $boot->enable) : array();
+        foreach($am as $k) {
+            if (strpos( $k ,'.') ) {
+                continue;
+            }
+            $enabled[$k] = true;
+        }
+        
+        
+        $disabled =  !empty($boot->disable) ?  explode(',', $boot->disable) : array();
+        foreach($disabled as $k) {
+            if ( strpos( $k ,'.') ) {
+                continue;
+            }
+            if (isset($enabled[$k])) {
+                unset($enabled[$k]);
+            }   
+        }
+         //echo '<PRE>';       var_Dump($enabled);
+
+        return array_keys($enabled); 
+    }
+    
     function hasModule($name) 
     {
         $this->init();
         if (!strpos( $name,'.') ) {
             // use enable / disable..
-            
-            
-            $enabled =  array('Core') ;
-            $enabled = !empty($this->appModules) ? 
-                array_merge($enabled, explode(',',  $this->appModules)) : 
-                $enabled;
-            $disabled =  explode(',', $this->appDisable ? $this->appDisable: '');
-            
-            //print_R($opts);
-            
-            return in_array($name, $enabled) && !in_array($name, $disabled);
+            return in_array($name, $this->modules()); 
         }
         
         $x = DB_DataObject::factory('Group_Rights');
index 8ee9e0b..f103e9a 100644 (file)
@@ -107,23 +107,25 @@ class Pman_Login extends Pman
          
         /** -- these need modulizing somehow! **/
         
-        if ($this->hasModule('Fax')) {
-            // should check fax module???
-            $f = DB_DataObject::factory('Fax_Queue');
-            $aur['faxMax'] = $f->getMaxId();
-            $aur['faxNumPending'] = $f->getNumPending();
-        }
         
-        if ($this->hasModule('Documents')) {
-        // inbox...
-            $d = DB_DataObject::factory('Documents_Tracking');
-            $d->person_id = $au->id;
-            //$d->status = 0; // unread
-            $d->whereAdd('date_read IS NULL');
-            $d->applyFilters(array('query'=> array('unread' => 1)), $au);
-            $aur['inbox_unread'] = $d->count();
+        
+        // basically calls Pman_MODULE_Login::sendAuthUserDetails($aur) on all the modules
+        //echo '<PRE>'; print_r($this->modules());
+        // technically each module should only add properties to an array named after that module..
+        
+        foreach($this->modules() as $m) {
+            if (!file_exists($this->rootDir.'/Pman/'.$m.'/Login.php')) {
+                continue;
+            }
+            $cls = 'Pman_'.$m.'_Login';
+            require_once 'Pman/'.$m.'/Login.php';
+            $x = new $cls;
+            $x->authUser = $au;
+            $aur = $x->sendAuthUserDetails($aur);
         }
         
+                 
+        
         //echo '<PRE>';print_r($aur);
         
         $this->jok($aur);
index 655d0f3..e00d0af 100644 (file)
@@ -13,8 +13,8 @@ require_once 'Pman.php';
  * 
  * - applySort($au, $sortcol, $direction)
  * - applyFilters($_REQUEST, $authUser) -- apply any query filters on data. and hide stuff not to be seen.
- * - postListExtra - add extra column data on the results (like new messages etc.)
- * -postListFilter($data, $authUser, $request) return $data - add extra data to an object
+ * - postListExtra($_REQUEST) : array(extra_data) - add extra column data on the results (like new messages etc.)
+ * - postListFilter($data, $authUser, $request) return $data - add extra data to an object
  * 
  * - toRooSingleArray($authUser, $request) // single fetch, add data..
  * - toRooArray($request) /// toArray if you need to return different data.. for a list fetch.