<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
Test?<div><br><div><div>Op 10-aug-2007, om 16:46 heeft William Smith het volgende geschreven:</div><br class="Apple-interchange-newline"><blockquote type="cite">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' =&gt; 'textfield',<br>  '#title' =&gt; t('Subject');<br>  '#default_value' =&gt; $node-&gt;title,<br>  '#size' =&gt; 50, <br>  '#maxlength' =&gt; 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> &lt;<a href="mailto:antoine.spadoni@gmail.com">antoine.spadoni@gmail.com</a>&gt; 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-&gt;nid;<br>  $uid = $node-&gt;uid;<br>  if ($type == 'comment' &amp;&amp; $node-&gt;nid) {<br>    $node = node_load($node-&gt;nid); <br>  }<br>  if (user_access('access private messages') &amp;&amp; in_array($teaser ? 'teaser' : $type, variable_get('privatemsg_link_'. $node-&gt;type, array())) &amp;&amp; $uid != $user-&gt;uid &amp;&amp; $user-&gt;privatemsg_allow) { <br>    if (!isset($access[$uid])) {<br>      $author = user_load(array('uid' =&gt; $uid));<br>      $access[$uid] = user_access('access private messages', $author) &amp;&amp; $author-&gt;uid &amp;&amp; $author-&gt;privatemsg_allow; <br>    }<br>    if ($access[$uid]) {<br>      $links['privatemsg_write_to_author'] = array(<br>        'title' =&gt; t('Write to seller'),<br>        'href' =&gt; '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)) &amp;&amp; ($msg-&gt;recipient = db_result(db_query('SELECT name FROM {users} WHERE uid = %d', $uid)))) {<br>    $message = $msg;<br>  }<br><br>  if ($message &amp;&amp; !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-&gt;uid));<br><br>    if (!stristr($message-&gt;subject, t('Re:'))) {<br>      $message-&gt;subject = t('Re:') .' '. $message-&gt;subject; <br>    }<br>  <br>    // quoting; [quote] if default input format uses bbcode or quote, else &gt; quoting<br>    foreach (filter_list_format(filter_resolve_format(FILTER_FORMAT_DEFAULT)) as $filter) {<br>      if ($filter-&gt;module == 'bbcode' || $filter-&gt;module == 'quote') { <br>        $bbcode = TRUE;<br>        break;<br>      }<br>    }<br>    if (isset($bbcode)) {<br>      $message-&gt;message = "\n\n[quote=". $message-&gt;recipient .']'. $message-&gt;message .'[/quote]'; <br>    }<br>    else {<br>      $message-&gt;message = "\n\n\n". str_replace("\n", "\n&gt; ", "\n". $message-&gt;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' =&gt; array());<br><br>  $form['thread'] = array('#type' =&gt; 'value', '#value' =&gt; isset($message-&gt;thread) ? $message-&gt;thread : 0); <br>  $form['header']['#theme'] = 'privatemsg_new_msg_header';<br>  $form['header']['recipient'] = array(<br>    '#type' =&gt; 'hidden',<br>    '#title' =&gt; t('Purchase'), <br>    '#description' =&gt; t('Separate multiple names with commas.'),<br>    '#default_value' =&gt; isset($recipient) ? $recipient : $message-&gt;recipient,<br>    '#autocomplete_path' =&gt; 'privatemsg/autocomplete', <br>    '#size' =&gt; 50,<br>    '#maxlength' =&gt; 1000,<br>  );<br><br><font style="font-weight: bold;" size="1">  $form['header']['subject'] = array(<br>    '#type' =&gt; 'textfield', <br>    '#title' =&gt; t('Subject'),<br>    '#default_value' =&gt; $message-&gt;subject,<br>    '#size' =&gt; 50,<br>    '#maxlength' =&gt; 64,<br>  );<br><br></font>  $form['privatemsgbody'] = array( <br>    '#type' =&gt; 'textarea',<br>    '#title' =&gt; t('Message'),<br>    '#default_value' =&gt; $message-&gt;message,<br>    '#cols' =&gt; 80,<br>    '#rows' =&gt; 6, <br>  );<br>  $form[] = filter_form($message-&gt;format);<br>  $form[] = array(<br>    '#type' =&gt; 'submit',<br>    '#value' =&gt; t('Preview')<br>  );<br>  $form[] = array(<br>    '#type' =&gt; 'submit', <br>    '#value' =&gt; 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><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--<span class="Apple-converted-space"> </span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">[ Drupal support list | <a href="http://lists.drupal.org">http://lists.drupal.org</a>/ ]</div> </blockquote></div><br></div></body></html>