DataObjects/Core_email.php
[Pman.Core] / DataObjects / Core_email.php
index a195235..fb6dd78 100644 (file)
@@ -43,25 +43,23 @@ class Pman_Core_DataObjects_Core_email extends DB_DataObject
         $cgm = DB_DataObject::Factory('core_group_member')->tableName();;
       
         $this->selectAdd("
-           (
-            SELECT 
-                count(user_id) 
-            FROM 
-                {$cgm}
-            WHERE 
-                to_group_id = {$cgm}.group_id
-            ) 
-            AS group_member_count,
+            (
+                SELECT 
+                    count(id) 
+                FROM 
+                    {$cgm}
+                WHERE 
+                    to_group_id = {$cgm}.group_id
+            )  AS group_member_count,
             
-           (
-            SELECT 
-                count(user_id) 
-            FROM 
-                {$cgm}
-            WHERE 
-                bcc_group_id = {$cgm}.group_id
-           ) 
-           AS bcc_group_member_count
+            (
+                SELECT 
+                    count(id) 
+                FROM 
+                    {$cgm}
+                WHERE 
+                    bcc_group_id = {$cgm}.group_id
+            )  AS bcc_group_member_count
         ");
     }
     
@@ -130,7 +128,7 @@ class Pman_Core_DataObjects_Core_email extends DB_DataObject
             $map[$i->id] = $new_image->id;
         }
         
-        print_r('test??');exit;
+        
         libxml_use_internal_errors (true);
         $doc = new DOMDocument('1.0', 'UTF-8');
         $doc->loadHTML('<?xml encoding="UTF-8"><HTML><BODY>'.$this->bodytext.'</BODY></HTML>');
@@ -536,9 +534,21 @@ Content-Transfer-Encoding: 7bit
         if (!file_exists(dirname($cachePath))) {
             mkdir(dirname($cachePath), 0700, true);
         }
-        print_R($this->bodytext);exit;
-        file_put_contents($cachePath, $this->bodytext);
         
+        if (empty($this->use_file)) {
+            file_put_contents($cachePath, $this->bodytext);
+            return;
+        }
+        // use-file -- uses the original template...
+        $mailtext = file_get_contents($this->use_file);        
+         
+        require_once 'Mail/mimeDecode.php';
+        require_once 'Mail/RFC822.php';
+        
+        $decoder = new Mail_mimeDecode($mailtext);
+        $parts = $decoder->getSendArray();
+        file_put_contents($parts[2], $this->bodytext);
+         
     }
     
     function cachedImages()
@@ -586,6 +596,17 @@ Content-Transfer-Encoding: 7bit
             return false;
         }
         
+        if (!empty($this->use_file)) {
+            $ctime = filemtime($cachePath);
+            $mtime = filemtime($this->use_file);
+            if($ctime >= $mtime){
+                return true;
+            }
+            return false;
+            
+        }
+        
+        
         
         $ctime = filemtime($cachePath);
         $mtime = array();