18 require_once SQ_INCLUDE_PATH.
'/asset_edit/asset_edit_fns.inc';
19 require_once SQ_LIB_PATH.
'/html_form/html_form.inc';
45 $this->static_screens = Array (
'details' => Array (
'name' => translate(
'inbox'),
'use_tab' => TRUE,
'force_unlock' => FALSE,
'lock_type' =>
'mail',),);
62 $user = $asset->_getUser();
64 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
65 $messages = $ms->getMessages($user->id, NULL, Array (SQ_MSG_UNREAD, SQ_MSG_READ), Array (), NULL, NULL,
'name');
66 $write_access = $asset->writeAccess(
'mail');
69 <style type=
"text/css">
70 @
import url(<?php echo sq_web_path(
'data')?>/asset_types/inbox/css/inbox.css.php);
73 <table border=
"0" cellspacing=
"2" cellpadding=
"2" width=
"100%">
75 <td valign=
"top"><?php echo translate(
'to'); ?>:</td>
77 <?php multiple_asset_finder($prefix.
'_To', Array(), Array(
'user' =>
'D')); ?>
81 <td valign=
"top"><?php echo translate(
'subject'); ?>:</td>
83 <input type=
"text" id=
"<?php echo $prefix; ?>_Subject" name=
"<?php echo $prefix; ?>_Subject" style=
"width:300px" />
87 <td valign=
"top"><?php echo translate(
'priority'); ?>:</td>
89 <select
id=
"<?php echo $prefix; ?>_Priority" name=
"<?php echo $prefix; ?>_Priority" style=
"float:left; width: 100px;">
90 <option value=
"1"><?php echo translate(
'highest'); ?></option>
91 <option value=
"2"><?php echo translate(
'high'); ?></option>
92 <option value=
"3" selected=
"selected"><?php echo translate(
'standard'); ?></option>
93 <option value=
"4"><?php echo translate(
'low'); ?></option>
94 <option value=
"5"><?php echo translate(
'lowest'); ?></option>
100 <textarea cols=
"3" rows=
"3" style=
"clear:both; width: 95%; height: 250px" id=
"<?php echo $prefix; ?>_Content" name=
"<?php echo $prefix; ?>_Content"></textarea>
108 <div style=
"text-align: center"><?php echo translate(
'inbox_lock'); ?></div>
113 return $write_access;
130 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
133 if (isset ($_POST[$prefix.
'_To'])) {
134 $userid = $GLOBALS[
'SQ_SYSTEM']->currentUserId();
136 $recepients = Array ();
137 foreach ($_POST[$prefix.
'_To'] as $key => $sender) {
138 $recepients[] = $sender[
'assetid'];
142 'subject' => $_POST[$prefix.
'_Subject'],
143 'body' => $_POST[$prefix.
'_Content'],
146 $message = $ms->newMessage($recepients,
'inbox.message', $msg_reps);
147 $message->priority = $_POST[$prefix.
'_Priority'];
150 foreach ($recepients as $key => $sender) {
151 if (empty ($sender))
continue;
153 $message = $ms->newMessage(Array ($userid),
'inbox.sent', $msg_reps);
154 $message->from = $sender;
155 $message->status =
'R';
156 $message->priority = $_POST[$prefix.
'_Priority'];
161 if ($noaction) echo
'<!-- ###No Action### -->';
178 $user = $asset->_getUser();
180 $priority = Array (
'',
'Highest',
'High',
'Normal',
'Low',
'Lowest');
182 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
183 $messages = $ms->getMessages($user->id, NULL, Array (SQ_MSG_UNREAD, SQ_MSG_READ), Array (), NULL, NULL,
'name');
184 $write_access = $asset->writeAccess(
'mail');
185 $num_messages = count($messages);
187 <style type=
"text/css">
188 @
import url(<?php echo sq_web_path(
'data')?>/asset_types/inbox/css/inbox.css.php);
190 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib'); ?>/js/JsHttpConnector.js"></script>
191 <script type=
"text/javascript">
193 var prefix =
"<?php echo $prefix; ?>";
194 var Bodies =
new Object();
197 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data'); ?>/asset_types/inbox/js/inbox.js"></script>
198 <div
id=
"inbox_container">
199 <table border=
"0" cellspacing=
"0" cellpadding=
"1" width=
"100%" id=
"inbox_table">
201 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'to')); ?></td>
202 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'subject')); ?></td>
203 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'sent')); ?></td>
208 <td
class=
"sq-backend-table-header">
209 <?php check_box($prefix.
'_delete_all',
'1', FALSE,
'changeAllDelStatuses(this.checked)'); ?>
210 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"trashIcon" class=
"trash" onclick=
"changeAllStatuses()" />
211 <?php echo strtoupper(translate(
'delete')); ?>
221 for ($i = 0; $i < $num_messages; $i ++) {
223 $data = $messages[$i];
224 if ($data[
'type'] !=
'inbox.sent')
continue;
227 $sender_img = $GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($data[
'type_code']);
229 $body = preg_replace(
"/[\n\t\r]/im",
'<br />', $data[
'body']);
230 $body = str_replace(
'"',
'"', $body);
232 <script type=
"text/javascript">
234 Bodies[
"<?php echo $data['msgid'];?>"] =
"<?php echo $body; ?>";
238 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
239 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/internal_message/priority_'.$data[
'priority'].
'.png', 16, 16,
'', $priority[$data[
'priority']].
' priority') ?>
240 <?php sq_print_icon($sender_img, 16, 16) ?>
241 <a name=
"msg_<?php echo $data['msgid'];?>"></a>
242 <?php echo $data[
'from_name'];?>
243 <?php hidden_field($prefix.
'_messages['.$data[
'msgid'].
']',
'1'); ?>
245 <td
class=
"sq-backend-table-cell" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
246 <?php echo $data[
'subject'];?>
248 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
249 <?php echo $GLOBALS[
'SQ_SYSTEM']->datetime($data[
'sent']); ?>
255 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
256 <?php check_box($prefix.
'_delete['.$data[
'msgid'].
']',
'1', FALSE,
'changeStatus('.$data[
'msgid'].
')'); ?>
257 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"trashIcon<?php echo $data['msgid'];?>" class=
"trash" onclick=
"changeStatus('<?php echo $data['msgid'];?>')" />
270 <div
id=
"sq_message_body"></div>
274 return $write_access;
291 $delete = (isset ($_POST[$prefix.
'_delete'])) ? array_keys($_POST[$prefix.
'_delete']) : Array();
293 if (empty($delete)) {
297 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
299 foreach ($delete as $messageid) {
301 $message = $ms->getMessageById($messageid);
302 if (!$message->updateStatus(SQ_MSG_DELETED)) {
303 trigger_localised_error(
'CORE0063', E_USER_WARNING, $messageid);
324 $user = $asset->_getUser();
326 $priority = Array (
'',
'Highest',
'High',
'Normal',
'Low',
'Lowest');
328 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
329 $messages = $ms->getMessages($user->id, NULL, Array (SQ_MSG_UNREAD, SQ_MSG_READ), Array (), NULL, NULL,
'name');
330 $write_access = $asset->writeAccess(
'mail');
333 $num_messages = count($messages);
336 for ($i = 0; $i < $num_messages; $i ++) {
337 $data = $messages[$i];
338 if ($data[
'status'] == SQ_MSG_UNREAD) {
341 if ($data[
'type'] ==
'inbox.sent') {
348 <script type=
"text/javascript" src=
"<?php echo sq_web_path('lib'); ?>/js/JsHttpConnector.js"></script>
349 <script type=
"text/javascript">
351 var prefix =
"<?php echo urlencode($prefix); ?>";
352 var Bodies =
new Object();
355 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data'); ?>/asset_types/inbox/js/inbox.js"></script>
356 <style type=
"text/css">
357 @
import url(<?php echo sq_web_path(
'data')?>/asset_types/inbox/css/inbox.css.php);
359 <div
id=
"inbox_container">
362 if ($num_inbox == 0) {
363 echo
'<div style="text-align: center">Your inbox is empty.</div></div>';
365 $num_per_page = $GLOBALS[
'SQ_SYSTEM']->getUserPrefs(
'inbox',
'SQ_INBOX_MAIL_PER_PAGE');
366 if (empty($num_per_page)) $num_per_page = 20;
367 $total_assets = $num_inbox;
368 $num_pages = ceil($total_assets / $num_per_page);
370 $link_offset = array_get_index($_POST, $prefix.
'_link_offset', 0);
373 if ( (round(($link_offset + $num_per_page) / $num_per_page)) > (ceil($total_assets / $num_per_page)) ) {
374 $link_offset = (ceil($total_assets / $num_per_page)-1)*$num_per_page;
377 <!-- start print pagination bar top -->
378 <table
class=
"sq-backend-table">
379 <tr><td
class=
"sq-backend-table-header-header"><b>
381 hidden_field($prefix.
'_link_offset', $link_offset);
382 if ($link_offset > 0) {
384 <a title=
"<?php echo translate('pagination_go_to_first') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_link_offset', '0'); set_hidden_field('process_form', '0'); submit_form(); return false;">
387 ?><span title=
"<?php echo translate('pagination_cannot_go_further_back') ?>" style=
"color: #333"><?php
392 if ($link_offset > 0) {
397 ?> <?php
398 if ($link_offset > 0) {
399 ?><a title=
"<?php echo translate('pagination_go_to_previous') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_link_offset', '<?php echo $link_offset - $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
401 ?><span title=
"<?php echo translate('pagination_cannot_go_further_back') ?>" style=
"color: #333"><?php
406 if ($link_offset > 0) {
412 <?php echo translate(
'page_number', round(($link_offset + $num_per_page) / $num_per_page), ceil($total_assets / $num_per_page)); ?>
414 if (($link_offset + $num_per_page) < $total_assets) {
415 ?><a title=
"<?php echo translate('pagination_go_to_next') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_link_offset', '<?php echo $link_offset + $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
417 ?><span title=
"<?php echo translate('pagination_cannot_go_further_forward') ?>" style=
"color: #333"><?php
422 if (($link_offset + $num_per_page) < $total_assets) {
427 ?> <?php
428 if (($link_offset + $num_per_page) < $total_assets) {
429 ?><a title=
"<?php echo translate('pagination_go_to_last') ?>" style=
"text-decoration: none; color: #fff" href=
"#" onClick=
"Javascript: set_hidden_field('<?php echo $prefix ?>_link_offset', '<?php echo ($num_pages - 1) * $num_per_page; ?>'); set_hidden_field('process_form', '0'); submit_form(); return false;"><?php
431 ?><span title=
"<?php echo translate('pagination_cannot_go_further_forward') ?>" style=
"color: #333"><?php
436 if (($link_offset + $num_per_page) < $total_assets) {
444 <!-- end print pagination bar -->
445 <table border=
"0" cellspacing=
"0" cellpadding=
"1" id=
"inbox_table">
447 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'from')); ?></td>
448 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'subject')); ?></td>
449 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'sent')); ?></td>
450 <td
class=
"sq-backend-table-header">
455 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"letterIcon" class=
"read" />
460 <?php echo strtoupper(translate(
'read')); ?>
466 <td
class=
"sq-backend-table-header">
467 <?php check_box($prefix.
'_delete_all',
'1', FALSE,
'changeAllDelStatuses(this.checked)'); ?>
468 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"trashIcon" class=
"trash" />
469 <?php echo strtoupper(translate(
'delete')); ?>
479 for ($i = 0; $i < $num_messages; $i ++) {
481 $data = $messages[$i];
482 if ($data[
'type'] ==
'inbox.sent')
continue;
484 if (($total_assets < $link_offset) || (($link_offset+$num_per_page-1) < $total_assets)) {
490 $sender_img = $GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($data[
'type_code']);
491 $body = preg_replace(
"/[\n\t\r]/im",
'<br />', $data[
'body']);
492 $body = str_replace(
'"',
'\"', $body);
494 <script type=
"text/javascript">
497 Bodies[
"<?php echo $data['msgid'];?>"] =
"<?php echo $body; ?>";
501 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
502 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/internal_message/priority_'.$data[
'priority'].
'.png', 16, 16,
'', $priority[$data[
'priority']].
' priority') ?>
503 <?php sq_print_icon($sender_img, 16, 16) ?>
504 <a name=
"msg_<?php echo $data['msgid'];?>"></a>
505 <?php echo $data[
'from_name'];?>
506 <?php hidden_field($prefix.
'_messages['.$data[
'msgid'].
']',
'1'); ?>
508 <td
class=
"sq-backend-table-cell" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
509 <?php echo $data[
'subject'];?>
511 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
512 <?php echo $GLOBALS[
'SQ_SYSTEM']->datetime($data[
'sent']); ?>
514 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
517 check_box(urlencode($prefix).
'_mark_as_read['.$data[
'msgid'].
']',
'1', ($data[
'status'] == SQ_MSG_READ),
'readClick(this)', ($write_access) ?
'' :
'style="display:none"');
519 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"letterIcon[<?php echo $data['msgid'];?>]" class=
"<?php echo (($data['status'] == SQ_MSG_UNREAD) ? 'un' : ''); ?>read" onclick=
"readClick(this)" />
525 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap">
526 <?php check_box($prefix.
'_delete['.$data[
'msgid'].
']',
'1', FALSE,
'changeStatus('.$data[
'msgid'].
')'); ?>
527 <img src=
"<?php echo sq_web_path('lib'); ?>/web/images/blank.gif" alt=
"" id=
"trashIcon[<?php echo $data['msgid'];?>]" class=
"trash" onclick=
"changeStatus('<?php echo $data['msgid'];?>', 'delete')" />
540 <script type=
"text/javascript">
545 <div
id=
"sq_message_body"></div>
552 return $write_access;
568 $msgs = (isset ($_REQUEST[$prefix.
'_messages'])) ? array_keys($_REQUEST[$prefix.
'_messages']) : Array ();
569 $read = (isset ($_REQUEST[$prefix.
'_mark_as_read'])) ? array_keys($_REQUEST[$prefix.
'_mark_as_read']) : Array ();
575 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
577 foreach ($msgs as $msgid) {
578 $message = $ms->getMessageById($msgid);
579 if (in_array($msgid, $read) && $message->status == SQ_MSG_UNREAD) {
580 if (!$message->updateStatus(SQ_MSG_READ)) {
581 trigger_localised_error(
'CORE0076', E_USER_WARNING, $msgid);
585 if (!in_array($msgid, $read) && $message->status == SQ_MSG_READ) {
586 if (!$message->updateStatus(SQ_MSG_UNREAD)) {
587 trigger_localised_error(
'CORE0076', E_USER_WARNING, $msgid);
607 $msgs = (isset ($_POST[$prefix.
'_messages'])) ? array_keys($_POST[$prefix.
'_messages']) : Array ();
608 $delete = (isset ($_POST[$prefix.
'_delete'])) ? array_keys($_POST[$prefix.
'_delete']) : Array ();
614 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
616 foreach ($msgs as $msgid) {
617 $message = $ms->getMessageById($msgid);
618 if (in_array($msgid, $delete) && $message->status != SQ_MSG_DELETED) {
619 if (!$message->updateStatus(SQ_MSG_DELETED)) {
620 trigger_localised_error(
'CORE0063', E_USER_WARNING, $data[
'msgid']);
625 $o->addOnLoad(
'if (parent.frames["sidenav"] && parent.frames["sidenav"].refresh_internal_messages) parent.frames["sidenav"].refresh_internal_messages();');
644 $user = $asset->_getUser();
646 $priority = Array(
'',
'Highest',
'High',
'Normal',
'Low',
'Lowest');
648 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
649 $messages = $ms->getMessages($user->id, NULL, Array(SQ_MSG_DELETED), Array(), NULL, NULL,
'name');
650 $write_access = $asset->writeAccess(
'mail');
652 <style type=
"text/css">
653 @
import url(<?php echo sq_web_path(
'data')?>/asset_types/inbox/css/inbox.css.php);
655 <script type=
"text/javascript" >
657 var Bodies =
new Object();
658 var prefix =
"<?php echo $prefix; ?>";
661 <script type=
"text/javascript" src=
"<?php echo sq_web_path('data'); ?>/asset_types/inbox/js/inbox.js"></script>
664 if (empty($messages)) {
665 ?><div style=
"text-align: center"><?php echo translate(
'inbox_trash_empty'); ?></div><?php
669 <div
id=
"inbox_container">
671 <table border=
"0" cellspacing=
"0" cellpadding=
"1" id=
"inbox_table">
673 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'from')); ?></td>
674 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'subject')); ?></td>
675 <td
class=
"sq-backend-table-header"><?php echo strtoupper(translate(
'sent')); ?></td>
680 <td
class=
"sq-backend-table-header">
681 <?php check_box($prefix.
'_select_all_recover',
'1', FALSE,
'check_all(document.main_form, "'.$prefix.
'_recover", this.checked);'); ?>
682 <?php echo strtoupper(translate(
'recover')); ?>
684 <td
class=
"sq-backend-table-header">
685 <?php check_box($prefix.
'_select_all_purge',
'1', FALSE,
'check_all(document.main_form, "'.$prefix.
'_purge", this.checked);'); ?>
686 <?php echo strtoupper(translate(
'purge')); ?>
695 $num_messages = count($messages);
697 for ($i = 0; $i < $num_messages; $i ++) {
699 $data = $messages[$i];
702 $sender_img = $GLOBALS[
'SQ_SYSTEM']->am->getAssetIconURL($data[
'type_code']);
704 $body = preg_replace(
"/[\n\t\r]/im",
'<br />', $data[
'body']);
705 $body = str_replace(
'"',
'\"', $body);
707 <script type=
"text/javascript">
709 Bodies[
"<?php echo $data['msgid'];?>"] =
"<?php echo $body; ?>";
713 <td
class=
"sq-backend-table-cell" nowrap=
"nowrap" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
714 <?php sq_print_icon(sq_web_path(
'lib').
'/web/images/icons/internal_message/priority_'.$data[
'priority'].
'.png', 16, 16,
'', $priority[$data[
'priority']].
' priority') ?>
715 <?php sq_print_icon($sender_img, 16, 16) ?>
716 <a name=
"msg_<?php echo $data['msgid'];?>"></a>
717 <?php echo $data[
'from_name'];?>
718 <?php hidden_field($prefix.
'_messages['.$data[
'msgid'].
']',
'1'); ?>
720 <td
class=
"sq-backend-table-cell" onclick=
"showBody('<?php echo $data['msgid'];?>', this)" style=
"cursor: pointer">
721 <?php echo $data[
'subject'];?>
723 <td
class=
"sq-backend-table-cell" onclick=
"showBody('<?php echo $data['msgid'];?>', this);" style=
"cursor: pointer;white-space: nowrap;">
724 <?php echo $GLOBALS[
'SQ_SYSTEM']->datetime($data[
'sent']); ?>
731 <td
class=
"sq-backend-table-cell" nowrap>
734 if ($asset->writeAccess(
'mail')) {
735 check_box($prefix.
'_recover['.$data[
'msgid'].
']');
742 <td
class=
"sq-backend-table-cell" nowrap>
743 <?php check_box($prefix.
'_purge['.$data[
'msgid'].
']'); ?>
756 <div
id=
"sq_message_body"></div>
778 $msgs = (isset ($_POST[$prefix.
'_messages'])) ? array_keys($_POST[$prefix.
'_messages']) : Array();
779 $recover = (isset ($_POST[$prefix.
'_recover'])) ? array_keys($_POST[$prefix.
'_recover']) : Array();
780 $purge = (isset ($_POST[$prefix.
'_purge'])) ? array_keys($_POST[$prefix.
'_purge']) : Array();
786 $ms = $GLOBALS[
'SQ_SYSTEM']->getMessagingService();
788 if (!empty ($recover)) {
789 foreach ($recover as $messageid) {
791 $message = $ms->getMessageById($messageid);
792 if (!$message->updateStatus(SQ_MSG_READ)) {
793 trigger_localised_error(
'CORE0064', E_USER_WARNING, $messageid);
798 if (!empty ($purge)) {
799 foreach ($purge as $messageid) {
801 $message = $ms->getMessageById($messageid);
802 if (!$message->delete()) {
803 trigger_localised_error(
'CORE0063', E_USER_WARNING, $data[
'msgid']);