Skip to content

Commit

Permalink
Set ownerid of invite campaign to 1 for fresh new installations (#380)
Browse files Browse the repository at this point in the history
* Set ownerid to 1 for fresh new installations

Signed-off-by: Xheni Myrtaj <myrtajxheni@gmail.com>

*  backwards compatibility, better variable name and PHPdoc

Signed-off-by: Xheni Myrtaj <myrtajxheni@gmail.com>
  • Loading branch information
xh3n1 authored and michield committed Jul 29, 2018
1 parent 6f795f6 commit d1d6ce3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion public_html/lists/admin/initialise.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function output($message)
SaveConfig('organisation_name', strip_tags($_REQUEST['adminemail']), 1);
}
// add a draft campaign for invite plugin
addInviteCampaign();
addInviteCampaign(1);
// add a testlist
$info = s('List for testing');
$result = Sql_query("insert into {$tables['list']} (name,description,entered,active,owner) values(\"test\",\"$info\",now(),0,1)");
Expand Down
12 changes: 10 additions & 2 deletions public_html/lists/admin/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1479,12 +1479,16 @@ function addSubscriberStatistics($item, $amount, $list = 0)
}
}


/**
* Insert a draft campaign for use with the Invite plugin
* @param null|int $forcedOwnerId
* @return bool|mysqli_result
* @throws Exception
* @todo Make the campaign content translatable
* @todo Add Campaign Meta Title to clarify purpose of this draft
*/
function addInviteCampaign() {
function addInviteCampaign($forcedOwnerId = null) {

$message =
'<p>Hi [FIRST NAME%%there], remember us? You first signed up for our email newsletter on&nbsp;[ENTERED] &ndash; please click here to confirm you&#39;re happy to continue receiving our messages:</p>
Expand All @@ -1502,7 +1506,11 @@ function addInviteCampaign() {
$inviteMessage = addslashes($message);
$inviteMessageSubject = "Do you want to continue receiving our messages?";
$uuid = uuid::generate(4);
$ownerid = $_SESSION['logindetails']['id'];
if ( $forcedOwnerId !== null) {
$ownerid = $forcedOwnerId;
} else {
$ownerid = $_SESSION['logindetails']['id'];
}
$footer = sql_escape(getConfig('messagefooter'));
$result = Sql_query("insert into {$GLOBALS['tables']['message']} (uuid,subject,message,entered, status, owner, footer, sendformat) values(\"$uuid\",\"$inviteMessageSubject\",\"$inviteMessage\",now(),\"draft\",\"$ownerid\",\"$footer\",\"invite\" )");

Expand Down

0 comments on commit d1d6ce3

Please sign in to comment.