--- ecard_5.x-1.3.module	2008-07-02 11:16:02.000000000 +0200
+++ ecard.module	2008-07-04 11:14:00.000000000 +0200
@@ -5,13 +5,14 @@
 
 // Implementation of hook_perm().
 function ecard_perm() {
-  return array('view ecards', 'send ecards');
+  return array('view ecards', 'send ecards', 'send own ecards');
 }
 
 /**
  * Implementation of hook_menu.
  */
 function ecard_menu($may_cache) {
+  global $user;
   $items = array();
   if (!$may_cache) {
     $items[] = array(
@@ -29,9 +30,9 @@ function ecard_menu($may_cache) {
       'callback' => 'drupal_get_form',
       'callback arguments' => array('ecard_form'),
       'type' => MENU_CALLBACK,
-      'access' => user_access('send ecards')
+      'access' => (user_access('send ecards')) || (user_access('send own ecards') && ($user->uid == $node->uid))
     );
-    
+ 
     $items[] = array (
 		'path' => 'ecard/view',
 		'callback' => 'ecard_view',
@@ -174,6 +175,7 @@ function ecard_nodeapi(&$node, $op, $tea
  * Define the form 
  */ 
 function ecard_form($node=NULL,$form_values=NULL) { 
+        global $user;
 	if ($node == NULL)
 		drupal_goto();
 
@@ -191,7 +193,8 @@ function ecard_form($node=NULL,$form_val
 			unset ($_SESSION['message']);
 		}
 		
- 	  // Things to happen if step is 1
+ 	  // Things to happen if step is 1 but don't display if no access is permitted
+	  if ((!isset($form['view_message']['msg']['#value'])) && ((user_access('send ecards')) || (user_access('send own ecards') && ($user->uid == $node->uid)))) {
  	  //make a fieldset 
 	  		  $form['block'] = array(
 			'#type' => 'fieldset',
@@ -246,7 +249,7 @@ function ecard_form($node=NULL,$form_val
 			'#type' => 'value',
 			'#value' => $node->nid
 		);
-		
+           }		
   return $form;
 }
 
