DataObjects/Events.php
[Pman.Core] / DataObjects / Core_person.php
index 2c2141d..cdd4fdd 100644 (file)
@@ -151,7 +151,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         $decoder = new Mail_mimeDecode($mailtext);
         $parts = $decoder->getSendArray();
         
-        if (PEAR::isError($parts)) {
+        if (is_a($parts,'PEAR_Error')) {
             return $parts;
             //echo "PROBLEM: {$parts->message}";
             //exit;
@@ -304,8 +304,17 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         if (!empty($ff->Pman['local_autoauth']) && 
             ($ff->Pman['local_autoauth'] === true) &&
             (!empty($_SERVER['SERVER_ADDR'])) &&
-            ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
-            ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')  
+            (
+                (
+                    $_SERVER['SERVER_ADDR'] == '127.0.0.1' &&
+                    $_SERVER['REMOTE_ADDR'] == '127.0.0.1'
+                )
+                ||
+                (
+                    $_SERVER['SERVER_ADDR'] == '::1' &&
+                    $_SERVER['REMOTE_ADDR'] == '::1'
+                )
+            )
         ) {
             $group = DB_DataObject::factory('core_group');
             $group->get('name', 'Administrators');
@@ -330,8 +339,17 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         
         if (!empty($ff->Pman['local_autoauth']) && 
             (!empty($_SERVER['SERVER_ADDR'])) &&
-            ($_SERVER['SERVER_ADDR'] == '127.0.0.1') &&
-            ($_SERVER['REMOTE_ADDR'] == '127.0.0.1')  &&
+            (
+                (
+                    $_SERVER['SERVER_ADDR'] == '127.0.0.1' &&
+                    $_SERVER['REMOTE_ADDR'] == '127.0.0.1'
+                )
+                ||
+                (
+                    $_SERVER['SERVER_ADDR'] == '::1' &&
+                    $_SERVER['REMOTE_ADDR'] == '::1'
+                )
+            ) &&
             ($default_admin ||  $u->get('email', $ff->Pman['local_autoauth']))
         ) {
             $_SESSION[get_class($this)][$sesPrefix .'-auth'] = serialize($default_admin ? $default_admin : $u);
@@ -350,9 +368,11 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
         $u->whereAdd(' LENGTH(passwd) > 0');
         $n = $u->count();
         $_SESSION[get_class($this)][$sesPrefix .'-empty']  = $n;
-        $error =  PEAR::getStaticProperty('DB_DataObject','lastError');
-        if ($error) {
-            die($error->toString()); // not really a good thing to do...
+        if (class_exists('PEAR')) {
+            $error =  PEAR::getStaticProperty('DB_DataObject','lastError');
+            if ($error) {
+                die($error->toString()); // not really a good thing to do...
+            }
         }
         if (!$n){ // authenticated as there are no users in the system...
             return true;
@@ -502,8 +522,11 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     function checkPassword($val)
     {
         
+        
         if (substr($this->passwd,0,1) == '$') {
-            
+            if (function_exists('pasword_verify')) {
+                return password_verify($val, $this->passwd);
+            }
             return crypt($val,$this->passwd) == $this->passwd ;
         }
         // old style md5 passwords...- cant be used with courier....
@@ -512,6 +535,10 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
     
     function setPassword($value) 
     {
+        if (function_exists('pasword_hash')) {
+            return password_hash($value);
+        }
+        
         $salt='';
         while(strlen($salt)<9) {
             $salt.=chr(rand(64,126));
@@ -789,6 +816,24 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
             
         }
         
+        if(!empty($q['in_group_name'])){
+            
+            $v = $this->escape($q['in_group_name']);
+            
+            $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 = '{$v}'
+                )"
+            );
+        }
+        
         // #2307 Search Country!!
         if (!empty($q['query']['in_country'])) {
             // DB_DataObject::debugLevel(1);
@@ -1003,7 +1048,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
      * this is called after checkPerm..
      */
     
-    function beforeDelete()
+    function beforeDelete($dependants_array, $roo)
     {
         
         $e = DB_DataObject::Factory('Events');
@@ -1025,7 +1070,7 @@ class Pman_Core_DataObjects_Core_person extends DB_DataObject
      */
     function checkPerm($lvl, $au, $changes=false) //heck who is trying to access this. false == access denied..
     {
-         print_r($au);exit;
+         
        // do we have an empty system..
         if ($au && $au->id == -1) {
             return true;