PersonalMessage.template.php 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2011 Simple Machines
  8. * @license http://www.simplemachines.org/about/smf/license.php BSD
  9. *
  10. * @version 2.1 Alpha 1
  11. */
  12. // This is the main sidebar for the personal messages section.
  13. function template_pm_above()
  14. {
  15. global $context, $settings, $options, $txt;
  16. echo '
  17. <div id="personal_messages">';
  18. // Show the capacity bar, if available.
  19. if (!empty($context['limit_bar']))
  20. {
  21. echo '
  22. <table width="100%" cellspacing="1" cellpadding="3" class="bordercolor" style="margin-bottom: 1em">
  23. <tr class="titlebg2">
  24. <td width="200" align="right"><strong>', $txt['pm_capacity'], ':</strong></td>
  25. <td width="50%">
  26. <div class="capacity_bar">
  27. <div class="', $context['limit_bar']['percent'] > 85 ? 'full' : ($context['limit_bar']['percent'] > 40 ? 'filled' : 'empty'), '" style="width: ', $context['limit_bar']['bar'], '%;"></div>
  28. </div>
  29. </td>
  30. <td width="200"', $context['limit_bar']['percent'] > 90 ? ' class="alert"' : '', '>
  31. ', $context['limit_bar']['text'], '
  32. </td>
  33. </tr>
  34. </table>';
  35. }
  36. // Message sent? Show a small indication.
  37. if (isset($context['pm_sent']))
  38. echo '
  39. <div class="windowbg" id="profile_success">
  40. ', $txt['pm_sent'], '
  41. </div>';
  42. }
  43. // Just the end of the index bar, nothing special.
  44. function template_pm_below()
  45. {
  46. global $context, $settings, $options;
  47. echo '
  48. </div>';
  49. }
  50. function template_folder()
  51. {
  52. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  53. // The every helpful javascript!
  54. echo '
  55. <script type="text/javascript"><!-- // --><![CDATA[
  56. var allLabels = {};
  57. var currentLabels = {};
  58. function loadLabelChoices()
  59. {
  60. var listing = document.forms.pmFolder.elements;
  61. var theSelect = document.forms.pmFolder.pm_action;
  62. var add, remove, toAdd = {length: 0}, toRemove = {length: 0};
  63. if (theSelect.childNodes.length == 0)
  64. return;';
  65. // This is done this way for internationalization reasons.
  66. echo '
  67. if (!(\'-1\' in allLabels))
  68. {
  69. for (var o = 0; o < theSelect.options.length; o++)
  70. if (theSelect.options[o].value.substr(0, 4) == "rem_")
  71. allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text;
  72. }
  73. for (var i = 0; i < listing.length; i++)
  74. {
  75. if (listing[i].name != "pms[]" || !listing[i].checked)
  76. continue;
  77. var alreadyThere = [], x;
  78. for (x in currentLabels[listing[i].value])
  79. {
  80. if (!(x in toRemove))
  81. {
  82. toRemove[x] = allLabels[x];
  83. toRemove.length++;
  84. }
  85. alreadyThere[x] = allLabels[x];
  86. }
  87. for (x in allLabels)
  88. {
  89. if (!(x in alreadyThere))
  90. {
  91. toAdd[x] = allLabels[x];
  92. toAdd.length++;
  93. }
  94. }
  95. }
  96. while (theSelect.options.length > 2)
  97. theSelect.options[2] = null;
  98. if (toAdd.length != 0)
  99. {
  100. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", "");
  101. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '");
  102. theSelect.options[theSelect.options.length - 1].disabled = true;
  103. for (i in toAdd)
  104. {
  105. if (i != "length")
  106. theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i);
  107. }
  108. }
  109. if (toRemove.length != 0)
  110. {
  111. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", "");
  112. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '");
  113. theSelect.options[theSelect.options.length - 1].disabled = true;
  114. for (i in toRemove)
  115. {
  116. if (i != "length")
  117. theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i);
  118. }
  119. }
  120. }
  121. // ]]></script>';
  122. echo '
  123. <form action="', $scripturl, '?action=pm;sa=pmactions;', $context['display_mode'] == 2 ? 'conversation;' : '', 'f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '" method="post" accept-charset="', $context['character_set'], '" name="pmFolder">';
  124. // If we are not in single display mode show the subjects on the top!
  125. if ($context['display_mode'] != 1)
  126. {
  127. template_subject_list();
  128. echo '<br />';
  129. }
  130. // Got some messages to display?
  131. if ($context['get_pmessage']('message', true))
  132. {
  133. // Show a few buttons if we are in conversation mode and outputting the first message.
  134. if ($context['display_mode'] == 2)
  135. {
  136. // Build the normal button array.
  137. $conversation_buttons = array(
  138. 'reply' => array('text' => 'reply_to_all', 'image' => 'reply.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=send;f=' . $context['folder'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';pmsg=' . $context['current_pm'] . ';u=all'),
  139. 'delete' => array('text' => 'delete_conversation', 'image' => 'delete.gif', 'lang' => true, 'url' => $scripturl . '?action=pm;sa=pmactions;pm_actions[' . $context['current_pm'] . ']=delete;conversation;f=' . $context['folder'] . ';start=' . $context['start'] . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '') . ';' . $context['session_var'] . '=' . $context['session_id'], 'custom' => 'onclick="return confirm(\'' . addslashes($txt['remove_message']) . '?\');"'),
  140. );
  141. // Show the conversation buttons.
  142. echo '
  143. <div class="modbuttons_top margintop flow_hidden">';
  144. template_button_strip($conversation_buttons, 'right');
  145. echo '
  146. </div>';
  147. }
  148. echo '
  149. <div class="tborder" style="padding: 1px">';
  150. // Show the helpful titlebar - generally.
  151. if ($context['display_mode'] != 1)
  152. echo '
  153. <div id="forumposts">
  154. <h3 class="catbg3">
  155. <span>', $txt['author'], '</span>
  156. <span id="top_subject">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
  157. </h3>
  158. </div>';
  159. // Cache some handy buttons.
  160. $quote_button = create_button('quote.gif', 'reply_quote', 'quote', 'align="middle"');
  161. $reply_button = create_button('im_reply.gif', 'reply', 'reply', 'align="middle"');
  162. $reply_all_button = create_button('im_reply_all.gif', 'reply_to_all', 'reply_to_all', 'align="middle"');
  163. $forward_button = create_button('quote.gif', 'reply_quote', 'reply_quote', 'align="middle"');
  164. $delete_button = create_button('delete.gif', 'remove_message', 'remove', 'align="middle"');
  165. while ($message = $context['get_pmessage']('message'))
  166. {
  167. $is_first_post = !isset($is_first_post) ? true : false;
  168. // Show information about the poster of this message.
  169. echo '
  170. <div class="bordercolor" id="msg', $message['id'], '">
  171. <div class="clearfix ', !$is_first_post ? 'topborder ' : '', ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2'), ' largepadding">
  172. <div class="floatleft poster">
  173. <h4>', $message['member']['link'], '</h4>
  174. <ul class="reset smalltext" id="msg_', $message['id'], '_extra_info">';
  175. // Show the member's custom title, if they have one.
  176. if (isset($message['member']['title']) && $message['member']['title'] != '')
  177. echo '
  178. <li>', $message['member']['title'], '</li>';
  179. // Show the member's primary group (like 'Administrator') if they have one.
  180. if (isset($message['member']['group']) && $message['member']['group'] != '')
  181. echo '
  182. <li>', $message['member']['group'], '</li>';
  183. // Don't show these things for guests.
  184. if (!$message['member']['is_guest'])
  185. {
  186. // Show the post group if and only if they have no other group or the option is on, and they are in a post group.
  187. if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
  188. echo '
  189. <li>', $message['member']['post_group'], '</li>';
  190. echo '
  191. <li>', $message['member']['group_stars'], '</li>';
  192. // Is karma display enabled? Total or +/-?
  193. if ($modSettings['karmaMode'] == '1')
  194. echo '
  195. <li class="margintop">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
  196. elseif ($modSettings['karmaMode'] == '2')
  197. echo '
  198. <li class="margintop">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
  199. // Is this user allowed to modify this member's karma?
  200. if ($message['member']['karma']['allow'])
  201. echo '
  202. <li>
  203. <a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
  204. <a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pm=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a>
  205. </li>';
  206. // Show online and offline buttons?
  207. if (!empty($modSettings['onlineEnable']))
  208. echo '
  209. <li>', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', $settings['use_image_buttons'] ? '<img src="' . $message['member']['online']['image_href'] . '" alt="' . $message['member']['online']['text'] . '" border="0" style="margin-top: 2px;" />' : $message['member']['online']['text'], $context['can_send_pm'] ? '</a>' : '', $settings['use_image_buttons'] ? '<span class="smalltext"> ' . $message['member']['online']['text'] . '</span>' : '', '</li>';
  210. // Show the member's gender icon?
  211. if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
  212. echo '
  213. <li>', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
  214. // Show how many posts they have made.
  215. if (!isset($context['disabled_fields']['posts']))
  216. echo '
  217. <li>', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
  218. // Any custom fields for standard placement?
  219. if (!empty($message['member']['custom_fields']))
  220. {
  221. foreach ($message['member']['custom_fields'] as $custom)
  222. if (empty($custom['placement']) && !empty($custom['value']))
  223. echo '
  224. <li>', $custom['title'], ': ', $custom['value'], '</li>';
  225. }
  226. // Show avatars, images, etc.?
  227. if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
  228. echo '
  229. <li class="margintop" style="overflow: auto;">', $message['member']['avatar']['image'], '</li>';
  230. // Show their personal text?
  231. if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
  232. echo '
  233. <li class="margintop">', $message['member']['blurb'], '</li>';
  234. // Any custom fields to show as icons?
  235. if (!empty($message['member']['custom_fields']))
  236. {
  237. $shown = false;
  238. foreach ($message['member']['custom_fields'] as $custom)
  239. {
  240. if ($custom['placement'] != 1 || empty($custom['value']))
  241. continue;
  242. if (empty($shown))
  243. {
  244. $shown = true;
  245. echo '
  246. <li class="margintop">
  247. <ul class="reset nolist">';
  248. }
  249. echo '
  250. <li>', $custom['value'], '</li>';
  251. }
  252. if ($shown)
  253. echo '
  254. </ul>
  255. </li>';
  256. }
  257. // This shows the popular messaging icons.
  258. if ($message['member']['has_messenger'] && $message['member']['can_view_profile'])
  259. echo '
  260. <li class="margintop">
  261. <ul class="reset nolist">
  262. ', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '<li>' . $message['member']['icq']['link'] . '</li>' : '', '
  263. ', !isset($context['disabled_fields']['msn']) && !empty($message['member']['msn']['link']) ? '<li>' . $message['member']['msn']['link'] . '</li>' : '', '
  264. ', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '<li>' . $message['member']['aim']['link'] . '</li>' : '', '
  265. ', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '<li>' . $message['member']['yim']['link'] . '</li>' : '', '
  266. </ul>
  267. </li>';
  268. // Show the profile, website, email address, and personal message buttons.
  269. if ($settings['show_profile_buttons'])
  270. {
  271. echo '
  272. <li class="margintop">
  273. <ul class="reset nolist">';
  274. // Don't show the profile button if you're not allowed to view the profile.
  275. if ($message['member']['can_view_profile'])
  276. echo '
  277. <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.gif" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '" border="0" />' : $txt['view_profile']), '</a></li>';
  278. // Don't show an icon if they haven't specified a website.
  279. if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
  280. echo '
  281. <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/www_sm.gif" alt="' . $message['member']['website']['title'] . '" border="0" />' : $txt['www']), '</a></li>';
  282. // Don't show the email address if they want it hidden.
  283. if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')))
  284. echo '
  285. <li><a href="', $scripturl, '?action=emailuser;sa=email;msg=', $message['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.gif" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';
  286. // Since we know this person isn't a guest, you *can* message them.
  287. if ($context['can_send_pm'])
  288. echo '
  289. <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . '.gif" alt="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '" border="0" />' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
  290. echo '
  291. </ul>
  292. </li>';
  293. }
  294. // Are we showing the warning status?
  295. if ($message['member']['can_see_warning'])
  296. echo '
  297. <li>', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<img src="', $settings['images_url'], '/warning_', $message['member']['warning_status'], '.gif" alt="', $txt['user_warn_' . $message['member']['warning_status']], '" />', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
  298. }
  299. // Done with the information about the poster... on to the post itself.
  300. echo '
  301. </ul>
  302. </div>
  303. <div class="postarea">
  304. <div class="flow_hidden">
  305. <div class="keyinfo">
  306. <h5>
  307. <strong>', $message['subject'], '</strong>
  308. </h5>';
  309. // Show who the message was sent to.
  310. echo '
  311. <div class="smalltext">
  312. &#171; <strong> ', $txt['sent_to'], ':</strong> ';
  313. // People it was sent directly to....
  314. if (!empty($message['recipients']['to']))
  315. echo implode(', ', $message['recipients']['to']);
  316. // Otherwise, we're just going to say "some people"...
  317. elseif ($context['folder'] != 'sent')
  318. echo '(', $txt['pm_undisclosed_recipients'], ')';
  319. echo '
  320. <strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
  321. </div>';
  322. // If we're in the sent items, show who it was sent to besides the "To:" people.
  323. if (!empty($message['recipients']['bcc']))
  324. echo '
  325. <div class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</div>';
  326. if (!empty($message['is_replied_to']))
  327. echo '
  328. <div class="smalltext">&#171; ', $txt['pm_is_replied_to'], ' &#187;</div>';
  329. echo '
  330. </div>
  331. <ul class="reset smalltext postingbuttons">';
  332. // Show reply buttons if you have the permission to send PMs.
  333. if ($context['can_send_pm'])
  334. {
  335. // You can't really reply if the member is gone.
  336. if (!$message['member']['is_guest'])
  337. {
  338. // Were than more than one recipient you can reply to? (Only shown when not in conversation mode.)
  339. if ($message['number_recipients'] > 1 && $context['display_mode'] != 2)
  340. echo '
  341. <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=all">', $reply_all_button, '</a></li>';
  342. echo '
  343. <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button, '</a></li>
  344. <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote', $context['folder'] == 'sent' ? '' : ';u=' . $message['member']['id'], '">', $quote_button, '</a></li>';
  345. }
  346. // This is for "forwarding" - even if the member is gone.
  347. else
  348. echo '
  349. <li><a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $forward_button, '</a></li>';
  350. }
  351. echo '
  352. <li><a href="', $scripturl, '?action=pm;sa=pmactions;pm_actions[', $message['id'], ']=delete;f=', $context['folder'], ';start=', $context['start'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', addslashes($txt['remove_message']), '?\');">', $delete_button, '</a></li>';
  353. if (empty($context['display_mode']))
  354. echo '
  355. <li><input style="vertical-align: middle;" type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check" /></li>';
  356. echo '
  357. </ul>
  358. </div>
  359. <div class="personalmessage">
  360. <hr width="100%" size="1" class="hrcolor" />
  361. ', $message['body'], '
  362. </div>';
  363. if (!empty($modSettings['enableReportPM']) && $context['folder'] != 'sent')
  364. echo '
  365. <div class="reportlinks smalltext righttext">
  366. <a href="', $scripturl, '?action=pm;sa=report;l=', $context['current_label_id'], ';pmsg=', $message['id'], '">', $txt['pm_report_to_admin'], '</a>
  367. </div>';
  368. // Are there any custom profile fields for above the signature?
  369. if (!empty($message['member']['custom_fields']))
  370. {
  371. $shown = false;
  372. foreach ($message['member']['custom_fields'] as $custom)
  373. {
  374. if ($custom['placement'] != 2 || empty($custom['value']))
  375. continue;
  376. if (!$shown)
  377. {
  378. $shown = true;
  379. echo '
  380. <div class="custom_fields_above_signature">
  381. <ul class="reset nolist>';
  382. }
  383. echo '
  384. <li>', $custom['value'], '</li>';
  385. }
  386. if ($shown)
  387. echo '
  388. </ul>
  389. </div>';
  390. }
  391. // Show the member's signature?
  392. if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
  393. echo '
  394. <div class="signature">', $message['member']['signature'], '</div>';
  395. // Add an extra line at the bottom if we have labels enabled.
  396. if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2)
  397. {
  398. echo '
  399. <div class="labels righttext">';
  400. // Add the label drop down box.
  401. if (!empty($context['currently_using_labels']))
  402. {
  403. echo '
  404. <select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();">
  405. <option value="">', $txt['pm_msg_label_title'], ':</option>
  406. <option value="" disabled="disabled">---------------</option>';
  407. // Are there any labels which can be added to this?
  408. if (!$message['fully_labeled'])
  409. {
  410. echo '
  411. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  412. foreach ($context['labels'] as $label)
  413. {
  414. if (!isset($message['labels'][$label['id']]))
  415. echo '
  416. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  417. }
  418. }
  419. // ... and are there any that can be removed?
  420. if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
  421. {
  422. echo '
  423. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  424. foreach ($message['labels'] as $label)
  425. echo '
  426. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  427. }
  428. echo '
  429. </select>
  430. <noscript>
  431. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
  432. </noscript>';
  433. }
  434. echo '
  435. </div>';
  436. }
  437. echo '
  438. </div>
  439. </div>
  440. </div>';
  441. }
  442. echo '
  443. </div>';
  444. if (empty($context['display_mode']))
  445. echo '
  446. <div class="catbg flow_hidden" style="padding: 1px; margin-top: 1ex;">
  447. <div class="floatleft pagesection">', $txt['pages'], ': ', $context['page_index'], '</div>
  448. <div class="floatright"><input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" style="font-weight: normal;" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" /></div>
  449. </div>';
  450. // Show a few buttons if we are in conversation mode and outputting the first message.
  451. elseif ($context['display_mode'] == 2 && isset($conversation_buttons))
  452. template_button_strip($conversation_buttons);
  453. echo '
  454. <br />';
  455. }
  456. // Individual messages = buttom list!
  457. if ($context['display_mode'] == 1)
  458. {
  459. template_subject_list();
  460. echo '<br />';
  461. }
  462. echo '
  463. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  464. </form>';
  465. }
  466. // Just list all the personal message subjects - to make templates easier.
  467. function template_subject_list()
  468. {
  469. global $context, $options, $settings, $modSettings, $txt, $scripturl;
  470. echo '
  471. <table width="100%" class="table_grid">
  472. <tr class="titlebg">
  473. <td align="center" width="2%"><a href="', $scripturl, '?action=pm;view;f=', $context['folder'], ';start=', $context['start'], ';sort=', $context['sort_by'], ($context['sort_direction'] == 'up' ? '' : ';desc'), ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''), '"><img src="', $settings['images_url'], '/im_switch.gif" alt="', $txt['pm_change_view'], '" title="', $txt['pm_change_view'], '" width="16" height="16" /></a></td>
  474. <td style="width: 32ex;"><a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=date', $context['sort_by'] == 'date' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['date'], $context['sort_by'] == 'date' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
  475. <td width="46%"><a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=subject', $context['sort_by'] == 'subject' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', $txt['subject'], $context['sort_by'] == 'subject' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
  476. <td><a href="', $scripturl, '?action=pm;f=', $context['folder'], ';start=', $context['start'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', '">', ($context['from_or_to'] == 'from' ? $txt['from'] : $txt['to']), $context['sort_by'] == 'name' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
  477. <td align="center" width="24"><input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" /></td>
  478. </tr>';
  479. if (!$context['show_delete'])
  480. echo '
  481. <tr>
  482. <td class="windowbg" colspan="5">', $txt['msg_alert_none'], '</td>
  483. </tr>';
  484. $next_alternate = 0;
  485. while ($message = $context['get_pmessage']('subject'))
  486. {
  487. echo '
  488. <tr class="', $next_alternate ? 'windowbg' : 'windowbg2', '">
  489. <td align="center" width="4%">
  490. <script type="text/javascript"><!-- // --><![CDATA[
  491. currentLabels[', $message['id'], '] = {';
  492. if (!empty($message['labels']))
  493. {
  494. $first = true;
  495. foreach ($message['labels'] as $label)
  496. {
  497. echo $first ? '' : ',', '
  498. "', $label['id'], '": "', $label['name'], '"';
  499. $first = false;
  500. }
  501. }
  502. echo '
  503. };
  504. // ]]></script>
  505. ', $message['is_replied_to'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.gif" style="margin-right: 4px;" alt="' . $txt['pm_replied'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.gif" style="margin-right: 4px;" alt="' . $txt['pm_read'] . '" />', '</td>
  506. <td>', $message['time'], '</td>
  507. <td>', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.gif" alt="*" />' : ''), '<a href="', ($context['display_mode'] == 0 || $context['current_pm'] == $message['id'] ? '' : ($scripturl . '?action=pm;pmid=' . $message['id'] . ';kstart;f=' . $context['folder'] . ';start=' . $context['start'] . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'up' ? ';' : ';desc') . ($context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : ''))), '#msg', $message['id'], '">', $message['subject'], '</a>', $message['is_unread'] ? '&nbsp;<img src="' . $settings['lang_images_url'] . '/new.gif" alt="' . $txt['new'] . '" />' : '', '</td>
  508. <td>', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '</td>
  509. <td align="center" width="4%"><input type="checkbox" name="pms[]" id="deletelisting', $message['id'], '" value="', $message['id'], '"', $message['is_selected'] ? ' checked="checked"' : '', ' onclick="if (document.getElementById(\'deletedisplay', $message['id'], '\')) document.getElementById(\'deletedisplay', $message['id'], '\').checked = this.checked;" class="input_check" /></td>
  510. </tr>';
  511. $next_alternate = !$next_alternate;
  512. }
  513. echo '
  514. </table>
  515. <div class="catbg flow_hidden smallpadding">
  516. <div class="floatleft pagesection">', $txt['pages'], ': ', $context['page_index'], '</div>
  517. <div class="floatright">&nbsp;';
  518. if ($context['show_delete'])
  519. {
  520. if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent')
  521. {
  522. echo '
  523. <select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();">
  524. <option value="">', $txt['pm_sel_label_title'], ':</option>
  525. <option value="" disabled="disabled">---------------</option>';
  526. echo '
  527. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  528. foreach ($context['labels'] as $label)
  529. if ($label['id'] != $context['current_label_id'])
  530. echo '
  531. <option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  532. echo '
  533. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  534. foreach ($context['labels'] as $label)
  535. echo '
  536. <option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  537. echo '
  538. </select>
  539. <noscript>
  540. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" />
  541. </noscript>';
  542. }
  543. echo '
  544. <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" />';
  545. }
  546. echo '
  547. </div>
  548. </div>';
  549. }
  550. function template_search()
  551. {
  552. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  553. echo '
  554. <script type="text/javascript"><!-- // --><![CDATA[
  555. function expandCollapseLabels()
  556. {
  557. var current = document.getElementById("searchLabelsExpand").style.display != "none";
  558. document.getElementById("searchLabelsExpand").style.display = current ? "none" : "";
  559. document.getElementById("expandLabelsIcon").src = smf_images_url + (current ? "/expand.gif" : "/collapse.gif");
  560. }
  561. // ]]></script>
  562. <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
  563. <div class="cat_bar">
  564. <h3 class="catbg">', $txt['pm_search_title'], '</h3>
  565. </div>';
  566. if (!empty($context['search_errors']))
  567. {
  568. echo '
  569. <div class="errorbox">
  570. ', implode('<br />', $context['search_errors']['messages']), '
  571. </div>';
  572. }
  573. if ($context['simple_search'])
  574. {
  575. echo '
  576. <fieldset id="simple_search">
  577. <span class="upperframe"><span></span></span>
  578. <div class="roundframe">
  579. <div id="search_term_input">
  580. <strong>', $txt['pm_search_text'], ':</strong>
  581. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  582. <input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit" />
  583. </div>
  584. <a href="', $scripturl, '?action=pm;sa=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['pm_search_advanced'], '</a>
  585. <input type="hidden" name="advanced" value="0" />
  586. </div>
  587. <span class="lowerframe"><span></span></span>
  588. </fieldset>';
  589. }
  590. // Advanced search!
  591. else
  592. {
  593. echo '
  594. <fieldset id="advanced_search">
  595. <span class="upperframe"><span></span></span>
  596. <div class="roundframe">
  597. <input type="hidden" name="advanced" value="1" />
  598. <span class="enhanced">
  599. <strong>', $txt['pm_search_text'], ':</strong>
  600. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  601. <script type="text/javascript"><!-- // --><![CDATA[
  602. function initSearch()
  603. {
  604. if (document.forms.searchform.search.value.indexOf("%u") != -1)
  605. document.forms.searchform.search.value = unescape(document.forms.searchform.search.value);
  606. }
  607. createEventListener(window);
  608. window.addEventListener("load", initSearch, false);
  609. // ]]></script>
  610. <select name="searchtype">
  611. <option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_all'], '</option>
  612. <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_any'], '</option>
  613. </select>
  614. </span>
  615. <dl id="search_options">
  616. <dt>', $txt['pm_search_user'], ':</dt>
  617. <dd><input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
  618. <dt>', $txt['pm_search_order'], ':</dt>
  619. <dd>
  620. <select name="sort">
  621. <option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option>
  622. <option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option>
  623. <option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option>
  624. </select>
  625. </dd>
  626. <dt class="options">', $txt['pm_search_options'], ':</dt>
  627. <dd class="options">
  628. <label for="show_complete"><input type="checkbox" name="show_complete" id="show_complete" value="1"', !empty($context['search_params']['show_complete']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_show_complete'], '</label><br />
  629. <label for="subject_only"><input type="checkbox" name="subject_only" id="subject_only" value="1"', !empty($context['search_params']['subject_only']) ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_search_subject_only'], '</label>
  630. </dd>
  631. <dt class="between">', $txt['pm_search_post_age'], ':</dt>
  632. <dd>', $txt['pm_search_between'], ' <input type="text" name="minage" value="', empty($context['search_params']['minage']) ? '0' : $context['search_params']['minage'], '" size="5" maxlength="5" class="input_text" />&nbsp;', $txt['pm_search_between_and'], '&nbsp;<input type="text" name="maxage" value="', empty($context['search_params']['maxage']) ? '9999' : $context['search_params']['maxage'], '" size="5" maxlength="5" class="input_text" /> ', $txt['pm_search_between_days'], '</dd>
  633. </dl>
  634. </div>
  635. <span class="lowerframe"><span></span></span>
  636. </fieldset>';
  637. // Do we have some labels setup? If so offer to search by them!
  638. if ($context['currently_using_labels'])
  639. {
  640. echo '
  641. <fieldset class="labels">
  642. <span class="upperframe"><span></span></span>
  643. <div class="roundframe">
  644. <div class="title_bar">
  645. <h4 class="titlebg">
  646. <span class="ie6_header floatleft"><a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><img src="', $settings['images_url'], '/expand.gif" id="expandLabelsIcon" alt="" /></a> <a href="javascript:void(0);" onclick="expandCollapseLabels(); return false;"><strong>', $txt['pm_search_choose_label'], '</strong></a></span>
  647. </h4>
  648. </div>
  649. <ul id="searchLabelsExpand" class="reset" ', $context['check_all'] ? 'style="display: none;"' : '', '>';
  650. foreach ($context['search_labels'] as $label)
  651. echo '
  652. <li>
  653. <label for="searchlabel_', $label['id'], '"><input type="checkbox" id="searchlabel_', $label['id'], '" name="searchlabel[', $label['id'], ']" value="', $label['id'], '" ', $label['checked'] ? 'checked="checked"' : '', ' class="input_check" />
  654. ', $label['name'], '</label>
  655. </li>';
  656. echo '
  657. </ul>
  658. <p>
  659. <input type="checkbox" name="all" id="check_all" value="" ', $context['check_all'] ? 'checked="checked"' : '', ' onclick="invertAll(this, this.form, \'searchlabel\');" class="input_check" /><em> <label for="check_all">', $txt['check_all'], '</label></em>
  660. </p>
  661. </div>
  662. <span class="lowerframe"><span></span></span>
  663. </fieldset>';
  664. }
  665. echo '
  666. <div class="righttext padding">
  667. <input type="submit" name="submit" value="', $txt['pm_search_go'], '" class="button_submit" />
  668. </div>';
  669. }
  670. echo '
  671. </table>
  672. </form>';
  673. }
  674. function template_search_results()
  675. {
  676. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  677. // This splits broadly into two types of template... complete results first.
  678. if (!empty($context['search_params']['show_complete']))
  679. {
  680. echo '
  681. <table border="0" width="100%" align="center" cellpadding="3" cellspacing="1" class="bordercolor">
  682. <tr class="titlebg">
  683. <td colspan="3">', $txt['pm_search_results'], '</td>
  684. </tr>
  685. <tr class="catbg" height="30">
  686. <td colspan="3"><strong>', $txt['pages'], ':</strong> ', $context['page_index'], '</td>
  687. </tr>
  688. </table>';
  689. }
  690. else
  691. {
  692. echo '
  693. <table border="0" width="100%" align="center" cellpadding="3" cellspacing="1" class="bordercolor">
  694. <tr class="titlebg">
  695. <td colspan="3">', $txt['pm_search_results'], '</td>
  696. </tr>
  697. <tr class="catbg">
  698. <td colspan="3"><strong>', $txt['pages'], ':</strong> ', $context['page_index'], '</td>
  699. </tr>
  700. <tr class="titlebg">
  701. <td width="30%">', $txt['date'], '</td>
  702. <td width="50%">', $txt['subject'], '</td>
  703. <td width="20%">', $txt['from'], '</td>
  704. </tr>';
  705. }
  706. $alternate = true;
  707. // Print each message out...
  708. foreach ($context['personal_messages'] as $message)
  709. {
  710. // We showing it all?
  711. if (!empty($context['search_params']['show_complete']))
  712. {
  713. // @todo This still needs to be made pretty.
  714. echo '
  715. <br />
  716. <table width="100%" align="center" cellpadding="3" cellspacing="1" border="0" class="bordercolor">
  717. <tr class="titlebg">
  718. <td align="left">
  719. <div class="floatleft">
  720. ', $message['counter'], '&nbsp;&nbsp;<a href="', $message['href'], '">', $message['subject'], '</a>
  721. </div>
  722. <div class="floatright">
  723. ', $txt['search_on'], ': ', $message['time'], '
  724. </div>
  725. </td>
  726. </tr>
  727. <tr class="catbg">
  728. <td>', $txt['from'], ': ', $message['member']['link'], ', ', $txt['to'], ': ';
  729. // Show the recipients.
  730. // @todo This doesn't deal with the sent item searching quite right for bcc.
  731. if (!empty($message['recipients']['to']))
  732. echo implode(', ', $message['recipients']['to']);
  733. // Otherwise, we're just going to say "some people"...
  734. elseif ($context['folder'] != 'sent')
  735. echo '(', $txt['pm_undisclosed_recipients'], ')';
  736. echo '
  737. </td>
  738. </tr>
  739. <tr class="windowbg2" valign="top">
  740. <td>', $message['body'], '</td>
  741. </tr>
  742. <tr class="windowbg">
  743. <td align="right" class="middletext">';
  744. if ($context['can_send_pm'])
  745. {
  746. $quote_button = create_button('quote.gif', 'reply_quote', 'reply_quote', 'align="middle"');
  747. $reply_button = create_button('im_reply.gif', 'reply', 'reply', 'align="middle"');
  748. // You can only reply if they are not a guest...
  749. if (!$message['member']['is_guest'])
  750. echo '
  751. <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote;u=', $context['folder'] == 'sent' ? '' : $message['member']['id'], '">', $quote_button , '</a>', $context['menu_separator'], '
  752. <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';u=', $message['member']['id'], '">', $reply_button , '</a> ', $context['menu_separator'];
  753. // This is for "forwarding" - even if the member is gone.
  754. else
  755. echo '
  756. <a href="', $scripturl, '?action=pm;sa=send;f=', $context['folder'], $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';pmsg=', $message['id'], ';quote">', $quote_button , '</a>', $context['menu_separator'];
  757. }
  758. echo '
  759. </td>
  760. </tr>
  761. </table>';
  762. }
  763. // Otherwise just a simple list!
  764. else
  765. {
  766. // @todo No context at all of the search?
  767. echo '
  768. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" valign="top">
  769. <td>', $message['time'], '</td>
  770. <td>', $message['link'], '</td>
  771. <td>', $message['member']['link'], '</td>
  772. </tr>';
  773. }
  774. $alternate = !$alternate;
  775. }
  776. // Finish off the page...
  777. if (!empty($context['search_params']['show_complete']))
  778. {
  779. // No results?
  780. if (empty($context['personal_messages']))
  781. echo '
  782. <table width="100%" align="center" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-width: 0 1px 1px 1px;">
  783. <tr class="windowbg">
  784. <td align="center">', $txt['pm_search_none_found'], '</td>
  785. </tr>
  786. </table>';
  787. else
  788. echo '
  789. <br />';
  790. echo '
  791. <table width="100%" align="center" cellpadding="3" cellspacing="0" border="0" class="tborder" style="border-width: 0 1px 1px 1px;">
  792. <tr class="catbg" height="30">
  793. <td colspan="3"><strong>', $txt['pages'], ':</strong> ', $context['page_index'], '</td>
  794. </tr>
  795. </table>';
  796. }
  797. else
  798. {
  799. if (empty($context['personal_messages']))
  800. echo '
  801. <tr class="windowbg2">
  802. <td colspan="3" align="center">', $txt['pm_search_none_found'], '</td>
  803. </tr>';
  804. echo '
  805. <tr class="catbg">
  806. <td colspan="3"><strong>', $txt['pages'], ':</strong> ', $context['page_index'], '</td>
  807. </tr>
  808. </table>';
  809. }
  810. }
  811. function template_send()
  812. {
  813. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  814. // Show which messages were sent successfully and which failed.
  815. if (!empty($context['send_log']))
  816. {
  817. echo '
  818. <div class="cat_bar">
  819. <h3 class="catbg">', $txt['pm_send_report'], '</h3>
  820. </div>
  821. <div class="windowbg">
  822. <span class="topslice"><span></span></span>
  823. <div class="content">';
  824. if (!empty($context['send_log']['sent']))
  825. foreach ($context['send_log']['sent'] as $log_entry)
  826. echo '<span class="error">', $log_entry, '</span><br />';
  827. if (!empty($context['send_log']['failed']))
  828. foreach ($context['send_log']['failed'] as $log_entry)
  829. echo '<span class="error">', $log_entry, '</span><br />';
  830. echo '
  831. </div>
  832. <span class="botslice"><span></span></span>
  833. </div>
  834. <br />';
  835. }
  836. // Show the preview of the personal message.
  837. if (isset($context['preview_message']))
  838. echo '
  839. <div class="cat_bar">
  840. <h3 class="catbg">', $context['preview_subject'], '</h3>
  841. </div>
  842. <div class="windowbg">
  843. <span class="topslice"><span></span></span>
  844. <div class="content">
  845. ', $context['preview_message'], '
  846. </div>
  847. <span class="botslice"><span></span></span>
  848. </div>
  849. <br />';
  850. // Main message editing box.
  851. echo '
  852. <div class="cat_bar">
  853. <h3 class="catbg">
  854. <span class="ie6_header floatleft"><img src="', $settings['images_url'], '/icons/im_newmsg.gif" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '</span>
  855. </h3>
  856. </div>';
  857. echo '
  858. <form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
  859. <div>
  860. <span class="upperframe"><span></span></span>
  861. <div class="roundframe">';
  862. // If there were errors for sending the PM, show them.
  863. if (!empty($context['post_error']['messages']))
  864. {
  865. echo '
  866. <div class="errorbox">
  867. <strong>', $txt['error_while_submitting'], '</strong>
  868. <ul>';
  869. foreach ($context['post_error']['messages'] as $error)
  870. echo '
  871. <li class="error">', $error, '</li>';
  872. echo '
  873. </ul>
  874. </div>';
  875. }
  876. echo '
  877. <dl id="post_header">';
  878. // To and bcc. Include a button to search for members.
  879. echo '
  880. <dt>
  881. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), '>', $txt['pm_to'], ':</span>
  882. </dt>';
  883. // Autosuggest will be added by the JavaScript later on.
  884. echo '
  885. <dd>
  886. <input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
  887. // A link to add BCC, only visible with JavaScript enabled.
  888. echo '
  889. <span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
  890. // A div that'll contain the items found by the autosuggest.
  891. echo '
  892. <div id="to_item_list_container"></div>';
  893. echo '
  894. </dd>';
  895. // This BCC row will be hidden by default if JavaScript is enabled.
  896. echo '
  897. <dt id="bcc_div">
  898. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), '>', $txt['pm_bcc'], ':</span>
  899. </dt>
  900. <dd id="bcc_div2">
  901. <input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
  902. <div id="bcc_item_list_container"></div>
  903. </dd>';
  904. // The subject of the PM.
  905. echo '
  906. <dt>
  907. <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), '>', $txt['subject'], ':</span>
  908. </dt>
  909. <dd>
  910. <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="40" maxlength="50" />
  911. </dd>
  912. </dl>';
  913. // Showing BBC?
  914. if ($context['show_bbc'])
  915. {
  916. echo '
  917. <div id="bbcBox_message"></div>';
  918. }
  919. // What about smileys?
  920. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  921. echo '
  922. <div id="smileyBox_message"></div>';
  923. // Show BBC buttons, smileys and textbox.
  924. echo '
  925. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  926. // Require an image to be typed to save spamming?
  927. if ($context['require_verification'])
  928. {
  929. echo '
  930. <div class="post_verification">
  931. <strong>', $txt['pm_visual_verification_label'], ':</strong>
  932. ', template_control_verification($context['visual_verification_id'], 'all'), '
  933. </div>';
  934. }
  935. // Send, Preview, spellcheck buttons.
  936. echo '
  937. <p><label for="outbox"><input type="checkbox" name="outbox" id="outbox" value="1" tabindex="', $context['tabindex']++, '"', $context['copy_to_outbox'] ? ' checked="checked"' : '', ' class="input_check" /> ', $txt['pm_save_outbox'], '</label></p>
  938. <p id="shortcuts" class="smalltext">
  939. ', $context['browser']['is_firefox'] ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
  940. </p>
  941. <p id="post_confirm_strip" class="righttext">
  942. ', template_control_richedit_buttons($context['post_box_name']), '
  943. </p>
  944. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  945. <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
  946. <input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
  947. <input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
  948. <input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
  949. <input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
  950. </div>
  951. <span class="lowerframe"><span></span></span>
  952. </div>
  953. </form>';
  954. // Show the message you're replying to.
  955. if ($context['reply'])
  956. echo '
  957. <br />
  958. <br />
  959. <div class="cat_bar">
  960. <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
  961. </div>
  962. <div class="title_bar">
  963. <h3 class="titlebg">
  964. <span class="floatleft">', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</span>
  965. <span class="floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
  966. </h3>
  967. </div>
  968. <div class="windowbg2">
  969. <span class="topslice"><span></span></span>
  970. <div class="content">
  971. ', $context['quoted_message']['body'], '
  972. </div>
  973. <span class="botslice"><span></span></span>
  974. </div>';
  975. echo '
  976. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?fin20"></script>
  977. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?fin20"></script>
  978. <script type="text/javascript"><!-- // --><![CDATA[
  979. var oPersonalMessageSend = new smf_PersonalMessageSend({
  980. sSelf: \'oPersonalMessageSend\',
  981. sSessionId: \'', $context['session_id'], '\',
  982. sSessionVar: \'', $context['session_var'], '\',
  983. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  984. sToControlId: \'to_control\',
  985. aToRecipients: [';
  986. foreach ($context['recipients']['to'] as $i => $member)
  987. echo '
  988. {
  989. sItemId: ', JavaScriptEscape($member['id']), ',
  990. sItemName: ', JavaScriptEscape($member['name']), '
  991. }', $i == count($context['recipients']['to']) - 1 ? '' : ',';
  992. echo '
  993. ],
  994. aBccRecipients: [';
  995. foreach ($context['recipients']['bcc'] as $i => $member)
  996. echo '
  997. {
  998. sItemId: ', JavaScriptEscape($member['id']), ',
  999. sItemName: ', JavaScriptEscape($member['name']), '
  1000. }', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
  1001. echo '
  1002. ],
  1003. sBccControlId: \'bcc_control\',
  1004. sBccDivId: \'bcc_div\',
  1005. sBccDivId2: \'bcc_div2\',
  1006. sBccLinkId: \'bcc_link\',
  1007. sBccLinkContainerId: \'bcc_link_container\',
  1008. bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
  1009. sShowBccLinkTemplate: ', JavaScriptEscape('
  1010. <a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqWin(this.href);">(?)</a>'
  1011. ), '
  1012. });
  1013. ';
  1014. echo '
  1015. // ]]></script>';
  1016. }
  1017. // This template asks the user whether they wish to empty out their folder/messages.
  1018. function template_ask_delete()
  1019. {
  1020. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  1021. echo '
  1022. <div class="cat_bar">
  1023. <h3 class="catbg">', ($context['delete_all'] ? $txt['delete_message'] : $txt['delete_all']), '</h3>
  1024. </div>
  1025. <div class="windowbg">
  1026. <span class="topslice"><span></span></span>
  1027. <div class="content">
  1028. <p>', $txt['delete_all_confirm'], '</p><br />
  1029. <strong><a href="', $scripturl, '?action=pm;sa=removeall2;f=', $context['folder'], ';', $context['current_label_id'] != -1 ? ';l=' . $context['current_label_id'] : '', ';', $context['session_var'], '=', $context['session_id'], '">', $txt['yes'], '</a> - <a href="javascript:history.go(-1);">', $txt['no'], '</a></strong>
  1030. </div>
  1031. <span class="botslice"><span></span></span>
  1032. </div>';
  1033. }
  1034. // This template asks the user what messages they want to prune.
  1035. function template_prune()
  1036. {
  1037. global $context, $settings, $options, $scripturl, $txt;
  1038. echo '
  1039. <form action="', $scripturl, '?action=pm;sa=prune" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['pm_prune_warning'], '\');">
  1040. <div class="cat_bar">
  1041. <h3 class="catbg">', $txt['pm_prune'], '</h3>
  1042. </div>
  1043. <div class="windowbg">
  1044. <span class="topslice"><span></span></span>
  1045. <div class="content">
  1046. <p>', $txt['pm_prune_desc1'], ' <input type="text" name="age" size="3" value="14" class="input_text" /> ', $txt['pm_prune_desc2'], '</p>
  1047. <div class="righttext">
  1048. <input type="submit" value="', $txt['delete'], '" class="button_submit" />
  1049. </div>
  1050. </div>
  1051. <span class="botslice"><span></span></span>
  1052. </div>
  1053. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1054. </form>';
  1055. }
  1056. // Here we allow the user to setup labels, remove labels and change rules for labels (i.e, do quite a bit)
  1057. function template_labels()
  1058. {
  1059. global $context, $settings, $options, $scripturl, $txt;
  1060. echo '
  1061. <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '">
  1062. <div class="title_bar">
  1063. <h3 class="titlebg">', $txt['pm_manage_labels'], '</h3>
  1064. </div>
  1065. <div class="description">
  1066. ', $txt['pm_labels_desc'], '
  1067. </div>
  1068. <table width="100%" class="table_grid">
  1069. <thead>
  1070. <tr class="catbg">
  1071. <th class="smalltext" colspan="2">
  1072. <div class="floatright centertext" style="width: 4%;"><input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" /></div>
  1073. ', $txt['pm_label_name'], '
  1074. </th>
  1075. </tr>
  1076. </thead>
  1077. <tbody>';
  1078. if (count($context['labels']) < 2)
  1079. echo '
  1080. <tr class="windowbg2">
  1081. <td colspan="2" align="center">', $txt['pm_labels_no_exist'], '</td>
  1082. </tr>';
  1083. else
  1084. {
  1085. $alternate = true;
  1086. foreach ($context['labels'] as $label)
  1087. {
  1088. if ($label['id'] == -1)
  1089. continue;
  1090. echo '
  1091. <tr class="', $alternate ? 'windowbg2' : 'windowbg', '">
  1092. <td>
  1093. <input type="text" name="label_name[', $label['id'], ']" value="', $label['name'], '" size="30" maxlength="30" class="input_text" />
  1094. </td>
  1095. <td width="4%" align="center"><input type="checkbox" class="input_check" name="delete_label[', $label['id'], ']" /></td>
  1096. </tr>';
  1097. $alternate = !$alternate;
  1098. }
  1099. }
  1100. echo '
  1101. </tbody>
  1102. </table>';
  1103. if (!count($context['labels']) < 2)
  1104. echo '
  1105. <div class="padding righttext">
  1106. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit" />
  1107. <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" onclick="return confirm(\'', $txt['pm_labels_delete'], '\');" class="button_submit" />
  1108. </div>';
  1109. echo '
  1110. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1111. </form>
  1112. <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '" style="margin-top: 1ex;">
  1113. <div class="cat_bar">
  1114. <h3 class="catbg">', $txt['pm_label_add_new'], '</h3>
  1115. </div>
  1116. <div class="windowbg">
  1117. <span class="topslice"><span></span></span>
  1118. <div class="content">
  1119. <dl class="settings">
  1120. <dt>
  1121. <strong><label for="add_label">', $txt['pm_label_name'], '</label>:</strong>
  1122. </dt>
  1123. <dd>
  1124. <input type="text" id="add_label" name="label" value="" size="30" maxlength="30" class="input_text" />
  1125. </dd>
  1126. </dl>
  1127. <div class="righttext">
  1128. <input type="submit" name="add" value="', $txt['pm_label_add_new'], '" class="button_submit" />
  1129. </div>
  1130. </div>
  1131. <span class="botslice"><span></span></span>
  1132. </div>
  1133. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1134. </form>';
  1135. }
  1136. // Template for reporting a personal message.
  1137. function template_report_message()
  1138. {
  1139. global $context, $settings, $options, $txt, $scripturl;
  1140. echo '
  1141. <form action="', $scripturl, '?action=pm;sa=report;l=', $context['current_label_id'], '" method="post" accept-charset="', $context['character_set'], '">
  1142. <input type="hidden" name="pmsg" value="', $context['pm_id'], '" />
  1143. <div class="cat_bar">
  1144. <h3 class="catbg">', $txt['pm_report_title'], '</h3>
  1145. </div>
  1146. <div class="description">
  1147. ', $txt['pm_report_desc'], '
  1148. </div>
  1149. <div class="windowbg">
  1150. <span class="topslice"><span></span></span>
  1151. <div class="content">
  1152. <dl class="settings">';
  1153. // If there is more than one admin on the forum, allow the user to choose the one they want to direct to.
  1154. // @todo Why?
  1155. if ($context['admin_count'] > 1)
  1156. {
  1157. echo '
  1158. <dt>
  1159. <strong>', $txt['pm_report_admins'], ':</strong>
  1160. </dt>
  1161. <dd>
  1162. <select name="ID_ADMIN">
  1163. <option value="0">', $txt['pm_report_all_admins'], '</option>';
  1164. foreach ($context['admins'] as $id => $name)
  1165. echo '
  1166. <option value="', $id, '">', $name, '</option>';
  1167. echo '
  1168. </select>
  1169. </dd>';
  1170. }
  1171. echo '
  1172. <dt>
  1173. <strong>', $txt['pm_report_reason'], ':</strong>
  1174. </dt>
  1175. <dd>
  1176. <textarea name="reason" rows="4" cols="70" style="' . ($context['browser']['is_ie8'] ? 'width: 635px; max-width: 80%; min-width: 80%' : 'width: 80%') . ';"></textarea>
  1177. </dd>
  1178. </dl>
  1179. <input type="submit" name="report" value="', $txt['pm_report_message'], '" class="button_submit" />
  1180. </div>
  1181. <span class="botslice"><span></span></span>
  1182. </div>
  1183. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1184. </form>';
  1185. }
  1186. // Little template just to say "Yep, it's been submitted"
  1187. function template_report_message_complete()
  1188. {
  1189. global $context, $settings, $options, $txt, $scripturl;
  1190. echo '
  1191. <div class="cat_bar">
  1192. <h3 class="catbg">', $txt['pm_report_title'], '</h3>
  1193. </div>
  1194. <div class="windowbg">
  1195. <span class="topslice"><span></span></span>
  1196. <div class="content">
  1197. <p>', $txt['pm_report_done'], '</p>
  1198. <a href="', $scripturl, '?action=pm;l=', $context['current_label_id'], '">', $txt['pm_report_return'], '</a>
  1199. </div>
  1200. <span class="botslice"><span></span></span>
  1201. </div>';
  1202. }
  1203. // Manage rules.
  1204. function template_rules()
  1205. {
  1206. global $context, $settings, $options, $txt, $scripturl;
  1207. echo '
  1208. <form action="', $scripturl, '?action=pm;sa=manrules" method="post" accept-charset="', $context['character_set'], '" name="manRules">
  1209. <div class="title_bar">
  1210. <h3 class="titlebg">', $txt['pm_manage_rules'], '</h3>
  1211. </div>
  1212. <div class="description">
  1213. ', $txt['pm_manage_rules_desc'], '
  1214. </div>
  1215. <table width="100%" class="table_grid">
  1216. <thead>
  1217. <tr class="catbg">
  1218. <th class="smalltext">
  1219. ', $txt['pm_rule_title'], '
  1220. </th>
  1221. <th width="4%" align="center">';
  1222. if (!empty($context['rules']))
  1223. echo '
  1224. <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />';
  1225. echo '
  1226. </th>
  1227. </tr>
  1228. </thead>
  1229. <tbody>';
  1230. if (empty($context['rules']))
  1231. echo '
  1232. <tr class="windowbg2">
  1233. <td colspan="2" align="center">
  1234. ', $txt['pm_rules_none'], '
  1235. </td>
  1236. </tr>';
  1237. $alternate = false;
  1238. foreach ($context['rules'] as $rule)
  1239. {
  1240. echo '
  1241. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  1242. <td>
  1243. <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a>
  1244. </td>
  1245. <td width="4%" align="center">
  1246. <input type="checkbox" name="delrule[', $rule['id'], ']" class="input_check" />
  1247. </td>
  1248. </tr>';
  1249. $alternate = !$alternate;
  1250. }
  1251. echo '
  1252. </tbody>
  1253. </table>
  1254. <div class="righttext">
  1255. [<a href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>]';
  1256. if (!empty($context['rules']))
  1257. echo '
  1258. [<a href="', $scripturl, '?action=pm;sa=manrules;apply;', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['pm_js_apply_rules_confirm'], '\');">', $txt['pm_apply_rules'], '</a>]';
  1259. if (!empty($context['rules']))
  1260. echo '
  1261. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1262. <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" onclick="return confirm(\'', $txt['pm_js_delete_rule_confirm'], '\');" class="button_submit" />';
  1263. echo '
  1264. </div>
  1265. </form>';
  1266. }
  1267. // Template for adding/editing a rule.
  1268. function template_add_rule()
  1269. {
  1270. global $context, $settings, $options, $txt, $scripturl;
  1271. echo '
  1272. <script type="text/javascript"><!-- // --><![CDATA[
  1273. var criteriaNum = 0;
  1274. var actionNum = 0;
  1275. var groups = new Array()
  1276. var labels = new Array()';
  1277. foreach ($context['groups'] as $id => $title)
  1278. echo '
  1279. groups[', $id, '] = "', addslashes($title), '";';
  1280. foreach ($context['labels'] as $label)
  1281. if ($label['id'] != -1)
  1282. echo '
  1283. labels[', ($label['id'] + 1), '] = "', addslashes($label['name']), '";';
  1284. echo '
  1285. function addCriteriaOption()
  1286. {
  1287. if (criteriaNum == 0)
  1288. {
  1289. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1290. if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
  1291. criteriaNum++;
  1292. }
  1293. criteriaNum++
  1294. setOuterHTML(document.getElementById("criteriaAddHere"), \'<br /><select name="ruletype[\' + criteriaNum + \']" id="ruletype\' + criteriaNum + \'" onchange="updateRuleDef(\' + criteriaNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_criteria_pick']), ':<\' + \'/option><option value="mid">', addslashes($txt['pm_rule_mid']), '<\' + \'/option><option value="gid">', addslashes($txt['pm_rule_gid']), '<\' + \'/option><option value="sub">', addslashes($txt['pm_rule_sub']), '<\' + \'/option><option value="msg">', addslashes($txt['pm_rule_msg']), '<\' + \'/option><option value="bud">', addslashes($txt['pm_rule_bud']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="defdiv\' + criteriaNum + \'" style="display: none;"><input type="text" name="ruledef[\' + criteriaNum + \']" id="ruledef\' + criteriaNum + \'" onkeyup="rebuildRuleDesc();" value="" class="input_text" /><\' + \'/span><span id="defseldiv\' + criteriaNum + \'" style="display: none;"><select name="ruledefgroup[\' + criteriaNum + \']" id="ruledefgroup\' + criteriaNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_group']), '<\' + \'/option>';
  1295. foreach ($context['groups'] as $id => $group)
  1296. echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
  1297. echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
  1298. }
  1299. function addActionOption()
  1300. {
  1301. if (actionNum == 0)
  1302. {
  1303. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1304. if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
  1305. actionNum++;
  1306. }
  1307. actionNum++
  1308. setOuterHTML(document.getElementById("actionAddHere"), \'<br /><select name="acttype[\' + actionNum + \']" id="acttype\' + actionNum + \'" onchange="updateActionDef(\' + actionNum + \'); rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_action']), ':<\' + \'/option><option value="lab">', addslashes($txt['pm_rule_label']), '<\' + \'/option><option value="del">', addslashes($txt['pm_rule_delete']), '<\' + \'/option><\' + \'/select>&nbsp;<span id="labdiv\' + actionNum + \'" style="display: none;"><select name="labdef[\' + actionNum + \']" id="labdef\' + actionNum + \'" onchange="rebuildRuleDesc();"><option value="">', addslashes($txt['pm_rule_sel_label']), '<\' + \'/option>';
  1309. foreach ($context['labels'] as $label)
  1310. if ($label['id'] != -1)
  1311. echo '<option value="', ($label['id'] + 1), '">', addslashes($label['name']), '<\' + \'/option>';
  1312. echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
  1313. }
  1314. function updateRuleDef(optNum)
  1315. {
  1316. if (document.getElementById("ruletype" + optNum).value == "gid")
  1317. {
  1318. document.getElementById("defdiv" + optNum).style.display = "none";
  1319. document.getElementById("defseldiv" + optNum).style.display = "";
  1320. }
  1321. else if (document.getElementById("ruletype" + optNum).value == "bud" || document.getElementById("ruletype" + optNum).value == "")
  1322. {
  1323. document.getElementById("defdiv" + optNum).style.display = "none";
  1324. document.getElementById("defseldiv" + optNum).style.display = "none";
  1325. }
  1326. else
  1327. {
  1328. document.getElementById("defdiv" + optNum).style.display = "";
  1329. document.getElementById("defseldiv" + optNum).style.display = "none";
  1330. }
  1331. }
  1332. function updateActionDef(optNum)
  1333. {
  1334. if (document.getElementById("acttype" + optNum).value == "lab")
  1335. {
  1336. document.getElementById("labdiv" + optNum).style.display = "";
  1337. }
  1338. else
  1339. {
  1340. document.getElementById("labdiv" + optNum).style.display = "none";
  1341. }
  1342. }
  1343. // Rebuild the rule description!
  1344. function rebuildRuleDesc()
  1345. {
  1346. // Start with nothing.
  1347. text = "";
  1348. joinText = "";
  1349. actionText = "";
  1350. hadBuddy = false;
  1351. foundCriteria = false;
  1352. foundAction = false;
  1353. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1354. {
  1355. if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
  1356. {
  1357. if (foundCriteria)
  1358. joinText = document.getElementById("logic").value == \'and\' ? ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ' : ', JavaScriptEscape(' ' . $txt['pm_readable_or'] . ' '), ';
  1359. else
  1360. joinText = \'\';
  1361. foundCriteria = true;
  1362. curNum = document.forms.addrule.elements[i].id.match(/\d+/);
  1363. curVal = document.forms.addrule.elements[i].value;
  1364. if (curVal == "gid")
  1365. curDef = document.getElementById("ruledefgroup" + curNum).value.php_htmlspecialchars();
  1366. else if (curVal != "bud")
  1367. curDef = document.getElementById("ruledef" + curNum).value.php_htmlspecialchars();
  1368. else
  1369. curDef = "";
  1370. // What type of test is this?
  1371. if (curVal == "mid" && curDef)
  1372. text += joinText + ', JavaScriptEscape($txt['pm_readable_member']), '.replace("{MEMBER}", curDef);
  1373. else if (curVal == "gid" && curDef && groups[curDef])
  1374. text += joinText + ', JavaScriptEscape($txt['pm_readable_group']), '.replace("{GROUP}", groups[curDef]);
  1375. else if (curVal == "sub" && curDef)
  1376. text += joinText + ', JavaScriptEscape($txt['pm_readable_subject']), '.replace("{SUBJECT}", curDef);
  1377. else if (curVal == "msg" && curDef)
  1378. text += joinText + ', JavaScriptEscape($txt['pm_readable_body']), '.replace("{BODY}", curDef);
  1379. else if (curVal == "bud" && !hadBuddy)
  1380. {
  1381. text += joinText + ', JavaScriptEscape($txt['pm_readable_buddy']), ';
  1382. hadBuddy = true;
  1383. }
  1384. }
  1385. if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
  1386. {
  1387. if (foundAction)
  1388. joinText = ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ';
  1389. else
  1390. joinText = "";
  1391. foundAction = true;
  1392. curNum = document.forms.addrule.elements[i].id.match(/\d+/);
  1393. curVal = document.forms.addrule.elements[i].value;
  1394. if (curVal == "lab")
  1395. curDef = document.getElementById("labdef" + curNum).value.php_htmlspecialchars();
  1396. else
  1397. curDef = "";
  1398. // Now pick the actions.
  1399. if (curVal == "lab" && curDef && labels[curDef])
  1400. actionText += joinText + ', JavaScriptEscape($txt['pm_readable_label']), '.replace("{LABEL}", labels[curDef]);
  1401. else if (curVal == "del")
  1402. actionText += joinText + ', JavaScriptEscape($txt['pm_readable_delete']), ';
  1403. }
  1404. }
  1405. // If still nothing make it default!
  1406. if (text == "" || !foundCriteria)
  1407. text = "', $txt['pm_rule_not_defined'], '";
  1408. else
  1409. {
  1410. if (actionText != "")
  1411. text += ', JavaScriptEscape(' ' . $txt['pm_readable_then'] . ' '), ' + actionText;
  1412. text = ', JavaScriptEscape($txt['pm_readable_start']), ' + text + ', JavaScriptEscape($txt['pm_readable_end']), ';
  1413. }
  1414. // Set the actual HTML!
  1415. setInnerHTML(document.getElementById("ruletext"), text);
  1416. }
  1417. // ]]></script>';
  1418. echo '
  1419. <form action="', $scripturl, '?action=pm;sa=manrules;save;rid=', $context['rid'], '" method="post" accept-charset="', $context['character_set'], '" name="addrule" id="addrule">
  1420. <div class="cat_bar">
  1421. <h3 class="catbg">', $context['rid'] == 0 ? $txt['pm_add_rule'] : $txt['pm_edit_rule'], '</h3>
  1422. </div>
  1423. <div class="windowbg">
  1424. <span class="topslice"><span></span></span>
  1425. <div class="content">
  1426. <dl class="settings">
  1427. <dt>
  1428. <strong>', $txt['pm_rule_name'], ':</strong><br />
  1429. <span class="smalltext">', $txt['pm_rule_name_desc'], '</span>
  1430. </dt>
  1431. <dd>
  1432. <input type="text" name="rule_name" value="', empty($context['rule']['name']) ? $txt['pm_rule_name_default'] : $context['rule']['name'], '" class="input_text" style="width: 100%" />
  1433. </dd>
  1434. </dl>
  1435. <fieldset>
  1436. <legend>', $txt['pm_rule_criteria'], '</legend>';
  1437. // Add a dummy criteria to allow expansion for none js users.
  1438. $context['rule']['criteria'][] = array('t' => '', 'v' => '');
  1439. // For each criteria print it out.
  1440. $isFirst = true;
  1441. foreach ($context['rule']['criteria'] as $k => $criteria)
  1442. {
  1443. if (!$isFirst && $criteria['t'] == '')
  1444. echo '<div id="removeonjs1">';
  1445. else
  1446. echo '<br />';
  1447. echo '
  1448. <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
  1449. <option value="">', $txt['pm_rule_criteria_pick'], ':</option>
  1450. <option value="mid" ', $criteria['t'] == 'mid' ? 'selected="selected"' : '', '>', $txt['pm_rule_mid'], '</option>
  1451. <option value="gid" ', $criteria['t'] == 'gid' ? 'selected="selected"' : '', '>', $txt['pm_rule_gid'], '</option>
  1452. <option value="sub" ', $criteria['t'] == 'sub' ? 'selected="selected"' : '', '>', $txt['pm_rule_sub'], '</option>
  1453. <option value="msg" ', $criteria['t'] == 'msg' ? 'selected="selected"' : '', '>', $txt['pm_rule_msg'], '</option>
  1454. <option value="bud" ', $criteria['t'] == 'bud' ? 'selected="selected"' : '', '>', $txt['pm_rule_bud'], '</option>
  1455. </select>
  1456. <span id="defdiv', $k, '" ', !in_array($criteria['t'], array('gid', 'bud')) ? '' : 'style="display: none;"', '>
  1457. <input type="text" name="ruledef[', $k, ']" id="ruledef', $k, '" onkeyup="rebuildRuleDesc();" value="', in_array($criteria['t'], array('mid', 'sub', 'msg')) ? $criteria['v'] : '', '" class="input_text" />
  1458. </span>
  1459. <span id="defseldiv', $k, '" ', $criteria['t'] == 'gid' ? '' : 'style="display: none;"', '>
  1460. <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
  1461. <option value="">', $txt['pm_rule_sel_group'], '</option>';
  1462. foreach ($context['groups'] as $id => $group)
  1463. echo '
  1464. <option value="', $id, '" ', $criteria['t'] == 'gid' && $criteria['v'] == $id ? 'selected="selected"' : '', '>', $group, '</option>';
  1465. echo '
  1466. </select>
  1467. </span>';
  1468. // If this is the dummy we add a means to hide for non js users.
  1469. if ($isFirst)
  1470. $isFirst = false;
  1471. elseif ($criteria['t'] == '')
  1472. echo '</div>';
  1473. }
  1474. echo '
  1475. <span id="criteriaAddHere"></span><br />
  1476. <a href="#" onclick="addCriteriaOption(); return false;" id="addonjs1" style="display: none;">(', $txt['pm_rule_criteria_add'], ')</a>
  1477. <br /><br />
  1478. ', $txt['pm_rule_logic'], ':
  1479. <select name="rule_logic" id="logic" onchange="rebuildRuleDesc();">
  1480. <option value="and" ', $context['rule']['logic'] == 'and' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_and'], '</option>
  1481. <option value="or" ', $context['rule']['logic'] == 'or' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_or'], '</option>
  1482. </select>
  1483. </fieldset>
  1484. <fieldset>
  1485. <legend>', $txt['pm_rule_actions'], '</legend>';
  1486. // As with criteria - add a dummy action for "expansion".
  1487. $context['rule']['actions'][] = array('t' => '', 'v' => '');
  1488. // Print each action.
  1489. $isFirst = true;
  1490. foreach ($context['rule']['actions'] as $k => $action)
  1491. {
  1492. if (!$isFirst && $action['t'] == '')
  1493. echo '<div id="removeonjs2">';
  1494. else
  1495. echo '<br />';
  1496. echo '
  1497. <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
  1498. <option value="">', $txt['pm_rule_sel_action'] , ':</option>
  1499. <option value="lab" ', $action['t'] == 'lab' ? 'selected="selected"' : '', '>', $txt['pm_rule_label'] , '</option>
  1500. <option value="del" ', $action['t'] == 'del' ? 'selected="selected"' : '', '>', $txt['pm_rule_delete'] , '</option>
  1501. </select>
  1502. <span id="labdiv', $k, '">
  1503. <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
  1504. <option value="">', $txt['pm_rule_sel_label'], '</option>';
  1505. foreach ($context['labels'] as $label)
  1506. if ($label['id'] != -1)
  1507. echo '
  1508. <option value="', ($label['id'] + 1), '" ', $action['t'] == 'lab' && $action['v'] == $label['id'] ? 'selected="selected"' : '', '>', $label['name'], '</option>';
  1509. echo '
  1510. </select>
  1511. </span>';
  1512. if ($isFirst)
  1513. $isFirst = false;
  1514. elseif ($action['t'] == '')
  1515. echo '
  1516. </div>';
  1517. }
  1518. echo '
  1519. <span id="actionAddHere"></span><br />
  1520. <a href="#" onclick="addActionOption(); return false;" id="addonjs2" style="display: none;">(', $txt['pm_rule_add_action'], ')</a>
  1521. </fieldset>
  1522. </div>
  1523. <span class="botslice"><span></span></span>
  1524. </div>
  1525. <div class="cat_bar">
  1526. <h3 class="catbg">', $txt['pm_rule_description'], '</h3>
  1527. </div>
  1528. <div class="information">
  1529. <div id="ruletext" class="smalltext">', $txt['pm_rule_js_disabled'], '</div>
  1530. </div>
  1531. <div class="righttext">
  1532. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1533. <input type="submit" name="save" value="', $txt['pm_rule_save'], '" class="button_submit" />
  1534. </div>
  1535. </form>';
  1536. // Now setup all the bits!
  1537. echo '
  1538. <script type="text/javascript"><!-- // --><![CDATA[';
  1539. foreach ($context['rule']['criteria'] as $k => $c)
  1540. echo '
  1541. updateRuleDef(', $k, ');';
  1542. foreach ($context['rule']['actions'] as $k => $c)
  1543. echo '
  1544. updateActionDef(', $k, ');';
  1545. echo '
  1546. rebuildRuleDesc();';
  1547. // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
  1548. if ($context['rid'])
  1549. echo '
  1550. document.getElementById("removeonjs1").style.display = "none";
  1551. document.getElementById("removeonjs2").style.display = "none";';
  1552. echo '
  1553. document.getElementById("addonjs1").style.display = "";
  1554. document.getElementById("addonjs2").style.display = "";';
  1555. echo '
  1556. // ]]></script>';
  1557. }
  1558. ?>