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_branch 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         $object = 'branch';
39         $branch = $this->name;
40     
41         
42         //$this->impl()->debug=1;
43         //print_r(array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'));
44     
45          $res = $this->repo()->impl()->history('.', array('since'=> '{'.$start.'}' , 'before' => '{'.$end .'}'), $object, $branch);
46           
47          // find the last rev the day before...
48          
49          
50           
51          $obj = $this->repo()->historyToSummary($res, $notify->act_start);
52          if (!$obj) {
53             // echo "History returned nothing";
54              return true;
55          }
56          $obj->from_dt = $start;
57          $obj->to_dt = $end;
58          $obj->branch = $this->name;
59             //print_r($obj);exit; 
60           
61        
62         $ret =   $rcpt->buildMail('repo_daily_changes', $obj);
63         
64         return $ret;
65         
66          
67          
68         
69         
70         
71     }
72      
73     
74 }
75