sync
[web.mtrack] / MTrackWeb / Gitlive.php
index b6d5763..3db2ba2 100644 (file)
@@ -3,7 +3,7 @@
 /**
  * JSON api for gitlive desktop application
  */
-
+require_once 'MTrackWeb.php';
 class MTrackWeb_Gitlive extends MTrackWeb
 {
     function h401()
@@ -18,12 +18,12 @@ class MTrackWeb_Gitlive extends MTrackWeb
         if (!isset($_SERVER['PHP_AUTH_USER'])) {
             $this->h401();
         } 
-        $u = DB_DataObject::factory('Person');
+        $u = DB_DataObject::factory('core_person');
         //$u->active = 1;
         $u->whereAdd('LENGTH(passwd) > 1');
         //$u->company_id = $this->company->id;
          
-        $u->email = $_SERVER['PHP_AUTH_USER']
+        $u->email = $_SERVER['PHP_AUTH_USER'];
         if ($u->count() > 1 || !$u->find(true)) {
             $this->h401();
             
@@ -33,7 +33,7 @@ class MTrackWeb_Gitlive extends MTrackWeb
         //    return $this->errmsg('disabled');
         //}
         
-        if ($u->checkPassword($_REQUEST['password'])) {
+        if ($u->checkPassword($_SERVER['PHP_AUTH_PW'])) {
             $u->login();
             $this->authUser = $u;
             // we do not log automated???
@@ -45,4 +45,41 @@ class MTrackWeb_Gitlive extends MTrackWeb
             
     }
     
+    function get($pi) {
+        
+        $pi .= (strlen($pi) ? $this->bootLoader->ext : '');
+        $r = DB_DataObject::factory('mtrack_repos');
+        if (!$r->get('shortname', $pi)) {
+            $this->jerr("invalid repo");
+        }
+        // make sure it's a valid project..
+        if (!$this->projectPerm($r->project_id, 'MTrack.Issue', 'S')) {
+            $this->jerr("no perms");
+        }
+        //DB_DAtaObject::DebugLevel(1);
+        $t = DB_DataObject::Factory('mtrack_ticket');
+        $t->autoJoin();
+        $t->whereAdd("join_status_id.name IN ( 'open', 'new')");
+        $t->project_id = $r->project_id;
+        // only need id / name / status?
+        //$ar = $t->fetchAll('id', ');
+        $t->selectAdd();
+        $t->selectAdd('
+                mtrack_ticket.id as id ,
+                mtrack_ticket.summary as summary,
+                mtrack_ticket.description as description
+        ');
+        
+        $t->find();
+        $ret = array();
+        while ($t->fetch()) {
+            $ret[] = $t->toArray('%s', 0);
+        }
+         
+    //    print_R($ar);
+        $this->jok($ret);
+        $this->jok("WORKED!");
+        
+    }
+    
 }
\ No newline at end of file