PageRenderTime 72ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/system/expressionengine/libraries/Messages.php

https://bitbucket.org/tdevonshire/hoolux
PHP | 5249 lines | 4593 code | 359 blank | 297 comment | 199 complexity | a6729e73dc11ea75ddbd542e5527bf56 MD5 | raw file

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

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

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