PersonalMessage.template.php 80 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996
  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 for stuff above the menu in 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_pm_popup()
  45. {
  46. global $context, $txt, $scripturl, $settings;
  47. // Unlike almost every other template, this is designed to be included into the HTML directly via $().load()
  48. echo '
  49. <div class="pm_bar">
  50. <div class="pm_sending floatright">
  51. ', $context['can_send_pm'] ? '<a href="' . $scripturl . '?action=pm;sa=send">' . $txt['pm_new_short'] . '</a> | ' : '', '
  52. ', $context['can_draft'] ? '<a href="' . $scripturl . '?action=pm;sa=showpmdrafts">' . $txt['pm_drafts_short'] . '</a> | ' : '', '
  53. <a href="', $scripturl, '?action=pm;sa=settings">', $txt['pm_settings_short'], '</a>
  54. </div>
  55. <div class="pm_mailbox floatleft">
  56. ', $txt['pm_unread'], '
  57. | <a href="', $scripturl, '?action=pm">', $txt['inbox'], '</a>
  58. | <a href="', $scripturl, '?action=pm;f=sent">', $txt['pm_sent_short'], '</a>
  59. </div>
  60. </div>
  61. <div class="pm_unread">';
  62. if (empty($context['unread_pms']))
  63. {
  64. echo '
  65. <div class="no_unread">', $txt['pm_no_unread'], '</div>';
  66. }
  67. else
  68. {
  69. foreach ($context['unread_pms'] as $id_pm => $pm_details)
  70. {
  71. echo '
  72. <div class="unread">
  73. <div class="avatar floatleft">', !empty($pm_details['member']) ? $pm_details['member']['avatar']['image'] : '', '</div>
  74. <div class="details floatleft">
  75. <div class="subject">', $pm_details['pm_link'], '</div>
  76. <div class="sender">', $pm_details['replied_to_you'] ? '<img src="' . $settings['images_url'] . '/icons/pm_replied.png" style="margin-right: 4px;" alt="' . $txt['pm_you_were_replied_to'] . '" title="' . $txt['pm_you_were_replied_to'] . '" />' : '<img src="' . $settings['images_url'] . '/icons/pm_read.png" style="margin-right: 4px;" alt="' . $txt['pm_was_sent_to_you'] . '" title="' . $txt['pm_was_sent_to_you'] . '" />',
  77. !empty($pm_details['member']) ? $pm_details['member']['link'] : $pm_details['member_from'], ' - ', $pm_details['time'], '</div>
  78. </div>
  79. <br class="clear" />
  80. </div>';
  81. }
  82. }
  83. echo '
  84. </div>';
  85. }
  86. function template_folder()
  87. {
  88. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  89. // The every helpful javascript!
  90. echo '
  91. <script type="text/javascript"><!-- // --><![CDATA[
  92. var allLabels = {};
  93. var currentLabels = {};
  94. function loadLabelChoices()
  95. {
  96. var listing = document.forms.pmFolder.elements;
  97. var theSelect = document.forms.pmFolder.pm_action;
  98. var add, remove, toAdd = {length: 0}, toRemove = {length: 0};
  99. if (theSelect.childNodes.length == 0)
  100. return;
  101. // This is done this way for internationalization reasons.
  102. if (!(\'-1\' in allLabels))
  103. {
  104. for (var o = 0; o < theSelect.options.length; o++)
  105. if (theSelect.options[o].value.substr(0, 4) == "rem_")
  106. allLabels[theSelect.options[o].value.substr(4)] = theSelect.options[o].text;
  107. }
  108. for (var i = 0; i < listing.length; i++)
  109. {
  110. if (listing[i].name != "pms[]" || !listing[i].checked)
  111. continue;
  112. var alreadyThere = [], x;
  113. for (x in currentLabels[listing[i].value])
  114. {
  115. if (!(x in toRemove))
  116. {
  117. toRemove[x] = allLabels[x];
  118. toRemove.length++;
  119. }
  120. alreadyThere[x] = allLabels[x];
  121. }
  122. for (x in allLabels)
  123. {
  124. if (!(x in alreadyThere))
  125. {
  126. toAdd[x] = allLabels[x];
  127. toAdd.length++;
  128. }
  129. }
  130. }
  131. while (theSelect.options.length > 2)
  132. theSelect.options[2] = null;
  133. if (toAdd.length != 0)
  134. {
  135. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_apply'], '", "");
  136. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_apply'], '");
  137. theSelect.options[theSelect.options.length - 1].disabled = true;
  138. for (i in toAdd)
  139. {
  140. if (i != "length")
  141. theSelect.options[theSelect.options.length] = new Option(toAdd[i], "add_" + i);
  142. }
  143. }
  144. if (toRemove.length != 0)
  145. {
  146. theSelect.options[theSelect.options.length] = new Option("', $txt['pm_msg_label_remove'], '", "");
  147. setInnerHTML(theSelect.options[theSelect.options.length - 1], "', $txt['pm_msg_label_remove'], '");
  148. theSelect.options[theSelect.options.length - 1].disabled = true;
  149. for (i in toRemove)
  150. {
  151. if (i != "length")
  152. theSelect.options[theSelect.options.length] = new Option(toRemove[i], "rem_" + i);
  153. }
  154. }
  155. }
  156. // ]]></script>';
  157. echo '
  158. <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">';
  159. // If we are not in single display mode show the subjects on the top!
  160. if ($context['display_mode'] != 1)
  161. {
  162. template_subject_list();
  163. echo '<div class="clear_right"><br /></div>';
  164. }
  165. // Got some messages to display?
  166. if ($context['get_pmessage']('message', true))
  167. {
  168. // Show the helpful titlebar - generally.
  169. if ($context['display_mode'] != 1)
  170. echo '
  171. <div class="cat_bar">
  172. <h3 class="catbg">
  173. <span id="author">', $txt['author'], '</span>
  174. <span id="topic_title">', $txt[$context['display_mode'] == 0 ? 'messages' : 'conversation'], '</span>
  175. </h3>
  176. </div>';
  177. // Show a few buttons if we are in conversation mode and outputting the first message.
  178. if ($context['display_mode'] == 2)
  179. {
  180. // Show the conversation buttons.
  181. echo '
  182. <div class="pagesection">';
  183. template_button_strip($context['conversation_buttons'], 'right');
  184. echo '
  185. </div>';
  186. }
  187. while ($message = $context['get_pmessage']('message'))
  188. {
  189. $window_class = $message['alternate'] == 0 ? 'windowbg' : 'windowbg2';
  190. echo '
  191. <div class="', $window_class, '">
  192. <div class="poster">
  193. <h4>
  194. <a id="msg', $message['id'], '"></a>';
  195. // Show online and offline buttons?
  196. if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
  197. echo '
  198. <img src="', $message['member']['online']['image_href'], '" alt="', $message['member']['online']['text'], '" />';
  199. // Show a link to the member's profile (but only if the sender isn't a guest).
  200. echo '
  201. ', $message['member']['link'], '';
  202. echo '
  203. </h4>';
  204. echo '
  205. <ul>';
  206. // Show the user's avatar.
  207. if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
  208. echo '
  209. <li class="avatar">
  210. <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a>
  211. </li>';
  212. if (!$message['member']['is_guest'])
  213. echo '
  214. <li class="icons">', $message['member']['group_icons'], '</li>';
  215. // Show the member's primary group (like 'Administrator') if they have one.
  216. if (isset($message['member']['group']) && $message['member']['group'] != '')
  217. echo '
  218. <li class="membergroup">', $message['member']['group'], '</li>';
  219. // Show the member's custom title, if they have one.
  220. if (isset($message['member']['title']) && $message['member']['title'] != '')
  221. echo '
  222. <li class="title">', $message['member']['title'], '</li>';
  223. // Don't show these things for guests.
  224. if (!$message['member']['is_guest'])
  225. {
  226. // 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.
  227. if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
  228. echo '
  229. <li class="postgroup">', $message['member']['post_group'], '</li>';
  230. // Show how many posts they have made.
  231. if (!isset($context['disabled_fields']['posts']))
  232. echo '
  233. <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
  234. // Is karma display enabled? Total or +/-?
  235. if ($modSettings['karmaMode'] == '1')
  236. echo '
  237. <li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
  238. elseif ($modSettings['karmaMode'] == '2')
  239. echo '
  240. <li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
  241. // Is this user allowed to modify this member's karma?
  242. if ($message['member']['karma']['allow'])
  243. echo '
  244. <li class="karma_allow">
  245. <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>
  246. </li>';
  247. // Show the member's gender icon?
  248. if (!empty($settings['show_gender']) && $message['member']['gender']['image'] != '' && !isset($context['disabled_fields']['gender']))
  249. echo '
  250. <li class="gender">', $txt['gender'], ': ', $message['member']['gender']['image'], '</li>';
  251. // Show their personal text?
  252. if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
  253. echo '
  254. <li class="blurb">', $message['member']['blurb'], '</li>';
  255. // Any custom fields to show as icons?
  256. if (!empty($message['member']['custom_fields']))
  257. {
  258. $shown = false;
  259. foreach ($message['member']['custom_fields'] as $custom)
  260. {
  261. if ($custom['placement'] != 1 || empty($custom['value']))
  262. continue;
  263. if (empty($shown))
  264. {
  265. $shown = true;
  266. echo '
  267. <li class="im_icons">
  268. <ol>';
  269. }
  270. echo '
  271. <li>', $custom['value'], '</li>';
  272. }
  273. if ($shown)
  274. echo '
  275. </ol>
  276. </li>';
  277. }
  278. // This shows the popular messaging icons.
  279. if ($message['member']['has_messenger'] && $message['member']['can_view_profile'])
  280. echo '
  281. <li class="im_icons">
  282. <ol>
  283. ', !isset($context['disabled_fields']['icq']) && !empty($message['member']['icq']['link']) ? '<li>' . $message['member']['icq']['link'] . '</li>' : '', '
  284. ', !isset($context['disabled_fields']['skype']) && !empty($message['member']['skype']['link']) ? '<li>' . $message['member']['skype']['link'] . '</li>' : '', '
  285. ', !isset($context['disabled_fields']['aim']) && !empty($message['member']['aim']['link']) ? '<li>' . $message['member']['aim']['link'] . '</li>' : '', '
  286. ', !isset($context['disabled_fields']['yim']) && !empty($message['member']['yim']['link']) ? '<li>' . $message['member']['yim']['link'] . '</li>' : '', '
  287. </ol>
  288. </li>';
  289. if ($message['can_report'])
  290. echo '
  291. <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>';
  292. // Show the IP to this user for this post - because you can moderate?
  293. if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
  294. echo '
  295. <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>';
  296. // Or, should we show it because this is you?
  297. elseif ($message['can_see_ip'])
  298. echo '
  299. <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>';
  300. // Okay, you are logged in, then we can show something about why IPs are logged...
  301. else
  302. echo '
  303. <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
  304. // Show the profile, website, email address, and personal message buttons.
  305. if ($message['member']['show_profile_buttons'])
  306. {
  307. echo '
  308. <li class="profile">
  309. <ol class="profile_icons">';
  310. // Show the profile button
  311. if ($message['member']['can_view_profile'])
  312. echo '
  313. <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>';
  314. // Don't show an icon if they haven't specified a website.
  315. if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
  316. echo '
  317. <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>';
  318. // Don't show the email address if they want it hidden.
  319. if (in_array($message['member']['show_email'], array('yes', 'yes_permission_override', 'no_through_forum')) && $context['can_send_email'])
  320. echo '
  321. <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>';
  322. // Since we know this person isn't a guest, you *can* message them.
  323. if ($context['can_send_pm'])
  324. echo '
  325. <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>';
  326. echo '
  327. </ol>
  328. </li>';
  329. }
  330. // Any custom fields for standard placement?
  331. if (!empty($message['member']['custom_fields']))
  332. {
  333. foreach ($message['member']['custom_fields'] as $custom)
  334. if (empty($custom['placement']) || empty($custom['value']))
  335. echo '
  336. <li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
  337. }
  338. // Are we showing the warning status?
  339. if ($message['member']['can_see_warning'])
  340. echo '
  341. <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>';
  342. }
  343. // Done with the information about the poster... on to the post itself.
  344. echo '
  345. </ul>
  346. </div>
  347. <div class="postarea">
  348. <div class="flow_hidden">
  349. <div class="keyinfo">
  350. <h5 id="subject_', $message['id'], '">
  351. ', $message['subject'], '
  352. </h5>';
  353. // Show who the message was sent to.
  354. echo '
  355. <span class="smalltext">&#171; <strong> ', $txt['sent_to'], ':</strong> ';
  356. // People it was sent directly to....
  357. if (!empty($message['recipients']['to']))
  358. echo implode(', ', $message['recipients']['to']);
  359. // Otherwise, we're just going to say "some people"...
  360. elseif ($context['folder'] != 'sent')
  361. echo '(', $txt['pm_undisclosed_recipients'], ')';
  362. echo '
  363. <strong> ', $txt['on'], ':</strong> ', $message['time'], ' &#187;
  364. </span>';
  365. // If we're in the sent items, show who it was sent to besides the "To:" people.
  366. if (!empty($message['recipients']['bcc']))
  367. echo '
  368. <br /><span class="smalltext">&#171; <strong> ', $txt['pm_bcc'], ':</strong> ', implode(', ', $message['recipients']['bcc']), ' &#187;</span>';
  369. if (!empty($message['is_replied_to']))
  370. echo '
  371. <br /><span class="smalltext">&#171; ', $txt['pm_is_replied_to'], ' &#187;</span>';
  372. echo '
  373. </div>
  374. <ul class="reset smalltext quickbuttons">';
  375. // Show reply buttons if you have the permission to send PMs.
  376. if ($context['can_send_pm'])
  377. {
  378. // You can't really reply if the member is gone.
  379. if (!$message['member']['is_guest'])
  380. {
  381. // Is there than more than one recipient you can reply to?
  382. if ($message['number_recipients'] > 1)
  383. echo '
  384. <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>';
  385. echo '
  386. <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>
  387. <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_action'], '</a></li>';
  388. }
  389. // This is for "forwarding" - even if the member is gone.
  390. else
  391. echo '
  392. <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>';
  393. }
  394. echo '
  395. <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>';
  396. if (empty($context['display_mode']))
  397. echo '
  398. <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>';
  399. echo '
  400. </ul>
  401. </div>
  402. <div class="post">
  403. <div class="inner" id="msg_', $message['id'], '"', '>', $message['body'], '</div>';
  404. // Are there any custom profile fields for above the signature?
  405. if (!empty($message['member']['custom_fields']))
  406. {
  407. $shown = false;
  408. foreach ($message['member']['custom_fields'] as $custom)
  409. {
  410. if ($custom['placement'] != 2 || empty($custom['value']))
  411. continue;
  412. if (!$shown)
  413. {
  414. $shown = true;
  415. echo '
  416. <div class="custom_fields_above_signature">
  417. <ul class="reset nolist">';
  418. }
  419. echo '
  420. <li>', $custom['value'], '</li>';
  421. }
  422. if ($shown)
  423. echo '
  424. </ul>
  425. </div>';
  426. }
  427. // Show the member's signature?
  428. if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
  429. echo '
  430. <div class="signature">', $message['member']['signature'], '</div>';
  431. // Add an extra line at the bottom if we have labels enabled.
  432. if ($context['folder'] != 'sent' && !empty($context['currently_using_labels']) && $context['display_mode'] != 2)
  433. {
  434. echo '
  435. <div class="labels righttext flow_auto">';
  436. // Add the label drop down box.
  437. if (!empty($context['currently_using_labels']))
  438. {
  439. echo '
  440. <select name="pm_actions[', $message['id'], ']" onchange="if (this.options[this.selectedIndex].value) form.submit();">
  441. <option value="">', $txt['pm_msg_label_title'], ':</option>
  442. <option value="" disabled="disabled">---------------</option>';
  443. // Are there any labels which can be added to this?
  444. if (!$message['fully_labeled'])
  445. {
  446. echo '
  447. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  448. foreach ($context['labels'] as $label)
  449. if (!isset($message['labels'][$label['id']]))
  450. echo '
  451. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  452. }
  453. // ... and are there any that can be removed?
  454. if (!empty($message['labels']) && (count($message['labels']) > 1 || !isset($message['labels'][-1])))
  455. {
  456. echo '
  457. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  458. foreach ($message['labels'] as $label)
  459. echo '
  460. <option value="', $label['id'], '">&nbsp;', $label['name'], '</option>';
  461. }
  462. echo '
  463. </select>
  464. <noscript>
  465. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" style="float: none" />
  466. </noscript>';
  467. }
  468. echo '
  469. </div>';
  470. }
  471. echo '
  472. </div>
  473. </div>
  474. <div class="moderatorbar">
  475. </div>
  476. </div>';
  477. }
  478. if (empty($context['display_mode']))
  479. echo '
  480. <div class="pagesection">
  481. <div class="floatleft">', $context['page_index'], '</div>
  482. <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>
  483. </div>';
  484. // Show a few buttons if we are in conversation mode and outputting the first message.
  485. elseif ($context['display_mode'] == 2 && isset($context['conversation_buttons']))
  486. {
  487. echo '
  488. <div class="pagesection">';
  489. template_button_strip($context['conversation_buttons'], 'right');
  490. echo '
  491. </div>';
  492. }
  493. echo '
  494. <br />';
  495. }
  496. // Individual messages = buttom list!
  497. if ($context['display_mode'] == 1)
  498. {
  499. template_subject_list();
  500. echo '<br />';
  501. }
  502. echo '
  503. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  504. </form>';
  505. }
  506. // Just list all the personal message subjects - to make templates easier.
  507. function template_subject_list()
  508. {
  509. global $context, $options, $settings, $modSettings, $txt, $scripturl;
  510. echo '
  511. <table width="100%" class="table_grid">
  512. <thead>
  513. <tr class="catbg">
  514. <th align="center" width="4%" class="centercol first_th">
  515. <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>
  516. </th>
  517. <th class="lefttext" width="22%">
  518. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  519. </th>
  520. <th class="lefttext" width="46%">
  521. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  522. </th>
  523. <th class="lefttext">
  524. <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' ? ' <span class="sort sort_' . $context['sort_direction'] . '"></span>' : '', '</a>
  525. </th>
  526. <th width="4%" class="centercol last_th">
  527. <input type="checkbox" onclick="invertAll(this, this.form);" class="input_check" />
  528. </th>
  529. </tr>
  530. </thead>
  531. <tbody>';
  532. if (!$context['show_delete'])
  533. echo '
  534. <tr class="windowbg2">
  535. <td colspan="5">', $txt['pm_alert_none'], '</td>
  536. </tr>';
  537. $next_alternate = false;
  538. while ($message = $context['get_pmessage']('subject'))
  539. {
  540. echo '
  541. <tr class="', $next_alternate ? 'windowbg' : 'windowbg2', '">
  542. <td align="center" width="4%">
  543. <script type="text/javascript"><!-- // --><![CDATA[
  544. currentLabels[', $message['id'], '] = {';
  545. if (!empty($message['labels']))
  546. {
  547. $first = true;
  548. foreach ($message['labels'] as $label)
  549. {
  550. echo $first ? '' : ',', '
  551. "', $label['id'], '": "', $label['name'], '"';
  552. $first = false;
  553. }
  554. }
  555. echo '
  556. };
  557. // ]]></script>
  558. ', $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>
  559. <td>', $message['time'], '</td>
  560. <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>
  561. <td>', ($context['from_or_to'] == 'from' ? $message['member']['link'] : (empty($message['recipients']['to']) ? '' : implode(', ', $message['recipients']['to']))), '</td>
  562. <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>
  563. </tr>';
  564. $next_alternate = !$next_alternate;
  565. }
  566. echo '
  567. </tbody>
  568. </table>
  569. <div class="pagesection">
  570. <div class="floatleft">', $context['page_index'], '</div>
  571. <div class="floatright">&nbsp;';
  572. if ($context['show_delete'])
  573. {
  574. if (!empty($context['currently_using_labels']) && $context['folder'] != 'sent')
  575. {
  576. echo '
  577. <select name="pm_action" onchange="if (this.options[this.selectedIndex].value) this.form.submit();" onfocus="loadLabelChoices();">
  578. <option value="">', $txt['pm_sel_label_title'], ':</option>
  579. <option value="" disabled="disabled">---------------</option>';
  580. echo '
  581. <option value="" disabled="disabled">', $txt['pm_msg_label_apply'], ':</option>';
  582. foreach ($context['labels'] as $label)
  583. {
  584. if ($label['id'] != $context['current_label_id'])
  585. echo '
  586. <option value="add_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  587. }
  588. echo '
  589. <option value="" disabled="disabled">', $txt['pm_msg_label_remove'], ':</option>';
  590. foreach ($context['labels'] as $label)
  591. {
  592. echo '
  593. <option value="rem_', $label['id'], '">&nbsp;', $label['name'], '</option>';
  594. }
  595. echo '
  596. </select>
  597. <noscript>
  598. <input type="submit" value="', $txt['pm_apply'], '" class="button_submit" style="float: none" />
  599. </noscript>';
  600. }
  601. echo '
  602. <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" />';
  603. }
  604. echo '
  605. </div>
  606. </div>';
  607. }
  608. function template_search()
  609. {
  610. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  611. echo '
  612. <form action="', $scripturl, '?action=pm;sa=search2" method="post" accept-charset="', $context['character_set'], '" name="searchform" id="searchform">
  613. <div class="cat_bar">
  614. <h3 class="catbg">', $txt['pm_search_title'], '</h3>
  615. </div>';
  616. if (!empty($context['search_errors']))
  617. {
  618. echo '
  619. <div class="errorbox">
  620. ', implode('<br />', $context['search_errors']['messages']), '
  621. </div>';
  622. }
  623. if ($context['simple_search'])
  624. {
  625. echo '
  626. <fieldset id="simple_search">
  627. <div class="roundframe">
  628. <div id="search_term_input">
  629. <strong>', $txt['pm_search_text'], ':</strong>
  630. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  631. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />
  632. </div>
  633. <a href="', $scripturl, '?action=pm;sa=search;advanced" onclick="this.href += \';search=\' + escape(document.forms.searchform.search.value);">', $txt['pm_search_advanced'], '</a>
  634. <input type="hidden" name="advanced" value="0" />
  635. </div>
  636. </fieldset>';
  637. }
  638. // Advanced search!
  639. else
  640. {
  641. echo '
  642. <fieldset id="advanced_search">
  643. <div class="roundframe">
  644. <input type="hidden" name="advanced" value="1" />
  645. <span class="enhanced">
  646. <strong>', $txt['pm_search_text'], ':</strong>
  647. <input type="text" name="search"', !empty($context['search_params']['search']) ? ' value="' . $context['search_params']['search'] . '"' : '', ' size="40" class="input_text" />
  648. <script type="text/javascript"><!-- // --><![CDATA[
  649. createEventListener(window);
  650. window.addEventListener("load", initSearch, false);
  651. // ]]></script>
  652. <select name="searchtype">
  653. <option value="1"', empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_all'], '</option>
  654. <option value="2"', !empty($context['search_params']['searchtype']) ? ' selected="selected"' : '', '>', $txt['pm_search_match_any'], '</option>
  655. </select>
  656. </span>
  657. <dl id="search_options">
  658. <dt>', $txt['pm_search_user'], ':</dt>
  659. <dd><input type="text" name="userspec" value="', empty($context['search_params']['userspec']) ? '*' : $context['search_params']['userspec'], '" size="40" class="input_text" /></dd>
  660. <dt>', $txt['pm_search_order'], ':</dt>
  661. <dd>
  662. <select name="sort">
  663. <option value="relevance|desc">', $txt['pm_search_orderby_relevant_first'], '</option>
  664. <option value="id_pm|desc">', $txt['pm_search_orderby_recent_first'], '</option>
  665. <option value="id_pm|asc">', $txt['pm_search_orderby_old_first'], '</option>
  666. </select>
  667. </dd>
  668. <dt class="options">', $txt['pm_search_options'], ':</dt>
  669. <dd class="options">
  670. <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 />
  671. <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>
  672. </dd>
  673. <dt class="between">', $txt['pm_search_post_age'], ':</dt>
  674. <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>
  675. </dl>';
  676. if (!$context['currently_using_labels'])
  677. echo '
  678. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />';
  679. echo '
  680. <br class="clear_right" />
  681. </div>
  682. </fieldset>';
  683. // Do we have some labels setup? If so offer to search by them!
  684. if ($context['currently_using_labels'])
  685. {
  686. echo '
  687. <fieldset class="labels">
  688. <div class="roundframe">
  689. <div class="title_bar">
  690. <h4 class="titlebg">
  691. <img id="advanced_panel_toggle" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/collapse.png" alt="*" /><a href="#" id="advanced_panel_link">', $txt['pm_search_choose_label'], '</a>
  692. </h4>
  693. </div>
  694. <div id="advanced_panel_div">
  695. <ul id="searchLabelsExpand" class="reset" >';
  696. foreach ($context['search_labels'] as $label)
  697. echo '
  698. <li>
  699. <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" />
  700. ', $label['name'], '</label>
  701. </li>';
  702. echo '
  703. </ul>
  704. </div>
  705. <p>
  706. <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>
  707. <input type="submit" name="pm_search" value="', $txt['pm_search_go'], '" class="button_submit" />
  708. </p>
  709. <br class="clear_right" />
  710. </div>
  711. </fieldset>';
  712. // Some javascript for the advanced toggling
  713. echo '
  714. <script type="text/javascript"><!-- // --><![CDATA[
  715. var oAdvancedPanelToggle = new smc_Toggle({
  716. bToggleEnabled: true,
  717. bCurrentlyCollapsed: true,
  718. aSwappableContainers: [
  719. \'advanced_panel_div\'
  720. ],
  721. aSwapImages: [
  722. {
  723. sId: \'advanced_panel_toggle\',
  724. srcExpanded: smf_images_url + \'/collapse.png\',
  725. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  726. srcCollapsed: smf_images_url + \'/expand.png\',
  727. altCollapsed: ', JavaScriptEscape($txt['show']), '
  728. }
  729. ],
  730. aSwapLinks: [
  731. {
  732. sId: \'advanced_panel_link\',
  733. msgExpanded: ', JavaScriptEscape($txt['pm_search_choose_label']), ',
  734. msgCollapsed: ', JavaScriptEscape($txt['pm_search_choose_label']), '
  735. }
  736. ]
  737. });
  738. // ]]></script>';
  739. }
  740. }
  741. echo '
  742. </form>';
  743. }
  744. function template_search_results()
  745. {
  746. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  747. echo '
  748. <div class="cat_bar">
  749. <h3 class="catbg">', $txt['pm_search_results'], '</h3>
  750. </div>
  751. <div class="pagesection">
  752. ', $context['page_index'], '
  753. </div>';
  754. // complete results ?
  755. if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
  756. echo '
  757. <table width="100%" class="table_grid">
  758. <thead>
  759. <tr class="catbg">
  760. <th class="lefttext first_th" width="30%">', $txt['date'], '</th>
  761. <th class="lefttext" width="50%">', $txt['subject'], '</th>
  762. <th class="lefttext last_th" width="20%">', $txt['from'], '</th>
  763. </tr>
  764. </thead>
  765. <tbody>';
  766. $alternate = true;
  767. // Print each message out...
  768. foreach ($context['personal_messages'] as $message)
  769. {
  770. // We showing it all?
  771. if (!empty($context['search_params']['show_complete']))
  772. {
  773. echo '
  774. <div class="title_bar">
  775. <h3 class="titlebg">
  776. <span class="floatright">', $txt['search_on'], ': ', $message['time'], '</span>
  777. <span class="floatleft">', $message['counter'], '&nbsp;&nbsp;<a href="', $message['href'], '">', $message['subject'], '</a></span>
  778. </h3>
  779. </div>
  780. <div class="cat_bar">
  781. <h3 class="catbg">', $txt['from'], ': ', $message['member']['link'], ', ', $txt['to'], ': ';
  782. // Show the recipients.
  783. // @todo This doesn't deal with the sent item searching quite right for bcc.
  784. if (!empty($message['recipients']['to']))
  785. echo implode(', ', $message['recipients']['to']);
  786. // Otherwise, we're just going to say "some people"...
  787. elseif ($context['folder'] != 'sent')
  788. echo '(', $txt['pm_undisclosed_recipients'], ')';
  789. echo '
  790. </h3>
  791. </div>
  792. <div class="windowbg', $alternate ? '2': '', '">
  793. <div class="content">
  794. ', $message['body'], '
  795. <p class="pm_reply righttext">';
  796. if ($context['can_send_pm'])
  797. {
  798. $quote_button = create_button('quote.png', 'reply_quote', 'reply_quote', 'class="centericon"');
  799. $reply_button = create_button('im_reply.png', 'reply', 'reply', 'class="centericon"');
  800. // You can only reply if they are not a guest...
  801. if (!$message['member']['is_guest'])
  802. echo '
  803. <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'], '
  804. <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'];
  805. // This is for "forwarding" - even if the member is gone.
  806. else
  807. echo '
  808. <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'];
  809. }
  810. echo '
  811. </p>
  812. </div>
  813. </div>';
  814. }
  815. // Otherwise just a simple list!
  816. else
  817. {
  818. // @todo No context at all of the search?
  819. echo '
  820. <tr class="', $alternate ? 'windowbg' : 'windowbg2', '" valign="top">
  821. <td>', $message['time'], '</td>
  822. <td>', $message['link'], '</td>
  823. <td>', $message['member']['link'], '</td>
  824. </tr>';
  825. }
  826. $alternate = !$alternate;
  827. }
  828. // Finish off the page...
  829. if (empty($context['search_params']['show_complete']) && !empty($context['personal_messages']))
  830. echo '
  831. </tbody>
  832. </table>';
  833. // No results?
  834. if (empty($context['personal_messages']))
  835. echo '
  836. <div class="windowbg">
  837. <div class="content">
  838. <p class="centertext">', $txt['pm_search_none_found'], '</p>
  839. </div>
  840. </div>';
  841. echo '
  842. <div class="pagesection">
  843. ', $context['page_index'], '
  844. </div>';
  845. }
  846. function template_send()
  847. {
  848. global $context, $settings, $options, $scripturl, $modSettings, $txt;
  849. // Show which messages were sent successfully and which failed.
  850. if (!empty($context['send_log']))
  851. {
  852. echo '
  853. <div class="cat_bar">
  854. <h3 class="catbg">', $txt['pm_send_report'], '</h3>
  855. </div>
  856. <div class="windowbg">
  857. <div class="content">';
  858. if (!empty($context['send_log']['sent']))
  859. foreach ($context['send_log']['sent'] as $log_entry)
  860. echo '<span class="error">', $log_entry, '</span><br />';
  861. if (!empty($context['send_log']['failed']))
  862. foreach ($context['send_log']['failed'] as $log_entry)
  863. echo '<span class="error">', $log_entry, '</span><br />';
  864. echo '
  865. </div>
  866. </div>
  867. <br />';
  868. }
  869. // Show the preview of the personal message.
  870. echo '
  871. <div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
  872. <div class="cat_bar">
  873. <h3 class="catbg">
  874. <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
  875. </h3>
  876. </div>
  877. <div class="windowbg">
  878. <div class="content">
  879. <div class="post" id="preview_body">
  880. ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
  881. </div>
  882. </div>
  883. </div>
  884. </div>';
  885. // Main message editing box.
  886. echo '
  887. <div class="cat_bar">
  888. <h3 class="catbg">
  889. <img src="', $settings['images_url'], '/icons/im_newmsg.png" class="icon" alt="', $txt['new_message'], '" title="', $txt['new_message'], '" />&nbsp;', $txt['new_message'], '
  890. </h3>
  891. </div>';
  892. echo '
  893. <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\']);">
  894. <div>
  895. <div class="roundframe">
  896. <br class="clear" />';
  897. // If there were errors for sending the PM, show them.
  898. echo '
  899. <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
  900. <dl>
  901. <dt>
  902. <strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
  903. </dt>
  904. <dd class="error" id="error_list">
  905. ', empty($context['post_error']['messages']) ? '' : implode('<br />', $context['post_error']['messages']), '
  906. </dd>
  907. </dl>
  908. </div>';
  909. if (!empty($modSettings['drafts_pm_enabled']))
  910. echo '
  911. <div id="draft_section" class="infobox"', isset($context['draft_saved']) ? '' : ' style="display: none;"', '>',
  912. sprintf($txt['draft_pm_saved'], $scripturl . '?action=pm;sa=showpmdrafts'), '
  913. ', (!empty($modSettings['drafts_keep_days']) ? ' <strong>' . sprintf($txt['draft_save_warning'], $modSettings['drafts_keep_days']) . '</strong>' : ''), '
  914. </div>';
  915. echo '
  916. <dl id="post_header">';
  917. // To and bcc. Include a button to search for members.
  918. echo '
  919. <dt>
  920. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_to']) ? ' class="error"' : ''), ' id="caption_to">', $txt['pm_to'], ':</span>
  921. </dt>';
  922. // Autosuggest will be added by the JavaScript later on.
  923. echo '
  924. <dd id="pm_to" class="clear_right">
  925. <input type="text" name="to" id="to_control" value="', $context['to_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />';
  926. // A link to add BCC, only visible with JavaScript enabled.
  927. echo '
  928. <span class="smalltext" id="bcc_link_container" style="display: none;"></span>';
  929. // A div that'll contain the items found by the autosuggest.
  930. echo '
  931. <div id="to_item_list_container"></div>';
  932. echo '
  933. </dd>';
  934. // This BCC row will be hidden by default if JavaScript is enabled.
  935. echo '
  936. <dt class="clear_left" id="bcc_div">
  937. <span', (isset($context['post_error']['no_to']) || isset($context['post_error']['bad_bcc']) ? ' class="error"' : ''), ' id="caption_bbc">', $txt['pm_bcc'], ':</span>
  938. </dt>
  939. <dd id="bcc_div2">
  940. <input type="text" name="bcc" id="bcc_control" value="', $context['bcc_value'], '" tabindex="', $context['tabindex']++, '" size="40" style="width: 130px;" class="input_text" />
  941. <div id="bcc_item_list_container"></div>
  942. </dd>';
  943. // The subject of the PM.
  944. echo '
  945. <dt class="clear_left">
  946. <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
  947. </dt>
  948. <dd id="pm_subject">
  949. <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"', '/>
  950. </dd>
  951. </dl><hr class="clear" />';
  952. // Showing BBC?
  953. if ($context['show_bbc'])
  954. {
  955. echo '
  956. <div id="bbcBox_message"></div>';
  957. }
  958. // What about smileys?
  959. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  960. echo '
  961. <div id="smileyBox_message"></div>';
  962. // Show BBC buttons, smileys and textbox.
  963. echo '
  964. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  965. // Require an image to be typed to save spamming?
  966. if ($context['require_verification'])
  967. {
  968. echo '
  969. <div class="post_verification">
  970. <strong>', $txt['pm_visual_verification_label'], ':</strong>
  971. ', template_control_verification($context['visual_verification_id'], 'all'), '
  972. </div>';
  973. }
  974. // Send, Preview, spellcheck buttons.
  975. echo '
  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($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 = [];
  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']), '] = "', 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']), '">', 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']), '" ', $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. ?>