summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Negyesi2007-09-09 14:56:11 (GMT)
committer Karoly Negyesi2007-09-09 14:56:11 (GMT)
commitaad4d2b7a47d77472bd6ba87629a37d724a1f622 (patch)
tree9b9b7774092e4af24cba70bf59f7b74bb082f864
parent29361eff8ebc39fc5756d85e735d01e559dd0632 (diff)
fixes
-rw-r--r--mail_edit.module5
-rw-r--r--privatemsg.module26
2 files changed, 16 insertions, 15 deletions
diff --git a/mail_edit.module b/mail_edit.module
index c524a0f..95b8d2e 100644
--- a/mail_edit.module
+++ b/mail_edit.module
@@ -52,11 +52,11 @@ function mail_edit_mail_alter(&$mailkey, &$to, &$subject, &$body, &$from, &$head
$variables['!sender_name'] = $sender->name;
$variables['!sender_page'] = url("user/$sender->uid", NULL, NULL, TRUE);
if (!empty($sender->contact)) {
- $variables['!sender_contact_page'] = url("user/$sender->uid/contact", NULL, NULL, TRUE);
+ $variables['!sender_contact_page'] = url("privatemsg/new/$sender->uid", NULL, NULL, TRUE);
}
if ($recipient) {
$variables['!recipient_name'] = $recipient->name;
- $variables['!recipient_name'] = url("user/$recipient->uid", NULL, NULL, TRUE);
+ $variables['!recipient_page'] = url("user/$recipient->uid", NULL, NULL, TRUE);
$variables['!edit_uri'] = url('user/'. $account->uid .'/edit', NULL, NULL, TRUE);
if (substr($mailkey, 0, 5) == 'user-') {
$variables['!username'] = $recipient->name;
@@ -163,6 +163,7 @@ function mail_edit_form($mailkey) {
'#variables' => array(
'!recipient_name' => t('Name of the recipient.'),
'!recipient_page' => ('The user page of the recipient.'),
+ '!sender_name' => t('Name of the sender.'),
'!sender_page' => t('The user page of the sender.'),
'!sender_contact_page' => t('The contact page of the sender.'),
),
diff --git a/privatemsg.module b/privatemsg.module
index a135c8c..adebd2f 100644
--- a/privatemsg.module
+++ b/privatemsg.module
@@ -567,6 +567,7 @@ function privatemsg_block_user($author, $recipient = NULL) {
$recipient = ($recipient) ? $recipient : $user->uid;
if (!privatemsg_user_blocked($author, $recipient)) {
db_query("INSERT INTO {privatemsg_block_user} (author, recipient) VALUES (%d, %d)", $author, $recipient);
+ drupal_set_message(t('User has been blocked'));
}
}
@@ -575,6 +576,7 @@ function privatemsg_unblock_user($author, $recipient = NULL) {
$recipient = ($recipient) ? $recipient : $user->uid;
if (privatemsg_user_blocked($author, $recipient)) {
db_query("DELETE FROM {privatemsg_block_user} WHERE author = %d AND recipient = %d", $author, $recipient);
+ drupal_set_message(t('User has been unblocked'));
}
}
@@ -1487,7 +1489,6 @@ function privatemsg_new_form($message = NULL) {
// notices. Also we remove the message if it's a reply in a threaded view,
// the original message will be seen anyways.
if (!isset($message->subject) || variable_get('privatemsg_threaded_view', 0)) {
- $message->subject = '';
$message->message = '';
}
@@ -1508,6 +1509,7 @@ function privatemsg_new_form($message = NULL) {
'#autocomplete_path' => 'privatemsg/autocomplete',
'#size' => 50,
'#maxlength' => 1000,
+ '#required' => TRUE,
);
$form['header']['subject'] = array(
'#type' => 'textfield',
@@ -1515,10 +1517,11 @@ function privatemsg_new_form($message = NULL) {
'#default_value' => $message->subject,
'#size' => 50,
'#maxlength' => 64,
+ '#required' => TRUE,
);
$form['privatemsgbody'] = array(
'#type' => 'textarea',
- '#title' => t('Message'),
+ '#title' => empty($message->thread) ? t('Message') : t('Reply'),
'#default_value' => $message->message,
'#cols' => 80,
'#rows' => 6,
@@ -1589,12 +1592,6 @@ function privatemsg_new_form_validate($form_id, $form_values) {
if (!isset($form_values['format']) || !filter_access($form_values['format'])) {
form_set_error('format', t('The supplied input format is invalid.'));
}
- if (empty($form_values['recipient'])) {
- form_set_error('recipient', t('To field is required.'));
- }
- if (empty($form_values['subject'])) {
- form_set_error('subject', t('Subject field is required.'));
- }
if (empty($form_values['privatemsgbody'])) {
form_set_error('privatemsgbody', t('Message field is required.'));
}
@@ -1656,6 +1653,11 @@ function privatemsg_send_privatemsg($recipient, $subject, $body, $format = FILTE
}
function _privatemsg_send($sender, $recipient, $subject, $body, $format, $thread = 0, $type = 'private-message') {
+ if (!privatemsg_message_allowed($recipient->uid, $sender->uid)) {
+ drupal_set_message(t('You cannot contact %recipient', array('%recipient' => $recipient->name)));
+ return;
+ }
+
// hook to allow other modules to alter any aspect of a privatemsg
// by accepting these params by reference. Any module can cancel a
// privatemsg by returning false here
@@ -2499,15 +2501,12 @@ function privatemsg_load($message_id) {
function privatemsg_subscriptions_mailvars_pmsg($sid, $object_id, $placeholders, $sql_args) {
$message = privatemsg_load($object_id);
- $sql_args[] = $message->recipient;
$sql = "SELECT u.uid, u.name, u.mail, u.language
FROM {users} u
INNER JOIN {subscriptions} s ON u.uid = s.uid AND send_interval != -1
INNER JOIN {subscriptions_sent} ss ON u.uid = ss.uid
- WHERE $placeholders u.status= 1 AND s.stype = 'pmsg%s' AND s.uid = %d";
- $d = $sql_args;
- array_unshift($d, $sql);
- $result = db_query($sql, $sql_args);
+ WHERE u.status= 1 AND s.stype = 'pmsg%s' AND s.uid = %d";
+ $result = db_query($sql, $sid, $message->recipient);
return array(
'result' => $result,
'!message_sender' => $message->name,
@@ -2528,6 +2527,7 @@ function privatemsg_subscriptions_handle($message, $cron = FALSE) {
if (!$cron) {
subscriptions_hold($message, 'pmsg', 'insert', $message->uid);
}
+ watchdog('debug', var_export($message, TRUE));
subscriptions_mailvars($message->type, $message->id, $message->author, 'pmsg', $cron);
}