PersonalMessage.template.php 70 KB

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