meeting-room-booking-system / mrbs-code

MRBS application code
Other
124 stars 60 forks source link

make email custom field email a mailto: link #1324

Open jberanek opened 10 years ago

jberanek commented 10 years ago

Hi I have added a custom field for a second email address. Currently the email output in the view_entry page shows as a text only field but i would like it the email address to render as a simple mailto: when clicked (It doesn't need to send the contents of the room booking form simply redirect to the default email programme) to make it easier for site admins to email people associated with the booking. Can you please explain which file i should edit to achieve this my field entry in the db table is "facilemail" Thanks for the support

Reported by: huwhuw

Original Ticket: mrbs/support-requests/590

Attachments: https://sourceforge.net/p/mrbs/support-requests/590/attachment/mailto.png

jberanek commented 10 years ago

Hmm, tricky as the room booking details are output by the function "create_details_row" in functions_view.inc, and the value is always HTML escaped. So, this function will need a new parameter to specify the value is pre-escaped.

Then you'll need a special case in create_details_body() under the for loop:

  foreach ($fields as $field)

That does something like:

          else if ($key == 'facilmail')
          {
            $value = "<a href=\"mailto:".htmlspecialchars($value)."\">".htmlspecialchars($value)."</a>";
            $pre_escaped = TRUE;
          }

Then at the top of create_details_body() add:

  pre_escaped = FALSE;

and in the aforementioned for loop change:

      $tbody .= create_details_row($label, $value, $as_html, $class);

to:

      $tbody .= create_details_row($label, $value, $as_html, $class, $pre_escaped);

Original comment by: jberanek

jberanek commented 10 years ago

Thanks John I tried that putting in your mods (i think) correctly. The file now outputs with lots of repeats on certain custom fields I have commented your mods in the file with //jbfix

Original comment by: huwhuw

Attachments: https://sourceforge.net/p/mrbs/support-requests/_discuss/thread/05b11e05/7a50/attachment/functions_view.inc

jberanek commented 10 years ago

Here is a screen shop of what i get after modifying. Thanks for any ideas!

Original comment by: huwhuw

Attachments: https://sourceforge.net/p/mrbs/support-requests/_discuss/thread/05b11e05/ab6b/attachment/mrbs-repeating.png