DataObjects/core.sql
[Pman.Core] / DataObjects / Person.php
index ec47f6d..48bab37 100644 (file)
@@ -41,19 +41,14 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     ###END_AUTOCODE
     /**
      *
-     * Build an email to sent do user
      *
-     * key 'args'
      *
-     * no_auth => disable authentication check on
-     * templateDir => alternative template directory.
-     * HTTP_HOST
      *
-     * expects mail/TMPLATE.txt (if .html exists, it will be the html body version)
-     * 
-     * @param {String} $templateFile  (mail/XXXXXXX.txt) exclude the mail and .txt bit.
-     * @param {Array|Object} $args   data to send out..
-     * @return {Array|PEAR_Error} array of $recipents, $header, $body 
+     *  FIXME !!!! -- USE Pman_Core_Mailer !!!!!
+     *
+     *
+     *
+     *  
      */
     function buildMail($templateFile, $args)
     {
@@ -314,6 +309,12 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         $u = DB_DataObject::factory('Person');
         $u->whereAdd(' LENGTH(passwd) > 0');
         if (!$u->count()){
+            
+            // fake person - open system..
+            $ce = DB_DataObject::factory('core_enum');
+            $ce->initEnums();
+            
+            
             $u = DB_DataObject::factory('Person');
             $u->id = -1;
             return $u;
@@ -530,6 +531,8 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         
     }
     
+    
+    
     function hasPerm($name, $lvl) 
     {
         static $pcache = array();
@@ -684,13 +687,13 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
             
         }
         
-        
         if (!empty($q['query']['search'])) {
             $s = $this->escape($q['query']['search']);
                     $this->whereAdd("
                         $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%' 
                         
                     ");
@@ -806,9 +809,14 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     }
     function onInsert($req, $roo)  
     {
-        
-        if ($roo->authUser->id < 0) {
+         
+        $p = DB_DataObject::factory('person');
+        if ($roo->authUser->id < 0 && $p->count() == 1) {
+            // this seems a bit risky...
+            
             $g = DB_DataObject::factory('Groups');
+            $g->initGroups();
+            
             $g->type = 0;
             $g->get('name', 'Administrators');