? issue_567558_extra.patch
? storm--891916-1.patch
? storm--891934-1.patch
? storm--891934-3.patch
? storm--891934-5.patch
Index: storm.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/storm.module,v
retrieving revision 1.10.4.59
diff -u -p -r1.10.4.59 storm.module
--- storm.module	23 Aug 2010 17:12:04 -0000	1.10.4.59
+++ storm.module	12 Sep 2010 21:03:58 -0000
@@ -454,7 +454,7 @@ function storm_dateext_expand($element) 
     $parents[] = $type;
     $element[$type] = array(
       '#type' => 'select',
-      '#value' => $element['#value'][$type],
+      '#value' => isset($element['#value'][$type]) ? $element['#value'][$type] : NULL,
       '#attributes' => $element['#attributes'],
       '#options' => $options,
       '#attributes' => array('onchange' => "storm_datext_tonull(this, '". $element['#id'] ."')"),
Index: stormticket/stormticket.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/stormticket/stormticket.module,v
retrieving revision 1.5.4.47
diff -u -p -r1.5.4.47 stormticket.module
--- stormticket/stormticket.module	9 Sep 2010 22:16:37 -0000	1.5.4.47
+++ stormticket/stormticket.module	12 Sep 2010 21:03:58 -0000
@@ -355,13 +355,13 @@ function stormticket_form(&$node) {
       }
     }
 
