Skip to content

Commit

Permalink
support of multi message deletions
Browse files Browse the repository at this point in the history
  • Loading branch information
chilek committed Sep 8, 2016
1 parent 319b9da commit 63cb523
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 13 deletions.
1 change: 1 addition & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ version ?.??.?? (????-??-??):
- allow to select company/division for mass invoice printing [chilan]
- defined html class multi-check which allows tbodies function with multi
select elements on lists [chilan]
- support of multi message deletions [chilan]

version 1.11.20 (2016-04-19):

Expand Down
1 change: 1 addition & 0 deletions lib/locale/pl/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
$_LANG['Are you sure, you want to delete that device?'] = 'Jesteś pewien, że chcesz usunąć to urządzenie?';
$_LANG['Are you sure, you want to delete that event?'] = 'Jesteś pewien, że chcesz usunąć ten wpis?';
$_LANG['Are you sure, you want to delete that message?'] = 'Jesteś pewien, że chcesz usunąć tę wiadomość?';
$_LANG['Are you sure, you want to delete all selected messages?'] = 'Jesteś pewien, że chcesz usunąć wszystkie wybrane wiadomości?';
$_LANG['Are you sure, you want to delete that network?'] = 'Jesteś pewien, że chcesz usunąć tę sieć?';
$_LANG['Are you sure, you want to delete that payment?'] = 'Jesteś pewien, że chcesz usunąć tę płatność?';
$_LANG['Are you sure, you want to delete that tariff?'] = 'Jesteś pewien, że chcesz usunąć tę taryfę?';
Expand Down
27 changes: 18 additions & 9 deletions modules/messagedel.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2013 LMS Developers
* (C) Copyright 2001-2016 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
Expand All @@ -24,15 +24,24 @@
* $Id$
*/

if (isset($_GET['id']) && $_GET['is_sure'] == '1') {
$id = intval($_GET['id']);
if ($id) {
$DB->BeginTrans();
$DB->Execute('DELETE FROM messageitems WHERE messageid = ?', array($id));
$DB->Execute('DELETE FROM messages WHERE id = ?', array($id));
$DB->CommitTrans();
if ($_GET['is_sure'] == '1')
if (isset($_GET['id'])) {
$id = intval($_GET['id']);
if ($id) {
$DB->BeginTrans();
$DB->Execute('DELETE FROM messageitems WHERE messageid = ?', array($id));
$DB->Execute('DELETE FROM messages WHERE id = ?', array($id));
$DB->CommitTrans();
}
} elseif (isset($_POST['marks']) && $_GET['is_sure'] == '1') {
$ids = implode(',', array_map('intval', $_POST['marks']));
if (!empty($ids)) {
$DB->BeginTrans();
$DB->Execute('DELETE FROM messageitems WHERE messageid IN (' . $ids . ')');
$DB->Execute('DELETE FROM messages WHERE id IN (' . $ids . ')');
$DB->CommitTrans();
}
}
}

$SESSION->redirect('?'.$SESSION->get('backto'));

Expand Down
28 changes: 24 additions & 4 deletions templates/default/message/messagelist.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
{block name=module_content}
<!--// $Id$ //-->
<H1>{$layout.pagetitle}</H1>
<script type="text/javascript">
<!--
function delete_messages() {
if (confirmLink(this, '{trans("Are you sure, you want to delete all selected messages?")}')) {
document.page.action = '?m=messagedel';
document.page.submit();
}
}
//-->
</script>
<form method="post" name="page">
<TABLE class="lmsbox">
<COLGROUP>
<COL style="width: 1%;">
Expand Down Expand Up @@ -76,7 +87,7 @@ <H1>{$layout.pagetitle}</H1>
</TR>
{/if}
</THEAD>
<TBODY>
<TBODY class="multi-check">
{cycle values="light,lucid" print=false}
{section name=messagelist loop=$messagelist start=$start max=$pagelimit}
{assign var=message value=$messagelist[messagelist]}
Expand All @@ -95,15 +106,16 @@ <H1>{$layout.pagetitle}</H1>
<img src="img/sms.gif" alt="sms">
{/if}
</TD>
<TD class="bold" onclick="return self.location.href='?m=messageinfo&amp;id={$message.id}';">
{$message.subject}
<TD class="bold">
<span onclick="return self.location.href='?m=messageinfo&amp;id={$message.id}';">{$message.subject}</span>
</TD>
<TD class="text-right nobr" onclick="return self.location.href='?m=messageinfo&amp;id={$message.id}';">
{$message.cnt|default:0}
</TD>
<TD class="text-right nobr">
<A onclick="return confirmLink(this, '{trans("Are you sure, you want to delete that message?")}')" href="?m=messagedel&amp;id={$message.id}"><IMG src="img/delete.gif" alt="[ {trans("Delete")} ]" title="[ {trans("Delete")} ]"></A>
<A href="?m=messageinfo&amp;id={$message.id}"><IMG src="img/info.gif" alt="[ {trans("Info")} ]" title="[ {trans("Info")} ]"></A>
<input type="checkbox" name="marks[{$message.id}]" value="{$message.id}"{if $marks.messageid} checked{/if}>
</TD>
</TR>
{sectionelse}
Expand All @@ -125,10 +137,18 @@ <H1>{$layout.pagetitle}</H1>
<TR>
<TD colspan="2" class="nobr">
</TD>
<TD colspan="3" class="bold">
<TD class="bold">
{t a=$listdata.total}Total: $a{/t}
</TD>
<TD colspan="2" class="text-right nobr">
<a onclick="javascript:delete_messages();">{trans("Delete")} <img src="img/delete.gif" alt="{trans("Delete")}"></a>&nbsp;
<label>
{trans("Check All")}
<INPUT TYPE="checkbox" NAME="allbox" onchange="CheckAll('page', this, [])" VALUE="1">
</label>
</TD>
</TR>
</TFOOT>
</TABLE>
</form>
{/block}

0 comments on commit 63cb523

Please sign in to comment.