<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>application/modules/spindle/models/Service/BugTracker.php</filename>
    </added>
    <added>
      <filename>application/modules/spindle/views/scripts/bug/add.ajax.phtml</filename>
    </added>
    <added>
      <filename>application/modules/spindle/views/scripts/bug/content/view.phtml</filename>
    </added>
    <added>
      <filename>public/api/spindle/bug/jsonrpc.php</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,7 +1,7 @@
 - Import bugapp into Spindle module
-  - Refactor User model
-    - authenticate() should validate via the form
-    - loginAction() of UserController should then only call authenticate()
+  - Create comment/comments objects
+  - Refactor url() usage
+    - Should use baseUrl() instead
   - Refactor views
     - Determine optimal UI for app
       - split BorderContainer (top and center)</diff>
      <filename>TODO</filename>
    </modified>
    <modified>
      <diff>@@ -53,7 +53,6 @@ class Bootstrap extends My_Application_Bootstrap_Base
     public function initHelpers()
     {
         Zend_Controller_Action_HelperBroker::addPrefix('My_Controller_Helper');
-        Zend_Controller_Action_HelperBroker::getStaticHelper('ResourceLoader');
         return $this;
     }
 </diff>
      <filename>application/Bootstrap.php</filename>
    </modified>
    <modified>
      <diff>@@ -31,8 +31,6 @@ class Spindle_Bootstrap extends My_Application_Bootstrap_Module
     public function initAutoloader()
     {
         $autoloader = $this-&gt;getResourceLoader();
-        $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('ResourceLoader');
-        $helper-&gt;addResourceLoader('spindle', $autoloader);
         return $this;
     }
 </diff>
      <filename>application/modules/spindle/Bootstrap.php</filename>
    </modified>
    <modified>
      <diff>@@ -14,6 +14,10 @@ class Spindle_BugController extends Zend_Controller_Action
 
     public function preDispatch()
     {
+        $ac = $this-&gt;_helper-&gt;getHelper('AjaxContext');
+        $ac-&gt;addActionContext('add', 'html');
+        $ac-&gt;initContext($this-&gt;_getParam('format'));
+
         $this-&gt;model        = new Spindle_Model_BugTracker;
         $this-&gt;commentModel = new Spindle_Model_CommentManager;
 </diff>
      <filename>application/modules/spindle/controllers/BugController.php</filename>
    </modified>
    <modified>
      <diff>@@ -280,6 +280,24 @@ class Spindle_Model_BugTracker extends Spindle_Model_Model
         return $adapter-&gt;fetchPairs('select id, priority FROM priority_type');
     }
 