-    if ($_SESSION['stormticket_list_filter']['organization_nid'] && !$node->organization_nid) {
+    if (isset($_SESSION['stormticket_list_filter']['organization_nid']) && !$node->organization_nid) {
       $node->organization_nid = $_SESSION['stormticket_list_filter']['organization_nid'];
     }
-    if ($_SESSION['stormticket_list_filter']['project_nid'] && !$node->project_nid) {
+    if (isset($_SESSION['stormticket_list_filter']['project_nid']) && !$node->project_nid) {
       $node->project_nid = $_SESSION['stormticket_list_filter']['project_nid'];
     }
-    if ($_SESSION['stormticket_list_filter']['task_nid'] && !$node->task_nid) {
+    if (isset($_SESSION['stormticket_list_filter']['task_nid']) && !$node->task_nid) {
       $node->task_nid = $_SESSION['stormticket_list_filter']['task_nid'];
     }
 
@@ -395,7 +395,9 @@ function stormticket_form(&$node) {
   $organizations = array();
   while ($organization = db_fetch_object($r)) {
     $organizations[$organization->nid] = $organization->title;
-    if (!$node->organization_nid) $node->organization_nid = $organization->nid;
+    if (!isset($node->organization_nid)) {
+      $node->organization_nid = $organization->nid;
+    }
   }
   $form['group1']['organization_nid'] = array(
     '#type' => 'select',
@@ -417,25 +419,25 @@ function stormticket_form(&$node) {
   $form['group1']['project_nid'] = array(
     '#type' => 'select',
     '#title' => t('Project'),
-    '#default_value' => $node->project_nid,
+    '#default_value' => isset($node->project_nid) ? $node->project_nid : 0,
     '#options' => array(0 => '-') + $projects,
     '#process' => array('storm_dependent_select_process'),
     '#attributes' => array('onchange' => "stormtask_project_tasks('edit-organization-nid', this, 'edit-task-nid', 'edit-assigned-nid', true, '-')"),
   );
 
-  $tree = _stormtask_get_tree($node->project_nid);
+  $tree = isset(_stormtask_get_tree($node->project_nid)) ? _stormtask_get_tree($node->project_nid) : array();
   $tasks = _stormtask_plain_tree($tree);
   $form['group1']['task_nid'] = array(
     '#type' => 'select',
     '#title' => t('Task'),
-    '#default_value' => $node->task_nid,
+    '#default_value' => isset($node->task_nid) ? $node->task_nid : 0,
     '#options' => array(0 => '-') + $tasks,
     '#process' => array('storm_dependent_select_process'),
   );
   
   $form['group1']['task_nid_old'] = array(
     '#type' => 'hidden',
-    '#default_value' => $node->task_nid,
+    '#default_value' => isset($node->task_nid) ? $node->task_nid : NULL,
   );
   
   $form['group2'] = array(
@@ -493,7 +495,7 @@ function stormticket_form(&$node) {
     '#type' => 'dateext',
     '#title' => t('Date end'),
     '#withnull' => TRUE,
-    '#default_value' => _storm_gmtimestamp_to_date($node->dateend),
+    '#default_value' => isset($node->dateend) ? _storm_gmtimestamp_to_date($node->dateend) : NULL,
   );
 
   $durationunits = stormattribute_attributes_bydomain('Duration unit');
@@ -508,7 +510,7 @@ function stormticket_form(&$node) {
     '#type' => 'textfield',
     '#title' => t('Duration'),
     '#size' => 20,
-    '#default_value' => $node->duration,
+    '#default_value' => isset($node->duration) ? $node->duration : NULL,
   );
 
   $form['group4'] = array(
@@ -530,7 +532,7 @@ function stormticket_form(&$node) {
     '#title' => t('Price'),
     '#type' => 'textfield',
     '#size' => 15,
-    '#default_value' => $node->price,
+    '#default_value' => isset($node->price) ? $node->price : NULL,
   );
 
   $currencies = stormattribute_attributes_bydomain('Currency');
@@ -547,13 +549,13 @@ function stormticket_form(&$node) {
     '#weight' => module_exists('content') ? content_extra_field_weight($node->type, 'group5') : -15,
   );
   
-  $options = storm_get_assignment_options($node->organization_nid, $node->project_nid);
+  $options = isset($node->project_nid) ? storm_get_assignment_options($node->organization_nid, $node->project_nid) : storm_get_assignment_options($node->organization_nid);
   
   $form['group5']['assigned_nid'] = array(
     '#type' => 'select',
     '#title' => t('Assigned to'),
     '#options' => $options,
-    '#default_value' => $node->assigned_nid,
+    '#default_value' => isset($node->assigned_nid) ? $node->assigned_nid : NULL,
   );
 
   $form['group6'] = array(
@@ -572,7 +574,7 @@ function stormticket_form(&$node) {
   $form['group6']['billed'] = array(
     '#type' => 'checkbox',
     '#title' => t('Billed'),
-    '#default_value' => $node->billed,
+    '#default_value' => isset($node->billed) ? $node->billed : 0,
     '#weight' => 2,
   );
 
@@ -582,7 +584,7 @@ function stormticket_form(&$node) {
 
   $form['title_old'] = array(
     '#type' => 'hidden',
-    '#default_value' => $node->title_old,
+    '#default_value' => isset($node->title_old) ? $node->title_old : NULL,
   );
 
   return $form;
@@ -665,16 +667,16 @@ function _stormticket_beforesave(&$node)
         WHERE type='stormproject' AND n.nid=%d";
   $r = db_query($s, $node->project_nid);
   $p = db_fetch_object($r);
-  $node->project_title = $p->title;
+  $node->project_title = isset($p->title) ? $p->title : '';
 
   $s = "SELECT title, stepno FROM {node} n INNER JOIN {stormtask} t ON n.nid=t.nid WHERE n.type='stormtask' AND n.nid=%d";
   $r = db_query($s, $node->task_nid);
   $ta = db_fetch_object($r);
-  $node->task_title = $ta->title;
-  $node->task_stepno = $ta->stepno;
+  $node->task_title = isset($ta->title) ? $ta->title : '';
+  $node->task_stepno = isset($ta->stepno) ? $ta->stepno : '';
   
   $assigned = node_load($node->assigned_nid);
-  $node->assigned_title = $assigned->title;
+  $node->assigned_title = isset($assigned->title) ? $assigned->title : '';
   
   // Allow use of comma when inputting numerical values - str_replace with period decimal
   $node->duration = str_replace(',', '.', $node->duration);
@@ -687,7 +689,7 @@ function _stormticket_beforesave(&$node)
 function stormticket_nodeapi(&$node, $op, $teaser, $page) {
   switch ($op) {
     case 'prepare':
-      if (!$node->nid) {
+      if (!isset($node->nid)) {
         $category_list = stormattribute_attributes_bydomain('Ticket category');
         $node->ticketcategory = $category_list['default'];
 
Index: stormticket/stormticket.test
===================================================================
RCS file: stormticket/stormticket.test
diff -N stormticket/stormticket.test
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ stormticket/stormticket.test	12 Sep 2010 21:03:58 -0000
@@ -0,0 +1,45 @@
+<?php
+class StormticketTestCase extends DrupalWebTestCase {
+
+  public static function getInfo() {
+    return array(
+      'name' => t('Storm Ticket Functionality'),
+      'description' => t('Test the functionality of the Storm Ticket module'),
+      'group' => 'Storm',
+    );
+  }
+
+  public function setUp() {
+    parent::setUp('storm', 'stormattribute', 'stormorganization', 'stormproject', 'stormtask', 'stormticket');
+  }
+
+  public function testStormticketCreate() {
+    // Create and login user
+    $user = $this->drupalCreateUser(array('Storm organization: add', 'Storm organization: view all', 'Storm project: add', 'Storm project: view all', 'Storm task: add', 'Storm task: view all', 'Storm ticket: add', 'Storm ticket: view all'));
+    $this->drupalLogin($user);
+
+    // Create organization and invoice
+    $org = array(
+      'title' => $this->randomName(32),
+      'body' => $this->randomName(64),
+    );
+    $prj = array(
+      'title' => $this->randomName(32),
+      'organization_nid' => '1',
+    );
+    $task = array(
+      'title' => $this->randomName(32),
+      'body' => $this->randomName(64),
+    );
+    $ticket = array(
+      'title' => $this->randomName(32),
+      'body' => $this->randomName(64),
+    );
+    $this->drupalPost('node/add/stormorganization', $org, t('Save'));
+    $this->drupalPost('node/add/stormproject', $prj, t('Save'));
+    $this->drupalPost('node/add/stormtask', $task, t('Save'));
+    $this->drupalPost('node/add/stormticket', $ticket, t('Save'));
+
+    $this->assertText(t('Ticket @title has been created.', array('@title' => $ticket['title'])));;
+  }
+}
Index: stormticket/stormticket.theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/storm/stormticket/stormticket.theme.inc,v
retrieving revision 1.5.4.19
diff -u -p -r1.5.4.19 stormticket.theme.inc
--- stormticket/stormticket.theme.inc	23 Aug 2010 16:46:13 -0000	1.5.4.19
+++ stormticket/stormticket.theme.inc	12 Sep 2010 21:03:58 -0000
@@ -37,7 +37,6 @@ function theme_stormticket_view($node, $
   drupal_add_css(drupal_get_path('module', 'storm') . '/storm-node.css', 'module');
   
   $node = node_prepare($node, $teaser);
-  $l_pos = 1; // Used to increase the link position number (see issue 814820)
   
   $node->content['links'] = array(
     '#prefix' => '<div class="stormlinks"><dl>',
@@ -45,8 +44,8 @@ function theme_stormticket_view($node, $
     '#weight' => -25,
   );
 
-  $node->content['links']['expenses'] = theme('storm_link', 'stormticket', 'stormexpense', $node->nid, $l_pos++);
-  $node->content['links']['timetrackings'] = theme('storm_link', 'stormticket', 'stormtimetracking', $node->nid, $l_pos++);
+  $node->content['links']['expenses'] = theme('storm_link', 'stormticket', 'stormexpense', $node->nid, 1);
+  $node->content['links']['timetrackings'] = theme('storm_link', 'stormticket', 'stormtimetracking', $node->nid, 2);
 
   // Code to create invoice auto_add link
   if (module_exists('storminvoice')) {
@@ -55,7 +54,7 @@ function theme_stormticket_view($node, $
       '#prefix' => variable_get('storm_icons_display', TRUE) ? '<dt id="storminvoices" class="stormcomponent">' : '<dt class="stormcomponent">',
       '#suffix' => '</dt>',
       '#value' => theme('storminvoice_autoadd_links', $node->nid, $node->billable, $node->billed),
-      '#weight' => $l_pos++,
+      '#weight' => 3,
     );
   }
 
@@ -69,21 +68,21 @@ function theme_stormticket_view($node, $
     '#prefix' => '<div class="organization">',
     '#suffix' => '</div>',
     '#value' => theme('storm_view_item', t('Organization'), l($node->organization_title, 'node/'. $node->organization_nid)),
-    '#weight' => $w++,
+    '#weight' => 1,
   );
 
   $node->content['group1']['project_nid'] = array(
     '#prefix' => '<div class="project">',
     '#suffix' => '</div>',
     '#value' => theme('storm_view_item', t('Project'), l($node->project_title, 'node/'. $node->project_nid)),
-    '#weight' => $w++,
+    '#weight' => 2,
   );
 
   $node->content['group1']['task_nid'] = array(
     '#prefix' => '<div class="task">',
     '#suffix' => '</div>',
     '#value' => theme('storm_view_item', t('Task'), l($node->task_title, 'node/'. $node->task_nid)),
-    '#weight' => $w++,
+    '#weight' => 2,
   );
 
   $node->content['group2'] = array(
@@ -123,7 +122,6 @@ function theme_stormticket_view($node, $
     '#prefix' => '<div class="assigned">',
     '#suffix' => '</div>',
     '#value' => theme('storm_view_item', t('Assigned to'), l($node->assigned_title, 'node/'. $node->assigned_nid)),
-    '#weight' => 4,
   );
   
   $node->content['body_field'] = array(
