[mod] Set a default subject to appear in editor subject line

3rd party code for phpList

[mod] Set a default subject to appear in editor subject line

Postby jsherk » 1:46pm, Fri 01 Jun, 2007

Here's a summary of how you can set a DEFAULT SUBJECT in the subject line of the editor:

Thanks to hernol and kuber for the code...

Step 1
ADD "DEFAULT SUBJECT" AS AN OPTION IN THE CONFIGURE MENU:

Open defaultconfig.inc and after this
Code: Select all
"message_from_name" => array("Webmaster",
"What name do system messages appear to come from","text"),
Add this
# what is the default subject for messages without or with a space
"default_subject" => array($D_website." Newsletter",
"What is the default subject","text"),


Step 2
MAKE THE "DEFAULT SUBJECT" APPEAR ON SUBJECT LINE OF EDITOR WHEN YOU CLICK 'Send Message':

Open send_core.php and look for this
Code: Select all
if (!$id) {
$defaulttemplate = getConfig('defaultmessagetemplate');
Sql_Query(sprintf('insert into %s (subject,status,entered,sendformat,embargo,repeatuntil,owner,template,tofield,replyto)
values("(no subject)","draft",now(),"text and HTML",now(),now(),%d,%d,"","")',$GLOBALS["tables"]["message"],$_SESSION["logindetails"]["id"],$defaulttemplate));

Change it to this
Code: Select all
if (!$id) {
$defaulttemplate = getConfig('defaultmessagetemplate');
$default_subject = "'".getConfig('default_subject')."'";
Sql_Query(sprintf('insert into %s (subject,status,entered,sendformat,embargo,repeatuntil,owner,template,tofield,replyto)
values(%s,"draft",now(),"text and HTML",now(),now(),%d,%d,"","")',$GLOBALS["tables"]["message"],$default_subject,$_SESSION["logindetails"]["id"],$defaulttemplate));

Note that there are three changes to the above code:
(i) Added the line $default_subject = "'".getConfig('default_subject')."'";
(ii) Changed "(no subject)" to %s
(iii) inserted $default_subject, just before $_SESSION


Step 3 ***Note that this step is optional. You do not need to implement this 3rd step, if you don't like this feature***
AUTOMATICALLY INSERT "DEFAULT SUBJECT" INTO NEWSLETTER IF THE SUBJECT IS BLANK or SUBJECT IS (no subject):

Open sendemaillib.php and after this
Code: Select all
$cached[$messageid]["fromname"] = trim($cached[$messageid]["fromname"]);
$cached[$messageid]["to"] = $message["tofield"];

Add this
Code: Select all
$default_subject = getConfig("default_subject");
if ($message["subject"] == "" || $message["subject"] == "(no subject)"){
$message["subject"] = $default_subject;
$cached[$messageid]["subject"] = $default_subject;
}
else {
$cached[$messageid]["subject"] = $message["subject"];
}
jsherk
PL Geek
 
Posts: 101
Joined: 11:37pm, Mon 28 May, 2007

Postby H2B2 » 10:38pm, Sat 02 Jun, 2007

Thanks for putting the pieces together. I'll include this in the phplist mods doc: http://docs.phplist.com/PhplistHacks
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby zemda » 1:40pm, Fri 16 May, 2008

Its great.

Is it possible to add automatic Newsletter ID or Issue date next to the 'Newsletter' string ?
zemda
phpLister
 
Posts: 14
Joined: 1:22pm, Fri 16 May, 2008


Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 2 guests