Browse files

Copy to draft feature (#340)

* Copy to draft feature

* bugfix in sql query

* Modified and inserted additional insert queries per bramley's suggestions.
Now copies data from messagedata and listmessage tables.
  • Loading branch information...
rolanyang authored and samtuke committed Jul 2, 2018
1 parent 9720cd1 commit df4bd188db708ce2075ad1d5756d34aa1e6bf75c
Showing with 26 additions and 0 deletions.
  1. +26 −0 public_html/lists/admin/messages.php
@@ -157,6 +157,27 @@
$action_result .= "<hr /><br />\n";
if (isset($_GET['duplicate'])) {
Sql_Query(sprintf('insert into %s (uuid, subject, fromfield, tofield, replyto, message, textmessage, footer, entered,
modified, embargo, repeatuntil, repeatinterval, requeueinterval, status, htmlformatted, sendformat, template, rsstemplate, owner)
select "%s", subject, fromfield, tofield, replyto, message, textmessage, footer, now(),
now(), now(), now(), repeatinterval, requeueinterval, "draft", htmlformatted,
sendformat, template, rsstemplate, "%d" from %s
where id = %d',
$GLOBALS['tables']['message'], (string) Uuid::generate(4), $_SESSION['logindetails']['id'],$GLOBALS['tables']['message'],
if ($newId = Sql_Insert_Id()) { // if we don't have a newId then the copy failed
Sql_Query(sprintf('insert into %s (id,name,data) '.
'select %d,name,data from %s where name in ("sendmethod","sendurl","campaigntitle","excludelist","subject") and id = %d',
Sql_Query(sprintf('insert into %s (messageid, listid, entered) select %d, listid, now() from %s where messageid = %d',
if (isset($_GET['resend'])) {
$resend = sprintf('%d', $_GET['resend']);
@@ -604,6 +625,11 @@
if ($msg['status'] == 'sent') {
$actionbuttons .= '<span class="edit">'.PageLinkButton('messages', s('Copy to Draft'),
'tab=draft&duplicate='.$msg['id'], '', s('Copy to Draft')).'</span>';
$ls->addColumn($listingelement, $GLOBALS['I18N']->get('Action'),
'<div class="messageactions">'.$actionbuttons.'</div>');

0 comments on commit df4bd18

Please sign in to comment.