php8
[web.mtrack] / MTrackWeb / Log.php
index b8f0460..c1bfd73 100644 (file)
@@ -5,21 +5,23 @@ require_once 'MTrackWeb.php';
 
 class MTrackWeb_Log extends MTrackWeb
 {
-    var $template = 'log.html';
+     
     function getAuth()
     {
         
         parent::getAuth();
-        MTrackACL::requireAllRights('Browser', 'read');
+       
         return true;
     }
     
     function get($pi)
     {
        // echo "STARGING";
-        if (!empty($_REQUEST['embed'])) {
-            $this->masterTemplate=$this->template;
+        if (!isset($_REQUEST['ajax_body'])) {
+            return;
         }
+        $this->masterTemplate = 'log.html';
+         
        
         $this->pi = empty($pi) ? '' : ($pi . $this->bootLoader->ext);
        
@@ -30,23 +32,28 @@ class MTrackWeb_Log extends MTrackWeb
         if (!$this->repo->id) {
             return HTML_FlexyFramework::run('Browse');  
         };
+          
+        if (!$this->projectPerm($this->repo->project_id, 'MTrack.Repos', 'S')) {
+            return HTML_FlexyFramework::run('Noperm');  // noperm = loggedin -> need more perms / not.. try loggin in..
+        }
         
          
         
         $this->branches = $this->repo->getBranches();
 
-        MTrackACL::requireAllRights("repo:{$this->repo->id}", 'read');
         
         
-        $this->title = "Log $file";
+        $this->title = "Log $this->filename";
         
         $this->branches = $this->repo->getBranches();
         
         
         $this->crumbs = array();
         $location = '';
-        $crumbs = explode('/', $file);
-        array_unshift($crumbs,'');
+        $this->basename = basename($this->filename);
+        $crumbs = dirname($this->filename) == '.'  || !strlen(dirname($this->filename)) ?
+            array() : explode('/', dirname($this->filename));
+      
         foreach($crumbs as $path) 
         {
             
@@ -88,12 +95,18 @@ class MTrackWeb_Log extends MTrackWeb
             
         $last_day = null;
         $even = 1;
-        $hist = $this->repo->history($file, 100, $object, $ident);
-         
+        
+        $offset= empty($_GET['offset']) ? 0 : (int) $_GET['offset'];
+        $this->offset = $offset+100;
+        $hist = $this->repo->history($this->filename, array($offset,100), $object, $ident);
+        
         if (empty($hist)) {
-            return;
+            return; // an error conditon!?!
+        }
+        $this->rev = $hist[0]->rev;
+        if (count($hist) < 100) {
+            $this->offset = 0;
         }
-        
         // code here...
         // repo has a 'release' branch, this should be used to track what needs 
         // merging from 'HEAD' to update it
@@ -122,12 +135,12 @@ class MTrackWeb_Log extends MTrackWeb
                 
             $last_day = $day;
             $M = array();
-            if (preg_match('/#([0-9]+)\s+/', $h->changelog, $M)) {
+           // if (preg_match('/#([0-9]+)\s+/', $h->changelog, $M)) {
                 
-                $h->ticket = MTrackIssue::loadByNSIdent($M[1]) ;
+           //     $h->ticket = MTrackIssue::loadByNSIdent($M[1]) ;
                 // ticket->status == closed == ok to commit to another branch...
                // echo '<PRE>'; print_r($h->ticket);
-            }
+           // }