kill stupid tab bug
[potlatch2.git] / net / systemeD / potlatch2 / BugLayer.as
index 09e7e20e1b145f8bcf4c03d899bf5a4f3a7c2a18..35b47fa2d3e676309dcbc27657ab5a2550bea63a 100644 (file)
@@ -12,6 +12,7 @@ package net.systemeD.potlatch2 {
 
         private var baseUrl:String;
         private var apiKey:String;
+        private var detailsUrl:String;
 
         // as strings, since that's how they are in tags and http calls
         public static var BUG_STATUS_OPEN:String = "1";
@@ -19,16 +20,25 @@ package net.systemeD.potlatch2 {
         public static var BUG_STATUS_INVALID:String = "3"; // or 'non-reproduceable'
         public static const status:Array = ["", "open", "fixed", "invalid"];
 
-        public function BugLayer(n:String, map:Map, s:String, baseUrl:String, apiKey:String) {
+        public function BugLayer(n:String, map:Map, s:String, baseUrl:String, apiKey:String, detailsURL:String) {
             this.baseUrl = baseUrl;
             this.apiKey = apiKey;
+            this.detailsUrl = detailsURL;
             super(n,map,s);
         }
 
         public function closeBug(m:Marker, nickname:String, comment:String, status:String = null):void {
             var id:String = m.getTag('bug_id');
             nickname ||= 'NoName';
+            // nicknames have length and character restictions. The character restrictions should be taken care of
+            // by the BugPanel.mxml restriction.
+            if (nickname.length < 3 || nickname.length > 16) {
+              nickname = 'NoName';
+            }
             comment ||= 'No Comment';
+            if (comment.length > 1000) {
+              comment = comment.substr(0,1000); // that's index, length
+            }
             status ||= BUG_STATUS_FIXED;
             var urlReq:URLRequest = new URLRequest(baseUrl+"changeBugStatus?id="+id+"&status="+status+"&comment="+encodeURIComponent(comment)+"&nickname="+encodeURIComponent(nickname)+"&key="+apiKey);
             urlReq.method = "POST";
@@ -75,5 +85,11 @@ package net.systemeD.potlatch2 {
             }
         }
 
+        public function bugDetailsUrl(m:Marker):String {
+            if (detailsUrl == '')
+              return null;
+            return detailsUrl+m.id;
+        }
+
     }
 }