DataObjects/core.sql
[Pman.Core] / DataObjects / Core_mailing_list_message.php
index a81272b..026a1cc 100644 (file)
@@ -140,9 +140,6 @@ class Pman_Core_DataObjects_Core_mailing_list_message extends DB_DataObject
     
     function attachmentIds()
     {
-        
-         $roo = HTML_FlexyFramework::get()->page;
-        
         libxml_use_internal_errors (true);
         $doc = new DOMDocument('1.0', 'UTF-8');
         $doc->loadHTML('<?xml encoding="UTF-8">'.$this->bodytext);
@@ -162,7 +159,7 @@ class Pman_Core_DataObjects_Core_mailing_list_message extends DB_DataObject
             }
             $ret[] = $cid[1];
         }
-       // print_r($ret);
+        
         return $ret;
     }
     /**
@@ -210,7 +207,7 @@ class Pman_Core_DataObjects_Core_mailing_list_message extends DB_DataObject
         $r = new Pman_Core_Mailer(array(
             'template'=> $this->tableName() . '-' . $this->id,
             'templateDir' => $templateDir,
-            'page' => $q,
+            'page' => $this,
             'contents' => $contents
         ));
         
@@ -225,6 +222,10 @@ class Pman_Core_DataObjects_Core_mailing_list_message extends DB_DataObject
     
     function cachedMailWithOutImages($force = false, $replace_links = true)
     {  
+        $random_hash = md5(date('r', time()));
+        
+        $this->cachedImages($random_hash);
+        
         $cachePath = session_save_path() . '/email-cache-' . getenv('APACHE_RUN_USER') . '/mail/' . $this->tableName() . '-' . $this->id . '.txt';
           
         if (!$force && $this->isGenerated($cachePath)) {
@@ -247,8 +248,6 @@ class Pman_Core_DataObjects_Core_mailing_list_message extends DB_DataObject
         ))."\n");
         
         
-        $random_hash = md5(date('r', time()));
-        
 // note the extra space to finish the last line..
         fwrite($fh, " " . "
 Content-Type: multipart/alternative; boundary=alt-{$random_hash}
@@ -257,7 +256,7 @@ Content-Type: multipart/alternative; boundary=alt-{$random_hash}
 Content-Type: text/plain; charset=utf-8; format=flowed
 Content-Transfer-Encoding: 7bit
 
-{$message->plaintext}
+{$this->plaintext}
     
 --alt-{$random_hash}
 Content-Type: multipart/related; boundary=rel-{$random_hash}
@@ -266,7 +265,7 @@ Content-Type: multipart/related; boundary=rel-{$random_hash}
 Content-Type: text/html; charset=utf-8
 Content-Transfer-Encoding: 7bit
 
-{$message->bodytext}
+{$this->bodytext}
 
 ");  
 
@@ -276,8 +275,6 @@ Content-Transfer-Encoding: 7bit
 --alt-{$random_hash}--
 ");
         fclose($fh);
-      
-        $this->cachedImages($random_hash);
         
     }
     
@@ -286,6 +283,7 @@ Content-Transfer-Encoding: 7bit
         $imageCache = session_save_path() . '/email-cache-' . getenv('APACHE_RUN_USER') . '/mail/' . $this->tableName() . '-' . $this->id . '-images.txt';
         
         $ids = $this->attachmentIds();
+        
         //$this->jerr(print_r($ids,true));
         
          
@@ -346,6 +344,11 @@ Content-Disposition: inline; filename={$imgfn}
         return '"' . addslashes($this->from_name) . '" <' . $this->from_email. '>'  ;
     }
     
+    function formatDate($dt, $format = 'd/M/Y')
+    {
+        return date($format, strtotime($dt));
+    } 
+    
     
     
 }