diff --git a/lib/class/privatemsg.class.php b/lib/class/privatemsg.class.php index 374d083e..703a4efb 100644 --- a/lib/class/privatemsg.class.php +++ b/lib/class/privatemsg.class.php @@ -124,6 +124,12 @@ class PrivateMsg extends database_object return Dba::write($sql, array($read ? 1 : 0, $this->id)); } + public function delete() + { + $sql = "DELETE FROM `user_pvmsg` WHERE `id` = ?"; + return Dba::write($sql, array($this->id)); + } + public static function create(array $data) { $subject = trim(strip_tags($data['subject'])); diff --git a/lib/javascript/dynamicpage.js b/lib/javascript/dynamicpage.js index 11bcbb93..2fcc21d5 100644 --- a/lib/javascript/dynamicpage.js +++ b/lib/javascript/dynamicpage.js @@ -104,7 +104,7 @@ $(function() { }, error: function(jqXHR, status, errorThrown) { - // Display error here? + alert(errorThrown); } }); diff --git a/pvmsg.php b/pvmsg.php index 5d49a269..8cc8fc2a 100644 --- a/pvmsg.php +++ b/pvmsg.php @@ -45,6 +45,8 @@ switch ($action) { require_once AmpConfig::get('prefix') . '/templates/show_add_pvmsg.inc.php'; break; case 'add_message': + if (AmpConfig::get('demo_mode')) { break; } + // Remove unauthorized defined values from here if (isset($_POST['from_user'])) { unset($_POST['from_user']); @@ -65,14 +67,69 @@ switch ($action) { show_confirmation($title, $body, AmpConfig::get('web_path') . '/browse.php?action=pvmsg'); } break; + case 'set_is_read': + if (AmpConfig::get('demo_mode')) { break; } + + $msgs = split(",", $_REQUEST['msgs']); + foreach ($msgs as $msg_id) { + $pvmsg = new PrivateMsg(intval($msg_id)); + if ($pvmsg->id && $pvmsg->to_user === $GLOBALS['user']->id) { + $read = intval($_REQUEST['read']) !== 0; + $pvmsg->set_is_read($read); + } else { + debug_event('UI::access_denied', 'Unknown or unauthorized private message `' . $pvmsg->id . '`.', '3'); + UI::access_denied(); + exit(); + } + } + + show_confirmation(T_('Messages State Changed'), T_('Messages state have been changed.'), AmpConfig::get('web_path') . "/browse.php?action=pvmsg"); + break; + case 'delete': + if (AmpConfig::get('demo_mode')) { break; } + + $msgs = scrub_out($_REQUEST['msgs']); + show_confirmation( + T_('Message Deletion'), + T_('Are you sure you want to permanently delete the selected messages?'), + AmpConfig::get('web_path')."/pvmsg.php?action=confirm_delete&msgs=" . $msgs, + 1, + 'delete_message' + ); + break; + case 'confirm_delete': + if (AmpConfig::get('demo_mode')) { break; } + + $msgs = split(",", $_REQUEST['msgs']); + foreach ($msgs as $msg_id) { + $msg_id = intval($msg_id); + $pvmsg = new PrivateMsg($msg_id); + if ($pvmsg->id && $pvmsg->to_user === $GLOBALS['user']->id) { + $pvmsg->delete(); + } else { + debug_event('UI::access_denied', 'Unknown or unauthorized private message #' . $msg_id . '.', '3'); + UI::access_denied(); + exit(); + } + } + + show_confirmation(T_('Messages Deletion'), T_('Messages have been deleted.'), AmpConfig::get('web_path') . "/browse.php?action=pvmsg"); + break; case 'show': default: - $pvmsg = new PrivateMsg($_REQUEST['pvmsg_id']); - $pvmsg->format(); - if (!$pvmsg->is_read) { - $pvmsg->set_is_read(true); + $msg_id = intval($_REQUEST['pvmsg_id']); + $pvmsg = new PrivateMsg($msg_id); + if ($pvmsg->id && $pvmsg->to_user === $GLOBALS['user']->id) { + $pvmsg->format(); + if (!$pvmsg->is_read) { + $pvmsg->set_is_read(true); + } + require_once AmpConfig::get('prefix') . '/templates/show_pvmsg.inc.php'; + } else { + debug_event('UI::access_denied', 'Unknown or unauthorized private message #' . $msg_id . '.', '3'); + UI::access_denied(); + exit(); } - require_once AmpConfig::get('prefix') . '/templates/show_pvmsg.inc.php'; break; } diff --git a/templates/show_denied.inc.php b/templates/show_denied.inc.php index 359e24c2..b4748473 100644 --- a/templates/show_denied.inc.php +++ b/templates/show_denied.inc.php @@ -41,11 +41,11 @@ if (empty($logo_url)) {
Ampache - +
-
+

diff --git a/templates/show_pvmsg_row.inc.php b/templates/show_pvmsg_row.inc.php index 1f1e3796..028cf2cc 100644 --- a/templates/show_pvmsg_row.inc.php +++ b/templates/show_pvmsg_row.inc.php @@ -21,6 +21,7 @@ */ ?> + f_link; ?> f_from_user_link; ?> f_to_user_link; ?> @@ -29,4 +30,7 @@ + + + diff --git a/templates/show_pvmsgs.inc.php b/templates/show_pvmsgs.inc.php index dc361b0d..b29a03a2 100644 --- a/templates/show_pvmsgs.inc.php +++ b/templates/show_pvmsgs.inc.php @@ -22,15 +22,29 @@ $thcount = 5; ?> +
    -
  • +
  • +
  • +
  • +
get_show_header()) require AmpConfig::get('prefix') . '/templates/list_header.inc.php'; ?> + @@ -57,6 +71,7 @@ $thcount = 5; + diff --git a/templates/show_registration_confirmation.inc.php b/templates/show_registration_confirmation.inc.php index 56d21bc5..17a7073c 100644 --- a/templates/show_registration_confirmation.inc.php +++ b/templates/show_registration_confirmation.inc.php @@ -56,7 +56,7 @@ $_SESSION['login'] = true; ?>

-

+

- <?php echo T_('site_title'); ?> - Update + <?php echo AmpConfig::get('site_title'); ?> - Update diff --git a/upnp/MediaServerServiceDesc.php b/upnp/MediaServerServiceDesc.php index 52a6a375..b6a87c2f 100644 --- a/upnp/MediaServerServiceDesc.php +++ b/upnp/MediaServerServiceDesc.php @@ -22,7 +22,7 @@ echo ''; Ampacheampache.orghttp://ampache.org - + Ampachehttp://ampache.org
id . '&type=pvmsg&sort=subject', T_('Subject'),'pvmsg_sort_subject'); ?> id . '&type=pvmsg&sort=from_user', T_('Sender'),'pvmsg_sort_from_user'); ?> id . '&type=pvmsg&sort=to_user', T_('Recipient'),'pvmsg_sort_to_user'); ?>
id . '&type=pvmsg&sort=subject', T_('Subject'),'pvmsg_sort_subject'); ?> id . '&type=pvmsg&sort=from_user', T_('Sender'),'pvmsg_sort_from_user'); ?> id . '&type=pvmsg&sort=to_user', T_('Recipient'),'pvmsg_sort_to_user'); ?>