MTrackWeb.php
authorAlan Knowles <alan@akbkhome.com>
Thu, 23 Jun 2011 03:37:51 +0000 (11:37 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 23 Jun 2011 03:37:51 +0000 (11:37 +0800)
MTrackWeb.php

index f68be2a..9ef617d 100644 (file)
@@ -80,30 +80,30 @@ class MTrackWeb extends HTML_FlexyFramework_Page
     function currentProject($val = false)
     {
         // we do need the option for me to look at all projects...
+        
+        
         static $currentProject = false;
         if (empty($_SESSION[__CLASS__])) {
             $_SESSION[__CLASS__] = array();
         }
+        
         if ($val !== false) {
             // attempt to set it..
             $_SESSION[__CLASS__]['active_project_id'] = $val ;
             $currentProject = false;
             // reset to ensure not cached..
         }
+        $ar = $this->userProjects();
+        if (!isset($ar[$currentProject])) {
+            $currentProject = false;
+            $_SESSION[__CLASS__]['active_project_id'] = false;
+        }
         if ($currentProject !== false) {
             return $currentProject;
         }
         
         
-        $p = DB_DataObject::factory('Projects');
-        $ar = array();
-        if ($this->authUser) {
-            $p->applyFilters(array(), $this->authUser);
-            $p->whereAdd('id in (SELECT distinct(project_id) FROM mtrack_repos)');
-            unset($p->client_id);
-            $ar = $p->fetchAll('id', 'name');
-        }
-        
+         
         //print_r($ar);
         
         if (empty($_SESSION[__CLASS__]['active_project_id']) ||
@@ -131,10 +131,9 @@ class MTrackWeb extends HTML_FlexyFramework_Page
     }
     
     
-    function loadProjectList()
+    function userProjects()
     {
-       // DB_DataObject::debugLevel(1);
-
+        
         $p = DB_DataObject::factory('Projects');
         if (!$this->authUser) {
             $p->code = '*PUBLIC';
@@ -154,6 +153,15 @@ class MTrackWeb extends HTML_FlexyFramework_Page
             unset($p->client_id); // default projects serach enforces this..
             $ar = $p->fetchAll('id', 'name');
         }
+        
+    }
+    
+    
+    function loadProjectList()
+    {
+       // DB_DataObject::debugLevel(1);
+
+        $ar = $this->userProjects();
          
         $this->elements['active_project_id'] = new HTML_Template_Flexy_Element();
         $this->elements['active_project_id']->setOptions($ar);