better detect disable http auht
[Pman.Core] / DataObjects / Core_person.php
index c7f3c5c..56c08af 100644 (file)
@@ -48,6 +48,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     public $phone_direct; // varchar(32)  NOT NULL  DEFAULT '';
     public $countries; // VARCHAR(128) NULL;
     
+    public $language;
+    
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
     
@@ -252,11 +254,14 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     function isAuth()
     {
         // do not start a session if we are using http auth...
-        if (empty($_SERVER['PHP_AUTH_USER']) && php_sapi_name() != "cli") {
-            @session_start();
+        // we have a situation where the app is behind a http access and is also login
+        // need to work out a way to handle that.
+        if (php_sapi_name() != "cli" && (empty($_SERVER['PHP_AUTH_USER']) || !empty($ff->disable_http_auth)))  {
+             @session_start();
         }
-       
-        $ff= HTML_FlexyFramework::get();
+        
+         
        
         $sesPrefix = $this->sesPrefix();
         
@@ -285,7 +290,9 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         // http basic auth..
         $u = DB_DataObject::factory($this->tableName());
         
-        if (!empty($_SERVER['PHP_AUTH_USER']) 
+        if (empty($ff->disable_http_auth)  // http auth requests should not have this...
+            &&
+            !empty($_SERVER['PHP_AUTH_USER']) 
             &&
             !empty($_SERVER['PHP_AUTH_PW'])
             &&
@@ -299,6 +306,10 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
             self::$authUser = $u;
             return true; 
         }
+        
+        // at this point all http auth stuff is done, so we can init session
+        
+        
         //die("test init");
         if (!$this->canInitializeSystem()) {
           //  die("can not init");
@@ -523,11 +534,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         $this->isAuth(); // force session start..
         
         $sesPrefix = $this->sesPrefix();
-        
         $_SESSION[get_class($this)][$sesPrefix .'-auth-timeout'] = -1;
-        
         $_SESSION[get_class($this)][$sesPrefix .'-auth'] = "";
-        
         self::$authUser = false;
         
     }    
@@ -1007,6 +1015,25 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
                 )"
             );
         }
+        if(!empty($q['in_group_starts'])){
+            
+            $v = $this->escape($q['in_group_starts']);
+            
+            $this->whereAdd("
+                $tn_p.id IN (
+                    SELECT 
+                        DISTINCT(user_id) FROM $tn_gm
+                    LEFT JOIN
+                        $tn_g
+                    ON
+                        $tn_g.id = $tn_gm.group_id
+                    WHERE 
+                        $tn_g.name LIKE '{$v}%'
+                )"
+            );
+        }
+        
+        
         
         // #2307 Search Country!!
         if (!empty($q['query']['in_country'])) {
@@ -1077,6 +1104,15 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
                 {$this->tableName()}.name LIKE '%{$this->escape($q['query']['name'])}%'
             ");
         }
+        
+         if(!empty($q['query']['name_or_email'])){
+            $v = $this->escape($q['query']['name_or_email']);
+            $this->whereAdd("
+                {$this->tableName()}.name LIKE '%{$v}%'
+                OR
+                {$this->tableName()}.email LIKE '%{$v}%'
+            ");
+        }
          if(!empty($q['query']['name_starts'])){
             $this->whereAdd("
                 {$this->tableName()}.name LIKE '{$this->escape($q['query']['name_starts'])}%'
@@ -1156,7 +1192,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
             
             if (!$roo->hasPerm('Core.Projects_All', 'S')) {
                 $peps = $p->people($pids);
-                $this->whereAddIn("{$tn}.id", $peps, 'int');
+                $this->whereAddIn("{$this->tableName()}.id", $peps, 'int');
             }
         }    
         
@@ -1206,7 +1242,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
             
             COALESCE((
                 SELECT
-                    GROUP_CONCAT(  core_group.name separator  '\n')
+                    GROUP_CONCAT(  CASE WHEN core_group.display_name = '' THEN core_group.name ELSE core_group.display_name  END  separator  '\n')
                 FROM
                     core_group_member
                 LEFT JOIN
@@ -1215,6 +1251,8 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
                     core_group.id = core_group_member.group_id
                 WHERE
                     core_group_member.user_id = core_person.id
+                ORDER BY
+                    core_group.display_name ASC
             ), '')  as member_of");
     }