DataObjects/core.sql
[Pman.Core] / DataObjects / Person.php
index 2f71b02..48bab37 100644 (file)
@@ -41,9 +41,14 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
     ###END_AUTOCODE
     /**
      *
-     * @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)
     {
@@ -139,16 +144,15 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         }
         $headers['Date'] = date('r');
         
-        
         if ($htmlbody !== false) {
+            require_once 'Mail/mime.php';
             $mime = new Mail_mime(array('eol' => "\n"));
-            $mime->setHeaders($headers);
             $mime->setTXTBody($body);
             $mime->setHTMLBody($htmlbody);
             // I think there might be code in mediaoutreach toEmail somewhere
             // h embeds images here..
             $body = $mime->get();
-            $headers = $mime->headers($hdrs);
+            $headers = $mime->headers($headers);
             
         }
         
@@ -305,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;
@@ -521,6 +531,8 @@ class Pman_Core_DataObjects_Person extends DB_DataObject
         
     }
     
+    
+    
     function hasPerm($name, $lvl) 
     {
         static $pcache = array();
@@ -675,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%' 
                         
                     ");
@@ -797,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');