+    public function save(array $info, $validator = null)
+    {
+        if (empty($info['reporter_id'])) {
+            $user  = $this-&gt;getIdentity();
+            if (isset($user-&gt;id)) {
+                $info['reporter_id'] = $user-&gt;id;
+            }
+        }
+        $form = $this-&gt;getBugForm();
+        $form-&gt;addElement('hidden', 'reporter_id', array(
+            'required'   =&gt; true,
+            'validators' =&gt; array(
+                'Digits',
+            ),
+        ));
+        return parent::save($info, $validator);
+    }
+
     /**
      * Fetch an individual bug by id
      * 
@@ -452,7 +470,7 @@ class Spindle_Model_BugTracker extends Spindle_Model_Model
     public function getBugForm()
     {
         if (null === $this-&gt;_form) {
-            $this-&gt;_form = new Spindle_Model_Form_Bug;
+            $this-&gt;_form = new Spindle_Model_Form_Bug(array('model' =&gt; $this));
         }
         return $this-&gt;_form;
     }</diff>
      <filename>application/modules/spindle/models/BugTracker.php</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,9 @@ class Spindle_Model_BugTracker_Bug extends Spindle_Model_Result
         'id',
         'reporter_id',
         'developer_id',
+        'priority',
         'priority_id',
+        'issue_type',
         'type_id',
         'resolution_id',
         'summary',</diff>
      <filename>application/modules/spindle/models/BugTracker/Bug.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,15 @@
 &lt;?php
 class Spindle_Model_Form_Bug extends Zend_Dojo_Form
 {
+    protected $_model;
+
     public function init()
     {
-        $this-&gt;addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
-        $this-&gt;addPrefixPath('My_Form_Decorator', 'My/Form/Decorator/', 'decorator');
+        $this-&gt;setName('bugform')
+             -&gt;addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element')
+             -&gt;addPrefixPath('My_Form_Decorator', 'My/Form/Decorator/', 'decorator');
 
-        $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('ResourceLoader');
-        $model  = $helper-&gt;getModel('BugTracker');
+        $model  = $this-&gt;getModel();
 
         $priorities = $model-&gt;getPriorities();
         $types      = $model-&gt;getTypes();
@@ -51,4 +53,18 @@ class Spindle_Model_Form_Bug extends Zend_Dojo_Form
             'decorators' =&gt; array('ViewHelper'),
         ));
     }
+
+    public function setModel($model)
+    {
+        $this-&gt;_model = $model;
+        return $this;
+    }
+
+    public function getModel()
+    {
+        if (null === $this-&gt;_model) {
+            $this-&gt;setModel(new Spindle_Model_BugTracker());
+        }
+        return $this-&gt;_model;
+    }
 }</diff>
      <filename>application/modules/spindle/models/Form/Bug.php</filename>
    </modified>
    <modified>
      <diff>@@ -1,13 +1,14 @@
 &lt;?php
 class Spindle_Model_Form_Register extends Zend_Dojo_Form
 {
+    protected $_model;
+
     public function init()
     {
         $this-&gt;addPrefixPath('My_Form_Element', 'My/Form/Element/', 'element');
         $this-&gt;addPrefixPath('My_Form_Decorator', 'My/Form/Decorator/', 'decorator');
 
-        $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('ResourceLoader');
-        $user   = $helper-&gt;getModel('UserManager'); // mainly ensure it's loaded, for validation'
+        $user   = $this-&gt;getModel();
 
         $this-&gt;addElementPrefixPath('Spindle_Model_Validate', dirname(__FILE__) . '/../Validate', 'validate');
 
@@ -78,4 +79,15 @@ class Spindle_Model_Form_Register extends Zend_Dojo_Form
             'label'    =&gt; 'Register',
         ));
     }
+
+    public function setModel($model)
+    {
+        $this-&gt;_model = $model;
+        return $this;
+    }
+
+    public function getModel()
+    {
+        return $this-&gt;_model;
+    }
 }</diff>
      <filename>application/modules/spindle/models/Form/Register.php</filename>
    </modified>
    <modified>
      <diff>@@ -183,7 +183,11 @@ abstract class Spindle_Model_Model implements Zend_Acl_Resource_Interface
     public function getIdentity()
     {
         if (null === $this-&gt;_identity) {
-            return 'guest';
+            $auth = Zend_Auth::getInstance();
+            if (!$auth-&gt;hasIdentity()) {
+                return 'guest';
+            }
+            $this-&gt;setIdentity($auth-&gt;getIdentity());
         }
 
         return $this-&gt;_identity;
@@ -321,7 +325,6 @@ abstract class Spindle_Model_Model implements Zend_Acl_Resource_Interface
             $info = $info[$parent];
         }
 
-
         if (array_key_exists('id', $info)) {
             $id = $info['id'];
             unset($info['id']);
@@ -331,7 +334,7 @@ abstract class Spindle_Model_Model implements Zend_Acl_Resource_Interface
             }
         }
         if (null === $row) {
-            $row = $table-&gt;createRow();
+            $row = $table-&gt;createRow($info);
             $row-&gt;date_created = date('Y-m-d');
         }
 </diff>
      <filename>application/modules/spindle/models/Model.php</filename>
    </modified>
    <modified>
      <diff>@@ -150,7 +150,7 @@ class Spindle_Model_Service_Pastebin
     protected function _getPastebin()
     {
         if (null === $this-&gt;_pastebin) {
-            $this-&gt;_pastebin = $this-&gt;_getResourceLoader()-&gt;getModel('pastebin');
+            $this-&gt;_pastebin = new Spindle_Model_Pastebin();
         }
         return $this-&gt;_pastebin;
     }</diff>
      <filename>application/modules/spindle/models/Service/Pastebin.php</filename>
    </modified>
    <modified>
      <diff>@@ -169,7 +169,7 @@ class Spindle_Model_UserManager extends Spindle_Model_Model
     public function getRegisterForm()
     {
         if (empty($this-&gt;_formRegister)) {
-            $this-&gt;_formRegister = new Spindle_Model_Form_Register;
+            $this-&gt;_formRegister = new Spindle_Model_Form_Register(array('model' =&gt; $this));
         }
         return $this-&gt;_formRegister;
     }</diff>
      <filename>application/modules/spindle/models/UserManager.php</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,7 @@ class Spindle_Model_UserManager_User
     implements Zend_Auth_Adapter_Interface, Zend_Acl_Role_Interface
 {
     protected $_allowed = array(
+        'id',
         'username',
         'password',
         'email',</diff>
      <filename>application/modules/spindle/models/UserManager/User.php</filename>
    </modified>
    <modified>
      <diff>@@ -11,14 +11,5 @@
 &lt;textarea readonly=&quot;readonly&quot;&gt;&lt;?= $this-&gt;escape($this-&gt;bug-&gt;description) ?&gt;&lt;/textarea&gt;
 
 &lt;h3&gt;Comments&lt;/h3&gt;
-&lt;?= $this-&gt;comments($this-&gt;url(
-    array(
-        'module'     =&gt; 'spindle',
-        'controller' =&gt; 'bug',
-        'action'     =&gt; 'view',
-        'id'         =&gt; $this-&gt;bug-&gt;id,
-    ),
-    'default',
-    true
-)) ?&gt;
+&lt;?= $this-&gt;comments($this-&gt;baseUrl() . '/spindle/bug/view/' . $this-&gt;bug-&gt;id) ?&gt;
 </diff>
      <filename>application/modules/spindle/views/scripts/bug/view.phtml</filename>
    </modified>
    <modified>
      <diff>@@ -14,5 +14,7 @@ RewriteCond %{REQUEST_FILENAME} -l [OR]
 RewriteCond %{REQUEST_FILENAME} -d
 RewriteRule ^.*$ - [NC,L]
 RewriteRule ^list          list.php  [L,QSA]
+RewriteRule ^jsonrpc           jsonrpc.php [L]
+RewriteRule ^content/jsonrpc   jsonrpc.php [L]
 RewriteRule ^.*$ index.php [NC,L]
 </diff>
      <filename>public/api/spindle/bug/.htaccess</filename>
    </modified>
    <modified>
      <diff>@@ -12,7 +12,9 @@ $whitelist = array(
     '/content/all-grid.html',
 );
 
-if (!in_array($file, $whitelist)) {
+if (!in_array($file, $whitelist)
+    &amp;&amp; !preg_match('#^/content/(bug)-(\d+)\.html$#', $file, $matches)
+) {
     header('HTTP/1.0 501 Not Implemented');
     echo &quot;&lt;h1&gt;501 - Not Implemented&lt;/h1&gt;&quot;;
     echo &quot;&lt;p&gt;Page requested: &quot; . htmlentities($file) . &quot;&lt;/p&gt;&quot;;
@@ -33,10 +35,11 @@ $view-&gt;baseUrl = Zend_Registry::get('baseUrl');
 $view-&gt;model   = $model;
 
 if (isset($matches) &amp;&amp; $matches) {
-    $view-&gt;id    = $matches[2];
+    $view-&gt;bug    = $model-&gt;fetchBug($matches[2]);
     switch ($matches[1]) {
+        case 'bug':
         default:
-            $viewScript = '';
+            $viewScript = 'bug/content/view.phtml';
             break;
     }
 } else {</diff>
      <filename>public/api/spindle/bug/index.php</filename>
    </modified>
    <modified>
      <diff>@@ -2,8 +2,16 @@ dojo.provide(&quot;bug._base&quot;);
 
 (function(){
     dojo.require(&quot;bug.layout.BugLayout&quot;);
+    dojo.require(&quot;dijit.Dialog&quot;);
+    dojo.require(&quot;dijit.form.ValidationTextBox&quot;);
+    dojo.require(&quot;dijit.form.FilteringSelect&quot;);
+    dojo.require(&quot;dijit.form.SimpleTextarea&quot;);
+    dojo.require(&quot;dijit.form.Button&quot;);
+    dojo.require(&quot;dijit.form.Form&quot;);
     dojo.require(&quot;dojox.data.QueryReadStore&quot;);
     dojo.require(&quot;dojox.grid.DataGrid&quot;);
+    dojo.require(&quot;dojox.rpc.Service&quot;);
+    dojo.require(&quot;dojox.rpc.JsonRPC&quot;);
 
     bug.initLayout = function() {
         console.log(&quot;In bug.initLayout()&quot;);
@@ -17,4 +25,67 @@ dojo.provide(&quot;bug._base&quot;);
         mainPane.resize();
         dijit.byId(&quot;spindleNavMenuAccordion&quot;).selectChild(dijit.byId(&quot;spindleNavMenuBugs&quot;));
     };
+
+    bug.newDialog = function() {
+        if (!bug._newDialog) {
+            bug._newDialog = new dijit.Dialog({
+                title:         &quot;Submit new issue&quot;,
+                href:          spindle.baseUrl + &quot;/spindle/bug/add/format/html&quot;,
+                parseOnLoad:   true,
+                refreshOnShow: false,
+                style:         &quot;height: 375px; width: 450px;&quot;,
+                onLoad:        function() {
+                    var bform = dojo.byId(&quot;bugform&quot;);
+                    spindle.prepareForm(bform);
+                    dojo.connect(bform, &quot;onsubmit&quot;, bug, &quot;processNewBug&quot;);
+                }
+            });
+            dojo.body().appendChild(bug._newDialog.domNode);
+        }
+        bug._newDialog.startup();
+        bug._newDialog.show();
+    };
+
+    bug.processNewBug = function(e) {
+        e.preventDefault();
+
+        var bugDef  = spindle.prepareFormElements(dojo.byId(&quot;bugform&quot;));
+
+        console.log(bugDef);
+
+        var service = bug._getService();
+
+        if (&quot;id&quot; in bugDef) {
+            delete bugDef.id;
+        }
+
+        service.add(bugDef).addCallback(function(result) {
+            if (!result.error &amp;&amp; !result.success) {
+                var errors = [{
+                    label:    &quot;General Transport Error: &quot;, 
+                    messages: [&quot;A general error occurred; please try again later.&quot;],
+                }];
+                spindle.createErrorDialog(errors);
+                return;
+            } else if (result.error) {
+                spindle.createErrorDialog(result.messages);
+                return;
+            }
+
+            bug._newDialog.hide();
+            var bugPane = dijit.byId(&quot;bugPane&quot;);
+            bugPane.setHref(&quot;/api/spindle/bug/content/bug-&quot; + result.success + &quot;.html&quot;);
+            bugPane.refresh();
+        });
+    };
+
+    bug._getService = function() {
+        if (!bug._service) {
+            bug._service = new dojox.rpc.Service(
+                spindle.baseUrl + &quot;/api/spindle/bug/content/jsonrpc.smd&quot;, 
+                { envelope:&quot;JSON-RPC-2.0&quot; }
+            );
+        }
+        return bug._service;
+    };
 })();</diff>
      <filename>public/js-src/bug/_base.js</filename>
    </modified>
    <modified>
      <diff>@@ -88,7 +88,7 @@ dojo.provide(&quot;spindle._base&quot;);
                     var rform = dojo.byId(&quot;register&quot;);
                     spindle.prepareForm(rform);
                     dojo.connect(rform, &quot;onsubmit&quot;, spindle, &quot;processRegisterForm&quot;);
-                },
+                }
             });
             dojo.body().appendChild(spindle._loginDialog.domNode);
         }</diff>
      <filename>public/js-src/spindle/_base.js</filename>
    </modified>
    <modified>
      <diff>@@ -18,7 +18,8 @@
                 &lt;div id=&quot;spindleNavMenuBugs&quot; dojoType=&quot;dijit.layout.AccordionPane&quot; 
                     title=&quot;Bugs&quot;&gt;
                     &lt;ul class=&quot;menu&quot;&gt;
-                        &lt;li&gt;&lt;a onClick=&quot;spindle.layoutSwitch('bug');dijit.byId('bugListTabContainer').selectChild(dijit.byId('bugListOpen'));&quot;&gt;Open Bugs&lt;/a&gt;&lt;/li&gt;
+                        &lt;li&gt;&lt;a onClick=&quot;bug.newDialog()&quot;&gt;Submit New Issue&lt;/a&gt;&lt;/li&gt;
+                        &lt;li&gt;&lt;a onClick=&quot;spindle.layoutSwitch('bug');dijit.byId('bugListTabContainer').selectChild(dijit.byId('bugListOpen'));&quot;&gt;Open s&lt;/a&gt;&lt;/li&gt;
                         &lt;li&gt;&lt;a onClick=&quot;spindle.layoutSwitch('bug');dijit.byId('bugListTabContainer').selectChild(dijit.byId('bugListResolved'));&quot;&gt;Resolved Bugs&lt;/a&gt;&lt;/li&gt;
                         &lt;li&gt;&lt;a onClick=&quot;spindle.layoutSwitch('bug');dijit.byId('bugListTabContainer').selectChild(dijit.byId('bugListAll'));&quot;&gt;All Bugs&lt;/a&gt;&lt;/li&gt;
                     &lt;/ul&gt;</diff>
      <filename>public/js-src/spindle/templates/NavMenu.html</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>74d84b873959afdf4a96833ef81a752f3327ded8</id>
    </parent>
  </parents>
  <author>
    <name>Matthew Weier O'Phinney</name>
    <email>matthew@weierophinney.net</email>
  </author>
  <url>http://github.com/weierophinney/pastebin/commit/18c927e4dd203415dfca2a8263a63db194aa6db1</url>
  <id>18c927e4dd203415dfca2a8263a63db194aa6db1</id>
  <committed-date>2008-12-23T15:10:31-08:00</committed-date>
  <authored-date>2008-12-23T15:10:31-08:00</authored-date>
  <message>New issue dialog, and relate services</message>
  <tree>4611a4b2d07cfad90c84b2f3967599401dddac3c</tree>
  <committer>
    <name>Matthew Weier O'Phinney</name>
    <email>matthew@weierophinney.net</email>
  </committer>
</commit>
