15c15
< 			break;
---
>       break;
39c39
< 	global $q;
---
>   global $q;
41,43c41,43
< 	  if (module_invoke('user', 'access', 'create newsletter') || module_invoke('user', 'access', 'administer simplenews')) {
< 		  return TRUE;
< 		}
---
>     if (module_invoke('user', 'access', 'create newsletter') || module_invoke('user', 'access', 'administer simplenews')) {
>       return TRUE;
>     }
46,48c46,48
< 	  if (module_invoke('user', 'access', 'administer simplenews')) {
< 		  return TRUE;
< 		}
---
>     if (module_invoke('user', 'access', 'administer simplenews')) {
>       return TRUE;
>     }
60,61c60,61
< 	if ($result->status == 1) {
< 	 	$stylesheet = drupal_get_path('module', 'simplenews').'/simplenews.css';
---
>   if ($result->status == 1) {
>      $stylesheet = drupal_get_path('module', 'simplenews').'/simplenews.css';
63,64c63,64
< 	}
< 	
---
>   }
>   
71c71
< 										 'callback' => 'simplenews_admin');
---
>                      'callback' => 'simplenews_admin');
104,105c104,105
< 										 'callback' => 'simplenews_confirm_subscription',
< 										 'type' => MENU_CALLBACK);
---
>                      'callback' => 'simplenews_confirm_subscription',
>                      'type' => MENU_CALLBACK);
108,109c108,109
< 										 'callback' => 'simplenews_confirm_subscription',
< 										 'type' => MENU_CALLBACK);
---
>                      'callback' => 'simplenews_confirm_subscription',
>                      'type' => MENU_CALLBACK);
121c121,124
< 	  variable_set($user->uid.'_sn_return',1);
---
>     variable_set($user->uid.'_sn_return',1);
>   }
>   else {
>     variable_set($user->uid.'_sn_return',0);
123,125d125
< 	else {
< 	  variable_set($user->uid.'_sn_return',0);
< 	}
132,134c132,134
< 	t('This will be the body of your newsletter. Available variables are:') . ' %site ' . t('(the name of your website),')
< 	 . ' %uri ' . t('(a link to your homepage),') . ' %uri_brief ' . t('(homepage link without the http://),')
< 	 . ' %mymail ' . t('(your email address),') . ' %date ' . t('(today\'s date),') . ' %login_uri ' . t('(link to login page).'), $atts, FALSE);
---
>   t('This will be the body of your newsletter. Available variables are:') . ' %site ' . t('(the name of your website),')
>    . ' %uri ' . t('(a link to your homepage),') . ' %uri_brief ' . t('(homepage link without the http://),')
>    . ' %mymail ' . t('(your email address),') . ' %date ' . t('(today\'s date),') . ' %login_uri ' . t('(link to login page).'), $atts, FALSE);
136c136
< 	$output .= module_invoke('filter', 'form', 'format', $node->format);
---
>   $output .= module_invoke('filter', 'form', 'format', $node->format);
138,149c138,149
< 	if (!$sel1 = $node->s_format) {
< 	  $sel1 = variable_get('simplenews_format', 'plain');
< 	}
< 	if (!$sel2 = $node->priority) {
< 	  $sel2 = variable_get('simplenews_priority', 0);
< 	}
< 	if (!$sel3 = $node->receipt) {
< 	  $sel3 = variable_get('simplenews_receipt', 0);
< 	}
< 	if (!$sel4 = $node->s_status) {
< 	  $sel4 = variable_get('simplenews_send', 0);
< 	}
---
>   if (!$sel1 = $node->s_format) {
>     $sel1 = variable_get('simplenews_format', 'plain');
>   }
>   if (!$sel2 = $node->priority) {
>     $sel2 = variable_get('simplenews_priority', 0);
>   }
>   if (!$sel3 = $node->receipt) {
>     $sel3 = variable_get('simplenews_receipt', 0);
>   }
>   if (!$sel4 = $node->s_status) {
>     $sel4 = variable_get('simplenews_send', 0);
>   }
153,165c153,165
< 	if ($node->s_status == 0) {
< 	  if (module_invoke('user', 'access', 'send newsletter')) {
< 	    $group .= form_checkbox(t('Send newsletter'), 'send', 1, $sel4);
< 		}
< 		else {
< 	    $atts = array('disabled'=>'disabled');
< 	    $group .= form_checkbox(t('You have no privileges to send this newsletter'), 'none', 0, FALSE, FALSE, $atts);
< 		}
< 	}
< 	else {
< 	  $atts = array('disabled'=>'disabled');
< 	  $group .= form_checkbox(t('This newsletter has been sent'), 'none', 0, TRUE, FALSE, $atts);
< 	}
---
>   if ($node->s_status == 0) {
>     if (module_invoke('user', 'access', 'send newsletter')) {
>       $group .= form_checkbox(t('Send newsletter'), 'send', 1, $sel4);
>     }
>     else {
>       $atts = array('disabled'=>'disabled');
>       $group .= form_checkbox(t('You have no privileges to send this newsletter'), 'none', 0, FALSE, FALSE, $atts);
>     }
>   }
>   else {
>     $atts = array('disabled'=>'disabled');
>     $group .= form_checkbox(t('This newsletter has been sent'), 'none', 0, TRUE, FALSE, $atts);
>   }
167,168c167,168
< 	$output .= form_hidden('s_status', $node->s_status);
< 	$output .= '<br />';
---
>   $output .= form_hidden('s_status', $node->s_status);
>   $output .= '<br />';
186,194c186,189
< 	//tid is also saved in this table since it is needed by _sn_send(), and the term_node table is
< 	//only updated after the execution of simplenews_insert(). It cannot be passed by a variable
< 	//since simplenews_cron() also calls _sn_send().
< 	if ($edit['send'] == 1) {
< 	  db_query("INSERT INTO {sn_newsletters} (nid, tid, s_status, s_format, priority, receipt)
<   	VALUES (%d, %d, %d, '%s', %d, %d)", $node->nid, $edit['taxonomy'][0], 1, $node->s_format, $node->priority, $node->receipt);
< 	  _sn_send(TRUE);
< 	}
< 	else {
---
>   //tid is also saved in this table since it is needed by _sn_send(), and the term_node table is
>   //only updated after the execution of simplenews_insert(). It cannot be passed by a variable
>   //since simplenews_cron() also calls _sn_send().
>   if ($edit['send'] == 1) {
196,197c191,197
<   	VALUES (%d, %d, %d, '%s', %d, %d)", $node->nid, $edit['taxonomy'][0], 0, $node->s_format, $node->priority, $node->receipt);
< 	}
---
>     VALUES (%d, %d, %d, '%s', %d, %d)", $node->nid, $edit['taxonomy'][0], 1, $node->s_format, $node->priority, $node->receipt);
>     _sn_send(TRUE);
>   }
>   else {
>     db_query("INSERT INTO {sn_newsletters} (nid, tid, s_status, s_format, priority, receipt)
>     VALUES (%d, %d, %d, '%s', %d, %d)", $node->nid, $edit['taxonomy'][0], 0, $node->s_format, $node->priority, $node->receipt);
>   }
208,210c208,210
< 	  _sn_send(TRUE);
< 	}
< 	else {
---
>     _sn_send(TRUE);
>   }
>   else {
213c213
< 	}
---
>   }
222,228c222,228
< 	if ($result) {
< 		drupal_set_message(t('Newsletter %title was successfully deleted.', array('%title'=>theme('placeholder', check_plain($node->title)))), 'status');
< 	}
< 	if (variable_get($user->uid.'_sn_return','') == 1) {
< 	  variable_set($user->uid.'_sn_return', 0);
< 		drupal_goto('admin/simplenews');
< 	}
---
>   if ($result) {
>     drupal_set_message(t('Newsletter %title was successfully deleted.', array('%title'=>theme('placeholder', check_plain($node->title)))), 'status');
>   }
>   if (variable_get($user->uid.'_sn_return','') == 1) {
>     variable_set($user->uid.'_sn_return', 0);
>     drupal_goto('admin/simplenews');
>   }
244c244
< 	$node = module_invoke('node', 'prepare', $node, $teaser);
---
>   $node = module_invoke('node', 'prepare', $node, $teaser);
258,261c258,261
< 		  $query = "SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'";
< 			if ($result = db_fetch_object(db_query($query, $edit['mail']))) {
< 			  db_query("UPDATE {sn_subscriptions} s SET s.uid = %d WHERE s.snid = %d", $edit['uid'], $result->snid);
< 			}
---
>       $query = "SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'";
>       if ($result = db_fetch_object(db_query($query, $edit['mail']))) {
>         db_query("UPDATE {sn_subscriptions} s SET s.uid = %d WHERE s.snid = %d", $edit['uid'], $result->snid);
>       }
264,268c264,268
< 		  $query = "SELECT s.snid FROM {sn_subscriptions} s WHERE s.uid = %d";
< 			if ($result = db_fetch_object(db_query($query, $account->uid))) {
< 			  db_query("UPDATE {sn_subscriptions} s SET s.mail = '%s' WHERE s.snid = %d", $edit['mail'], $result->snid);
< 			}
< 		break;
---
>       $query = "SELECT s.snid FROM {sn_subscriptions} s WHERE s.uid = %d";
>       if ($result = db_fetch_object(db_query($query, $account->uid))) {
>         db_query("UPDATE {sn_subscriptions} s SET s.mail = '%s' WHERE s.snid = %d", $edit['mail'], $result->snid);
>       }
>     break;
282,295c282,295
< 	else {
< 	  if ($_POST['sn']) {
< 		  $sn_email = $edit['sn_email'];
< 		  //valid_email_address() allows empty address, so check this first
< 		  if ($sn_email == '') {
< 			  $message = t('You have to supply an email address');
< 			}
< 			elseif (!valid_email_address($sn_email)) {
< 			  $message = t('The email address you supplied is not valid');
< 			}
< 			else {
< 			$snid_result = db_query("SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'", $sn_email);
< 			$snid_obj = db_fetch_object($snid_result);
< 			$name_default = variable_get('site_name', 'drupal');
---
>   else {
>     if ($_POST['sn']) {
>       $sn_email = $edit['sn_email'];
>       //valid_email_address() allows empty address, so check this first
>       if ($sn_email == '') {
>         $message = t('You have to supply an email address');
>       }
>       elseif (!valid_email_address($sn_email)) {
>         $message = t('The email address you supplied is not valid');
>       }
>       else {
>       $snid_result = db_query("SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'", $sn_email);
>       $snid_obj = db_fetch_object($snid_result);
>       $name_default = variable_get('site_name', 'drupal');
297,313c297,313
< 				  if ($user->uid == 0) {
< 				    if (!db_num_rows($snid_result)) {
< 					    $query = "SELECT u.uid FROM {users} u WHERE u.mail = '%s'";
< 					    if ($result = db_fetch_object(db_query($query, $sn_email))) {
< 						    $uid = $result->uid;
< 					  	}
< 						  else {
< 						    $uid = $user->uid;
< 						  }
< 					    db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $sn_email, $uid, 0);
< 							$snid_result = db_query("SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'", $sn_email);
<         			$snid_obj = db_fetch_object($snid_result);
< 							$watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($sn_email)));
< 				      watchdog('simplenews', $watchdog);
< 							}
< 					//send confirmation email: "Confirm subscription"
< 					$body = t('We have received a request for subscription of your email address, "%mail", to the %s newsletter. To confirm that you want to be added to this mailing list, simply visit the confirmation link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
---
>           if ($user->uid == 0) {
>             if (!db_num_rows($snid_result)) {
>               $query = "SELECT u.uid FROM {users} u WHERE u.mail = '%s'";
>               if ($result = db_fetch_object(db_query($query, $sn_email))) {
>                 $uid = $result->uid;
>               }
>               else {
>                 $uid = $user->uid;
>               }
>               db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $sn_email, $uid, 0);
>               $snid_result = db_query("SELECT s.snid FROM {sn_subscriptions} s WHERE s.mail = '%s'", $sn_email);
>               $snid_obj = db_fetch_object($snid_result);
>               $watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($sn_email)));
>               watchdog('simplenews', $watchdog);
>               }
>           //send confirmation email: "Confirm subscription"
>           $body = t('We have received a request for subscription of your email address, "%mail", to the %s newsletter. To confirm that you want to be added to this mailing list, simply visit the confirmation link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
315,329c315,329
< 					sn_mail_confirm($sn_email, $body, $snid_obj->snid, 'subscribe');
<   				$message = t('You will receive a confirmation email shortly');
< 					}
< 					else {
< 					  db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $sn_email, $user->uid, 1);
< 					  $message = t('Thanks for your subscription to our newsletter');
< 						$watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($sn_email)));
< 			      watchdog('simplenews', $watchdog);
< 					}
< 				}
< 				elseif ($edit['sn_subscribe'] == 'Unsubscribe') {
< 				  if ($user->uid == 0) {
< 				    if (db_num_rows($snid_result)) {
< 					    //send confirmation email: "Confirm deletion"
< 							$body = t('We have received a request for the removal of your email address, "%mail", from the %s newsletter. If you want to unsubscribe, simply visit the confirmation link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
---
>           sn_mail_confirm($sn_email, $body, $snid_obj->snid, 'subscribe');
>           $message = t('You will receive a confirmation email shortly');
>           }
>           else {
>             db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $sn_email, $user->uid, 1);
>             $message = t('Thanks for your subscription to our newsletter');
>             $watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($sn_email)));
>             watchdog('simplenews', $watchdog);
>           }
>         }
>         elseif ($edit['sn_subscribe'] == 'Unsubscribe') {
>           if ($user->uid == 0) {
>             if (db_num_rows($snid_result)) {
>               //send confirmation email: "Confirm deletion"
>               $body = t('We have received a request for the removal of your email address, "%mail", from the %s newsletter. If you want to unsubscribe, simply visit the confirmation link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
331,335c331,335
< 							sn_mail_confirm($sn_email, $body, $snid_obj->snid, 'unsubscribe');
< 					  }
< 						else {
< 						  //send confirmation email: "You were not subscribed. Visit site to subscribe."
< 							$body = t('We have received a request for the removal of your email address, "%mail", from the %s newsletter. However, you were not subscribed to this newsletter. If you want to subscribe, you can visit our website by using the link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
---
>               sn_mail_confirm($sn_email, $body, $snid_obj->snid, 'unsubscribe');
>             }
>             else {
>               //send confirmation email: "You were not subscribed. Visit site to subscribe."
>               $body = t('We have received a request for the removal of your email address, "%mail", from the %s newsletter. However, you were not subscribed to this newsletter. If you want to subscribe, you can visit our website by using the link at the bottom of this email.', array('%mail'=>$sn_email, '%s'=>variable_get('simplenews_from_name', $name_default)));
337,352c337,352
< 							sn_mail_confirm($sn_email, $body);
< 						}
< 					  $message = t('You will receive a confirmation email shortly');
< 					}
< 					else { 
< 				    $query = "DELETE FROM {sn_subscriptions} WHERE mail = '%s'";
< 				  	if (db_affected_rows(db_query($query, $sn_email))) {
< 				  	  $message = t('You have been removed from the newsletter subscription list');
< 							$watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($sn_email)));
< 				      watchdog('simplenews', $watchdog);
< 				  	}
< 					}
< 				}
< 			}
< 		}
< 		else {
---
>               sn_mail_confirm($sn_email, $body);
>             }
>             $message = t('You will receive a confirmation email shortly');
>           }
>           else { 
>             $query = "DELETE FROM {sn_subscriptions} WHERE mail = '%s'";
>             if (db_affected_rows(db_query($query, $sn_email))) {
>               $message = t('You have been removed from the newsletter subscription list');
>               $watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($sn_email)));
>               watchdog('simplenews', $watchdog);
>             }
>           }
>         }
>       }
>     }
>     else {
354,355c354,355
< 		}
< 	
---
>     }
>   
359,360c359,360
< 	if (module_invoke('user', 'access', 'view links in block') || module_invoke('user', 'access', 'administer simplenews')) {
<   	$vid = simplenews_get_vid();
---
>   if (module_invoke('user', 'access', 'view links in block') || module_invoke('user', 'access', 'administer simplenews')) {
>     $vid = simplenews_get_vid();
362,371c362,371
<   	while ($term = db_fetch_object($result)) {
< 	    if (variable_get('simplenews_l_'.$term->tid, 0) && variable_get('simplenews_r_'.$term->tid, 0)) {
< 		    $items[] .= l($term->name, 'taxonomy/term/'.$term->tid).theme('xml_icon', url('taxonomy/term/'.$term->tid.'/0/feed'));
< 	  	}
< 	    elseif (variable_get('simplenews_l_'.$term->tid, 0)) {
< 		    $items[] .= l($term->name, 'taxonomy/term/'.$term->tid);
< 		  }
< 	    elseif (variable_get('simplenews_r_'.$term->tid, 0)) {
< 		    $items[] .= $term->name.theme('xml_icon', url('taxonomy/term/'.$term->tid.'/0/feed'));
< 		  }
---
>     while ($term = db_fetch_object($result)) {
>       if (variable_get('simplenews_l_'.$term->tid, 0) && variable_get('simplenews_r_'.$term->tid, 0)) {
>         $items[] .= l($term->name, 'taxonomy/term/'.$term->tid).theme('xml_icon', url('taxonomy/term/'.$term->tid.'/0/feed'));
>       }
>       elseif (variable_get('simplenews_l_'.$term->tid, 0)) {
>         $items[] .= l($term->name, 'taxonomy/term/'.$term->tid);
>       }
>       elseif (variable_get('simplenews_r_'.$term->tid, 0)) {
>         $items[] .= $term->name.theme('xml_icon', url('taxonomy/term/'.$term->tid.'/0/feed'));
>       }
373,374c373,374
< 	$block['content'] .= theme('sn_item_list',$items);
< 	}
---
>   $block['content'] .= theme('sn_item_list',$items);
>   }
385,387c385,387
< 	if ($sub == 1 && $unsub == 1) {
< 	  $sn_form .= form_textfield(t('Email'), 'sn_email', $email, 20, 35);
< 		$options = array();
---
>   if ($sub == 1 && $unsub == 1) {
>     $sn_form .= form_textfield(t('Email'), 'sn_email', $email, 20, 35);
>     $options = array();
389c389
< 	  $options['Unsubscribe'] = t('Unsubscribe');
---
>     $options['Unsubscribe'] = t('Unsubscribe');
391,399c391,399
< 		$submit = t('Submit');
< 	}	
< 	else {
< 	  $sn_form .= '<div class="form-item"><label for="edit-sn_email">'.t('Email').':</label><br /><small>';
< 		$sn_form .= strlen($email) <= 30 ? $email : substr($email, 0, 29).'...';
< 		$sn_form .= '</small></div>';
< 		$sn_form .= form_hidden('sn_email', $email);
<   	if ($sub == 1) {
< 	    $sn_form .= form_hidden('sn_subscribe', 'Subscribe');
---
>     $submit = t('Submit');
>   }  
>   else {
>     $sn_form .= '<div class="form-item"><label for="edit-sn_email">'.t('Email').':</label><br /><small>';
>     $sn_form .= strlen($email) <= 30 ? $email : substr($email, 0, 29).'...';
>     $sn_form .= '</small></div>';
>     $sn_form .= form_hidden('sn_email', $email);
>     if ($sub == 1) {
>       $sn_form .= form_hidden('sn_subscribe', 'Subscribe');
401,403c401,403
<   	}
< 	  elseif ($unsub == 1) {
< 	    $sn_form .= form_hidden('sn_subscribe', 'Unsubscribe');
---
>     }
>     elseif ($unsub == 1) {
>       $sn_form .= form_hidden('sn_subscribe', 'Unsubscribe');
405,406c405,406
<   	}
< 	}
---
>     }
>   }
408c408
< 	$sn_form .= '</div>';
---
>   $sn_form .= '</div>';
410c410
< 	return $sn_form;
---
>   return $sn_form;
420,431c420,431
<    	$block_content .= theme('sn_form', 1, 1);
<  	}
<  	else {
<    	$query = 'SELECT s.snid FROM {sn_subscriptions} s WHERE s.uid = %d';
<   	if (db_num_rows(db_query($query, $user->uid))) {
< 		  $block_content .= theme('sn_form', 0, 1, $user->mail);
< 		}
< 		else {
< 		  $block_content .= theme('sn_form', 1, 0, $user->mail);
< 		}
< 	}
< 	return $block_content;
---
>      $block_content .= theme('sn_form', 1, 1);
>    }
>    else {
>      $query = 'SELECT s.snid FROM {sn_subscriptions} s WHERE s.uid = %d';
>     if (db_num_rows(db_query($query, $user->uid))) {
>       $block_content .= theme('sn_form', 0, 1, $user->mail);
>     }
>     else {
>       $block_content .= theme('sn_form', 1, 0, $user->mail);
>     }
>   }
>   return $block_content;
440,455c440,455
< 	$max_time = $max_time - 0.5;
< 	$result = db_query('SELECT s.nid, n.created FROM {node} n INNER JOIN {sn_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d ORDER BY n.created ASC', 1);
< 	while ($nid = db_fetch_object($result)) {
<  	  $node = module_invoke('node', 'load', array('nid' => $nid->nid));
< 		$node = simplenews_replace_vars($node, FALSE);
< 		if ($node->s_format == 'html') {
< 		  $node = module_invoke('node', 'prepare', $node, FALSE);
< 		}
< 		else {
< 		  // first do node_prepare() to allow PHP-code to be parsed, then strip remaining HTML-tags
< 		  $node = module_invoke('node', 'prepare', $node, FALSE);
< 		  $node->body = strip_tags($node->body);
< 		}
< 		$address_default = variable_get('site_mail', ini_get('sendmail_from'));
< 		$name_default = variable_get('site_name', 'drupal');
< 	  $node->from_address = variable_get('simplenews_from_address', $address_default);
---
>   $max_time = $max_time - 0.5;
>   $result = db_query('SELECT s.nid, n.created FROM {node} n INNER JOIN {sn_newsletters} s ON n.nid = s.nid WHERE s.s_status = %d ORDER BY n.created ASC', 1);
>   while ($nid = db_fetch_object($result)) {
>      $node = module_invoke('node', 'load', array('nid' => $nid->nid));
>     $node = simplenews_replace_vars($node, FALSE);
>     if ($node->s_format == 'html') {
>       $node = module_invoke('node', 'prepare', $node, FALSE);
>     }
>     else {
>       // first do node_prepare() to allow PHP-code to be parsed, then strip remaining HTML-tags
>       $node = module_invoke('node', 'prepare', $node, FALSE);
>       $node->body = strip_tags($node->body);
>     }
>     $address_default = variable_get('site_mail', ini_get('sendmail_from'));
>     $name_default = variable_get('site_name', 'drupal');
>     $node->from_address = variable_get('simplenews_from_address', $address_default);
458,497c458,497
< 		$result2 = db_query('SELECT mail, snid FROM {sn_subscriptions} WHERE s_status = %d AND a_status = %d', 0, 1);
< 		while ($mail = db_fetch_object($result2)) {
< 		  $md5 = md5($mail->mail);
< 			$h = substr($md5, 0, 10).$mail->snid;
< 		  if ($node->s_format == 'html') {
< 			  $node->message = $node->body.'<p>--<br />'.l(t('Click here to unsubscribe'), 'newsletterconfirm/remove/'.$h, array(), NULL, NULL, TRUE).'</p>';
< 			}
< 			else {
< 			  $node->message = $node->body."\n\n--\n".t('Unsubscribe link:').' '.url('newsletterconfirm/remove/'.$h, NULL, NULL, TRUE);
< 			}
< 		  $node->to = $mail->mail;
< 			if(sn_mail_send($node)) {
< 			  db_query('UPDATE {sn_subscriptions} SET s_status = %d WHERE snid = %d', 1, $mail->snid);
< 			}
< 			else {
< 			  $message = t('Newsletter "%title" could not be sent to %email.', array('%title'=>check_plain($node->title), '%email'=>$mail->mail));
< 				watchdog('simplenews', $message, WATCHDOG_ERROR);
< 			}
< 		  if ($timer) {
< 		    $int_time = sn_time();
< 		  }
< 		  else {
< 		    $int_time = $start_time;
< 		  }
< 		  if (!($int_time - $start_time < $max_time)) {
< 			  return;
< 			}
< 		}
< 		db_query('UPDATE {sn_subscriptions} SET s_status = %d', 0);
< 		db_query('UPDATE {sn_newsletters} SET s_status = %d WHERE nid = %d', 2, $node->nid);
< 		if ($timer) {
< 		  $int_time = sn_time();
< 		}
< 		else {
< 		  $int_time = $start_time;
< 		}
< 	  if (!($int_time - $start_time < $max_time)) {
< 	    return;
< 		}
< 	}
---
>     $result2 = db_query('SELECT mail, snid FROM {sn_subscriptions} WHERE s_status = %d AND a_status = %d', 0, 1);
>     while ($mail = db_fetch_object($result2)) {
>       $md5 = md5($mail->mail);
>       $h = substr($md5, 0, 10).$mail->snid;
>       if ($node->s_format == 'html') {
>         $node->message = $node->body.'<p>--<br />'.l(t('Click here to unsubscribe'), 'newsletterconfirm/remove/'.$h, array(), NULL, NULL, TRUE).'</p>';
>       }
>       else {
>         $node->message = $node->body."\n\n--\n".t('Unsubscribe link:').' '.url('newsletterconfirm/remove/'.$h, NULL, NULL, TRUE);
>       }
>       $node->to = $mail->mail;
>       if(sn_mail_send($node)) {
>         db_query('UPDATE {sn_subscriptions} SET s_status = %d WHERE snid = %d', 1, $mail->snid);
>       }
>       else {
>         $message = t('Newsletter "%title" could not be sent to %email.', array('%title'=>check_plain($node->title), '%email'=>$mail->mail));
>         watchdog('simplenews', $message, WATCHDOG_ERROR);
>       }
>       if ($timer) {
>         $int_time = sn_time();
>       }
>       else {
>         $int_time = $start_time;
>       }
>       if (!($int_time - $start_time < $max_time)) {
>         return;
>       }
>     }
>     db_query('UPDATE {sn_subscriptions} SET s_status = %d', 0);
>     db_query('UPDATE {sn_newsletters} SET s_status = %d WHERE nid = %d', 2, $node->nid);
>     if ($timer) {
>       $int_time = sn_time();
>     }
>     else {
>       $int_time = $start_time;
>     }
>     if (!($int_time - $start_time < $max_time)) {
>       return;
>     }
>   }
502,505c502,505
< 	$mail->encode = '';
< 	$mail->priority = 'none';
< 	$address_default = variable_get('site_mail', ini_get('sendmail_from'));
< 	$name_default = variable_get('site_name', 'drupal');
---
>   $mail->encode = '';
>   $mail->priority = 'none';
>   $address_default = variable_get('site_mail', ini_get('sendmail_from'));
>   $name_default = variable_get('site_name', 'drupal');
508,525c508,525
< 	$mail->to = $email;
< 	$mail->title = variable_get('simplenews_from_name', $name_default).' '.t('newsletter confirmation');
< 	$mail->message = t('Newsletter subscription status confirmation notice for').' '.variable_get('simplenews_from_name', $name_default).' '.t('newsletter.');
< 	$mail->message .= "\n\n".$message;
< 	if ($snid) {
< 	  $md5 = md5($email);
< 		$h = substr($md5, 0, 10).$snid;
< 		if ($op == 'subscribe') {
< 	    $mail->message .= "\n\n--\n".t('Subscribe link:').' '.url('newsletterconfirm/add/'.$h, NULL, NULL, TRUE);
< 		}
< 		elseif ($op == 'unsubscribe') {
< 		  $mail->message .= "\n\n--\n".t('Unsubscribe link:').' '.url('newsletterconfirm/remove/'.$h, NULL, NULL, TRUE);
< 		}
< 	}
< 	else {
< 	  global $base_url;
< 		$mail->message .= "\n\n--\n".t('Visit our site:').' '.$base_url;
< 	}
---
>   $mail->to = $email;
>   $mail->title = variable_get('simplenews_from_name', $name_default).' '.t('newsletter confirmation');
>   $mail->message = t('Newsletter subscription status confirmation notice for').' '.variable_get('simplenews_from_name', $name_default).' '.t('newsletter.');
>   $mail->message .= "\n\n".$message;
>   if ($snid) {
>     $md5 = md5($email);
>     $h = substr($md5, 0, 10).$snid;
>     if ($op == 'subscribe') {
>       $mail->message .= "\n\n--\n".t('Subscribe link:').' '.url('newsletterconfirm/add/'.$h, NULL, NULL, TRUE);
>     }
>     elseif ($op == 'unsubscribe') {
>       $mail->message .= "\n\n--\n".t('Unsubscribe link:').' '.url('newsletterconfirm/remove/'.$h, NULL, NULL, TRUE);
>     }
>   }
>   else {
>     global $base_url;
>     $mail->message .= "\n\n--\n".t('Visit our site:').' '.$base_url;
>   }
551,556c551,556
< 	  case 'outbox':
< 	  	$output .= simplenews_admin_news('notsent');
< 		break;
< 		case 'types':
< 		  $output .= t('You can create different newsletter types (or subjects) to categorize your news (e.g. Cats news, Dogs news, ...).') . '<br />&nbsp;<br />';
< 			if ($op2 == 'add' || $op2 == 'edit') {
---
>     case 'outbox':
>       $output .= simplenews_admin_news('notsent');
>     break;
>     case 'types':
>       $output .= t('You can create different newsletter types (or subjects) to categorize your news (e.g. Cats news, Dogs news, ...).') . '<br />&nbsp;<br />';
>       if ($op2 == 'add' || $op2 == 'edit') {
571,573c571,573
< 					else {
< 					  $output .= simplenews_types_overview();
< 					}
---
>           else {
>             $output .= simplenews_types_overview();
>           }
579,620c579,620
< 			}
< 			else {
< 			  $output .= simplenews_types_overview();
< 		  }
< 		break;
< 		case 'users':
< 		  if ($op2 == 'sni' && is_numeric($op3)) {
< 				  db_query('UPDATE {sn_subscriptions} SET a_status = 0 WHERE snid = %d', $op3);
< 			}
< 			elseif ($op2 == 'sna' && is_numeric($op3)) {
< 				  db_query('UPDATE {sn_subscriptions} SET a_status = 1 WHERE snid = %d', $op3);
< 			}
< 		  if ($op2 == 'delete' && is_numeric($op3)) {
< 			  $snid = $op3;
<   	    $user = db_fetch_object(db_query('SELECT s.mail FROM {sn_subscriptions} s WHERE snid = %d', $snid));
< 			  if ($_POST['edit']['confirm']) {
< 				  db_query('DELETE FROM {sn_subscriptions} WHERE snid = %d', $snid);
< 					drupal_set_message(t('The user %user was successfully deleted.', array('%user'=>theme('placeholder', $user->mail))), 'status');
< 					$watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($user->mail)));
< 				  watchdog('simplenews', $watchdog);
< 					drupal_goto('admin/simplenews/users');
< 				}
< 				else {
< 				  $output = simplenews_confirm_del_user($snid, $user);
< 				}
< 			}
< 			elseif ($op2 == 'add') {
< 				$output .= simplenews_admin_list_add();
< 			}
< 			elseif ($op2 == 'export') {
< 				$output .= simplenews_admin_list_export();
< 			}
< 			else {
< 	  	  $output .= simplenews_admin_list();
< 			}
< 		break;
< 		case 'settings':
< 		  $output .= simplenews_admin_settings();
< 		break;
< 		default:
< 		  $output .= simplenews_admin_news('sent');
< 	}
---
>       }
>       else {
>         $output .= simplenews_types_overview();
>       }
>     break;
>     case 'users':
>       if ($op2 == 'sni' && is_numeric($op3)) {
>           db_query('UPDATE {sn_subscriptions} SET a_status = 0 WHERE snid = %d', $op3);
>       }
>       elseif ($op2 == 'sna' && is_numeric($op3)) {
>           db_query('UPDATE {sn_subscriptions} SET a_status = 1 WHERE snid = %d', $op3);
>       }
>       if ($op2 == 'delete' && is_numeric($op3)) {
>         $snid = $op3;
>         $user = db_fetch_object(db_query('SELECT s.mail FROM {sn_subscriptions} s WHERE snid = %d', $snid));
>         if ($_POST['edit']['confirm']) {
>           db_query('DELETE FROM {sn_subscriptions} WHERE snid = %d', $snid);
>           drupal_set_message(t('The user %user was successfully deleted.', array('%user'=>theme('placeholder', $user->mail))), 'status');
>           $watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($user->mail)));
>           watchdog('simplenews', $watchdog);
>           drupal_goto('admin/simplenews/users');
>         }
>         else {
>           $output = simplenews_confirm_del_user($snid, $user);
>         }
>       }
>       elseif ($op2 == 'add') {
>         $output .= simplenews_admin_list_add();
>       }
>       elseif ($op2 == 'export') {
>         $output .= simplenews_admin_list_export();
>       }
>       else {
>         $output .= simplenews_admin_list();
>       }
>     break;
>     case 'settings':
>       $output .= simplenews_admin_settings();
>     break;
>     default:
>       $output .= simplenews_admin_news('sent');
>   }
630,631c630,631
< 	}
< 	else {
---
>   }
>   else {
633c633
< 	}
---
>   }
636c636
< 	  $terms = array_keys(module_invoke('taxonomy', 'node_get_terms_by_vocabulary', $node->nid, $vid, 'name'));
---
>     $terms = array_keys(module_invoke('taxonomy', 'node_get_terms_by_vocabulary', $node->nid, $vid, 'name'));
638c638
< 		                $terms[0] ? $terms[0] : t('n/a'),
---
>                     $terms[0] ? $terms[0] : t('n/a'),
640,641c640,641
< 										theme('simplenews_status', $node->status, 'published'),
< 										theme('simplenews_status', $node->s_status, 'sent'),
---
>                     theme('simplenews_status', $node->status, 'published'),
>                     theme('simplenews_status', $node->s_status, 'sent'),
650,652c650,652
< 	else {
<   	$key_table = TRUE;
< 	}
---
>   else {
>     $key_table = TRUE;
>   }
654,663c654,663
< 	
< 	if ($key_table) {
< 	$key_header = array(array('data' => t('Table key'), 'colspan' => '2'));
< 	$key_rows[] = array(theme('simplenews_status', 0, 'sent'), t('Not published/Not sent'));
< 	$key_rows[] = array(theme('simplenews_status', 2, 'sent'), t('Published/Sent'));
< 	$key_rows[] = array(theme('simplenews_status', 1, 'sent'), t('Currently sending by cron'));
< 	$output .= theme('table', $key_header, $key_rows);
< 	}
< 	
< 	return $output;
---
>   
>   if ($key_table) {
>   $key_header = array(array('data' => t('Table key'), 'colspan' => '2'));
>   $key_rows[] = array(theme('simplenews_status', 0, 'sent'), t('Not published/Not sent'));
>   $key_rows[] = array(theme('simplenews_status', 2, 'sent'), t('Published/Sent'));
>   $key_rows[] = array(theme('simplenews_status', 1, 'sent'), t('Currently sending by cron'));
>   $output .= theme('table', $key_header, $key_rows);
>   }
>   
>   return $output;
669,672c669,672
< 	}
< 	elseif ($source == 'sent') {
< 	$imgs = array(0 => 'sn-saved', 1 => 'sn-cron', 2 => 'sn-sent');
< 	}
---
>   }
>   elseif ($source == 'sent') {
>   $imgs = array(0 => 'sn-saved', 1 => 'sn-cron', 2 => 'sn-sent');
>   }
675c675
< 	return $output;
---
>   return $output;
679c679
< 	$header = array(NULL, t('Email'), t('Username'), t('Status'), array('data' => t('Operations'), 'colspan' => '2'));
---
>   $header = array(NULL, t('Email'), t('Username'), t('Status'), array('data' => t('Operations'), 'colspan' => '2'));
684,698c684,698
< 	}
< 	while ($subs = db_fetch_object($result)) {
<  		$key_table = TRUE;
< 	  $i++;
< 	  if ($subs->uid == 0) {
< 		  $subs->name = t('Unregistered user');
< 		}
< 		if ($subs->a_status == 0) {
< 		  $activate = l(t('activate'), 'admin/simplenews/users/sna/'.$subs->snid);
< 		}
< 		elseif ($subs->a_status == 1) {
< 		  $activate = l(t('inactivate'), 'admin/simplenews/users/sni/'.$subs->snid);
< 		}
< 	  $rows[] = array($i, $subs->mail, ($subs->uid ? l($subs->name, 'user/'.$subs->uid) : $subs->name), theme('simplenews_status', $subs->a_status, 'published'), l(t('delete'), 'admin/simplenews/users/delete/'.$subs->snid), $activate);
< 	}
---
>   }
>   while ($subs = db_fetch_object($result)) {
>      $key_table = TRUE;
>     $i++;
>     if ($subs->uid == 0) {
>       $subs->name = t('Unregistered user');
>     }
>     if ($subs->a_status == 0) {
>       $activate = l(t('activate'), 'admin/simplenews/users/sna/'.$subs->snid);
>     }
>     elseif ($subs->a_status == 1) {
>       $activate = l(t('inactivate'), 'admin/simplenews/users/sni/'.$subs->snid);
>     }
>     $rows[] = array($i, $subs->mail, ($subs->uid ? l($subs->name, 'user/'.$subs->uid) : $subs->name), theme('simplenews_status', $subs->a_status, 'published'), l(t('delete'), 'admin/simplenews/users/delete/'.$subs->snid), $activate);
>   }
705,711c705,711
< 	$output = theme('table', $header, $rows);
< 	if ($key_table) {
< 	  $key_header = array(array('data' => t('Table key'), 'colspan' => '2'));
< 	  $key_rows[] = array(theme('simplenews_status', 0, 'published'), t('Inactive/No newsletters will be sent'));
< 	  $key_rows[] = array(theme('simplenews_status', 1, 'published'), t('Active/User will receive newsletters'));
< 	  $output .= theme('table', $key_header, $key_rows);
< 	}
---
>   $output = theme('table', $header, $rows);
>   if ($key_table) {
>     $key_header = array(array('data' => t('Table key'), 'colspan' => '2'));
>     $key_rows[] = array(theme('simplenews_status', 0, 'published'), t('Inactive/No newsletters will be sent'));
>     $key_rows[] = array(theme('simplenews_status', 1, 'published'), t('Active/User will receive newsletters'));
>     $output .= theme('table', $key_header, $key_rows);
>   }
718,724c718,724
< 	if ($_POST['op'] == t('Submit')) {
< 	  $edit = $_POST['edit'];
< 	  if ($edit['emails'] != '') {
< 	    $emails = explode(",", $edit['emails']);
< 		 	foreach ($emails as $email) {
< 		    $email = trim($email);
< 			  if (valid_email_address($email)) {
---
>   if ($_POST['op'] == t('Submit')) {
>     $edit = $_POST['edit'];
>     if ($edit['emails'] != '') {
>       $emails = explode(",", $edit['emails']);
>        foreach ($emails as $email) {
>         $email = trim($email);
>         if (valid_email_address($email)) {
726,765c726,765
< 	        if (!db_num_rows(db_query($query, $email))) {
< 	          $query = "SELECT u.uid FROM {users} u WHERE u.mail = '%s'";
< 			      if ($result = db_fetch_object(db_query($query, $email))) {
< 			        $uid = $result->uid;
< 			      }
< 			      else {
< 			        $uid = 0;
< 		  	    }
< 		        if (db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $email, $uid, 1)) {
< 							$watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($email)));
< 				      watchdog('simplenews', $watchdog);
< 		          $added[] .= $email;
< 				  	}
< 			    }
< 				  else {
< 			  	  $duplicate[] .= $email;
< 		  		}
< 	  	  }
<   			else {
< 			    $invalid[] .= $email;
< 			  }
< 		  }
< 		}
< 		if ($added) {
< 		  $added = implode(", ", $added);
< 		  drupal_set_message(t('The following addresses were added:').' '.$added, 'status');
< 		}
< 		else {
< 		  drupal_set_message(t('No addresses were added.'),'status');
< 		}
< 		if ($duplicate) {
< 		  $duplicate = implode(", ", $duplicate);
< 		  drupal_set_message(t('The following addresses were already in the list:').' '.$duplicate, 'status');
< 		}
< 		if ($invalid) {
< 		  $invalid = implode(", ", $invalid);
< 		  drupal_set_message(t('The following addresses were invalid:').' '.$invalid, 'error');
< 		}
< 	}
< 	return form($output);
---
>           if (!db_num_rows(db_query($query, $email))) {
>             $query = "SELECT u.uid FROM {users} u WHERE u.mail = '%s'";
>             if ($result = db_fetch_object(db_query($query, $email))) {
>               $uid = $result->uid;
>             }
>             else {
>               $uid = 0;
>             }
>             if (db_query("INSERT INTO {sn_subscriptions} (mail, uid, a_status) VALUES ('%s', %d, %d)", $email, $uid, 1)) {
>               $watchdog = t('User "%email" added to the database.', array('%email'=>check_plain($email)));
>               watchdog('simplenews', $watchdog);
>               $added[] .= $email;
>             }
>           }
>           else {
>             $duplicate[] .= $email;
>           }
>         }
>         else {
>           $invalid[] .= $email;
>         }
>       }
>     }
>     if ($added) {
>       $added = implode(", ", $added);
>       drupal_set_message(t('The following addresses were added:').' '.$added, 'status');
>     }
>     else {
>       drupal_set_message(t('No addresses were added.'),'status');
>     }
>     if ($duplicate) {
>       $duplicate = implode(", ", $duplicate);
>       drupal_set_message(t('The following addresses were already in the list:').' '.$duplicate, 'status');
>     }
>     if ($invalid) {
>       $invalid = implode(", ", $invalid);
>       drupal_set_message(t('The following addresses were invalid:').' '.$invalid, 'error');
>     }
>   }
>   return form($output);
771,774c771,774
< 	$subgroup .= form_checkbox(t('Inactive users'), 'inactive', 1, $edit['inactive']);
< 	$output = form_group('Status', $subgroup);
< 	$output .= form_submit(t('Export'));
< 	$export = form($output);
---
>   $subgroup .= form_checkbox(t('Inactive users'), 'inactive', 1, $edit['inactive']);
>   $output = form_group('Status', $subgroup);
>   $output .= form_submit(t('Export'));
>   $export = form($output);
776,799c776,799
< 	  if ($edit['active'] == 1) {
< 		  $where[] = 'a_status = 1';
< 		}
< 		if ($edit['inactive'] == 1) {
< 		  $where[] = 'a_status = 0';
< 		}
< 		$where = $where ? ' WHERE '.implode(' OR ', $where) : NULL;
< 		if ($where) {
< 		  $query = 'SELECT mail FROM {sn_subscriptions}'.$where;
< 	    $result = db_query($query);
< 	    while ($mail = db_fetch_object($result)) {
< 	      $mails[] = $mail->mail;
< 	    }
< 		}
< 	  if ($mails) {
< 	    $mails = implode(", ", $mails);
< 	    $output = form_textarea(t('Email addresses'), 'emails', $mails, 60, 5);
<   	}
<   	else {
< 	    $output = form_textarea(t('Email addresses'), 'emails', t('No addresses were found.'), 60, 5);
< 	  }
< 		$export .= form($output);
< 	}
< 	return $export;
---
>     if ($edit['active'] == 1) {
>       $where[] = 'a_status = 1';
>     }
>     if ($edit['inactive'] == 1) {
>       $where[] = 'a_status = 0';
>     }
>     $where = $where ? ' WHERE '.implode(' OR ', $where) : NULL;
>     if ($where) {
>       $query = 'SELECT mail FROM {sn_subscriptions}'.$where;
>       $result = db_query($query);
>       while ($mail = db_fetch_object($result)) {
>         $mails[] = $mail->mail;
>       }
>     }
>     if ($mails) {
>       $mails = implode(", ", $mails);
>       $output = form_textarea(t('Email addresses'), 'emails', $mails, 60, 5);
>     }
>     else {
>       $output = form_textarea(t('Email addresses'), 'emails', t('No addresses were found.'), 60, 5);
>     }
>     $export .= form($output);
>   }
>   return $export;
815,834c815,834
< 	$edit = $_POST['edit'];
< 	variable_set('simplenews_format', $edit['format']);
< 	variable_set('simplenews_priority', $edit['priority']);
< 	variable_set('simplenews_receipt', $edit['receipt']);
< 	variable_set('simplenews_send', $edit['send']);
< 	variable_set('simplenews_time', $edit['time']);
< 	variable_set('simplenews_from_name', $edit['from_name']);
< 	  //valid_email_address() allows empty address, so check this first
< 	  if ($edit['from_address'] == '') {
< 	    drupal_set_message(t("You have to supply a sender's email address"), 'error');
<   	}
< 		elseif (!valid_email_address($edit['from_address'])) {
< 		  drupal_set_message(t("The sender's email address you supplied is not valid"), 'error');
< 		}
< 		else {
< 		  variable_set('simplenews_from_address', $edit['from_address']);
< 		  drupal_set_message(t('Your settings were saved.'), 'status');
< 		}
< 	}
< 	
---
>   $edit = $_POST['edit'];
>   variable_set('simplenews_format', $edit['format']);
>   variable_set('simplenews_priority', $edit['priority']);
>   variable_set('simplenews_receipt', $edit['receipt']);
>   variable_set('simplenews_send', $edit['send']);
>   variable_set('simplenews_time', $edit['time']);
>   variable_set('simplenews_from_name', $edit['from_name']);
>     //valid_email_address() allows empty address, so check this first
>     if ($edit['from_address'] == '') {
>       drupal_set_message(t("You have to supply a sender's email address"), 'error');
>     }
>     elseif (!valid_email_address($edit['from_address'])) {
>       drupal_set_message(t("The sender's email address you supplied is not valid"), 'error');
>     }
>     else {
>       variable_set('simplenews_from_address', $edit['from_address']);
>       drupal_set_message(t('Your settings were saved.'), 'status');
>     }
>   }
>   
837,841c837,841
< 	while ($term = db_fetch_object($result)) {
< 	  if ($_POST['op'] == t('Submit')) {
< 		  variable_set('simplenews_l_'.$term->tid, $edit['l'.$term->tid]);
< 			variable_set('simplenews_r_'.$term->tid, $edit['r'.$term->tid]);
< 		}
---
>   while ($term = db_fetch_object($result)) {
>     if ($_POST['op'] == t('Submit')) {
>       variable_set('simplenews_l_'.$term->tid, $edit['l'.$term->tid]);
>       variable_set('simplenews_r_'.$term->tid, $edit['r'.$term->tid]);
>     }
843,847c843,847
< 		$subgroup .= form_checkbox(t('Display link to RSS-feed'), 'r'.$term->tid, 1, variable_get('simplenews_r_'.$term->tid, 0));
< 		$group .= form_group($term->name, $subgroup);
< 	}  
< 	$output .= form_group(t('Simplenews block: link display options'), $group, t('You can choose which links to newsletter overview pages should be displayed in the simplenews block. Links are only displayed to users who have "view links in block" privileges.'));
< 	$output .= '<br />';
---
>     $subgroup .= form_checkbox(t('Display link to RSS-feed'), 'r'.$term->tid, 1, variable_get('simplenews_r_'.$term->tid, 0));
>     $group .= form_group($term->name, $subgroup);
>   }  
>   $output .= form_group(t('Simplenews block: link display options'), $group, t('You can choose which links to newsletter overview pages should be displayed in the simplenews block. Links are only displayed to users who have "view links in block" privileges.'));
>   $output .= '<br />';
854c854
< 	$output .= '<br />';
---
>   $output .= '<br />';
856,857c856,857
< 	$address_default = variable_get('site_mail', ini_get('sendmail_from'));
< 	$name_default = variable_get('site_name', 'drupal');
---
>   $address_default = variable_get('site_mail', ini_get('sendmail_from'));
>   $name_default = variable_get('site_name', 'drupal');
861,869c861,869
< 	$output .= '<br />';
< 	
< 	$max_time = array(1, 2, 3, 4);
< 	for ($i = 5; $i < ini_get('max_execution_time'); $i=$i+5) {
< 	$max_time[] = $i;
< 	}
< 	$group = form_select(t('Seconds'), 'time', variable_get('simplenews_time', 2), drupal_map_assoc($max_time));
< 	$output .= form_group(t('Maximum send time'), $group, t('Sets the maximum time in seconds during which newsletters are sent. If not all recipients have been mailed within this time, sending is further handled as a cronjob.').' <br /> '.t('The highest value in the dropdown list is based on max_execution_time in your php.ini file. Note that if not all previous newletters have been sent to all recipients yet, these are sent first.'));
< 	
---
>   $output .= '<br />';
>   
>   $max_time = array(1, 2, 3, 4);
>   for ($i = 5; $i < ini_get('max_execution_time'); $i=$i+5) {
>   $max_time[] = $i;
>   }
>   $group = form_select(t('Seconds'), 'time', variable_get('simplenews_time', 2), drupal_map_assoc($max_time));
>   $output .= form_group(t('Maximum send time'), $group, t('Sets the maximum time in seconds during which newsletters are sent. If not all recipients have been mailed within this time, sending is further handled as a cronjob.').' <br /> '.t('The highest value in the dropdown list is based on max_execution_time in your php.ini file. Note that if not all previous newletters have been sent to all recipients yet, these are sent first.'));
>   
878,885c878,885
< 	// Check to see if at least 1 term exists, else create one
< 	$tid = db_result(db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid));
< 	if (!$tid) {
<   	$edit['name'] = ucfirst(variable_get('site_name', 'Drupal')).' '.t('newsletters');
< 	  $edit['vid'] = $vid;
< 	  $edit['weigth'] = 0;
< 		$term = module_invoke('taxonomy', 'save_term', $edit);
< 	}
---
>   // Check to see if at least 1 term exists, else create one
>   $tid = db_result(db_query('SELECT tid FROM {term_data} WHERE vid = %d', $vid));
>   if (!$tid) {
>     $edit['name'] = ucfirst(variable_get('site_name', 'Drupal')).' '.t('newsletters');
>     $edit['vid'] = $vid;
>     $edit['weigth'] = 0;
>     $term = module_invoke('taxonomy', 'save_term', $edit);
>   }
893c893
< 	  //taxonomy_save_vocabulary() returns $status, and not $edit[] in Drupal 4.6+
---
>     //taxonomy_save_vocabulary() returns $status, and not $edit[] in Drupal 4.6+
895c895
< 	  'hierarchy' => '0', 'relations' => '0', 'module' => 'simplenews', 'nodes' => array('simplenews')));
---
>     'hierarchy' => '0', 'relations' => '0', 'module' => 'simplenews', 'nodes' => array('simplenews')));
897c897
< 		variable_set('simplenews_vid', $vid);
---
>     variable_set('simplenews_vid', $vid);
920c920
< 	$form .= form_hidden('vid', $edit['vid']);
---
>   $form .= form_hidden('vid', $edit['vid']);
931,937c931,937
< 	$op1_1 = substr($op2, 0, 10);
< 	$op1_2 = substr($op2, 10);
< 	$result = db_query('SELECT snid, mail FROM {sn_subscriptions} WHERE snid = %d', $op1_2);
< 	if ($subs = db_fetch_object($result)) {
< 	  if ($op1_1 == substr(md5($subs->mail), 0, 10)) {
< 	    if ($op1 == 'remove') {
< 		    if ($_POST['edit']['confirm']) {
---
>   $op1_1 = substr($op2, 0, 10);
>   $op1_2 = substr($op2, 10);
>   $result = db_query('SELECT snid, mail FROM {sn_subscriptions} WHERE snid = %d', $op1_2);
>   if ($subs = db_fetch_object($result)) {
>     if ($op1_1 == substr(md5($subs->mail), 0, 10)) {
>       if ($op1 == 'remove') {
>         if ($_POST['edit']['confirm']) {
939,950c939,950
<   	        drupal_set_message(t('%user was successfully deleted from the subscription list.', array('%user'=>theme('placeholder', $subs->mail))), 'status');
< 						$watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($subs->mail)));
< 				    watchdog('simplenews', $watchdog);
< 			  	}
<   	     drupal_goto('');
< 	      }
<   	    else {
< 	        $output .= simplenews_confirm_del_user_self($subs->mail);
< 	      }
< 		  }
< 	    elseif ($op1 == 'add') {
< 		    if ($_POST['edit']['confirm']) {
---
>             drupal_set_message(t('%user was successfully deleted from the subscription list.', array('%user'=>theme('placeholder', $subs->mail))), 'status');
>             $watchdog = t('User "%email" deleted from the database.', array('%email'=>check_plain($subs->mail)));
>             watchdog('simplenews', $watchdog);
>           }
>          drupal_goto('');
>         }
>         else {
>           $output .= simplenews_confirm_del_user_self($subs->mail);
>         }
>       }
>       elseif ($op1 == 'add') {
>         if ($_POST['edit']['confirm']) {
952,960c952,960
<   	        drupal_set_message(t('%user was successfully subscribed to the newsletter.', array('%user'=>theme('placeholder', $subs->mail))), 'status');
< 			  	}
<   	     drupal_goto('');
< 	      }
<   	    else {
< 	        $output .= simplenews_confirm_add_user_self($subs->mail);
< 	      }
< 		  }
< 		}
---
>             drupal_set_message(t('%user was successfully subscribed to the newsletter.', array('%user'=>theme('placeholder', $subs->mail))), 'status');
>           }
>          drupal_goto('');
>         }
>         else {
>           $output .= simplenews_confirm_add_user_self($subs->mail);
>         }
>       }
>     }
962,965c962,965
< 	}
< 	else {
< 	  drupal_not_found();
< 	}
---
>   }
>   else {
>     drupal_not_found();
>   }
990c990
< 	$variables = array('%site' => variable_get('site_name', 'drupal'), '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mymail' => $user->mail, '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE));
---
>   $variables = array('%site' => variable_get('site_name', 'drupal'), '%uri' => $base_url, '%uri_brief' => substr($base_url, strlen('http://')), '%mymail' => $user->mail, '%date' => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE));
992,995c992,995
< 	if ($teaser) {
< 	  $node->teaser = strtr($node->teaser, $variables);
< 	}
< 	return $node;
---
>   if ($teaser) {
>     $node->teaser = strtr($node->teaser, $variables);
>   }
>   return $node;
1009,1010c1009,1010
< 		  $output .= '<div class="sn-img-item">';
< 		  $output .= '<div class="sn-img"></div>';
---
>       $output .= '<div class="sn-img-item">';
>       $output .= '<div class="sn-img"></div>';
1012c1012
< 	  	$output .= '</div>';
---
>       $output .= '</div>';
