2
0

PersonalMessage.template.php 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2013 Simple Machines and individual contributors
  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. echo '
  21. <div class="title_bar">
  22. <h3 class="titlebg">
  23. <span class="floatleft">', $txt['pm_capacity'], ':</span>
  24. <span class="floatleft capacity_bar">
  25. <span class="', $context['limit_bar']['percent'] > 85 ? 'full' : ($context['limit_bar']['percent'] > 40 ? 'filled' : 'empty'), '" style="width: ', $context['limit_bar']['percent'] / 10, 'em;"></span>
  26. </span>
  27. <span class="floatright', $context['limit_bar']['percent'] > 90 ? ' alert' : '', '">', $context['limit_bar']['text'], '</span>
  28. </h3>
  29. </div>';
  30. // Message sent? Show a small indication.
  31. if (isset($context['pm_sent']))
  32. echo '
  33. <div class="infobox">
  34. ', $txt['pm_sent'], '
  35. </div>';
  36. }
  37. // Just the end of the index bar, nothing special.
  38. function template_pm_below()
  39. {
  40. global $context, $settings, $options;
  41. echo '
  42. </div>';
  43. }
  44. function template_folder()
  45. {
  46. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  47. // The every helpful javascript!
  48. echo '
  49. <script type="text/javascript"><!-- // --><![CDATA[
  50. var allLabels = {};
  51. var currentLabels = {};
  52. function loadLabelChoices()
  53. {
  54. var listing = document.forms.pmFolder.elements;
  55. var theSelect = document.forms.pmFolder.pm_action;
  56. var add, remove, toAdd = {length: 0}, toRemove = {length: 0};
  57. if (theSelect.childNodes.length == 0)
  58. return;
  59. // This is done this way for internationalization reasons.
  60. if (!(\'-1\' in allLabels))
  61. {
  62. for (var o = 0; o < theSelect.options.length; o++)
  63. if (theSelect.options[o].value.substr(0, 4) == "rem_")
  64. allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text;
  65. }
  66. for (var i = 0; i < listing.length; i++)
  67. {
  68. if (listing[i].name != "pms[]" || !listing[i].checked)
  69. continue;
  70. var alreadyThere = [], x;
  71. for (x in currentLabels[listing[i].value])
  72. {
  73. if (!(x in toRemove))
  74. {
  75. toRemove[x] = allLabels[x];
  76. toRemove.length++;
  77. }
  78. alreadyThere[x] = allLabels[x];
  79. }
  80. for (x in allLabels)
  81. {
  82. if (!(x in alreadyThere))
  83. {
  84. toAdd[x] = allLabels[x];
  85. toAdd.length++;
  86. }
  87. }
  88. }
  89. while (theSelect.options.length > 2)
  90. theSelect.options[2] = null;
  91. if (toAdd.length != 0)
  92. {
  93. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", "");
  94. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '");
  95. theSelect.options[theSelect.options.length - 1].disabled = true;
  96. for (i in toAdd)
  97. {
  98. if (i != "length")
  99. theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i);
  100. }
  101. }
  102. if (toRemove.length != 0)
  103. {
  104. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", "");
  105. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '");
  106. theSelect.options[theSelect.options.length - 1].disabled = true;
  107. for (i in toRemove)
  108. {
  109. if (i != "length")
  110. theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i);
  111. }
  112. }
  113. }
  114. // ]]></script>';
  115. echo '
  116. <form class="flow_hidden" 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">';
  117. // If we are not in single display mode show the subjects on the top!
  118. if ($context['display_mode'] != 1)
  119. {
  120. template_subject_list();
  121. echo '<div class="clear_right"><br /></div>';
  122. }
  123. // Got some messages to display?
  124. if ($context['get_pmessage']('message', true))
  125. {
  126. // Show the helpful titlebar - generally.
  127. if ($context['display_mode'] != 1)
  128. echo '
  129. <div class="cat_bar">
  130. <h3 class="catbg">
  131. <span id="author">', $txt['author'], '</span>
  132. <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
  133. </h3>
  134. </div>';
  135. // Show a few buttons if we are in conversation mode and outputting the first message.
  136. if ($context['display_mode'] == 2)
  137. {
  138. // Show the conversation buttons.
  139. echo '
  140. <div class="pagesection">';
  141. template_button_strip($context['conversation_buttons'], 'right');
  142. echo '
  143. </div>';
  144. }
  145. while ($message = $context['get_pmessage']('message'))
  146. {
  147. $window_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2';
  148. echo '
  149. <div class="', $window_class, '">
  150. <div class="poster">
  151. <ul class="dropmenu">
  152. <li>
  153. <h4>
  154. <a id="msg', $message['id'], '"></a>';
  155. // Show a link to the member's profile (but only if the sender isn't a guest).
  156. if (!$message['member']['is_guest'])
  157. echo '
  158. <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">';
  159. echo '
  160. <span style="padding: 6px; display: block;">', $message['member']['name'], '</span>';
  161. // Show avatars, images, etc.?
  162. if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
  163. echo '
  164. ', $message['member']['avatar']['image'], '';
  165. if (!$message['member']['is_guest'])
  166. echo '
  167. </a>';
  168. echo '
  169. </h4>
  170. <ul class="smalltext" id="msg_', $message['id'], '_extra_info">';
  171. // Show the member's custom title, if they have one.
  172. if (isset($message['member']['title']) && $message['member']['title'] != '')
  173. echo '
  174. <li class="title">', $message['member']['title'], '</li>';
  175. // Don't show these things for guests.
  176. if (!$message['member']['is_guest'])
  177. {
  178. // 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.
  179. if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
  180. echo '
  181. <li class="postgroup">', $message['member']['post_group'], '</li>';
  182. // Show how many posts they have made.
  183. if (!isset($context['disabled_fields']['posts']))
  184. echo '
  185. <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
  186. // Is karma display enabled? Total or +/-?
  187. if ($modSettings['karmaMode'] == '1')
  188. echo '
  189. <li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
  190. elseif ($modSettings['karmaMode'] == '2')
  191. echo '
  192. <li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
  193. // Is this user allowed to modify this member's karma?
  194. if ($message['member']['karma']['allow'])
  195. echo '
  196. <li class="karma_allow">
  197. <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> <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>
  198. </li>';
  199. // Show the member's gender icon?
  200. if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
  201. echo '
  202. <li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
  203. // Show their personal text?
  204. if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
  205. echo '
  206. <li class="blurb">', $message['member']['blurb'], '</li>';
  207. // Any custom fields to show as icons?
  208. if (!empty($message['member']['custom_fields']))
  209. {
  210. $shown = false;
  211. foreach ($message['member']['custom_fields'] as $custom)
  212. {
  213. if ($custom['placement'] != 1 || empty($custom['value']))
  214. continue;
  215. if (empty($shown))
  216. {
  217. $shown = true;
  218. echo '
  219. <li class="im_icons">
  220. <ul>';
  221. }
  222. echo '
  223. <li>', $custom['value'], '</li>';
  224. }
  225. if ($shown)
  226. echo '
  227. </ul>
  228. </li>';
  229. }
  230. // This shows the popular messaging icons.
  231. if ($message['member']['has_messenger'] && $message['member']['can_view_profile'])
  232. echo '
  233. <li class="im_icons">
  234. <ul>
  235. ', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '<li>' . $message['member']['icq']['link'] . '</li>' : '', '
  236. ', !isset($context['disabled_fields']['skype']) && !empty($message['member']['skype']['link']) ? '<li>' . $message['member']['skype']['link'] . '</li>' : '', '
  237. ', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '<li>' . $message['member']['aim']['link'] . '</li>' : '', '
  238. ', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '<li>' . $message['member']['yim']['link'] . '</li>' : '', '
  239. </ul>
  240. </li>';
  241. // Stuff for the staff to wallop them with.
  242. echo '
  243. <li><hr /></li>';
  244. if ($message['can_report'])
  245. echo '
  246. <li class="report_link"><a href="' . $scripturl . '?action=pm;sa=report;l=' . $context['current_label_id'] . ';pmsg=' . $message['id'] . '">' . $txt['pm_report_to_admin'] . '</a></li>';
  247. // Can we issue a warning because of this post? Remember, we can't give guests warnings.
  248. if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
  249. echo '
  250. <li class="issue_warning"><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '"><img src="', $settings['images_url'], '/warn.png" alt="', $txt['issue_warning_post'], '" title="', $txt['issue_warning_post'], '" /></a></li>';
  251. // Show the IP to this user for this post - because you can moderate?
  252. if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
  253. echo '
  254. <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
  255. // Or, should we show it because this is you?
  256. elseif ($message['can_see_ip'])
  257. echo '
  258. <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
  259. // Okay, you are logged in, then we can show something about why IPs are logged...
  260. else
  261. echo '
  262. <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
  263. // Show the profile, website, email address, and personal message buttons.
  264. if ($message['member']['show_profile_buttons'])
  265. {
  266. echo '
  267. <li class="profile">
  268. <ul>';
  269. // Show the profile button
  270. if ($message['member']['can_view_profile'])
  271. echo '
  272. <li><a href="', $message['member']['href'], '">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/icons/profile_sm.png" alt="' . $txt['view_profile'] . '" title="' . $txt['view_profile'] . '" />' : $txt['view_profile']), '</a></li>';
  273. // Don't show an icon if they haven't specified a website.
  274. if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
  275. echo '
  276. <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.png" alt="' . $message['member']['website']['title'] . '" />' : $txt['www']), '</a></li>';
  277. // Don't show the email address if they want it hidden.
  278. if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email'])
  279. echo '
  280. <li><a href="', $scripturl, '?action=emailuser;sa=email;uid=', $message['member']['id'], '" rel="nofollow">', ($settings['use_image_buttons'] ? '<img src="' . $settings['images_url'] . '/email_sm.png" alt="' . $txt['email'] . '" title="' . $txt['email'] . '" />' : $txt['email']), '</a></li>';
  281. // Since we know this person isn't a guest, you *can* message them.
  282. if ($context['can_send_pm'])
  283. echo '
  284. <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') . '.png" alt="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '" />' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
  285. echo '
  286. </ul>
  287. </li>';
  288. }
  289. // Any custom fields for standard placement?
  290. if (!empty($message['member']['custom_fields']))
  291. {
  292. foreach ($message['member']['custom_fields'] as $custom)
  293. if (empty($custom['placement']) || empty($custom['value']))
  294. echo '
  295. <li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
  296. }
  297. // Are we showing the warning status?
  298. if ($message['member']['can_see_warning'])
  299. echo '
  300. <li class="warning">', $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'], '.png" 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>';
  301. }
  302. echo '
  303. </ul>
  304. </li>';
  305. if (!$message['member']['is_guest'])
  306. echo '
  307. <li class="icons">', $message['member']['group_icons'], '</li>';
  308. // Show the member's primary group (like 'Administrator') if they have one.
  309. if (isset($message['member']['group']) && $message['member']['group'] != '')
  310. echo '
  311. <li class="membergroup">', $message['member']['group'], '</li>';
  312. // Show online and offline buttons? PHP could do with a little bit of cleaning up here for brevity, but it works.
  313. // The plan is to make these buttons act sensibly, and link to your own inbox in your own posts (with new PM notification).
  314. // Still has a little bit of hard-coded text. This may be a place where translators should be able to write inclusive strings,
  315. // instead of dealing with $txt['by'] etc in the markup. Must be brief to work, anyway. Cannot ramble on at all.
  316. if ($context['can_send_pm'] && $message['is_message_author'])
  317. {
  318. echo '
  319. <li class="poster_online"><a href="', $scripturl,'?action=pm">', $txt['pm_short'], ' ', $context['user']['unread_messages'] > 0 ? '[<strong>'. $context['user']['unread_messages'] . '</strong>]' : '' , '</a></li>';
  320. }
  321. elseif ($context['can_send_pm'] && !$message['is_message_author'] && !$message['member']['is_guest'])
  322. {
  323. if (!empty($modSettings['onlineEnable']))
  324. echo '
  325. <li class="poster_online"><a href="', $scripturl,'?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['member_online_text'], '">', $txt['send_message'], ' <img src="'. $message['member']['online']['image_href']. '" alt="" /></a></li>';
  326. else
  327. echo '
  328. <li class="poster_online"><a href="', $scripturl,'?action=pm;sa=send;u=', $message['member']['id'], '">', $txt['send_message'], '</a></li>';
  329. }
  330. elseif (!$context['can_send_pm'] && !empty($modSettings['onlineEnable']))
  331. echo '
  332. <li class="poster_online">', ($message['member']['online']['is_online']) ? $txt['online'] : $txt['offline'], '<img src="'. $message['member']['online']['image_href']. '" alt="" /></li>';
  333. // Done with the information about the poster... on to the post itself.
  334. echo '
  335. </ul>
  336. </div>
  337. <div class="postarea">
  338. <div class="flow_hidden">
  339. <div class="keyinfo">
  340. <h5 id="subject_', $message['id'], '">
  341. ', $message['subject'], '
  342. </h5>';
  343. // Show who the message was sent to.
  344. echo '
  345. <span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
  346. // People it was sent directly to....
  347. if (!empty($message['recipients']['to']))
  348. echo implode(', ', $message['recipients']['to']);
  349. // Otherwise, we're just going to say "some people"...
  350. elseif ($context['folder'] != 'sent')
  351. echo '(', $txt['pm_undisclosed_recipients'], ')';
  352. echo '
  353. <strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
  354. </span>';
  355. // If we're in the sent items, show who it was sent to besides the "To:" people.
  356. if (!empty($message['recipients']['bcc']))
  357. echo '
  358. <br /><span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
  359. if (!empty($message['is_replied_to']))
  360. echo '
  361. <br /><span class="smalltext">&#171; ', $txt['pm_is_replied_to'], ' &#187;</span>';
  362. echo '
  363. </div>
  364. <ul class="reset smalltext quickbuttons">';
  365. // Show reply buttons if you have the permission to send PMs.
  366. if ($context['can_send_pm'])
  367. {
  368. // You can't really reply if the member is gone.
  369. if (!$message['member']['is_guest'])
  370. {
  371. // Is there than more than one recipient you can reply to?
  372. if ($message['number_recipients'] > 1)
  373. echo '
  374. <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" class="reply_all_button">', $txt['reply_to_all'], '</a></li>';
  375. echo '
  376. <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'], '" class="reply_button">', $txt['reply'], '</a></li>
  377. <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'], '" class="quote_button">', $txt['quote'], '</a></li>';
  378. }
  379. // This is for "forwarding" - even if the member is gone.
  380. else
  381. echo '
  382. <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" class="quote_button">', $txt['reply_quote'], '</a></li>';
  383. }
  384. echo '
  385. <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']), '?\');" class="remove_button">', $txt['delete'], '</a></li>';
  386. if (empty($context['display_mode']))
  387. echo '
  388. <li class="inline_mod_check"><input type="checkbox" name="pms[]" id="deletedisplay', $message['id'], '" value="', $message['id'], '" onclick="document.getElementById(\'deletelisting', $message['id'], '\').checked = this.checked;" class="input_check" /></li>';
  389. echo '
  390. </ul>
  391. </div>
  392. <div class="post">
  393. <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>';
  394. // Are there any custom profile fields for above the signature?
  395. if (!empty($message['member']['custom_fields']))
  396. {
  397. $shown = false;
  398. foreach ($message['member']['custom_fields'] as $custom)
  399. {
  400. if ($custom['placement'] != 2 || empty($custom['value']))
  401. continue;
  402. if (!$shown)
  403. {
  404. $shown = true;
  405. echo '
  406. <div class="custom_fields_above_signature">
  407. <ul class="reset nolist">';
  408. }
  409. echo '
  410. <li>', $custom['value'], '</li>';
  411. }
  412. if ($shown)
  413. echo '
  414. </ul>
  415. </div>';
  416. }
  417. // Show the member's signature?
  418. if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
  419. echo '
  420. <div class="signature">', $message['member']['signature'], '</div>';
  421. // Add an extra line at the bottom if we have labels enabled.
  422. if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2)
  423. {
  424. echo '
  425. <div class="labels righttext flow_auto">';
  426. // Add the label drop down box.
  427. if (!empty($context['currently_using_labels']))
  428. {
  429. echo '
  430. <select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();">
  431. <option value="">', $txt['pm_msg_label_title'], ':</option>
  432. <option value="" disabled="disabled">---------------</option>';
  433. // Are there any labels which can be added to this?
  434. if (!$message['fully_labeled'])
  435. {
  436. echo '
  437. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  438. foreach ($context['labels'] as $label)
  439. if (!isset($message['labels'][$label['id']]))
  440. echo '
  441. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  442. }
  443. // ... and are there any that can be removed?
  444. if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
  445. {
  446. echo '
  447. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  448. foreach ($message['labels'] as $label)
  449. echo '
  450. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  451. }
  452. echo '
  453. </select>
  454. <noscript>
  455. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" style="float: none" />
  456. </noscript>';
  457. }
  458. echo '
  459. </div>';
  460. }
  461. echo '
  462. </div>
  463. </div>
  464. <div class="moderatorbar">
  465. </div>
  466. </div>';
  467. }
  468. if (empty($context['display_mode']))
  469. echo '
  470. <div class="pagesection">
  471. <div class="floatleft">', $context['page_index'], '</div>
  472. <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>
  473. </div>';
  474. // Show a few buttons if we are in conversation mode and outputting the first message.
  475. elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
  476. {
  477. echo '
  478. <div class="pagesection">';
  479. template_button_strip($context['conversation_buttons'], 'right');
  480. echo '
  481. </div>';
  482. }
  483. echo '
  484. <br />';
  485. }
  486. // Individual messages = buttom list!
  487. if ($context['display_mode'] == 1)
  488. {
  489. template_subject_list();
  490. echo '<br />';
  491. }
  492. echo '
  493. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  494. </form>';
  495. }
  496. // Just list all the personal message subjects - to make templates easier.
  497. function template_subject_list()
  498. {
  499. global $context, $options, $settings, $modSettings, $txt, $scripturl;
  500. echo '
  501. <table width="100%" class="table_grid">
  502. <thead>
  503. <tr class="catbg">
  504. <th align="center" width="4%" class="centercol first_th">
  505. <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.png" alt="', $txt['pm_change_view'], '" title="', $txt['pm_change_view'], '" width="16" height="16" /></a>
  506. </th>
  507. <th class="lefttext" width="22%">
  508. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  509. </th>
  510. <th class="lefttext" width="46%">
  511. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  512. </th>
  513. <th class="lefttext">
  514. <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 class="sort" src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.png" alt="" />' : '', '</a>
  515. </th>
  516. <th width="4%" class="centercol last_th">
  517. <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />
  518. </th>
  519. </tr>
  520. </thead>
  521. <tbody>';
  522. if (!$context['show_delete'])
  523. echo '
  524. <tr class="windowbg2">
  525. <td colspan="5">', $txt['pm_alert_none'], '</td>
  526. </tr>';
  527. $next_alternate = false;
  528. while ($message = $context['get_pmessage']('subject'))
  529. {
  530. echo '
  531. <tr class="', $next_alternate ? 'windowbg' : 'windowbg2', '">
  532. <td align="center" width="4%">
  533. <script type="text/javascript"><!-- // --><![CDATA[
  534. currentLabels[', $message['id'], '] = {';
  535. if (!empty($message['labels']))
  536. {
  537. $first = true;
  538. foreach ($message['labels'] as $label)
  539. {
  540. echo $first ? '' : ',', '
  541. "', $label['id'], '": "', $label['name'], '"';
  542. $first = false;
  543. }
  544. }
  545. echo '
  546. };
  547. // ]]></script>
  548. ', $message['is_replied_to'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.png" style="margin-right: 4px;" alt="' . $txt['pm_replied'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.png" style="margin-right: 4px;" alt="' . $txt['pm_read'] . '" />', '</td>
  549. <td>', $message['time'], '</td>
  550. <td>', ($context['display_mode'] != 0 && $context['current_pm'] == $message['id'] ? '<img src="' . $settings['images_url'] . '/selected.png" 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'], $message['is_unread'] ? '&nbsp;<span class="new_posts">' . $txt['new'] . '</span>' : '', '</a></td>
  551. <td>', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '</td>
  552. <td class="centercol" 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>
  553. </tr>';
  554. $next_alternate = !$next_alternate;
  555. }
  556. echo '
  557. </tbody>
  558. </table>
  559. <div class="pagesection">
  560. <div class="floatleft">', $context['page_index'], '</div>
  561. <div class="floatright">&nbsp;';
  562. if ($context['show_delete'])
  563. {
  564. if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent')
  565. {
  566. echo '
  567. <select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();">
  568. <option value="">', $txt['pm_sel_label_title'], ':</option>
  569. <option value="" disabled="disabled">---------------</option>';
  570. echo '
  571. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  572. foreach ($context['labels'] as $label)
  573. {
  574. if ($label['id'] != $context['current_label_id'])
  575. echo '
  576. <option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  577. }
  578. echo '
  579. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  580. foreach ($context['labels'] as $label)
  581. {
  582. echo '
  583. <option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  584. }
  585. echo '
  586. </select>
  587. <noscript>
  588. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" style="float: none" />
  589. </noscript>';
  590. }
  591. echo '
  592. <input type="submit" name="del_selected" value="', $txt['quickmod_delete_selected'], '" onclick="if (!confirm(\'', $txt['delete_selected_confirm'], '\')) return false;" class="button_submit" style="float: none" />';
  593. }
  594. echo '
  595. </div>
  596. </div>';
  597. }
  598. function template_search()
  599. {
  600. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  601. echo '
  602. <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
  603. <div class="cat_bar">
  604. <h3 class="catbg">', $txt['pm_search_title'], '</h3>
  605. </div>';
  606. if (!empty($context['search_errors']))
  607. {
  608. echo '
  609. <div class="errorbox">
  610. ', implode('<br />', $context['search_errors']['messages']), '
  611. </div>';
  612. }
  613. if ($context['simple_search'])
  614. {
  615. echo '
  616. <fieldset id="simple_search">
  617. <div class="roundframe">
  618. <div id="search_term_input">
  619. <strong>', $txt['pm_search_text'], ':</strong>
  620. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  621. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />
  622. </div>
  623. <a href="', $scripturl, '?action=pm;sa=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['pm_search_advanced'], '</a>
  624. <input type="hidden" name="advanced" value="0" />
  625. </div>
  626. </fieldset>';
  627. }
  628. // Advanced search!
  629. else
  630. {
  631. echo '
  632. <fieldset id="advanced_search">
  633. <div class="roundframe">
  634. <input type="hidden" name="advanced" value="1" />
  635. <span class="enhanced">
  636. <strong>', $txt['pm_search_text'], ':</strong>
  637. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  638. <script type="text/javascript"><!-- // --><![CDATA[
  639. createEventListener(window);
  640. window.addEventListener("load", initSearch, false);
  641. // ]]></script>
  642. <select name="searchtype">
  643. <option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_all'], '</option>
  644. <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_any'], '</option>
  645. </select>
  646. </span>
  647. <dl id="search_options">
  648. <dt>', $txt['pm_search_user'], ':</dt>
  649. <dd><input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
  650. <dt>', $txt['pm_search_order'], ':</dt>
  651. <dd>
  652. <select name="sort">
  653. <option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option>
  654. <option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option>
  655. <option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option>
  656. </select>
  657. </dd>
  658. <dt class="options">', $txt['pm_search_options'], ':</dt>
  659. <dd class="options">
  660. <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 />
  661. <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>
  662. </dd>
  663. <dt class="between">', $txt['pm_search_post_age'], ':</dt>
  664. <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>
  665. </dl>';
  666. if (!$context['currently_using_labels'])
  667. echo '
  668. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />';
  669. echo '
  670. <br class="clear_right" />
  671. </div>
  672. </fieldset>';
  673. // Do we have some labels setup? If so offer to search by them!
  674. if ($context['currently_using_labels'])
  675. {
  676. echo '
  677. <fieldset class="labels">
  678. <div class="roundframe">
  679. <div class="title_bar">
  680. <h4 class="titlebg">
  681. <img id="advanced_panel_toggle" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/', empty($context['show_advanced_options']) ? 'collapse' : 'expand', '.png" alt="*" /><a href="#" id="advanced_panel_link">', $txt['pm_search_choose_label'], '</a>
  682. </h4>
  683. </div>
  684. <div id="advanced_panel_div">
  685. <ul id="searchLabelsExpand" class="reset" >';
  686. foreach ($context['search_labels'] as $label)
  687. echo '
  688. <li>
  689. <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" />
  690. ', $label['name'], '</label>
  691. </li>';
  692. echo '
  693. </ul>
  694. </div>
  695. <p>
  696. <span class="floatleft"><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></span>
  697. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />
  698. </p>
  699. <br class="clear_right" />
  700. </div>
  701. </fieldset>';
  702. // Some javascript for the advanced toggling
  703. echo '
  704. <script type="text/javascript"><!-- // --><![CDATA[
  705. var oAdvancedPanelToggle = new smc_Toggle({
  706. bToggleEnabled: true,
  707. bCurrentlyCollapsed: ', empty($context['show_advanced_options']) ? 'true' : 'false', ',
  708. aSwappableContainers: [
  709. \'advanced_panel_div\'
  710. ],
  711. aSwapImages: [
  712. {
  713. sId: \'advanced_panel_toggle\',
  714. srcExpanded: smf_images_url + \'/collapse.png\',
  715. altExpanded: ', JavaScriptEscape($txt['upshrink_description']), ',
  716. srcCollapsed: smf_images_url + \'/expand.png\',
  717. altCollapsed: ', JavaScriptEscape($txt['upshrink_description']), '
  718. }
  719. ],
  720. aSwapLinks: [
  721. {
  722. sId: \'advanced_panel_link\',
  723. msgExpanded: ', JavaScriptEscape($txt['pm_search_choose_label']), ',
  724. msgCollapsed: ', JavaScriptEscape($txt['pm_search_choose_label']), '
  725. }
  726. ],
  727. oThemeOptions: {
  728. bUseThemeSettings: ', $context['user']['is_guest'] ? 'false' : 'true', ',
  729. sOptionName: \'admin_preferences\',
  730. sSessionVar: smf_session_var,
  731. sSessionId: smf_session_id,
  732. sThemeId: \'1\'
  733. }
  734. });
  735. // ]]></script>';
  736. }
  737. }
  738. echo '
  739. </form>';
  740. }
  741. function template_search_results()
  742. {
  743. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  744. echo '
  745. <div class="cat_bar">
  746. <h3 class="catbg">', $txt['pm_search_results'], '</h3>
  747. </div>
  748. <div class="pagesection">
  749. ', $context['page_index'], '
  750. </div>';
  751. // complete results ?
  752. if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
  753. echo '
  754. <table width="100%" class="table_grid">
  755. <thead>
  756. <tr class="catbg">
  757. <th class="lefttext first_th" width="30%">', $txt['date'], '</th>
  758. <th class="lefttext" width="50%">', $txt['subject'], '</th>
  759. <th class="lefttext last_th" width="20%">', $txt['from'], '</th>
  760. </tr>
  761. </thead>
  762. <tbody>';
  763. $alternate = true;
  764. // Print each message out...
  765. foreach ($context['personal_messages'] as $message)
  766. {
  767. // We showing it all?
  768. if (!empty($context['search_params']['show_complete']))
  769. {
  770. echo '
  771. <div class="title_bar">
  772. <h3 class="titlebg">
  773. <span class="floatright">', $txt['search_on'], ': ', $message['time'], '</span>
  774. <span class="floatleft">', $message['counter'], '&nbsp;&nbsp;<a href="', $message['href'], '">', $message['subject'], '</a></span>
  775. </h3>
  776. </div>
  777. <div class="cat_bar">
  778. <h3 class="catbg">', $txt['from'], ': ', $message['member']['link'], ', ', $txt['to'], ': ';
  779. // Show the recipients.
  780. // @todo This doesn't deal with the sent item searching quite right for bcc.
  781. if (!empty($message['recipients']['to']))
  782. echo implode(', ', $message['recipients']['to']);
  783. // Otherwise, we're just going to say "some people"...
  784. elseif ($context['folder'] != 'sent')
  785. echo '(', $txt['pm_undisclosed_recipients'], ')';
  786. echo '
  787. </h3>
  788. </div>
  789. <div class="windowbg', $alternate ? '2': '', '">
  790. <div class="content">
  791. ', $message['body'], '
  792. <p class="pm_reply righttext">';
  793. if ($context['can_send_pm'])
  794. {
  795. $quote_button = create_button('quote.png', 'reply_quote', 'reply_quote', 'class="centericon"');
  796. $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"');
  797. // You can only reply if they are not a guest...
  798. if (!$message['member']['is_guest'])
  799. echo '
  800. <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'], '
  801. <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'];
  802. // This is for "forwarding" - even if the member is gone.
  803. else
  804. echo '
  805. <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'];
  806. }
  807. echo '
  808. </p>
  809. </div>
  810. </div>';
  811. }
  812. // Otherwise just a simple list!
  813. else
  814. {
  815. // @todo No context at all of the search?
  816. echo '
  817. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" valign="top">
  818. <td>', $message['time'], '</td>
  819. <td>', $message['link'], '</td>
  820. <td>', $message['member']['link'], '</td>
  821. </tr>';
  822. }
  823. $alternate = !$alternate;
  824. }
  825. // Finish off the page...
  826. if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
  827. echo '
  828. </tbody>
  829. </table>';
  830. // No results?
  831. if (empty($context['personal_messages']))
  832. echo '
  833. <div class="windowbg">
  834. <div class="content">
  835. <p class="centertext">', $txt['pm_search_none_found'], '</p>
  836. </div>
  837. </div>';
  838. echo '
  839. <div class="pagesection">
  840. ', $context['page_index'], '
  841. </div>';
  842. }
  843. function template_send()
  844. {
  845. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  846. // Show which messages were sent successfully and which failed.
  847. if (!empty($context['send_log']))
  848. {
  849. echo '
  850. <div class="cat_bar">
  851. <h3 class="catbg">', $txt['pm_send_report'], '</h3>
  852. </div>
  853. <div class="windowbg">
  854. <div class="content">';
  855. if (!empty($context['send_log']['sent']))
  856. foreach ($context['send_log']['sent'] as $log_entry)
  857. echo '<span class="error">', $log_entry, '</span><br />';
  858. if (!empty($context['send_log']['failed']))
  859. foreach ($context['send_log']['failed'] as $log_entry)
  860. echo '<span class="error">', $log_entry, '</span><br />';
  861. echo '
  862. </div>
  863. </div>
  864. <br />';
  865. }
  866. // Show the preview of the personal message.
  867. echo '
  868. <div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
  869. <div class="cat_bar">
  870. <h3 class="catbg">
  871. <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
  872. </h3>
  873. </div>
  874. <div class="windowbg">
  875. <div class="content">
  876. <div class="post" id="preview_body">
  877. ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
  878. </div>
  879. </div>
  880. </div>
  881. </div>';
  882. // Main message editing box.
  883. echo '
  884. <div class="cat_bar">
  885. <h3 class="catbg">
  886. <img src="', $settings['images_url'], '/icons/im_newmsg.png" class="icon" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '
  887. </h3>
  888. </div>';
  889. echo '
  890. <form action="', $scripturl, '?action=pm;sa=send2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'message\']);">
  891. <div>
  892. <div class="roundframe">
  893. <br class="clear" />';
  894. // If there were errors for sending the PM, show them.
  895. echo '
  896. <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
  897. <dl>
  898. <dt>
  899. <strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
  900. </dt>
  901. <dd class="error" id="error_list">
  902. ', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
  903. </dd>
  904. </dl>
  905. </div>';
  906. if (!empty($modSettings['drafts_pm_enabled']))
  907. echo '
  908. <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
  909. sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
  910. ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
  911. </div>';
  912. echo '
  913. <dl id="post_header">';
  914. // To and bcc. Include a button to search for members.
  915. echo '
  916. <dt>
  917. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), ' id="caption_to">', $txt['pm_to'], ':</span>
  918. </dt>';
  919. // Autosuggest will be added by the JavaScript later on.
  920. echo '
  921. <dd id="pm_to" class="clear_right">
  922. <input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
  923. // A link to add BCC, only visible with JavaScript enabled.
  924. echo '
  925. <span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
  926. // A div that'll contain the items found by the autosuggest.
  927. echo '
  928. <div id="to_item_list_container"></div>';
  929. echo '
  930. </dd>';
  931. // This BCC row will be hidden by default if JavaScript is enabled.
  932. echo '
  933. <dt class="clear_left" id="bcc_div">
  934. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), ' id="caption_bbc">', $txt['pm_bcc'], ':</span>
  935. </dt>
  936. <dd id="bcc_div2">
  937. <input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
  938. <div id="bcc_item_list_container"></div>
  939. </dd>';
  940. // The subject of the PM.
  941. echo '
  942. <dt class="clear_left">
  943. <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
  944. </dt>
  945. <dd id="pm_subject">
  946. <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="80"',isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
  947. </dd>
  948. </dl><hr class="clear" />';
  949. // Showing BBC?
  950. if ($context['show_bbc'])
  951. {
  952. echo '
  953. <div id="bbcBox_message"></div>';
  954. }
  955. // What about smileys?
  956. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  957. echo '
  958. <div id="smileyBox_message"></div>';
  959. // Show BBC buttons, smileys and textbox.
  960. echo '
  961. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  962. // Require an image to be typed to save spamming?
  963. if ($context['require_verification'])
  964. {
  965. echo '
  966. <div class="post_verification">
  967. <strong>', $txt['pm_visual_verification_label'], ':</strong>
  968. ', template_control_verification($context['visual_verification_id'], 'all'), '
  969. </div>';
  970. }
  971. // Send, Preview, spellcheck buttons.
  972. echo '
  973. <p>
  974. <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>
  975. </p>
  976. <hr class="hrcolor" />
  977. <span id="post_confirm_strip" class="righttext">
  978. ', template_control_richedit_buttons($context['post_box_name']), '
  979. </span>
  980. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  981. <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
  982. <input type="hidden" name="replied_to" value="', !empty($context['quoted_message']['id']) ? $context['quoted_message']['id'] : 0, '" />
  983. <input type="hidden" name="pm_head" value="', !empty($context['quoted_message']['pm_head']) ? $context['quoted_message']['pm_head'] : 0, '" />
  984. <input type="hidden" name="f" value="', isset($context['folder']) ? $context['folder'] : '', '" />
  985. <input type="hidden" name="l" value="', isset($context['current_label_id']) ? $context['current_label_id'] : -1, '" />
  986. <br class="clear_right" />
  987. </div>
  988. </div>
  989. </form>';
  990. // If the admin enabled the pm drafts feature, show a draft selection box
  991. if (!empty($modSettings['drafts_enabled']) && !empty($context['drafts_pm_save']) && !empty($context['drafts']) && !empty($options['drafts_show_saved_enabled']))
  992. {
  993. echo '
  994. <br />
  995. <div id="postDraftOptionsHeader" class="title_bar">
  996. <h4 class="titlebg">
  997. <img id="postDraftExpand" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/collapse.png" alt="-" /> <strong><a href="#" id="postDraftExpandLink">', $txt['draft_load'], '</a></strong>
  998. </h4>
  999. </div>
  1000. <div id="postDraftOptions" class="load_drafts padding">
  1001. <dl class="settings">
  1002. <dt><strong>', $txt['subject'], '</strong></dt>
  1003. <dd><strong>', $txt['draft_saved_on'], '</strong></dd>';
  1004. foreach ($context['drafts'] as $draft)
  1005. echo '
  1006. <dt>', $draft['link'], '</dt>
  1007. <dd>', $draft['poster_time'], '</dd>';
  1008. echo '
  1009. </dl>
  1010. </div>';
  1011. }
  1012. echo '
  1013. <script type="text/javascript"><!-- // --><![CDATA[';
  1014. // The functions used to preview a personal message without loading a new page.
  1015. echo '
  1016. var txt_preview_title = "', $txt['preview_title'], '";
  1017. var txt_preview_fetch = "', $txt['preview_fetch'], '";
  1018. function previewPost()
  1019. {';
  1020. if (isBrowser('is_firefox'))
  1021. echo '
  1022. // Firefox doesn\'t render <marquee> that have been put it using javascript
  1023. if (document.forms.postmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
  1024. {
  1025. return submitThisOnce(document.forms.postmodify);
  1026. }';
  1027. echo '
  1028. if (window.XMLHttpRequest)
  1029. {
  1030. // Opera didn\'t support setRequestHeader() before 8.01.
  1031. // @todo Remove support for old browsers
  1032. if (\'opera\' in window)
  1033. {
  1034. var test = new XMLHttpRequest();
  1035. if (!(\'setRequestHeader\' in test))
  1036. return submitThisOnce(document.forms.postmodify);
  1037. }
  1038. // @todo Currently not sending poll options and option checkboxes.
  1039. var x = new Array();
  1040. var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', \'to\', \'bcc\'];
  1041. var numericFields = [\'recipient_to[]\', \'recipient_bcc[]\'];
  1042. var checkboxFields = [\'outbox\'];
  1043. for (var i = 0, n = textFields.length; i < n; i++)
  1044. if (textFields[i] in document.forms.postmodify)
  1045. {
  1046. // Handle the WYSIWYG editor.
  1047. if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
  1048. x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  1049. else
  1050. x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  1051. }
  1052. for (var i = 0, n = numericFields.length; i < n; i++)
  1053. if (numericFields[i] in document.forms.postmodify && \'value\' in document.forms.postmodify[numericFields[i]])
  1054. x[x.length] = numericFields[i] + \'=\' + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
  1055. for (var i = 0, n = checkboxFields.length; i < n; i++)
  1056. if (checkboxFields[i] in document.forms.postmodify && document.forms.postmodify.elements[checkboxFields[i]].checked)
  1057. x[x.length] = checkboxFields[i] + \'=\' + document.forms.postmodify.elements[checkboxFields[i]].value;
  1058. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=pm;sa=send2;preview;xml\', x.join(\'&\'), onDocSent);
  1059. document.getElementById(\'preview_section\').style.display = \'\';
  1060. setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
  1061. setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);
  1062. return false;
  1063. }
  1064. else
  1065. return submitThisOnce(document.forms.postmodify);
  1066. }
  1067. function onDocSent(XMLDoc)
  1068. {
  1069. if (!XMLDoc)
  1070. {
  1071. document.forms.postmodify.preview.onclick = new function ()
  1072. {
  1073. return true;
  1074. }
  1075. document.forms.postmodify.preview.click();
  1076. }
  1077. // Show the preview section.
  1078. var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
  1079. setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);
  1080. var bodyText = \'\';
  1081. for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
  1082. bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;
  1083. setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
  1084. document.getElementById(\'preview_body\').className = \'post\';
  1085. // Show a list of errors (if any).
  1086. var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
  1087. var errorList = new Array();
  1088. for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
  1089. errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
  1090. document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
  1091. setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));
  1092. // Adjust the color of captions if the given data is erroneous.
  1093. var captions = errors.getElementsByTagName(\'caption\');
  1094. for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
  1095. if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
  1096. document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');
  1097. if (errors.getElementsByTagName(\'post_error\').length == 1)
  1098. document.forms.postmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
  1099. else if (document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
  1100. {
  1101. if (\'runtimeStyle\' in document.forms.postmodify.', $context['post_box_name'], ')
  1102. document.forms.postmodify.', $context['post_box_name'], '.style.borderColor = \'\';
  1103. else
  1104. document.forms.postmodify.', $context['post_box_name'], '.style.border = null;
  1105. }
  1106. location.hash = \'#\' + \'preview_section\';
  1107. }';
  1108. // Code for showing and hiding drafts
  1109. if (!empty($context['drafts']))
  1110. echo '
  1111. var oSwapDraftOptions = new smc_Toggle({
  1112. bToggleEnabled: true,
  1113. bCurrentlyCollapsed: true,
  1114. aSwappableContainers: [
  1115. \'postDraftOptions\',
  1116. ],
  1117. aSwapImages: [
  1118. {
  1119. sId: \'postDraftExpand\',
  1120. srcExpanded: smf_images_url + \'/collapse.png\',
  1121. altExpanded: \'-\',
  1122. srcCollapsed: smf_images_url + \'/expand.png\',
  1123. altCollapsed: \'+\'
  1124. }
  1125. ],
  1126. aSwapLinks: [
  1127. {
  1128. sId: \'postDraftExpandLink\',
  1129. msgExpanded: ', JavaScriptEscape($txt['draft_hide']), ',
  1130. msgCollapsed: ', JavaScriptEscape($txt['draft_load']), '
  1131. }
  1132. ]
  1133. });';
  1134. echo '
  1135. // ]]></script>';
  1136. // Show the message you're replying to.
  1137. if ($context['reply'])
  1138. echo '
  1139. <br />
  1140. <br />
  1141. <div class="cat_bar">
  1142. <h3 class="catbg">', $txt['subject'], ': ', $context['quoted_message']['subject'], '</h3>
  1143. </div>
  1144. <div class="windowbg2">
  1145. <div class="content">
  1146. <div class="clear">
  1147. <span class="smalltext floatright">', $txt['on'], ': ', $context['quoted_message']['time'], '</span>
  1148. <strong>', $txt['from'], ': ', $context['quoted_message']['member']['name'], '</strong>
  1149. </div>
  1150. <hr />
  1151. ', $context['quoted_message']['body'], '
  1152. </div>
  1153. </div><br class="clear" />';
  1154. echo '
  1155. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/PersonalMessage.js?alp21"></script>
  1156. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  1157. <script type="text/javascript"><!-- // --><![CDATA[
  1158. var oPersonalMessageSend = new smf_PersonalMessageSend({
  1159. sSelf: \'oPersonalMessageSend\',
  1160. sSessionId: smf_session_id,
  1161. sSessionVar: smf_session_var,
  1162. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  1163. sToControlId: \'to_control\',
  1164. aToRecipients: [';
  1165. foreach ($context['recipients']['to'] as $i => $member)
  1166. echo '
  1167. {
  1168. sItemId: ', JavaScriptEscape($member['id']), ',
  1169. sItemName: ', JavaScriptEscape($member['name']), '
  1170. }', $i == count($context['recipients']['to']) - 1 ? '' : ',';
  1171. echo '
  1172. ],
  1173. aBccRecipients: [';
  1174. foreach ($context['recipients']['bcc'] as $i => $member)
  1175. echo '
  1176. {
  1177. sItemId: ', JavaScriptEscape($member['id']), ',
  1178. sItemName: ', JavaScriptEscape($member['name']), '
  1179. }', $i == count($context['recipients']['bcc']) - 1 ? '' : ',';
  1180. echo '
  1181. ],
  1182. sBccControlId: \'bcc_control\',
  1183. sBccDivId: \'bcc_div\',
  1184. sBccDivId2: \'bcc_div2\',
  1185. sBccLinkId: \'bcc_link\',
  1186. sBccLinkContainerId: \'bcc_link_container\',
  1187. bBccShowByDefault: ', empty($context['recipients']['bcc']) && empty($context['bcc_value']) ? 'false' : 'true', ',
  1188. sShowBccLinkTemplate: ', JavaScriptEscape('
  1189. <a href="#" id="bcc_link">' . $txt['make_bcc'] . '</a> <a href="' . $scripturl . '?action=helpadmin;help=pm_bcc" onclick="return reqOverlayDiv(this.href);">(?)</a>'
  1190. ), '
  1191. });
  1192. ';
  1193. echo '
  1194. // ]]></script>';
  1195. }
  1196. // This template asks the user whether they wish to empty out their folder/messages.
  1197. function template_ask_delete()
  1198. {
  1199. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  1200. echo '
  1201. <div class="cat_bar">
  1202. <h3 class="catbg">', ($context['delete_all'] ? $txt['delete_message'] : $txt['delete_all']), '</h3>
  1203. </div>
  1204. <div class="windowbg">
  1205. <div class="content">
  1206. <p>', $txt['delete_all_confirm'], '</p><br />
  1207. <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>
  1208. </div>
  1209. </div>';
  1210. }
  1211. // This template asks the user what messages they want to prune.
  1212. function template_prune()
  1213. {
  1214. global $context, $settings, $options, $scripturl, $txt;
  1215. echo '
  1216. <form action="', $scripturl, '?action=pm;sa=prune" method="post" accept-charset="', $context['character_set'], '" onsubmit="return confirm(\'', $txt['pm_prune_warning'], '\');">
  1217. <div class="cat_bar">
  1218. <h3 class="catbg">', $txt['pm_prune'], '</h3>
  1219. </div>
  1220. <div class="windowbg">
  1221. <div class="content">
  1222. <p>', $txt['pm_prune_desc1'], ' <input type="text" name="age" size="3" value="14" class="input_text" /> ', $txt['pm_prune_desc2'], '</p>
  1223. <input type="submit" value="', $txt['delete'], '" class="button_submit" />
  1224. </div>
  1225. </div>
  1226. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1227. </form>';
  1228. }
  1229. // Here we allow the user to setup labels, remove labels and change rules for labels (i.e, do quite a bit)
  1230. function template_labels()
  1231. {
  1232. global $context, $settings, $options, $scripturl, $txt;
  1233. echo '
  1234. <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '">
  1235. <div class="cat_bar">
  1236. <h3 class="catbg">', $txt['pm_manage_labels'], '</h3>
  1237. </div>
  1238. <div class="description">
  1239. ', $txt['pm_labels_desc'], '
  1240. </div>
  1241. <table width="100%" class="table_grid">
  1242. <thead>
  1243. <tr class="catbg">
  1244. <th class="lefttext first_th">
  1245. ', $txt['pm_label_name'], '
  1246. </th>
  1247. <th class="centertext last_th" width="4%">';
  1248. if (count($context['labels']) > 2)
  1249. echo '
  1250. <input type="checkbox" class="input_check" onclick="invertAll(this, this.form);" />';
  1251. echo '
  1252. </th>
  1253. </tr>
  1254. </thead>
  1255. <tbody>';
  1256. if (count($context['labels']) < 2)
  1257. echo '
  1258. <tr class="windowbg2">
  1259. <td colspan="2" align="center">', $txt['pm_labels_no_exist'], '</td>
  1260. </tr>';
  1261. else
  1262. {
  1263. $alternate = true;
  1264. foreach ($context['labels'] as $label)
  1265. {
  1266. if ($label['id'] == -1)
  1267. continue;
  1268. echo '
  1269. <tr class="', $alternate ? 'windowbg2' : 'windowbg', '">
  1270. <td>
  1271. <input type="text" name="label_name[', $label['id'], ']" value="', $label['name'], '" size="30" maxlength="30" class="input_text" />
  1272. </td>
  1273. <td width="4%" align="center"><input type="checkbox" class="input_check" name="delete_label[', $label['id'], ']" /></td>
  1274. </tr>';
  1275. $alternate = !$alternate;
  1276. }
  1277. }
  1278. echo '
  1279. </tbody>
  1280. </table>';
  1281. if (!count($context['labels']) < 2)
  1282. echo '
  1283. <div class="padding">
  1284. <input type="submit" name="save" value="', $txt['save'], '" class="button_submit" />
  1285. <input type="submit" name="delete" value="', $txt['quickmod_delete_selected'], '" onclick="return confirm(\'', $txt['pm_labels_delete'], '\');" class="button_submit" />
  1286. </div>';
  1287. echo '
  1288. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1289. </form>
  1290. <br class="clear" />
  1291. <form action="', $scripturl, '?action=pm;sa=manlabels" method="post" accept-charset="', $context['character_set'], '" style="margin-top: 1ex;">
  1292. <div class="cat_bar">
  1293. <h3 class="catbg">', $txt['pm_label_add_new'], '</h3>
  1294. </div>
  1295. <div class="windowbg">
  1296. <div class="content">
  1297. <dl class="settings">
  1298. <dt>
  1299. <strong><label for="add_label">', $txt['pm_label_name'], '</label>:</strong>
  1300. </dt>
  1301. <dd>
  1302. <input type="text" id="add_label" name="label" value="" size="30" maxlength="30" class="input_text" />
  1303. </dd>
  1304. </dl>
  1305. <input type="submit" name="add" value="', $txt['pm_label_add_new'], '" class="button_submit" />
  1306. </div>
  1307. </div>
  1308. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1309. </form><br />';
  1310. }
  1311. // Template for reporting a personal message.
  1312. function template_report_message()
  1313. {
  1314. global $context, $settings, $options, $txt, $scripturl;
  1315. echo '
  1316. <form action="', $scripturl, '?action=pm;sa=report;l=', $context['current_label_id'], '" method="post" accept-charset="', $context['character_set'], '">
  1317. <input type="hidden" name="pmsg" value="', $context['pm_id'], '" />
  1318. <div class="cat_bar">
  1319. <h3 class="catbg">', $txt['pm_report_title'], '</h3>
  1320. </div>
  1321. <div class="description">
  1322. ', $txt['pm_report_desc'], '
  1323. </div>
  1324. <div class="windowbg">
  1325. <div class="content">
  1326. <dl class="settings">';
  1327. // If there is more than one admin on the forum, allow the user to choose the one they want to direct to.
  1328. // @todo Why?
  1329. if ($context['admin_count'] > 1)
  1330. {
  1331. echo '
  1332. <dt>
  1333. <strong>', $txt['pm_report_admins'], ':</strong>
  1334. </dt>
  1335. <dd>
  1336. <select name="id_admin">
  1337. <option value="0">', $txt['pm_report_all_admins'], '</option>';
  1338. foreach ($context['admins'] as $id => $name)
  1339. echo '
  1340. <option value="', $id, '">', $name, '</option>';
  1341. echo '
  1342. </select>
  1343. </dd>';
  1344. }
  1345. echo '
  1346. <dt>
  1347. <strong>', $txt['pm_report_reason'], ':</strong>
  1348. </dt>
  1349. <dd>
  1350. <textarea name="reason" rows="4" cols="70" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 80%; min-width: 80%' : 'width: 80%') . ';"></textarea>
  1351. </dd>
  1352. </dl>
  1353. <div class="righttext">
  1354. <input type="submit" name="report" value="', $txt['pm_report_message'], '" class="button_submit" />
  1355. </div>
  1356. </div>
  1357. </div>
  1358. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1359. </form>';
  1360. }
  1361. // Little template just to say "Yep, it's been submitted"
  1362. function template_report_message_complete()
  1363. {
  1364. global $context, $settings, $options, $txt, $scripturl;
  1365. echo '
  1366. <div class="cat_bar">
  1367. <h3 class="catbg">', $txt['pm_report_title'], '</h3>
  1368. </div>
  1369. <div class="windowbg">
  1370. <div class="content">
  1371. <p>', $txt['pm_report_done'], '</p>
  1372. <a href="', $scripturl, '?action=pm;l=', $context['current_label_id'], '">', $txt['pm_report_return'], '</a>
  1373. </div>
  1374. </div>';
  1375. }
  1376. // Manage rules.
  1377. function template_rules()
  1378. {
  1379. global $context, $settings, $options, $txt, $scripturl;
  1380. echo '
  1381. <form action="', $scripturl, '?action=pm;sa=manrules" method="post" accept-charset="', $context['character_set'], '" name="manRules" id="manrules">
  1382. <div class="cat_bar">
  1383. <h3 class="catbg">', $txt['pm_manage_rules'], '</h3>
  1384. </div>
  1385. <div class="description">
  1386. ', $txt['pm_manage_rules_desc'], '
  1387. </div>
  1388. <table width="100%" class="table_grid">
  1389. <thead>
  1390. <tr class="catbg">
  1391. <th class="lefttext first_th">
  1392. ', $txt['pm_rule_title'], '
  1393. </th>
  1394. <th width="4%" class="centertext last_th">';
  1395. if (!empty($context['rules']))
  1396. echo '
  1397. <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />';
  1398. echo '
  1399. </th>
  1400. </tr>
  1401. </thead>
  1402. <tbody>';
  1403. if (empty($context['rules']))
  1404. echo '
  1405. <tr class="windowbg2">
  1406. <td colspan="2" align="center">
  1407. ', $txt['pm_rules_none'], '
  1408. </td>
  1409. </tr>';
  1410. $alternate = false;
  1411. foreach ($context['rules'] as $rule)
  1412. {
  1413. echo '
  1414. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
  1415. <td>
  1416. <a href="', $scripturl, '?action=pm;sa=manrules;add;rid=', $rule['id'], '">', $rule['name'], '</a>
  1417. </td>
  1418. <td width="4%" align="center">
  1419. <input type="checkbox" name="delrule[', $rule['id'], ']" class="input_check" />
  1420. </td>
  1421. </tr>';
  1422. $alternate = !$alternate;
  1423. }
  1424. echo '
  1425. </tbody>
  1426. </table>
  1427. <div class="righttext">
  1428. <a class="button_link" href="', $scripturl, '?action=pm;sa=manrules;add;rid=0">', $txt['pm_add_rule'], '</a>';
  1429. if (!empty($context['rules']))
  1430. echo '
  1431. [<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>]';
  1432. if (!empty($context['rules']))
  1433. echo '
  1434. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1435. <input type="submit" name="delselected" value="', $txt['pm_delete_selected_rule'], '" onclick="return confirm(\'', $txt['pm_js_delete_rule_confirm'], '\');" class="button_submit smalltext" />';
  1436. echo '
  1437. </div>
  1438. </form>';
  1439. }
  1440. // Template for adding/editing a rule.
  1441. function template_add_rule()
  1442. {
  1443. global $context, $settings, $options, $txt, $scripturl;
  1444. echo '
  1445. <script type="text/javascript"><!-- // --><![CDATA[
  1446. var criteriaNum = 0;
  1447. var actionNum = 0;
  1448. var groups = new Array()
  1449. var labels = new Array()';
  1450. foreach ($context['groups'] as $id => $title)
  1451. echo '
  1452. groups[', $id, '] = "', addslashes($title), '";';
  1453. foreach ($context['labels'] as $label)
  1454. if ($label['id'] != -1)
  1455. echo '
  1456. labels[', ($label['id'] + 1), '] = "', addslashes($label['name']), '";';
  1457. echo '
  1458. function addCriteriaOption()
  1459. {
  1460. if (criteriaNum == 0)
  1461. {
  1462. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1463. if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
  1464. criteriaNum++;
  1465. }
  1466. criteriaNum++
  1467. 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>';
  1468. foreach ($context['groups'] as $id => $group)
  1469. echo '<option value="', $id, '">', strtr($group, array("'" => "\'")), '<\' + \'/option>';
  1470. echo '<\' + \'/select><\' + \'/span><span id="criteriaAddHere"><\' + \'/span>\');
  1471. }
  1472. function addActionOption()
  1473. {
  1474. if (actionNum == 0)
  1475. {
  1476. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1477. if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
  1478. actionNum++;
  1479. }
  1480. actionNum++
  1481. 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>';
  1482. foreach ($context['labels'] as $label)
  1483. if ($label['id'] != -1)
  1484. echo '<option value="', ($label['id'] + 1), '">', addslashes($label['name']), '<\' + \'/option>';
  1485. echo '<\' + \'/select><\' + \'/span><span id="actionAddHere"><\' + \'/span>\');
  1486. }
  1487. // Rebuild the rule description!
  1488. function rebuildRuleDesc()
  1489. {
  1490. // Start with nothing.
  1491. var text = "";
  1492. var joinText = "";
  1493. var actionText = "";
  1494. var hadBuddy = false;
  1495. var foundCriteria = false;
  1496. var foundAction = false;
  1497. var curNum, curVal, curDef;
  1498. for (var i = 0; i < document.forms.addrule.elements.length; i++)
  1499. {
  1500. if (document.forms.addrule.elements[i].id.substr(0, 8) == "ruletype")
  1501. {
  1502. if (foundCriteria)
  1503. joinText = document.getElementById("logic").value == \'and\' ? ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ' : ', JavaScriptEscape(' ' . $txt['pm_readable_or'] . ' '), ';
  1504. else
  1505. joinText = \'\';
  1506. foundCriteria = true;
  1507. curNum = document.forms.addrule.elements[i].id.match(/\d+/);
  1508. curVal = document.forms.addrule.elements[i].value;
  1509. if (curVal == "gid")
  1510. curDef = document.getElementById("ruledefgroup" + curNum).value.php_htmlspecialchars();
  1511. else if (curVal != "bud")
  1512. curDef = document.getElementById("ruledef" + curNum).value.php_htmlspecialchars();
  1513. else
  1514. curDef = "";
  1515. // What type of test is this?
  1516. if (curVal == "mid" && curDef)
  1517. text += joinText + ', JavaScriptEscape($txt['pm_readable_member']), '.replace("{MEMBER}", curDef);
  1518. else if (curVal == "gid" && curDef && groups[curDef])
  1519. text += joinText + ', JavaScriptEscape($txt['pm_readable_group']), '.replace("{GROUP}", groups[curDef]);
  1520. else if (curVal == "sub" && curDef)
  1521. text += joinText + ', JavaScriptEscape($txt['pm_readable_subject']), '.replace("{SUBJECT}", curDef);
  1522. else if (curVal == "msg" && curDef)
  1523. text += joinText + ', JavaScriptEscape($txt['pm_readable_body']), '.replace("{BODY}", curDef);
  1524. else if (curVal == "bud" && !hadBuddy)
  1525. {
  1526. text += joinText + ', JavaScriptEscape($txt['pm_readable_buddy']), ';
  1527. hadBuddy = true;
  1528. }
  1529. }
  1530. if (document.forms.addrule.elements[i].id.substr(0, 7) == "acttype")
  1531. {
  1532. if (foundAction)
  1533. joinText = ', JavaScriptEscape(' ' . $txt['pm_readable_and'] . ' '), ';
  1534. else
  1535. joinText = "";
  1536. foundAction = true;
  1537. curNum = document.forms.addrule.elements[i].id.match(/\d+/);
  1538. curVal = document.forms.addrule.elements[i].value;
  1539. if (curVal == "lab")
  1540. curDef = document.getElementById("labdef" + curNum).value.php_htmlspecialchars();
  1541. else
  1542. curDef = "";
  1543. // Now pick the actions.
  1544. if (curVal == "lab" && curDef && labels[curDef])
  1545. actionText += joinText + ', JavaScriptEscape($txt['pm_readable_label']), '.replace("{LABEL}", labels[curDef]);
  1546. else if (curVal == "del")
  1547. actionText += joinText + ', JavaScriptEscape($txt['pm_readable_delete']), ';
  1548. }
  1549. }
  1550. // If still nothing make it default!
  1551. if (text == "" || !foundCriteria)
  1552. text = "', $txt['pm_rule_not_defined'], '";
  1553. else
  1554. {
  1555. if (actionText != "")
  1556. text += ', JavaScriptEscape(' ' . $txt['pm_readable_then'] . ' '), ' + actionText;
  1557. text = ', JavaScriptEscape($txt['pm_readable_start']), ' + text + ', JavaScriptEscape($txt['pm_readable_end']), ';
  1558. }
  1559. // Set the actual HTML!
  1560. setInnerHTML(document.getElementById("ruletext"), text);
  1561. }
  1562. // ]]></script>';
  1563. echo '
  1564. <form action="', $scripturl, '?action=pm;sa=manrules;save;rid=', $context['rid'], '" method="post" accept-charset="', $context['character_set'], '" name="addrule" id="addrule" class="flow_hidden">
  1565. <div class="cat_bar">
  1566. <h3 class="catbg">', $context['rid'] == 0 ? $txt['pm_add_rule'] : $txt['pm_edit_rule'], '</h3>
  1567. </div>
  1568. <div class="windowbg">
  1569. <div class="content">
  1570. <dl class="addrules">
  1571. <dt class="floatleft">
  1572. <strong>', $txt['pm_rule_name'], ':</strong><br />
  1573. <span class="smalltext">', $txt['pm_rule_name_desc'], '</span>
  1574. </dt>
  1575. <dd class="floatleft">
  1576. <input type="text" name="rule_name" value="', empty($context['rule']['name']) ? $txt['pm_rule_name_default'] : $context['rule']['name'], '" size="50" class="input_text" />
  1577. </dd>
  1578. </dl>
  1579. <fieldset>
  1580. <legend>', $txt['pm_rule_criteria'], '</legend>';
  1581. // Add a dummy criteria to allow expansion for none js users.
  1582. $context['rule']['criteria'][] = array('t' => '', 'v' => '');
  1583. // For each criteria print it out.
  1584. $isFirst = true;
  1585. foreach ($context['rule']['criteria'] as $k => $criteria)
  1586. {
  1587. if (!$isFirst && $criteria['t'] == '')
  1588. echo '<div id="removeonjs1">';
  1589. elseif (!$isFirst)
  1590. echo '<br />';
  1591. echo '
  1592. <select name="ruletype[', $k, ']" id="ruletype', $k, '" onchange="updateRuleDef(', $k, '); rebuildRuleDesc();">
  1593. <option value="">', $txt['pm_rule_criteria_pick'], ':</option>
  1594. <option value="mid" ', $criteria['t'] == 'mid' ? 'selected="selected"' : '', '>', $txt['pm_rule_mid'], '</option>
  1595. <option value="gid" ', $criteria['t'] == 'gid' ? 'selected="selected"' : '', '>', $txt['pm_rule_gid'], '</option>
  1596. <option value="sub" ', $criteria['t'] == 'sub' ? 'selected="selected"' : '', '>', $txt['pm_rule_sub'], '</option>
  1597. <option value="msg" ', $criteria['t'] == 'msg' ? 'selected="selected"' : '', '>', $txt['pm_rule_msg'], '</option>
  1598. <option value="bud" ', $criteria['t'] == 'bud' ? 'selected="selected"' : '', '>', $txt['pm_rule_bud'], '</option>
  1599. </select>
  1600. <span id="defdiv', $k, '" ', !in_array($criteria['t'], array('gid', 'bud')) ? '' : 'style="display: none;"', '>
  1601. <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" />
  1602. </span>
  1603. <span id="defseldiv', $k, '" ', $criteria['t'] == 'gid' ? '' : 'style="display: none;"', '>
  1604. <select name="ruledefgroup[', $k, ']" id="ruledefgroup', $k, '" onchange="rebuildRuleDesc();">
  1605. <option value="">', $txt['pm_rule_sel_group'], '</option>';
  1606. foreach ($context['groups'] as $id => $group)
  1607. echo '
  1608. <option value="', $id, '" ', $criteria['t'] == 'gid' && $criteria['v'] == $id ? 'selected="selected"' : '', '>', $group, '</option>';
  1609. echo '
  1610. </select>
  1611. </span>';
  1612. // If this is the dummy we add a means to hide for non js users.
  1613. if ($isFirst)
  1614. $isFirst = false;
  1615. elseif ($criteria['t'] == '')
  1616. echo '</div>';
  1617. }
  1618. echo '
  1619. <span id="criteriaAddHere"></span><br />
  1620. <a href="#" onclick="addCriteriaOption(); return false;" id="addonjs1" style="display: none;">(', $txt['pm_rule_criteria_add'], ')</a>
  1621. <br /><br />
  1622. ', $txt['pm_rule_logic'], ':
  1623. <select name="rule_logic" id="logic" onchange="rebuildRuleDesc();">
  1624. <option value="and" ', $context['rule']['logic'] == 'and' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_and'], '</option>
  1625. <option value="or" ', $context['rule']['logic'] == 'or' ? 'selected="selected"' : '', '>', $txt['pm_rule_logic_or'], '</option>
  1626. </select>
  1627. </fieldset>
  1628. <fieldset>
  1629. <legend>', $txt['pm_rule_actions'], '</legend>';
  1630. // As with criteria - add a dummy action for "expansion".
  1631. $context['rule']['actions'][] = array('t' => '', 'v' => '');
  1632. // Print each action.
  1633. $isFirst = true;
  1634. foreach ($context['rule']['actions'] as $k => $action)
  1635. {
  1636. if (!$isFirst && $action['t'] == '')
  1637. echo '<div id="removeonjs2">';
  1638. elseif (!$isFirst)
  1639. echo '<br />';
  1640. echo '
  1641. <select name="acttype[', $k, ']" id="acttype', $k, '" onchange="updateActionDef(', $k, '); rebuildRuleDesc();">
  1642. <option value="">', $txt['pm_rule_sel_action'] , ':</option>
  1643. <option value="lab" ', $action['t'] == 'lab' ? 'selected="selected"' : '', '>', $txt['pm_rule_label'] , '</option>
  1644. <option value="del" ', $action['t'] == 'del' ? 'selected="selected"' : '', '>', $txt['pm_rule_delete'] , '</option>
  1645. </select>
  1646. <span id="labdiv', $k, '">
  1647. <select name="labdef[', $k, ']" id="labdef', $k, '" onchange="rebuildRuleDesc();">
  1648. <option value="">', $txt['pm_rule_sel_label'], '</option>';
  1649. foreach ($context['labels'] as $label)
  1650. if ($label['id'] != -1)
  1651. echo '
  1652. <option value="', ($label['id'] + 1), '" ', $action['t'] == 'lab' && $action['v'] == $label['id'] ? 'selected="selected"' : '', '>', $label['name'], '</option>';
  1653. echo '
  1654. </select>
  1655. </span>';
  1656. if ($isFirst)
  1657. $isFirst = false;
  1658. elseif ($action['t'] == '')
  1659. echo '
  1660. </div>';
  1661. }
  1662. echo '
  1663. <span id="actionAddHere"></span><br />
  1664. <a href="#" onclick="addActionOption(); return false;" id="addonjs2" style="display: none;">(', $txt['pm_rule_add_action'], ')</a>
  1665. </fieldset>
  1666. </div>
  1667. <div class="cat_bar">
  1668. <h3 class="catbg">', $txt['pm_rule_description'], '</h3>
  1669. </div>
  1670. <div class="information">
  1671. <div id="ruletext">', $txt['pm_rule_js_disabled'], '</div>
  1672. </div>
  1673. <div class="righttext">
  1674. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  1675. <input type="submit" name="save" value="', $txt['pm_rule_save'], '" class="button_submit" />
  1676. </div>
  1677. </div>
  1678. </form>';
  1679. // Now setup all the bits!
  1680. echo '
  1681. <script type="text/javascript"><!-- // --><![CDATA[';
  1682. foreach ($context['rule']['criteria'] as $k => $c)
  1683. echo '
  1684. updateRuleDef(', $k, ');';
  1685. foreach ($context['rule']['actions'] as $k => $c)
  1686. echo '
  1687. updateActionDef(', $k, ');';
  1688. echo '
  1689. rebuildRuleDesc();';
  1690. // If this isn't a new rule and we have JS enabled remove the JS compatibility stuff.
  1691. if ($context['rid'])
  1692. echo '
  1693. document.getElementById("removeonjs1").style.display = "none";
  1694. document.getElementById("removeonjs2").style.display = "none";';
  1695. echo '
  1696. document.getElementById("addonjs1").style.display = "";
  1697. document.getElementById("addonjs2").style.display = "";';
  1698. echo '
  1699. // ]]></script>';
  1700. }
  1701. // Template for showing all the PM drafts of the user.
  1702. function template_showPMDrafts()
  1703. {
  1704. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  1705. echo '
  1706. <div class="cat_bar">
  1707. <h3 class="catbg">
  1708. <img src="', $settings['images_url'], '/message_sm.png" alt="" class="icon" />
  1709. ', $txt['drafts_show'], '
  1710. </h3>
  1711. </div>
  1712. <div class="pagesection">
  1713. <span>', $context['page_index'], '</span>
  1714. </div>';
  1715. // Button shortcuts
  1716. $edit_button = create_button('modify_inline.png', 'draft_edit', 'draft_edit', 'class="centericon"');
  1717. $remove_button = create_button('delete.png', 'draft_delete', 'draft_delete', 'class="centericon"');
  1718. // No drafts? Just show an informative message.
  1719. if (empty($context['drafts']))
  1720. echo '
  1721. <div class="tborder windowbg2 padding centertext">
  1722. ', $txt['draft_none'], '
  1723. </div>';
  1724. else
  1725. {
  1726. // For every draft to be displayed, give it its own div, and show the important details of the draft.
  1727. foreach ($context['drafts'] as $draft)
  1728. {
  1729. echo '
  1730. <div class="topic">
  1731. <div class="', $draft['alternate'] == 0 ? 'windowbg2' : 'windowbg', ' core_posts">
  1732. <div class="content">
  1733. <div class="counter">', $draft['counter'], '</div>
  1734. <div class="topic_details">
  1735. <h5><strong>', $draft['subject'], '</strong>&nbsp;';
  1736. echo '
  1737. </h5>
  1738. <span class="smalltext">&#171;&nbsp;<strong>', $txt['draft_saved_on'], ':</strong> ', sprintf($txt['draft_days_ago'], $draft['age']), (!empty($draft['remaining']) ? ', ' . sprintf($txt['draft_retain'], $draft['remaining']) : ''), '&#187;</span><br />
  1739. <span class="smalltext">&#171;&nbsp;<strong>', $txt['to'], ':</strong> ', implode(', ', $draft['recipients']['to']), '&nbsp;&#187;</span><br />
  1740. <span class="smalltext">&#171;&nbsp;<strong>', $txt['pm_bcc'], ':</strong> ', implode(', ', $draft['recipients']['bcc']), '&nbsp;&#187;</span>
  1741. </div>
  1742. <div class="list_posts">
  1743. ', $draft['body'], '
  1744. </div>
  1745. <ul class="reset smalltext quickbuttons">
  1746. <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;id_draft=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" class="reply_button"><span>', $txt['draft_edit'], '</span></a></li>
  1747. <li><a href="', $scripturl, '?action=pm;sa=showpmdrafts;delete=', $draft['id_draft'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['draft_remove'], '?\');" class="remove_button"><span>', $txt['draft_delete'], '</span></a></li>
  1748. </ul>
  1749. </div>
  1750. </div>
  1751. </div>';
  1752. }
  1753. }
  1754. // Show page numbers.
  1755. echo '
  1756. <div class="pagesection" style="margin-bottom: 0;">
  1757. <span>', $context['page_index'], '</span>
  1758. </div>';
  1759. }
  1760. ?>