fix merge
[Pman.MTrack] / DataObjects / Mtrack_change.php
index 6a6e95c..55ac511 100644 (file)
@@ -33,6 +33,7 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
             $cache[$this->ontable.':'. $this->onid];
         }
         $o = DB_DataObject::factory($this->ontable);
+        $o->autoJoin();
         $o->get($this->onid);
         $cache[$this->ontable.':'. $this->onid] = $o;
         return $o;
@@ -762,17 +763,30 @@ class Pman_MTrack_DataObjects_Mtrack_change extends DB_DataObject
         foreach ($this->audit() as $a) {
             $str[] = $a->toAuditString($this);
         }
+        // who to send to..
+        $d = DB_DataObject::factory('core_person');
+        $d->whereAddIn('id', array($t->created_person_id, $t->developer_id), 'int');
+        $d->whereAdd('telegram_id > 0');
+        $sendto = $d->fetchAll('id','telegram_id');
+        
+        // creator  //created_person_id
+        // assigned to developer_id
+        // exclude whoever modfiied it? (disable for testing.)
+        foreach($sendto as $pid => $tid) { 
+            if ($this->person_id == $pid) {
+                // continue;
+            }
+            $res = $tg->factory('SendMessage',array(
+                'chat_id' => $tid, 
+                'parse_mode' => 'MarkdownV2',
+                'text' => "/ticket@{$this->onid}  *". $tg->escape("[{$t->project_id_name}]] {$t->summary}") . "*\n\n".
+                        "{$this->cgtype} by ". $tg->escape($this->person()->name) . "\n\n" . $tg->escape(implode("\n", $str))
+            ))->send();
+        }
         
-        $res = $tg->factory('SendMessage',array(
-            'chat_id' => 35721679,   // fixme - this needs to be mapped to who we are sending to (currently it's only me!!!)
-            'parse_mode' => 'MarkdownV2',
-            'text' => "/ticket@{$this->onid}  *". $tg->escape($t->summary) . "*\n\n".
-                    "{$this->cgtype} by ". $tg->escape($this->person()->name) . "\n\n" . $tg->escape(implode("\n", $str))
-                
-          
-        ))->send();
-         
-        //print_R($res); 
+         //print_R($res); 
     }