#376020 Berdir, litwol: #288183 followup: possibility to allow empty subject on messa...
authorOleg Terenchuk
Thu, 19 Feb 2009 21:07:46 +0000 (21:07 +0000)
committerOleg Terenchuk
Thu, 19 Feb 2009 21:07:46 +0000 (21:07 +0000)
privatemsg.module

index 6b07bc6..d94b40c 100644 (file)
@@ -571,7 +571,6 @@ function privatemsg_new(&$form_state, $account = NULL) {
     '#maxlength'          => 255,
     '#default_value'      => $subject,
     '#weight'             => -5,
-    '#required'           => TRUE,
   );
   $form['privatemsg']['body']       = array(
     '#type'               => 'textarea',
@@ -627,7 +626,10 @@ function pm_send_validate($form, &$form_state) {
     $message['thread_id'] = $form_state['values']['thread_id'];
   }
 
-
+  $trimed_body = trim(truncate_utf8(strip_tags($message['body']), 50, TRUE, TRUE));
+  if (empty($message['subject']) && !empty($trimed_body)) {
+    $message['subject'] = $trimed_body;
+  }
 
   // Verify that recipient's name syntax is correct.
   $fragments = explode(',', $form_state['values']['recipient']);
@@ -1197,11 +1199,6 @@ function _privatemsg_validate_message($message, $author, $show_warnings = FALSE)
     $errors[] = t('Disallowed to send a message without subject');
   }
 
-  $trimmed = trim(strip_tags($message['body']));
-  if (empty($trimmed)) {
-    $errors[] = t('Blank messages are not allowed');
-  }
-
   if (empty($message['recipients']) || !is_array($message['recipients'])) {
     $errors[] = t('Disallowed to send a message without atleast one recipient');
   }