sync
[web.mtrack] / MTrackWeb / Cron / Notify.php
index ffd2e7a..313352c 100644 (file)
@@ -1,6 +1,8 @@
 <?php
 require_once 'MTrackWeb.php';
 
+// is this used currently - it's supposed to be for sending out notificatios on changes?
+
 class MTrackWeb_Cron_Notify extends MTrackWeb
 {
     
@@ -72,7 +74,7 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
                     $cs->autoJoin();
                     $cache[implode(',', $ar)] = $cs->fetchAll();
                 }
-                $u  = DB_DataObject::factory('Person');
+                $u  = DB_DataObject::factory('core_person');
                 $u->get($uid);
                 $method =  'notify_'. $lr[0] ;
                 if (method_exists($this,$method)) {
@@ -113,12 +115,31 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
      *   - to user...
      *   
      */
-    function calcAddress($ticket, $changes, $user) {
+    function calcAddress($ticket, $changes, $user)
+    {
         $ff = HTML_FlexyFramework::get();
-     
         
+        
+        $changers = array();
+        foreach($changes as $c) {
+            if ($change->person_id == $user->id) {
+                continue;
+            }
+            if (in_array($change->person_id_name, $changers)) {
+                continue;
+            }
+            $changers[] = $change->person_id_name;
+            
+        }
+        $fromname = '"'. addslashes($project->toEventString()). '"';
+        if (count($changers) == 1) {
+            $fromname = '"'. addslashes($changers[0]).  '"';
+        }
+        
+        $p = $ticket->project();
         $headers['To'] = '"'. addslashes($user->name). '" <' . $user->email .'>';
-        $headers['From'] =  $ff->MTrackWeb['email_address']; // could be the user who made the change...
+        $headers['From'] = '"'. addslashes($project->toEventString()). '" '. 
+                $ff->MTrackWeb['email_address']; // could be the user who made the change...
         
         //if (count($from) > 1) {
         //    $rep = array();
@@ -146,6 +167,11 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
         //global $MAX_DIFF;
         $ff = HTML_FlexyFramework::get();
      
+        
+        
+        
+     
+     
         // from is always the system.. ??
         // unless all the changers are the same..
         $headers = $this->calcAddress($ticket, $changes, $user);
@@ -196,7 +222,8 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
         // }
     
         $headers['Subject'] = sprintf("%s#%s %s (%s %s)",
-          $subj, $ticket->id, $ticket->summary, $ticket->status_name, $ticket->classification_id_name);
+          $subj, $ticket->id, $ticket->summary,
+          $ticket->status_name, $ticket->classification_id_name);
     
         $owner =  $ticket->owner_id ? $ticket->owner_id_name : 'nobody';
     
@@ -266,7 +293,7 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
                       
                     default:
                         $oldvalue = $audit->oldvalue($this);
-                        $value = $audit->oldvalue(($this);
+                        $value = $audit->oldvalue($this);
                         if (!strlen($oldvalue)) {
                             $body .= "Set {$audit->field()} to: {$value}\n";
                             continue;
@@ -291,7 +318,7 @@ class MTrackWeb_Cron_Notify extends MTrackWeb
     
 }
 
-
+/*
 class CanonicalLineEndingFilter extends php_user_filter {
     function filter($in, $out, &$consumed, $closing)
     {
@@ -313,4 +340,6 @@ class CanonicalLineEndingFilter extends php_user_filter {
       }
       return PSFS_PASS_ON;
     }
-    }
\ No newline at end of file
+}
+*/
+    
\ No newline at end of file