Fix #5661 - MTrack - daily email large and no branch
[Pman.MTrack] / DataObjects / Mtrack_repos_branch.php
1 <?php
2 /**
3  * Table Definition for mtrack_repos
4  */
5 class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
6
7 class Pman_MTrack_DataObjects_Mtrack_repos extends DB_DataObject 
8 {
9     ###START_AUTOCODE
10     /* the code below is auto generated do not remove the above tag */
11
12     public $__table = 'mtrack_repos';                    // table name
13     public $id;                              // int(11)  not_null primary_key auto_increment
14     public $name;                       // string(64)  not_null
15     public $repo_id;                         // string(16)  not_null
16      
17      
18     function repo()
19     {
20         static $cache;
21         if (isset($cache[$this->repo_id])) {
22             return $cache[$this->repo_id];
23         }
24         $r = DB_DataObject::factory('mtrack_repo');
25         $r->get($this->repo_id);
26         $cache[$this->repo_id] = $r;
27         return $r;
28     }
29
30     function notifyENDOFDAYMAIL($rcpt, $last_sent_date, $notify, $force)
31     {
32         // fisrst use history to show a list of changes between the dates.
33         //die("building end of day mail");
34         // var_dump($notify->act_start );
35         $start = date('Y-m-d H:i:s', strtotime($notify->act_start . ' - 1 DAY'));
36         $end = date('Y-m-d H:i:s', strtotime($notify->act_start));
37         
38            
39         $object = 'branch';
40         $branch = $this->name;
41     
42         
43         //$this->impl()->debug=1;
44         //print_r(array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'));
45     
46          $res = $this->repo()->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), $object, $branch);
47           
48          // find the last rev the day before...
49          
50          
51           
52          $obj = $this->repo()->historyToSummary($res, $notify->act_start);
53          if (!$obj) {
54             // echo "History returned nothing";
55              return true;
56          }
57          $obj->from_dt = $start;
58          $obj->to_dt = $end;
59          $obj->branch = $this->name;
60             //print_r($obj);exit; 
61           
62        
63         $ret =   $rcpt->buildMail('repo_daily_changes', $obj);
64         
65         return $ret;
66         
67          
68          
69         
70         
71         
72     }
73      
74     
75 }
76