DataObjects/Core_notify.php
[Pman.Core] / DataObjects / Person.php
index 55e81a8..5f397b6 100644 (file)
@@ -12,6 +12,7 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     public $__table = 'Person';                          // table name
     public $id;                              // int(11)  not_null primary_key auto_increment
     public $email;                           // string(128)  not_null
+    public $alt_email;
     
     public $company_id;                      // int(11)  
     public $office_id;                       // int(11)  
@@ -224,7 +225,16 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     function verifyAuth()
     { 
         $ff= HTML_FlexyFramework::get();
-        if (!empty($ff->Pman['auth_comptype']) && $ff->Pman['auth_comptype'] != $this->company()->comptype) {
+        if (!empty($ff->Pman['auth_comptype']) &&
+            (!$this->company_id || ($ff->Pman['auth_comptype'] != $this->company()->comptype))
+           ){
+            
+            // force a logout - without a check on the isAuth - as this is called from there..
+            $db = $this->getDatabaseConnection();
+            $sesPrefix = get_class($this) .'-'.$db->dsn['database'] ;
+            $_SESSION[__CLASS__][$sesPrefix .'-auth'] = "";
+            return false;
+            
             $ff->page->jerr("Login not permited to outside companies");
         }
         return true;
@@ -250,8 +260,10 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
             $u = DB_DataObject::factory('Person');
             if ($u->get($a->id)) { //&& strlen($u->passwd)) {
-                $u->verifyAuth();
+              
+                return $u->verifyAuth();
                 
+   
                 return true;
             }
             
@@ -350,7 +362,9 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     function login()
     {
         $this->isAuth(); // force session start..
-        $this->verifyAuth();
+        if (!$this->verifyAuth()) {
+            return false;
+        }
         $db = $this->getDatabaseConnection();
         
         
@@ -732,17 +746,38 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
             // use our magic search builder...
             
+             require_once 'Text/SearchParser.php';
+            $x = new Text_SearchParser($q['query']['search']);
+            
+            $props = array(
+                    "$tn_p.name",
+                    "$tn_p.email",
+                    "$tn_p.role",
+                    "$tn_p.phone",
+                    "$tn_p.remarks",
+                    "join_company_id_id.name"
+            );
+            
+            $str =  $x->toSQL(array(
+                'default' => $props,
+                'map' => array(
+                    'company' => 'join_company_id_id.name',
+                    //'country' => 'Clipping.country',
+                    //  'media' => 'Clipping.media_name',
+                ),
+                'escape' => array($this->getDatabaseConnection(), 'escapeSimple'), /// pear db or mdb object..
+
+            ));
             
             
-            $s = $this->escape($q['query']['search']);
-                    $this->whereAdd("
+            $this->whereAdd($str); /*
                         $tn_p.name LIKE '%$s%'  OR
                         $tn_p.email LIKE '%$s%'  OR
                         $tn_p.role LIKE '%$s%'  OR
                         $tn_p.phone LIKE '%$s%' OR
                         $tn_p.remarks LIKE '%$s%' 
                         
-                    ");
+                    ");*/
         }
         
         //
@@ -889,6 +924,11 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     
     function importFromArray($roo, $persons, $prefix)
     {
+        if (!is_array($persons) || empty($persons)) {
+            $roo->jerr("error in the person data. - empty on not valid");
+        }
+        DB_DataObject::factory('groups')->initGroups();
+        
         foreach($persons as $person){
             $p = DB_DataObject::factory('person');
             if($p->get('name', $person['name'])){