Hi William and Stefan,<br><br>Just tested the function, it works fine. I now get the node title within the Subject of the message.<br><br>Thank you for your help and advice regarding the hook_form_alter,<br><br>Antoine<br>
<br><br><div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Message: 2<br>Date: Fri, 10 Aug 2007 10:46:42 -0400<br>From: "William Smith" <
<a href="mailto:william.darren@gmail.com">william.darren@gmail.com</a>><br>Subject: Re: [support] Help: Privatemsg Module<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>Message-ID:<br> <
<a href="mailto:74630ca20708100746x651e9494r29c77346616895a@mail.gmail.com">74630ca20708100746x651e9494r29c77346616895a@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br>Antoine -<br>
<br>Admittedly I only looked this over quickly, so apologies if I've<br>misunderstood what you are trying to do, but think you would want to do<br>something like the following in privatemsg_new_form():<br><br>$node = node_load(arg(3));
<br><br>$form['header']['subject'] = array(<br> '#type' => 'textfield',<br> '#title' => t('Subject');<br> '#default_value' => $node->title,<br> '#size' => 50,
<br> '#maxlength' => 65,<br>);<br><br>Also, if privatemsg_new_form() is a function inside privatemsg.module,<br>rather then editing it directly, you may want to look into using<br>hook_form_alter to modify the form externally so that you don't have to hack
<br>the module.<br><br>William<br><br>On 8/10/07, Antoine Spadoni <<a href="mailto:antoine.spadoni@gmail.com">antoine.spadoni@gmail.com</a>> wrote:<br>><br>> Hi,<br>><br>> I am looking to do a slight modification in my Drupal installation within
<br>> the *Private*msg module.<br>><br>> Below my nodes, I added a contact author link and now I want to display<br>> the Title of the node within the Subject Field of the message.<br>><br>> So first, I added the nid of the node in the URL of the message in order
<br>> to be able to retrieve the title of the node:<br>> /**<br>> * Implementation of hook_link().<br>> */<br>> function privatemsg_link($type, $node = NULL, $teaser = FALSE) {<br>> global $user;<br>
> static $access = array();<br>> $links = array();<br>> $nid = $node->nid;<br>> $uid = $node->uid;<br>> if ($type == 'comment' && $node->nid) {<br>> $node = node_load($node->nid);
<br>> }<br>> if (user_access('access private messages') && in_array($teaser ?<br>> 'teaser' : $type, variable_get('privatemsg_link_'. $node->type, array())) &&<br>> $uid != $user->uid && $user->privatemsg_allow) {
<br>> if (!isset($access[$uid])) {<br>> $author = user_load(array('uid' => $uid));<br>> $access[$uid] = user_access('access private messages', $author) &&<br>> $author->uid && $author->privatemsg_allow;
<br>> }<br>> if ($access[$uid]) {<br>> $links['privatemsg_write_to_author'] = array(<br>> 'title' => t('Write to seller'),<br>> 'href' => 'privatemsg/new/'.$uid.'/'. $nid,
<br>> );<br>> }<br>> }<br>> return $links;<br>> }<br>><br>> But now I am unable to manage to modify properly this function and display<br>> the Title of the node within the Subject Field of the message:
<br>> /**<br>> * Provides a form to write a private message.<br>> */<br>> function privatemsg_new_form() {<br>> global $user;<br>> $message = 0;<br>><br>> $op = arg(1);<br>> if ($op == 'reply') {
<br>> $message = arg(2);<br>> }<br>> else if (($uid = arg(2)) && ($msg->recipient =<br>> db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid)))) {<br>> $message = $msg;
<br>> }<br>><br>> if ($message && !is_object($message)) {<br>> // This is a reply to another message<br>> $message = db_fetch_object(db_query('SELECT thread, subject, message,<br>>
<a href="http://u.name">u.name</a> AS recipient FROM {privatemsg} p INNER JOIN {users} u ON u.uid =<br>> p.author WHERE id = %d AND recipient = %d', $message, $user->uid));<br>><br>> if (!stristr($message->subject, t('Re:'))) {
<br>> $message->subject = t('Re:') .' '. $message->subject;<br>> }<br>><br>> // quoting; [quote] if default input format uses bbcode or quote, else<br>> > quoting<br>> foreach
<br>> (filter_list_format(filter_resolve_format(FILTER_FORMAT_DEFAULT)) as<br>> $filter) {<br>> if ($filter->module == 'bbcode' || $filter->module == 'quote') {<br>> $bbcode = TRUE;
<br>> break;<br>> }<br>> }<br>> if (isset($bbcode)) {<br>> $message->message = "\n\n[quote=". $message->recipient .']'.<br>> $message->message .'[/quote]';
<br>> }<br>> else {<br>> $message->message = "\n\n\n". str_replace("\n", "\n> ", "\n".<br>> $message->message);<br>> }<br>> }<br>><br>
> if (isset($_SESSION['recipients'])) {<br>> $recipient = implode(', ', $_SESSION['recipients']);<br>> unset($_SESSION['recipients']);<br>> }<br>><br>><br>> $form = array('preview' => array());
<br>><br>> $form['thread'] = array('#type' => 'value', '#value' =><br>> isset($message->thread) ? $message->thread : 0);<br>> $form['header']['#theme'] = 'privatemsg_new_msg_header';
<br>> $form['header']['recipient'] = array(<br>> '#type' => 'hidden',<br>> '#title' => t('Purchase'),<br>> '#description' => t('Separate multiple names with commas.'),
<br>> '#default_value' => isset($recipient) ? $recipient :<br>> $message->recipient,<br>> '#autocomplete_path' => 'privatemsg/autocomplete',<br>> '#size' => 50,
<br>> '#maxlength' => 1000,<br>> );<br>><br>> $form['header']['subject'] = array(<br>> '#type' => 'textfield',<br>> '#title' => t('Subject'),
<br>> '#default_value' => $message->subject,<br>> '#size' => 50,<br>> '#maxlength' => 64,<br>> );<br>><br>> $form['privatemsgbody'] = array(<br>
> '#type' => 'textarea',<br>> '#title' => t('Message'),<br>> '#default_value' => $message->message,<br>> '#cols' => 80,<br>> '#rows' => 6,
<br>> );<br>> $form[] = filter_form($message->format);<br>> $form[] = array(<br>> '#type' => 'submit',<br>> '#value' => t('Preview')<br>> );<br>> $form[] = array(
<br>> '#type' => 'submit',<br>> '#value' => t('Send private message')<br>> );<br>> $form['#after_build'] = array('_privatemsg_new_preview');<br>
><br>> drupal_add_js(drupal_get_path('module', 'privatemsg')<br>> .'/privatemsg.js');<br>><br>> return $form;<br>> }<br>><br>> Any help to get this modification done would be greatly appreciated!
<br>><br>> Thanks,<br>><br>> Antoine<br>><br>> --<br>> [ Drupal support list | <a href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]<br>><br>-------------- next part --------------<br>An HTML attachment was scrubbed...
<br>URL: <a href="http://lists.drupal.org/pipermail/support/attachments/20070810/3157e97c/attachment-0001.htm">http://lists.drupal.org/pipermail/support/attachments/20070810/3157e97c/attachment-0001.htm</a><br><br>------------------------------
<br><br>Message: 3<br>Date: Fri, 10 Aug 2007 16:48:07 +0200<br>From: Stefan Nagtegaal <<a href="mailto:drupal-support@robuustdesign.nl">drupal-support@robuustdesign.nl</a>><br>Subject: Re: [support] Help: Privatemsg Module
<br>To: <a href="mailto:support@drupal.org">support@drupal.org</a><br>Message-ID: <<a href="mailto:BF7DDC14-9B1A-424F-995D-9A37399359CE@robuustdesign.nl">BF7DDC14-9B1A-424F-995D-9A37399359CE@robuustdesign.nl</a>><br>
Content-Type: text/plain; charset="us-ascii"<br><br>Test?<br><br>Op 10-aug-2007, om 16:46 heeft William Smith het volgende geschreven:<br><br>> Antoine -<br>><br>> Admittedly I only looked this over quickly, so apologies if I've
<br>> misunderstood what you are trying to do, but think you would want<br>> to do something like the following in privatemsg_new_form():<br>><br>> $node = node_load(arg(3));<br>><br>> $form['header']['subject'] = array(
<br>> '#type' => 'textfield',<br>> '#title' => t('Subject');<br>> '#default_value' => $node->title,<br>> '#size' => 50,<br>> '#maxlength' => 65,
<br>> );<br>><br>> Also, if privatemsg_new_form() is a function inside<br>> privatemsg.module, rather then editing it directly, you may want to<br>> look into using hook_form_alter to modify the form externally so
<br>> that you don't have to hack the module.<br>><br>> William<br>><br>> On 8/10/07, Antoine Spadoni <<a href="mailto:antoine.spadoni@gmail.com">antoine.spadoni@gmail.com</a>> wrote:<br>> Hi,<br>
><br>> I am looking to do a slight modification in my Drupal installation<br>> within the Privatemsg module.<br>><br>> Below my nodes, I added a contact author link and now I want to<br>> display the Title of the node within the Subject Field of the message.
<br>><br>> So first, I added the nid of the node in the URL of the message in<br>> order to be able to retrieve the title of the node:<br>> /**<br>> * Implementation of hook_link().<br>> */<br>> function privatemsg_link($type, $node = NULL, $teaser = FALSE) {
<br>> global $user;<br>> static $access = array();<br>> $links = array();<br>> $nid = $node->nid;<br>> $uid = $node->uid;<br>> if ($type == 'comment' && $node->nid) {
<br>> $node = node_load($node->nid);<br>> }<br>> if (user_access('access private messages') && in_array($teaser ?<br>> 'teaser' : $type, variable_get('privatemsg_link_'. $node->type,
<br>> array())) && $uid != $user->uid && $user->privatemsg_allow) {<br>> if (!isset($access[$uid])) {<br>> $author = user_load(array('uid' => $uid));<br>> $access[$uid] = user_access('access private messages',
<br>> $author) && $author->uid && $author->privatemsg_allow;<br>> }<br>> if ($access[$uid]) {<br>> $links['privatemsg_write_to_author'] = array(<br>> 'title' => t('Write to seller'),
<br>> 'href' => 'privatemsg/new/'.$uid.'/'. $nid,<br>> );<br>> }<br>> }<br>> return $links;<br>> }<br>><br>> But now I am unable to manage to modify properly this function and
<br>> display the Title of the node within the Subject Field of the message:<br>> /**<br>> * Provides a form to write a private message.<br>> */<br>> function privatemsg_new_form() {<br>> global $user;
<br>> $message = 0;<br>><br>> $op = arg(1);<br>> if ($op == 'reply') {<br>> $message = arg(2);<br>> }<br>> else if (($uid = arg(2)) && ($msg->recipient = db_result(db_query
<br>> ('SELECT name FROM {users} WHERE uid = %d', $uid)))) {<br>> $message = $msg;<br>> }<br>><br>> if ($message && !is_object($message)) {<br>> // This is a reply to another message
<br>> $message = db_fetch_object(db_query('SELECT thread, subject,<br>> message, <a href="http://u.name">u.name</a> AS recipient FROM {privatemsg} p INNER JOIN {users}<br>> u ON u.uid = p.author WHERE id = %d AND recipient = %d', $message,
<br>> $user->uid));<br>><br>> if (!stristr($message->subject, t('Re:'))) {<br>> $message->subject = t('Re:') .' '. $message->subject;<br>> }<br>><br>> // quoting; [quote] if default input format uses bbcode or
<br>> quote, else > quoting<br>> foreach (filter_list_format(filter_resolve_format<br>> (FILTER_FORMAT_DEFAULT)) as $filter) {<br>> if ($filter->module == 'bbcode' || $filter->module == 'quote') {
<br>> $bbcode = TRUE;<br>> break;<br>> }<br>> }<br>> if (isset($bbcode)) {<br>> $message->message = "\n\n[quote=". $message->recipient .']'.<br>
> $message->message .'[/quote]';<br>> }<br>> else {<br>> $message->message = "\n\n\n". str_replace("\n", "\n> ", "\n".<br>> $message->message);
<br>> }<br>> }<br>><br>> if (isset($_SESSION['recipients'])) {<br>> $recipient = implode(', ', $_SESSION['recipients']);<br>> unset($_SESSION['recipients']);
<br>> }<br>><br>><br>> $form = array('preview' => array());<br>><br>> $form['thread'] = array('#type' => 'value', '#value' => isset<br>> ($message->thread) ? $message->thread : 0);
<br>> $form['header']['#theme'] = 'privatemsg_new_msg_header';<br>> $form['header']['recipient'] = array(<br>> '#type' => 'hidden',<br>> '#title' => t('Purchase'),
<br>> '#description' => t('Separate multiple names with commas.'),<br>> '#default_value' => isset($recipient) ? $recipient : $message-<br>> >recipient,<br>> '#autocomplete_path' => 'privatemsg/autocomplete',
<br>> '#size' => 50,<br>> '#maxlength' => 1000,<br>> );<br>><br>> $form['header']['subject'] = array(<br>> '#type' => 'textfield',
<br>> '#title' => t('Subject'),<br>> '#default_value' => $message->subject,<br>> '#size' => 50,<br>> '#maxlength' => 64,<br>> );<br>>
<br>> $form['privatemsgbody'] = array(<br>> '#type' => 'textarea',<br>> '#title' => t('Message'),<br>> '#default_value' => $message->message,
<br>> '#cols' => 80,<br>> '#rows' => 6,<br>> );<br>> $form[] = filter_form($message->format);<br>> $form[] = array(<br>> '#type' => 'submit',
<br>> '#value' => t('Preview')<br>> );<br>> $form[] = array(<br>> '#type' => 'submit',<br>> '#value' => t('Send private message')<br>
> );<br>> $form['#after_build'] = array('_privatemsg_new_preview');<br>><br>> drupal_add_js(drupal_get_path('module', 'privatemsg') .'/<br>> privatemsg.js');<br>
><br>> return $form;<br>> }<br>><br>> Any help to get this modification done would be greatly appreciated!<br>><br>> Thanks,<br>><br>> Antoine<br>><br>> --<br>> [ Drupal support list |
<a href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]<br>><br>> --<br>> [ Drupal support list | <a href="http://lists.drupal.org/">http://lists.drupal.org/</a> ]<br><br>-------------- next part --------------
<br>An HTML attachment was scrubbed...<br>URL: <a href="http://lists.drupal.org/pipermail/support/attachments/20070810/9ddee162/attachment.htm">http://lists.drupal.org/pipermail/support/attachments/20070810/9ddee162/attachment.htm
</a><br><br>------------------------------<br><br>--<br>[ Drupal support list | <a href="http://list.drupal.org/">http://list.drupal.org/</a> ]<br><br>End of support Digest, Vol 56, Issue 13<br>***************************************
<br></blockquote></div><br>