PageRenderTime 53ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/system/core/core.messages.php

https://github.com/danboy/Croissierd
PHP | 5494 lines | 4770 code | 404 blank | 320 comment | 215 complexity | 02e09200b7cfe6ae7e8fdcad36141dc1 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /*
  3. =====================================================
  4. ExpressionEngine - by EllisLab
  5. -----------------------------------------------------
  6. http://expressionengine.com/
  7. -----------------------------------------------------
  8. Copyright (c) 2003 - 2010 EllisLab, Inc.
  9. =====================================================
  10. THIS IS COPYRIGHTED SOFTWARE
  11. PLEASE READ THE LICENSE AGREEMENT
  12. http://expressionengine.com/docs/license.html
  13. =====================================================
  14. File: core.messages.php
  15. -----------------------------------------------------
  16. Purpose: Private Messages
  17. =====================================================
  18. */
  19. if ( ! defined('EXT'))
  20. {
  21. exit('Invalid file request');
  22. }
  23. class Messages {
  24. // URL Writing
  25. var $allegiance = 'cp'; // Side of the divide: cp or user
  26. var $CP = FALSE; // CP Object
  27. var $base_url = ''; // Base URL used throughout
  28. var $form_url = ''; // For CP Forms, since Rick was a doofus and changed how they work
  29. var $path = 'member/'; // User Side Path
  30. var $request = 'inbox'; // User Side Request
  31. var $cur_id = ''; // User Side ID, if any
  32. var $theme_class = 'profile_theme';
  33. var $images_folder = ''; // Location of Forum Images
  34. // Member Specific
  35. var $member_id = '';
  36. var $private_messages = '0'; // Number of unread private messages
  37. var $block_tracking = 'n'; // Block Sender Tracking
  38. // Member Group Specific
  39. var $allow_pm = 'y'; // Allowed to PM?
  40. var $attach_allowed = 'y'; // Attachments allowed?
  41. // Private Message Preferences
  42. var $storage_limit = 60; // Limit for messages to store per user (does not count deleted)
  43. var $send_limit = 20; // Limit for messages sent a day
  44. var $upload_path = ''; // Upload path for files
  45. var $attach_maxsize = 250; // Max size for attachments (KB)
  46. var $attach_total = 100; // Maximum amount for all PM attachments (MB)
  47. var $html_format = 'safe'; // HTML Formatting?
  48. var $auto_links = 'y'; // Auto convert URLs to links
  49. var $max_chars = 6000; // Maximum number of characters in a messages
  50. var $max_attachments = 1; // Maximum number of attachments per message
  51. // User Data Variables
  52. var $total_messages = ''; // Total Store Messages for User
  53. var $current_folder = '1'; // If any...
  54. var $folders = array(); // Folders for User
  55. var $hide_preview = FALSE; // Whether to show the Preview of Message
  56. var $attachments = array(); // Attachments for current message
  57. var $baddies = array(); // Blocked List; IDs only
  58. var $goodies = array(); // Buddies List; IDs only
  59. var $blocked = FALSE; // Blocked List
  60. var $buddies = FALSE; // Buddies List
  61. var $invalid_name = FALSE; // Invalid name submitted?
  62. // Menu Content
  63. var $menu_items = array(); // Abstracted data for creating menu
  64. var $menu = ''; // Menu fully formed
  65. // Processing and Returned Data
  66. var $title = ''; // Title of Page
  67. var $crumb = ''; // Crumb text for page
  68. var $return_data = ''; // Output data
  69. var $header_javascript = ''; // User Side Header JavaScript
  70. var $error = ''; // Submission Error
  71. var $single_parts = array(); // Parts of a page: text, form, images, content
  72. var $conditionals = array(); // Conditionals
  73. var $mimes = '';
  74. // Changeable Class Variables
  75. var $default_folders = array('Inbox', 'Sent');
  76. var $max_folders = 10; // Maximum number of folders per user
  77. var $per_page = 25; // Messages on a Folder's Page
  78. var $graph_width = '300'; // Width of Total Messages Graph
  79. var $emoticons_per_row = 5; // Number of Images Per Table Row
  80. var $delete_expiration = 30; // Erase deleted messages after X days
  81. var $disable_emoticons = 'n'; // Disable the showing of emoticons
  82. var $spellcheck_enabled = TRUE; // Enabled Spellcheck?
  83. /** -----------------------------------
  84. /** Constructor
  85. /** -----------------------------------*/
  86. function Messages()
  87. {
  88. global $IN, $LANG, $FNS, $PREFS, $SESS;
  89. /** -----------------------------------
  90. /** A Few Things to Define, Batman
  91. /** -----------------------------------*/
  92. $this->member_id = $SESS->userdata['member_id'];
  93. $this->allow_pm = ($SESS->userdata['group_id'] == '1') ? 'y' : $SESS->userdata['can_send_private_messages'];
  94. $this->allow_pm = ($this->allow_pm == 'y' && $SESS->userdata['accept_messages'] == 'y') ? 'y' : 'n';
  95. $this->attach_allowed = $SESS->userdata('can_attach_in_private_messages');
  96. $this->storage_limit = ($SESS->userdata['group_id'] == '1') ? 0 : $SESS->userdata['prv_msg_storage_limit'];
  97. $this->send_limit = $SESS->userdata['prv_msg_send_limit'];
  98. if ( ! defined('AMP')) define('AMP', '&amp;');
  99. if ( ! defined('BR')) define('BR', '<br />');
  100. if ( ! defined('NL')) define('NL', "\n");
  101. if ( ! defined('NBS')) define('NBS', "&nbsp;");
  102. $prefs = array( 'prv_msg_attach_maxsize',
  103. 'prv_msg_attach_total',
  104. 'prv_msg_html_format',
  105. 'prv_msg_auto_links',
  106. 'prv_msg_max_chars',
  107. 'prv_msg_max_attachments'
  108. );
  109. for($i=0, $t = sizeof($prefs); $i < $t; ++$i)
  110. {
  111. if (FALSE !== ($value = $PREFS->ini($prefs[$i])))
  112. {
  113. $name = str_replace('prv_msg_', '', $prefs[$i]);
  114. $this->{$name} = $value;
  115. }
  116. }
  117. $this->upload_path = $PREFS->ini('prv_msg_upload_path', TRUE);
  118. // -----------------------------------
  119. // Nearly every page requires this,
  120. // so just load it for all of them
  121. // -----------------------------------
  122. $LANG->fetch_language_file('messages');
  123. $this->title = $LANG->line('private_messages');
  124. $this->crumb = $LANG->line('private_messages');
  125. $this->images_folder = $PREFS->ini('theme_folder_url', TRUE).'cp_global_images/';
  126. $this->single_parts['path']['image_url'] = $this->images_folder;
  127. /** -----------------------------------
  128. /** Maintenance
  129. /** -----------------------------------*/
  130. srand(time());
  131. if ((rand() % 100) < 5)
  132. {
  133. $this->maintenance();
  134. }
  135. }
  136. /* END */
  137. /** -----------------------------------
  138. /** Determine request
  139. /** -----------------------------------*/
  140. function _determine_request()
  141. {
  142. global $IN;
  143. if ($this->allegiance == 'cp')
  144. {
  145. $this->base_url = BASE.AMP.'C=myaccount'.AMP.'M=messages'.AMP.'P=';
  146. $this->form_url = 'C=myaccount'.AMP.'M=messages'.AMP.'P=';
  147. $this->request = ($IN->GBL('P') !== FALSE) ? $IN->GBL('P') : 'inbox';
  148. }
  149. else
  150. {
  151. $this->form_url = $this->base_url;
  152. }
  153. }
  154. /* END */
  155. /** -----------------------------------
  156. /** Create Path
  157. /** -----------------------------------*/
  158. function _create_path($uri='', $hidden='')
  159. {
  160. if ($this->allegiance == 'user')
  161. {
  162. return $this->base_url.$uri.'/';
  163. }
  164. else
  165. {
  166. return $this->base_url.$uri.$hidden;
  167. }
  168. }
  169. /* END */
  170. // -----------------------------------
  171. // Process Page :
  172. // Convert and Template into Content
  173. // -----------------------------------
  174. function _process_template($template, $data = '')
  175. {
  176. global $LANG, $REGX;
  177. /** -------------------------------
  178. /** Process Conditionals
  179. /** -------------------------------*/
  180. if (sizeof($this->conditionals) > 0)
  181. {
  182. foreach($this->conditionals as $key => $value)
  183. {
  184. if ($value == 'y')
  185. {
  186. $template = preg_replace("/\{if\s+".$key."\}(.+?)\{\/if\}/si", "\\1", $template);
  187. $template = preg_replace("/\{if\s+not_".$key."\}(.+?)\{\/if\}/si", '', $template);
  188. }
  189. else
  190. {
  191. $template = preg_replace("/\{if\s+".$key."\}.+?\{\/if\}/si", '', $template);
  192. $template = preg_replace("/\{if\s+not_".$key."\}(.+?)\{\/if\}/si", "\\1", $template);
  193. }
  194. }
  195. }
  196. /** --------------------------
  197. /** Process any sent data
  198. /** --------------------------*/
  199. if (is_array($data) && sizeof($data) > 0)
  200. {
  201. foreach($data as $key => $value)
  202. {
  203. $template = str_replace(LD.$key.RD, $value, $template);
  204. }
  205. }
  206. /** -----------------------------
  207. /** Process any universal data
  208. /** -----------------------------*/
  209. if (sizeof($this->single_parts) > 0)
  210. {
  211. foreach($this->single_parts as $key => $value)
  212. {
  213. if (is_array($value) && sizeof($value) > 0)
  214. {
  215. foreach($value as $key2 => $value2)
  216. {
  217. if (is_array($value2) && sizeof($value2) > 0)
  218. {
  219. foreach($value2 as $key3 => $value3)
  220. {
  221. $template = str_replace(LD.$key.':'.$key2.':'.$key3.RD, $value3, $template);
  222. }
  223. }
  224. else
  225. {
  226. if ($key == 'input' && $key2 == 'body')
  227. {
  228. $value2 = $REGX->encode_ee_tags($value2, TRUE);
  229. }
  230. $template = str_replace(LD.$key.':'.$key2.RD,
  231. ($key == 'input' && $key2 != 'body' && $key2 != 'folder_name') ? htmlspecialchars($value2, ENT_QUOTES) : $value2,
  232. $template);
  233. }
  234. }
  235. }
  236. elseif( ! is_array($value))
  237. {
  238. if ($key != 'title' && ! stristr($value, '<option')) $value = htmlspecialchars($value, ENT_QUOTES); // {title} is link title for message menu
  239. $template = str_replace(LD.$key.RD, $value, $template);
  240. }
  241. }
  242. }
  243. /** -------------------------------------
  244. /** Finally, process all language text
  245. /** -------------------------------------*/
  246. if (isset($LANG->language) && is_array($LANG->language) && sizeof($LANG->language) > 0)
  247. {
  248. foreach($LANG->language as $key => $value)
  249. {
  250. $template = str_replace(LD.'lang:'.$key.RD, $value, $template);
  251. }
  252. }
  253. return $template;
  254. }
  255. /* END */
  256. /** -----------------------------------
  257. /** Manage Request
  258. /** -----------------------------------*/
  259. function manager()
  260. {
  261. global $PREFS;
  262. if ($this->allow_pm != 'y')
  263. {
  264. return;
  265. }
  266. $this->_determine_request();
  267. if (sizeof($this->folders) == 0)
  268. {
  269. $this->fetch_folders();
  270. }
  271. if ($this->disable_emoticons == 'y')
  272. {
  273. $PREFS->core_ini['enable_emoticons'] = 'n';
  274. }
  275. /** -----------------------------------
  276. /** Call request
  277. /** -----------------------------------*/
  278. if (method_exists($this, $this->request))
  279. {
  280. $this->{$this->request}();
  281. }
  282. else
  283. {
  284. $this->inbox();
  285. }
  286. /* -----------------------------------
  287. /* Member Module - Fixeroo
  288. /* - Rick has some legacy code in the member module that converts
  289. /* certain path variables automatically. We, however, do not want that
  290. /* in our most precious Private Messages, and so we do a bit of conversion
  291. /* -----------------------------------*/
  292. $this->return_data = preg_replace("/".LD."\s*path=(.*?)".RD."/", '&#123;path=\\1}', $this->return_data);
  293. $this->return_data = preg_replace("#".LD."\s*(profile_path\s*=.*?)".RD."#", '&#123;\\1}', $this->return_data);
  294. /** -----------------------------------
  295. /** Name to ID in Form Switch - Fixeroo
  296. /** -----------------------------------*/
  297. $this->return_data = str_replace('opener.document.submit_message.', "opener.document.getElementById('submit_message').", $this->return_data);
  298. }
  299. /* END */
  300. /** -----------------------------------
  301. /** Fetch Buddy and Block Lists
  302. /** -----------------------------------*/
  303. function fetch_lists($which='')
  304. {
  305. global $DB;
  306. if ($which == 'buddy')
  307. {
  308. $this->goodies = array();
  309. $this->buddies = array();
  310. }
  311. elseif($which == 'blocked')
  312. {
  313. $this->baddies = array();
  314. $this->blocked = array();
  315. }
  316. else
  317. {
  318. $this->goodies = array();
  319. $this->buddies = array();
  320. $this->baddies = array();
  321. $this->blocked = array();
  322. }
  323. $extra = ($which != '') ? "AND l.listed_type = '{$which}'" : '';
  324. $query = $DB->query("SELECT l.*, m.username, m.screen_name, m.member_id
  325. FROM exp_message_listed l, exp_members m
  326. WHERE l.listed_member = m.member_id
  327. AND l.member_id = '{$this->member_id}'
  328. $extra");
  329. if ($query->num_rows > 0)
  330. {
  331. foreach($query->result as $row)
  332. {
  333. if (empty($row['username']))
  334. {
  335. continue;
  336. }
  337. if ($row['listed_type'] == 'buddy')
  338. {
  339. $this->buddies[] = array($row['listed_member'], $row['username'], $row['screen_name'], $row['listed_description'], $row['listed_id'], $row['member_id']);
  340. $this->goodies[] = $row['listed_member'];
  341. }
  342. else
  343. {
  344. $this->blocked[] = array($row['listed_member'], $row['username'], $row['screen_name'], $row['listed_description'], $row['listed_id'], $row['member_id']);
  345. $this->baddies[] = $row['listed_member'];
  346. }
  347. }
  348. }
  349. }
  350. /* END */
  351. /** -----------------------------------
  352. /** Determine Folders for this User
  353. /** -----------------------------------*/
  354. function fetch_folders()
  355. {
  356. global $DB, $REGX;
  357. $this->folders = array();
  358. $query = $DB->query("SELECT * FROM exp_message_folders WHERE member_id = '{$this->member_id}'");
  359. if ($query->num_rows == 0)
  360. {
  361. $DB->query($DB->insert_string('exp_message_folders', array('member_id' => $this->member_id)));
  362. $this->folders['1'] = array($this->default_folders['0'], '0');
  363. $this->folders['2'] = array($this->default_folders['1'], '0');
  364. }
  365. else
  366. {
  367. $required = array('1' => array($query->row['folder1_name'], '0'), '2' => array($query->row['folder2_name'], '0'));
  368. for($i=3; $i <= $this->max_folders; $i++)
  369. {
  370. $this->folders[$i] = htmlspecialchars($query->row['folder'.$i.'_name'], ENT_QUOTES);
  371. }
  372. asort($this->folders);
  373. foreach($this->folders as $key => $value)
  374. {
  375. $this->folders[$key] = array($value, '0');
  376. }
  377. $this->folders = $required + $this->folders;
  378. $results = $DB->query("SELECT COUNT(*) AS count, message_folder FROM exp_message_copies
  379. WHERE recipient_id = '{$this->member_id}'
  380. AND message_deleted = 'n'
  381. GROUP BY message_folder");
  382. if ($results->num_rows > 0)
  383. {
  384. foreach($results->result as $row)
  385. {
  386. $this->folders[$row['message_folder']]['1'] = $row['count'];
  387. }
  388. }
  389. }
  390. }
  391. /* END */
  392. /** -----------------------------------
  393. /** Edit Folders
  394. /** -----------------------------------*/
  395. function folders()
  396. {
  397. global $LANG, $FNS;
  398. $template = $this->retrieve_template('message_edit_folders');
  399. $rows = $this->retrieve_template('message_edit_folders_row');
  400. $form_details = array('action' => $this->base_url.'edit_folders',
  401. 'id' => 'edit_folders',
  402. 'secure' => ($this->allegiance == 'cp') ? FALSE : TRUE
  403. );
  404. $this->single_parts['form']['form_declaration']['edit_folders'] = $FNS->form_declaration($form_details);
  405. $this->single_parts['include']['current_folders'] = '';
  406. $this->single_parts['include']['new_folder'] = '';
  407. if ( ! isset($this->single_parts['include']['success_message']))
  408. {
  409. $this->single_parts['include']['success_message'] = '';
  410. }
  411. /** -----------------------------------------
  412. /** Create Folder Rows
  413. /** -----------------------------------------*/
  414. $t=1;
  415. foreach($this->folders as $key => $value)
  416. {
  417. if ($value['0'] == '')
  418. {
  419. continue;
  420. }
  421. $t++;
  422. $this->single_parts['lang']['required'] = ($key < 3) ? $LANG->line('folder_required') : '';
  423. $this->single_parts['input']['folder_name'] = $value['0'];
  424. $this->single_parts['input']['folder_id'] = $key;
  425. $this->single_parts['style'] = ($t % 2) ? 'tableCellOne' : 'tableCellTwo';
  426. $this->single_parts['include']['current_folders'] .= $this->_process_template($rows);
  427. }
  428. /** -----------------------------------------
  429. /** Create New Folder Row, If Allowed
  430. /** -----------------------------------------*/
  431. if ($t <= $this->max_folders)
  432. {
  433. $t++;
  434. $this->single_parts['lang']['required'] = '';
  435. $this->single_parts['input']['folder_name'] = '';
  436. $this->single_parts['input']['folder_id'] = 'new';
  437. $this->single_parts['style'] = ($t % 2) ? 'tableCellOne' : 'tableCellTwo';
  438. $this->single_parts['include']['new_folder'] = $this->_process_template($rows);
  439. }
  440. /** ----------------------------------------
  441. /** Return the Folder's Contents
  442. /** ----------------------------------------*/
  443. $this->title = $LANG->line('edit_folders');
  444. $this->crumb = $LANG->line('edit_folders');
  445. $this->return_data = $this->_process_template($template);
  446. }
  447. /* END */
  448. /** -----------------------------------
  449. /** Edit Folders
  450. /** -----------------------------------*/
  451. function edit_folders()
  452. {
  453. global $REGX, $DB, $LANG;
  454. /** -----------------------------------
  455. /** Check Required
  456. /** -----------------------------------*/
  457. if ( ! isset($_POST['folder_1']) OR ! isset($_POST['folder_2']) OR $_POST['folder_1'] == '' OR $_POST['folder_2'] == '')
  458. {
  459. return $this->_error_page('missing_required_field');
  460. }
  461. /** -----------------------------------
  462. /** Get Our Modified Data
  463. /** -----------------------------------*/
  464. for($i=1, $data = array(); $i <= $this->max_folders; $i++)
  465. {
  466. if ( ! isset($_POST['folder_'.$i]) OR $_POST['folder_'.$i] == '')
  467. {
  468. $data['folder'.$i.'_name'] = '';
  469. $DB->query("UPDATE exp_message_copies SET message_deleted = 'y'
  470. WHERE recipient_id = '{$this->member_id}' AND message_folder = '{$i}'");
  471. if ( ! isset($empty)) $empty = 'folder'.$i.'_name';
  472. }
  473. else
  474. {
  475. $data['folder'.$i.'_name'] = $REGX->xss_clean($_POST['folder_'.$i]);
  476. }
  477. }
  478. /** -----------------------------------
  479. /** Get Our New Folder
  480. /** -----------------------------------*/
  481. if (isset($_POST['folder_new']) && $_POST['folder_new'] != '' && isset($empty))
  482. {
  483. $data[$empty] = $REGX->xss_clean($_POST['folder_new']);
  484. }
  485. $DB->query($DB->update_string('exp_message_folders', $data, "member_id = '{$this->member_id}'"));
  486. $this->fetch_folders();
  487. /** -----------------------------------
  488. /** Success Message
  489. /** -----------------------------------*/
  490. $this->single_parts['lang']['message'] = $LANG->line('folders_updated');
  491. $this->single_parts['include']['success_message'] = $this->_process_template($this->retrieve_template('message_success'));
  492. /** ----------------------------------------
  493. /** Return us back to Oz
  494. /** ----------------------------------------*/
  495. return $this->folders();
  496. }
  497. /* END */
  498. /** -----------------------------------
  499. /** Abstracted Default Menu
  500. /** -----------------------------------*/
  501. function abstract_menu()
  502. {
  503. global $LANG, $DB, $SESS, $LOC;
  504. /** ------------------------------
  505. /** Bulletin Board
  506. /** ------------------------------*/
  507. $style = ($SESS->userdata['last_view_bulletins'] <= $SESS->userdata['last_bulletin_date']) ? 'defaultBold' : '';
  508. $this->menu_items['single_items']['bulletin_board'] = array('text' => $LANG->line('bulletin_board'),
  509. 'link' => $this->_create_path('bulletin_board'),
  510. 'image' => '',
  511. 'style' => $style);
  512. /** ------------------------
  513. /** Compose New Message
  514. /** ------------------------*/
  515. $this->menu_items['single_items']['compose_message'] = array('text' => $LANG->line('compose_message'),
  516. 'link' => $this->_create_path('compose'),
  517. 'image' => '',
  518. 'style' => 'defaultBold');
  519. /** ------------------------
  520. /** Drafts Folder
  521. /** ------------------------*/
  522. $query = $DB->query("SELECT COUNT(*) AS count FROM exp_message_data
  523. WHERE sender_id = '{$this->member_id}'
  524. AND message_status = 'draft'");
  525. if ($query->row['count'] > 0)
  526. {
  527. $this->menu_items['repeat_items']['folders'][] = array('text' => $LANG->line('draft_messages') .' ('.$query->row['count'].')',
  528. 'link' => $this->_create_path('drafts'),
  529. 'image' => '',
  530. 'style' => '');
  531. }
  532. /** -------------------------------
  533. /** User Folders
  534. /** -------------------------------*/
  535. if (sizeof($this->folders) == 0)
  536. {
  537. $this->fetch_folders();
  538. }
  539. foreach($this->folders as $key => $value)
  540. {
  541. if ($value['0'] != '')
  542. {
  543. if ($this->allegiance == 'user')
  544. {
  545. $url = $this->base_url.'view_folder/'.$key.'/';
  546. }
  547. else
  548. {
  549. $url = $this->base_url.'view_folder'.AMP.'folder='.$key;
  550. }
  551. $this->menu_items['repeat_items']['folders'][] = array('text' => ' - '.$value['0'].' ('.$value['1'].')',
  552. 'link' => $url,
  553. 'image' => '',
  554. 'style' => '');
  555. }
  556. }
  557. /** ------------------------
  558. /** Deleted Folder
  559. /** ------------------------*/
  560. $query = $DB->query("SELECT COUNT(*) AS count FROM exp_message_copies
  561. WHERE recipient_id = '{$this->member_id}'
  562. AND message_deleted = 'y'");
  563. $this->menu_items['repeat_items']['folders'][] = array('text' => $LANG->line('deleted_messages').' ('.$query->row['count'].')',
  564. 'link' => $this->_create_path('deleted'),
  565. 'image' => '',
  566. 'style' => '');
  567. /* ------------------------
  568. // Message Tracking
  569. // ------------------------
  570. $this->menu_items['single_items']['track_messages'] = array('text' => $LANG->line('track_messages'),
  571. 'link' => $this->_create_path('track'),
  572. 'image' => '',
  573. 'style' => '');
  574. */
  575. /** ------------------------
  576. /** Edit Message Folders
  577. /** ------------------------*/
  578. $this->menu_items['single_items']['edit_folders'] = array('text' => $LANG->line('edit_folders'),
  579. 'link' => $this->_create_path('folders'),
  580. 'image' => '',
  581. 'style' => '');
  582. /** ------------------------
  583. /** Buddy List
  584. /** ------------------------*/
  585. $this->menu_items['single_items']['buddy_list'] = array('text' => $LANG->line('buddy_list'),
  586. 'link' => $this->_create_path('buddies'),
  587. 'image' => '',
  588. 'style' => '');
  589. /** ------------------------
  590. /** Block List
  591. /** ------------------------*/
  592. $this->menu_items['single_items']['block_list'] = array('text' => $LANG->line('blocked_list'),
  593. 'link' => $this->_create_path('blocked'),
  594. 'image' => '',
  595. 'style' => '');
  596. }
  597. /* END */
  598. /** -----------------------------------
  599. /** Create Messages Menu
  600. /** -----------------------------------*/
  601. function create_menu()
  602. {
  603. global $DB, $DSP, $IN, $LANG;
  604. if ($this->allow_pm == 'n')
  605. {
  606. return;
  607. }
  608. $this->_determine_request();
  609. $this->abstract_menu();
  610. /** --------------------------------
  611. /** Open/Close JavaScript
  612. /** --------------------------------*/
  613. if ($IN->GBL('myaccount_messages', 'COOKIE') && $IN->GBL('myaccount_messages', 'COOKIE') == 'on')
  614. {
  615. $text = '[-]';
  616. $hidden_style = '';
  617. }
  618. else
  619. {
  620. $text = '[+]';
  621. $hidden_style = 'display: none; padding:0;';
  622. }
  623. $hidden_link = '<a href="javascript:void(0);" id="extLink1" class="altLinks" onclick="showHide(1,this);return false;">'.$text.'</a>';
  624. /** --------------------------------
  625. /** Create Menu
  626. /** --------------------------------*/
  627. $map = array('bulletin_board', 'compose_message', 'folders', 'edit_folders', 'buddy_list', 'block_list');
  628. if ($this->allegiance == 'cp')
  629. {
  630. /** --------------------------------
  631. /** Menu Section + JavaScript
  632. /** --------------------------------*/
  633. $expand = '<img src="'.PATH_CP_IMG.'expand.gif" border="0" width="10" height="10" alt="Expand" />&nbsp;&nbsp;';
  634. $collapse = '<img src="'.PATH_CP_IMG.'collapse.gif" border="0" width="10" height="10" alt="Collapse" />&nbsp;&nbsp;';
  635. $pm_state = ($IN->GBL('M') == 'messages') ? TRUE : FALSE;
  636. $this->menu .= '<div id="menu_pm_h" style="display: '.(($pm_state == TRUE) ? 'none' : 'block').'; padding:0; margin: 0;">';
  637. $js = ' onclick="showhide_menu(\'menu_pm\');return false;" onmouseover="navTabOn(\'pmx\', \'tableHeadingAlt\', \'tableHeadingAltHover\');" onmouseout="navTabOff(\'pmx\', \'tableHeadingAlt\', \'tableHeadingAltHover\');" ';
  638. $this->menu .= $DSP->div();
  639. $this->menu .= "<div class='tableHeadingAlt' id='pmx' ".$js.">";
  640. $this->menu .= $expand.$LANG->line('private_messages');
  641. $this->menu .= $DSP->div_c();
  642. $this->menu .= $DSP->div_c();
  643. $this->menu .= $DSP->div_c();
  644. $this->menu .= '<div id="menu_pm_b" style="display: '.(($pm_state == TRUE) ? 'block' : 'none').'; padding:0; margin: 0;">';
  645. $js = ' onclick="showhide_menu(\'menu_pm\');return false;" onmouseover="navTabOn(\'pmx2\', \'tableHeadingAlt\', \'tableHeadingAltHover\');" onmouseout="navTabOff(\'pmx2\', \'tableHeadingAlt\', \'tableHeadingAltHover\');" ';
  646. $this->menu .= $DSP->div();
  647. $this->menu .= "<div class='tableHeadingAlt' id='pmx2' ".$js.">";
  648. $this->menu .= $collapse.$LANG->line('private_messages');
  649. $this->menu .= $DSP->div_c();
  650. $this->menu .= $DSP->div('profileMenuInner');
  651. /** --------------------------------
  652. /** Create Menu Based on Item Map
  653. /** --------------------------------*/
  654. foreach($map as $item)
  655. {
  656. if (isset($this->menu_items['repeat_items'][$item]))
  657. {
  658. foreach($this->menu_items['repeat_items'][$item] as $item_member)
  659. {
  660. $this->create_item($item_member);
  661. }
  662. }
  663. else
  664. {
  665. $this->create_item($this->menu_items['single_items'][$item]);
  666. }
  667. }
  668. $this->menu .= $DSP->div_c().$DSP->div_c().$DSP->div_c();
  669. }
  670. else
  671. {
  672. $template = $this->retrieve_template('message_menu');
  673. $rows = $this->retrieve_template('message_menu_rows');
  674. $this->single_parts['include']['hide_menu_style'] = $hidden_style;
  675. $this->single_parts['include']['hide_menu_link'] = $hidden_link;
  676. $this->single_parts['include']['hide_menu_js'] = $this->showhide_js();
  677. $this->single_parts['include']['menu_items'] = '';
  678. foreach($map as $item)
  679. {
  680. if (isset($this->menu_items['repeat_items'][$item]))
  681. {
  682. foreach($this->menu_items['repeat_items'][$item] as $item_member)
  683. {
  684. $this->single_parts['title'] = $item_member['text'];
  685. $this->single_parts['link'] = $item_member['link'];
  686. $this->single_parts['include']['menu_items'] .= $this->_process_template($rows);
  687. }
  688. }
  689. else
  690. {
  691. $this->single_parts['title'] = $this->menu_items['single_items'][$item]['text'];
  692. $this->single_parts['link'] = $this->menu_items['single_items'][$item]['link'];
  693. $this->single_parts['include']['menu_items'] .= $this->_process_template($rows);
  694. }
  695. }
  696. $this->menu = $this->_process_template($template);
  697. }
  698. }
  699. /* END */
  700. /** -----------------------------------
  701. /** Create Menu Item
  702. /** -----------------------------------*/
  703. function create_item($data)
  704. {
  705. global $DB, $DSP;
  706. $this->menu .= $DSP->div(($data['style'] != '') ? $data['style'] : 'navPad').
  707. $DSP->anchor($data['link'], $data['text']).
  708. $DSP->div_c();
  709. }
  710. /* END */
  711. // -----------------------------------
  712. // Inbox
  713. // This function is kind of superfluous, but I find it comforting
  714. // to know that there is an inbox function for a messaging system.
  715. // Besides, it makes it a tad easier to understand certain parts
  716. // of the code to have this function called opposed to what is
  717. // really being calling. That is all, move along now...
  718. // -----------------------------------
  719. function inbox()
  720. {
  721. $this->view_folder('1');
  722. }
  723. /* END */
  724. /** -----------------------------------
  725. /** Deleted Messages
  726. /** -----------------------------------*/
  727. function deleted()
  728. {
  729. $this->view_folder('0');
  730. }
  731. /* END */
  732. /** -----------------------------------
  733. /** View Folder Contents
  734. /** -----------------------------------*/
  735. function drafts()
  736. {
  737. global $LANG, $DB, $OUT, $IN, $LOC, $PREFS;
  738. $row_count = 0; // How many rows shown this far (i.e. offset)
  739. if ($this->allegiance == 'user')
  740. {
  741. $row_count = $this->cur_id;
  742. }
  743. else
  744. {
  745. $row_count = ($IN->GBL('page', 'GP') === false) ? 0 : $IN->GBL('page', 'GP');
  746. }
  747. if ( ! is_numeric($row_count))
  748. {
  749. $row_count = 0;
  750. }
  751. $this->single_parts['lang']['folder_id'] = '1';
  752. $this->single_parts['lang']['folder_name'] = $LANG->line('draft_messages');
  753. $this->conditionals['paginate'] = 'n';
  754. $this->conditionals['drafts_folder'] = 'y';
  755. $this->conditionals['sent_folder'] = 'n';
  756. $this->conditionals['trash_folder'] = 'n';
  757. $this->conditionals['regular_folder'] = 'n';
  758. /** ---------------------------------------
  759. /** Retrieve Folder Contents Query
  760. /** ---------------------------------------*/
  761. $dql = "SELECT
  762. exp_message_data.sender_id,
  763. exp_message_data.message_date,
  764. exp_message_data.message_id,
  765. exp_message_data.message_subject,
  766. exp_message_data.message_recipients,
  767. exp_message_data.message_cc,
  768. exp_message_data.message_attachments,
  769. exp_members.screen_name as sender,
  770. exp_members.username as sender_username ";
  771. $sql = "FROM exp_message_data
  772. LEFT JOIN exp_members ON exp_members.member_id = exp_message_data.sender_id
  773. WHERE exp_message_data.message_status = 'draft'
  774. AND exp_message_data.sender_id = '{$this->member_id}'
  775. ORDER BY exp_message_data.message_date ";
  776. /** ----------------------------------------
  777. /** Run "count" query for pagination
  778. /** ----------------------------------------*/
  779. $query = $DB->query("SELECT COUNT(exp_message_data.message_id) AS count ".$sql);
  780. /** ----------------------------------------
  781. /** If No Messages, we say so.
  782. /** ----------------------------------------*/
  783. if ($query->row['count'] == 0)
  784. {
  785. $this->title = $LANG->line('draft_messages');
  786. $this->crumb = $LANG->line('draft_messages');
  787. $this->single_parts['include']['folder_rows'] = $this->retrieve_template('message_no_folder_rows');
  788. $this->single_parts['form']['form_declaration']['modify_messages'] = '';
  789. $this->return_data = $this->folder_wrapper(($folder_id == '0') ? 'n' : 'y');
  790. return;
  791. }
  792. /** ----------------------------------------
  793. /** Determine Current Page
  794. /** ----------------------------------------*/
  795. $current_page = ($row_count / $this->per_page) + 1;
  796. $total_pages = intval($query->row['count'] / $this->per_page);
  797. if ($query->row['count'] % $this->per_page)
  798. {
  799. $total_pages++;
  800. }
  801. $this->single_parts['include']['page_count'] = $LANG->line('folder_page').' '.$current_page.' '.$LANG->line('of').' '.$total_pages;
  802. /** -----------------------------
  803. /** Do we need pagination?
  804. /** -----------------------------*/
  805. $pager = '';
  806. if ($query->row['count'] > $this->per_page)
  807. {
  808. if ( ! class_exists('Paginate'))
  809. {
  810. require PATH_CORE.'core.paginate'.EXT;
  811. }
  812. $PGR = new Paginate();
  813. if ($this->allegiance == 'user')
  814. {
  815. $PGR->path = $this->_create_path('drafts');
  816. }
  817. else
  818. {
  819. $PGR->base_url = $this->_create_path('drafts');
  820. $PGR->qstr_var = 'page';
  821. }
  822. $PGR->total_count = $query->row['count'];
  823. $PGR->per_page = $this->per_page;
  824. $PGR->cur_page = $row_count;
  825. $this->single_parts['include']['pagination_link'] = $PGR->show_links();
  826. $this->conditionals['paginate'] = 'y';
  827. $sql .= " LIMIT ".$row_count.", ".$this->per_page;
  828. }
  829. /** ----------------------------------------
  830. /** Retrieve Folder Contents
  831. /** ----------------------------------------*/
  832. $folder_rows_template = $this->retrieve_template('message_folder_rows');
  833. $r = '';
  834. $i = 0;
  835. $censor = FALSE;
  836. if ($PREFS->ini('enable_censoring') == 'y' && $PREFS->ini('censored_words') != '')
  837. {
  838. if ( ! class_exists('Typography'))
  839. {
  840. require PATH_CORE.'core.typography'.EXT;
  841. }
  842. $TYPE = new Typography(0);
  843. $censor = TRUE;
  844. }
  845. $query = $DB->query($dql.$sql);
  846. foreach($query->result as $row)
  847. {
  848. ++$i;
  849. $data = $row;
  850. $data['msg_id'] = 'd'.$row['message_id'];
  851. $data['message_date'] = $LOC->set_human_time($data['message_date']);
  852. $data['style'] = ($i % 2) ? 'tableCellTwo' : 'tableCellOne';
  853. $data['message_subject'] = ($censor === FALSE) ? $data['message_subject'] : $TYPE->filter_censored_words($data['message_subject']);
  854. if ($this->allegiance == 'user')
  855. {
  856. $data['message_url'] = $this->base_url.'compose/'.$row['message_id'].'/';
  857. }
  858. else
  859. {
  860. $data['message_url'] = $this->base_url.'compose'.AMP.'msg='.$row['message_id'];
  861. }
  862. $data['message_status'] = '';
  863. // This Requires Extra Queries and Processing
  864. // So We Only Do It When Those Variables Are Found
  865. if (stristr($folder_rows_template, '{recipients}') !== FALSE)
  866. {
  867. $data['recipients'] = htmlspecialchars($this->convert_recipients($row['message_recipients']), ENT_QUOTES);
  868. }
  869. if (stristr($folder_rows_template, '{cc}') !== FALSE)
  870. {
  871. $data['cc'] = htmlspecialchars($this->convert_recipients($row['message_cc']), ENT_QUOTES);
  872. }
  873. $r .= $this->_process_template($folder_rows_template, $data);
  874. }
  875. $this->single_parts['include']['folder_rows'] = $r;
  876. /** ----------------------------------------
  877. /** Return the Folder's Contents
  878. /** ----------------------------------------*/
  879. $this->title = $LANG->line('draft_messages');
  880. $this->crumb = $LANG->line('draft_messages');
  881. $this->return_data = $this->folder_wrapper('y', 'n', 'n');
  882. }
  883. /* END */
  884. /** -----------------------------------
  885. /** View Folder Contents
  886. /** -----------------------------------*/
  887. function view_folder($folder_id='')
  888. {
  889. global $LANG, $DB, $OUT, $IN, $LOC, $PREFS;
  890. // ---------------------------------
  891. // Find Requested Folder ID
  892. // $IN->QSTR - User
  893. // $IN->GBL('folder', 'GP') - CP
  894. // ---------------------------------
  895. $row_count = 0; // How many rows shown this far (i.e. offset)
  896. if ($folder_id == '')
  897. {
  898. if ($this->allegiance == 'user')
  899. {
  900. // Unknown, probably will have to do something similar to
  901. // the list of members where we have to create
  902. // a pseudo-query string in one of the URI segments
  903. // folder_pagenum : 1_1
  904. if ($this->cur_id == '')
  905. {
  906. $folder_id = 1;
  907. }
  908. else
  909. {
  910. $x = explode('_', $this->cur_id);
  911. $folder_id = ( ! is_numeric($x['0'])) ? 1 : $x['0'];
  912. $row_count = ( ! isset($x['1']) OR ! is_numeric($x['1'])) ? 0 : $x['1'];
  913. }
  914. }
  915. else
  916. {
  917. $folder_id = ($IN->GBL('folder', 'GP') === false) ? '1' : $IN->GBL('folder', 'GP');
  918. $row_count = ($IN->GBL('page', 'GP') === false) ? 0 : $IN->GBL('page', 'GP');
  919. }
  920. }
  921. if ( ! is_numeric($folder_id) OR $folder_id > $this->max_folders)
  922. {
  923. $folder_id = '1';
  924. }
  925. if ( ! is_numeric($row_count))
  926. {
  927. $row_count = 0;
  928. }
  929. /** ---------------------------------------
  930. /** Retrieve Folder Name for User
  931. /** ---------------------------------------*/
  932. if ($folder_id == '0')
  933. {
  934. $folder_name = $LANG->line('deleted_messages');
  935. }
  936. elseif ( ! isset($this->folders[$folder_id]['0']) OR $this->folders[$folder_id]['0'] == '')
  937. {
  938. if ($this->allegiance == 'cp')
  939. {
  940. return $DSP->no_access_message();
  941. }
  942. else
  943. {
  944. return $OUT->show_user_error('general', array($LANG->line('not_authorized')));
  945. }
  946. }
  947. else
  948. {
  949. $folder_name = $this->folders[$folder_id]['0'];
  950. }
  951. $this->single_parts['lang']['folder_name'] = $LANG->line('messages_folder').' - '.$folder_name;
  952. $this->single_parts['lang']['folder_id'] = $folder_id;
  953. $this->current_folder = $folder_id;
  954. $this->conditionals['paginate'] = 'n';
  955. /** -----------------------------------
  956. /** Folder Conditionals
  957. /** -----------------------------------*/
  958. $this->conditionals['drafts_folder'] = 'n';
  959. $this->conditionals['sent_folder'] = 'n';
  960. $this->conditionals['trash_folder'] = 'n';
  961. $this->conditionals['regular_folder'] = 'n';
  962. if ($folder_id == '0')
  963. {
  964. $this->conditionals['trash_folder'] = 'y';
  965. }
  966. elseif ($folder_id == '2')
  967. {
  968. $this->conditionals['sent_folder'] = 'y';
  969. }
  970. else
  971. {
  972. $this->conditionals['regular_folder'] = 'y';
  973. }
  974. /** ---------------------------------------
  975. /** Retrieve Folder Contents Query
  976. /** ---------------------------------------*/
  977. $dql = "SELECT
  978. exp_message_copies.message_status,
  979. exp_message_copies.message_id,
  980. exp_message_copies.message_read,
  981. exp_message_copies.copy_id as msg_id,
  982. exp_message_data.sender_id,
  983. exp_message_data.message_date,
  984. exp_message_data.message_subject,
  985. exp_message_data.message_recipients,
  986. exp_message_data.message_cc,
  987. exp_message_data.message_attachments,
  988. exp_members.screen_name as sender,
  989. exp_members.username as sender_username ";
  990. $sql = "FROM exp_message_copies
  991. LEFT JOIN exp_message_data ON exp_message_data.message_id = exp_message_copies.message_id
  992. LEFT JOIN exp_members ON exp_members.member_id = exp_message_copies.sender_id
  993. WHERE exp_message_copies.recipient_id = '{$this->member_id}' ";
  994. if ($folder_id == '0')
  995. {
  996. $sql .= "AND exp_message_copies.message_deleted = 'y' ";
  997. }
  998. else
  999. {
  1000. $sql .= "AND exp_message_copies.message_folder = '{$folder_id}'
  1001. AND exp_message_copies.message_deleted = 'n' ";
  1002. }
  1003. $sql .= "AND exp_message_data.message_status = 'sent'
  1004. ORDER BY exp_message_data.message_date desc";
  1005. /** ----------------------------------------
  1006. /** Run "count" query for pagination
  1007. /** ----------------------------------------*/
  1008. $query = $DB->query("SELECT COUNT(exp_message_copies.copy_id) AS count ".$sql);
  1009. /** ----------------------------------------
  1010. /** If No Messages, we say so.
  1011. /** ----------------------------------------*/
  1012. if ($query->row['count'] == 0)
  1013. {
  1014. $this->title = $folder_name;
  1015. $this->crumb = $folder_name;
  1016. $this->single_parts['include']['folder_rows'] = $this->retrieve_template('message_no_folder_rows');
  1017. $this->single_parts['form']['form_declaration']['modify_messages'] = '';
  1018. $this->return_data = $this->folder_wrapper(($folder_id == '0') ? 'n' : 'y');
  1019. return;
  1020. }
  1021. /** ----------------------------------------
  1022. /** Determine Current Page
  1023. /** ----------------------------------------*/
  1024. $current_page = ($row_count / $this->per_page) + 1;
  1025. $total_pages = intval($query->row['count'] / $this->per_page);
  1026. if ($query->row['count'] % $this->per_page)
  1027. {
  1028. $total_pages++;
  1029. }
  1030. $this->single_parts['include']['page_count'] = $LANG->line('folder_page').' '.$current_page.' '.$LANG->line('of').' '.$total_pages;
  1031. /** -----------------------------
  1032. /** Do we need pagination?
  1033. /** -----------------------------*/
  1034. $pager = '';
  1035. if ($query->row['count'] > $this->per_page)
  1036. {
  1037. if ( ! class_exists('Paginate'))
  1038. {
  1039. require PATH_CORE.'core.paginate'.EXT;
  1040. }
  1041. $PGR = new Paginate();
  1042. if ($this->allegiance == 'user')
  1043. {
  1044. $PGR->path = $this->base_url.'view_folder/'.$folder_id.'_';
  1045. }
  1046. else
  1047. {
  1048. $PGR->base_url = $this->base_url.'view_folder'.AMP.'folder='.$folder_id;
  1049. $PGR->qstr_var = 'page';
  1050. }
  1051. $PGR->total_count = $query->row['count'];
  1052. $PGR->per_page = $this->per_page;
  1053. $PGR->cur_page = $row_count;
  1054. $this->single_parts['include']['pagination_link'] = $PGR->show_links();
  1055. $this->conditionals['paginate'] = 'y';
  1056. $sql .= " LIMIT ".$row_count.", ".$this->per_page;
  1057. }
  1058. $censor = FALSE;
  1059. if ($PREFS->ini('enable_censoring') == 'y' && $PREFS->ini('censored_words') != '')
  1060. {
  1061. $censor = TRUE;
  1062. if ( ! class_exists('Typography'))
  1063. {
  1064. require PATH_CORE.'core.typography'.EXT;
  1065. }
  1066. $TYPE = new Typography(0);
  1067. }
  1068. /** ----------------------------------------
  1069. /** Retrieve Folder Contents
  1070. /** ----------------------------------------*/
  1071. $message_ids = array();
  1072. $folder_rows_template = $this->retrieve_template('message_folder_rows');
  1073. $i = 0;
  1074. $r = '';
  1075. $query = $DB->query($dql.$sql);
  1076. foreach($query->result as $row)
  1077. {
  1078. $i++;
  1079. $data = $row;
  1080. $message_ids[] = $row['message_id'];
  1081. $data['msg_id'] = ($row['message_read'] == 'n') ? 'u'.$row['msg_id'] : $row['msg_id'];
  1082. $data['buddy_list_link'] = '';
  1083. $data['block_list_link'] = '';
  1084. $data['message_date'] = $LOC->set_human_time($data['message_date']);
  1085. $data['style'] = ($i % 2) ? 'tableCellTwo' : 'tableCellOne';
  1086. if ($censor == TRUE)
  1087. {
  1088. $data['message_subject'] = $TYPE->filter_censored_words($row['message_subject']);
  1089. }
  1090. if ($this->allegiance == 'user')
  1091. {
  1092. $data['message_url'] = $this->base_url.'view_message/'.$row['msg_id'].'/';
  1093. //$data['buddy_list_link'] = $this->_create_path('add_buddy').$row['sender_id'].'/';
  1094. //$data['block_list_link'] = $this->_create_path('add_block').$row['sender_id'].'/';
  1095. }
  1096. else
  1097. {
  1098. $data['message_url'] = $this->base_url.'view_message'.AMP.'msg='.$row['msg_id'];
  1099. //$data['buddy_list_link'] = $this->_create_path('add_buddy').AMP.'id='.$row['sender_id'];
  1100. //$data['block_list_link'] = $this->_create_path('add_block').AMP.'id='.$row['sender_id'];
  1101. }
  1102. // --------------------------------
  1103. // Message Status Entities:
  1104. // &bull; - unread
  1105. // &rarr; - forwarded
  1106. // &crarr; - Reply
  1107. // --------------------------------
  1108. if ($row['message_status'] == 'replied')
  1109. {
  1110. $data['message_status'] = '&crarr;';
  1111. }
  1112. elseif ($row['message_status'] == 'forwarded')
  1113. {
  1114. $data['message_status'] = '&rarr;';
  1115. }
  1116. elseif ($row['message_read'] == 'y')
  1117. {
  1118. $data['message_status'] = '';
  1119. }
  1120. elseif($row['message_read'] == 'n')
  1121. {
  1122. $data['message_status'] = '&bull;';
  1123. }
  1124. // This Requires Extra Queries and Processing
  1125. // So We Only Do It When Those Variables Are Found
  1126. if (stristr($folder_rows_template, '{recipients}') !== FALSE)
  1127. {
  1128. $data['recipients'] = htmlspecialchars($this->convert_recipients($row['message_recipients']), ENT_QUOTES);
  1129. }
  1130. if (stristr($folder_rows_template, '{cc}') !== FALSE)
  1131. {
  1132. $data['cc'] = htmlspecialchars($this->convert_recipients($row['message_cc']), ENT_QUOTES);
  1133. }
  1134. $r .= $this->_process_template($folder_rows_template, $data);
  1135. }
  1136. $this->single_parts['include']['folder_rows'] = $r;
  1137. /** ----------------------------------------
  1138. /** If Displayed, Messages are Received (not read)
  1139. /** ----------------------------------------*/
  1140. if (sizeof($message_ids) > 0 && $this->block_tracking == 'n')
  1141. {
  1142. $DB->query("UPDATE exp_message_copies SET message_received = 'y'
  1143. WHERE recipient_id = '{$this->member_id}'
  1144. AND message_id IN ('".implode("','",$message_ids)."')");
  1145. }
  1146. /** ----------------------------------------
  1147. /** Return the Folder's Contents
  1148. /** ----------------------------------------*/
  1149. $this->title = $folder_name;
  1150. $this->crumb = $folder_name;
  1151. $this->return_data = $this->folder_wrapper(($folder_id == '0') ? 'n' : 'y');
  1152. }
  1153. /* END */
  1154. /** ----------------------------------------
  1155. /** Wrapper for a Folder and its Contents
  1156. /** ----------------------------------------*/
  1157. function folder_wrapper($deleted='y', $moved='y', $copied = 'y')
  1158. {
  1159. global $FNS;
  1160. $folder_template = $this->retrieve_template('message_folder');
  1161. $this->folders_pulldown();
  1162. $this->single_parts['include']['hidden_js'] = $this->hidden_js();
  1163. $this->single_parts['include']['toggle_js'] = $this->toggle_js();
  1164. $this->single_parts['path']['compose_message'] = $this->_create_path('compose');
  1165. $this->single_parts['path']['erase_messages'] = $this->_create_path('erase');
  1166. $details = array('hidden_fields' => array('this_folder' => $this->single_parts['lang']['folder_id'], 'daction' => ''),
  1167. 'action' => $this->_create_path('modify_messages'),
  1168. 'id' => 'target',
  1169. 'enctype' => 'multi',
  1170. 'secure' => ($this->allegiance == 'cp') ? FALSE : TRUE
  1171. );
  1172. $this->single_parts['form']['form_declaration']['modify_messages'] = $FNS->form_declaration($details);
  1173. /** ---------------------------------
  1174. /** Move, Copy, Delete Buttons
  1175. /** ---------------------------------*/
  1176. $this->_buttons($deleted, $moved, $copied);
  1177. /** -------------------------------
  1178. /** Storage Graph
  1179. /** -------------------------------*/
  1180. if ( ! isset($this->single_parts['image']['messages_graph']))
  1181. {
  1182. $this->storage_graph();
  1183. }
  1184. return $this->_process_template($folder_template);
  1185. }
  1186. /* END */
  1187. /** ----------------------------------------
  1188. /** Buttons for Various Pages
  1189. /** ----------------------------------------*/
  1190. function _buttons($deleted='y', $moved='y', $copied = 'y')
  1191. {
  1192. global $LANG;
  1193. $style = 'buttons';
  1194. /** ---------------------------------
  1195. /** Move, Copy, Delete Buttons
  1196. /** ---------------------------------*/
  1197. if ($deleted == 'n')
  1198. {
  1199. $this->single_parts['form']['delete_button'] = '';
  1200. }
  1201. else
  1202. {
  1203. $this->single_parts['form']['delete_button'] = "<button type='submit' id='delete' name='delete' value='delete' ".
  1204. "class='{$style}' title='{lang:delete_selected}' ".
  1205. "onclick='dynamic_action(\"delete\");'>".
  1206. "{lang:messages_delete}</button> ";
  1207. }
  1208. if ($moved == 'n')
  1209. {
  1210. $this->single_parts['form']['move_button'] = '';
  1211. }
  1212. else
  1213. {
  1214. $this->single_parts['form']['move_button'] = "<button type='submit' id='move' name='move' value='move' ".
  1215. "class='{$style}' title='{lang:move_selected}' ".
  1216. "onclick='dynamic_move();return false;'>".
  1217. "{lang:messages_move}</button>".NBS.NBS;
  1218. }
  1219. if ($copied == 'n')
  1220. {
  1221. $this->single_parts['form']['copy_button'] = '';
  1222. }
  1223. else
  1224. {
  1225. $this->single_parts['form']['copy_button'] = "<button type='submit' id='copy' name='copy' value='copy' ".
  1226. "class='{$style}' title='{lang:copy_selected}' ".
  1227. "onclick='dynamic_copy();return false;'>".
  1228. "{lang:messages_copy}</button>".NBS.NBS;
  1229. }
  1230. $this->single_parts['form']['forward_button'] = "<button type='submit' id='forward' name='forward' value='forward' ".
  1231. "…

Large files files are truncated, but you can click here to view the full file