Antoine -<br><br>Admittedly I only looked this over quickly, so apologies if I've misunderstood what you are trying to do, but think you would want 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 privatemsg.module, rather then editing it directly, you may want to look into using hook_form_alter to modify the form externally so that you don't have to hack the module.
<br><br>William<br><br><div><span class="gmail_quote">On 8/10/07, <b class="gmail_sendername">Antoine Spadoni</b> <<a href="mailto:antoine.spadoni@gmail.com">antoine.spadoni@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br><br>I am looking to do a slight modification in my Drupal installation within the <font size="-1"><span><b>Private</b><span style="font-weight: bold;">msg </span>module.<br><br>Below my nodes, I added a contact author link and now I want to 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 order to be able to retrieve the title of the node:<br><font size="1">/**<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 ? 'teaser' : $type, variable_get('privatemsg_link_'. $node->type, 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', $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>}</font><br><br>But now I am unable to manage to modify properly this function and display the Title of the node within the Subject Field of the message:<br><font size="1">
/**<br> * Provides a form to write a private message.<br> */<br><span style="font-weight: bold;">function privatemsg_new_form() </span>{<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('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, <a href="http://u.name" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
u.name</a> AS recipient FROM {privatemsg} p INNER JOIN {users} u ON u.uid
= 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 > quoting<br> foreach (filter_list_format(filter_resolve_format(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 .']'. $message->message .'[/quote]';
<br> }<br> else {<br> $message->message = "\n\n\n". str_replace("\n", "\n> ", "\n". $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($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->recipient,<br> '#autocomplete_path' => 'privatemsg/autocomplete',
<br> '#size' => 50,<br> '#maxlength' => 1000,<br> );<br><br><font style="font-weight: bold;" size="1"> $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></font> $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') .'/privatemsg.js');
<br><br> return $form;<br>}</font><br><br>Any help to get this modification done would be greatly appreciated!<br><br>Thanks,<br><br>Antoine<br></span></font>
<br>--<br>[ Drupal support list | <a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br></blockquote></div><br>