? .project_issue.module.swp
? includes/.comment.inc.swp
Index: project_issue.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v
retrieving revision 1.182
diff -u -F '^f' -r1.182 project_issue.module
--- project_issue.module	14 Sep 2010 23:49:06 -0000	1.182
+++ project_issue.module	15 Sep 2010 23:54:52 -0000
@@ -1813,20 +1813,58 @@ function project_issue_block($op = 'list
     // Invalidate the cache for this block since the categories might change.
     cache_clear_all('project_issue_cockpit_block:', 'cache', TRUE);
   }
-  elseif ($op == 'view' && ($node = project_get_project_from_menu()) && !empty($node->project_issue['issues']) && node_access('view', $node)) {
-    $cid = 'project_issue_cockpit_block:'. $node->nid;
-    if (($cache = cache_get($cid))) {
-      $block = $cache->data;
+  elseif ($op == 'view') {
+    if (isset($edit['homebox']) && isset($edit['homebox']->nid)) {
+      $node = node_load($edit['homebox']->nid);
     }
     else {
-      module_load_include('inc', 'project_issue', 'includes/issue_cockpit');
-      $block = array(
-        'subject' => t('Issues for @project', array('@project' => $node->title)),
-        'content' => theme('project_issue_issue_cockpit', $node),
-      );
-      cache_set($cid, $block);
+      $node = project_get_project_from_menu();
     }
-    return $block;
+    if ($node && !empty($node->project_issue['issues']) && node_access('view', $node)) {
+      $cid = 'project_issue_cockpit_block:'. $node->nid;
+      if (($cache = cache_get($cid))) {
+        $block = $cache->data;
+      }
+      else {
+        module_load_include('inc', 'project_issue', 'includes/issue_cockpit');
+        $block = array(
+          'subject' => t('Issues for @project', array('@project' => $node->title)),
+          'content' => theme('project_issue_issue_cockpit', $node),
+        );
+        cache_set($cid, $block);
+      }
+      return $block;
+    }
+  }
+}
+
+function project_issue_homebox_block_keys($block) {
+  return array('nid');
+}
+
+function project_issue_homebox_block_edit_form($block) {
+  $form = array();
+
+  $node = node_load($block->nid);
+  $form['project_title'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Project name'),
+    '#size' => 20,
+    '#autocomplete_path' => 'project/autocomplete/project',
+    '#default_value' => empty($node) ? '' : $node->title,
+  );
+  $form['#validate'][] = 'project_issue_homebox_block_edit_form_validate';
+
+  return $form;
+}
+
+function project_issue_homebox_block_edit_form_validate($form, &$form_state) {
+  $nid = db_result(db_query("SELECT nid FROM {node} WHERE title = '%s' AND type = '%s'", $form_state['values']['project_title'], 'project_project'));
+  if (empty($nid)) {
+    form_set_error('project_title', t('The name you entered (%title) is not a valid project.', array('%title' => $form_state['values']['project_title'])));
+  }
+  else {
+    $form_state['values']['nid'] = $nid;
   }
 }
 
