PersonalMessage.template.php 70 KB

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