[mod] Monthly repeat hack to send messages

3rd party code for phpList

Monthly Repeat Hack

Postby mjj67 » 8:59am, Tue 05 Jun, 2007

Hello All,

I've been using phplist for a few months now and like it but would really like messages to be repeatable each month, i.e. send on the fourth of the month.

I understand that the reason that this functionality is not there is because the repeat interval is not straight forward like daily, weekly,so I thought I'd try to hack my own.

I realise that if someone has an embargo of 31/05/2007 and applies a one month repeat the effect is not ideal, but I thought that just for a hack I'll assume people don't try to break it. If it works perhaps some kind soul can add some validation code to the send...

So here it is, a really basic hack, please don't laugh too hard

connect.php at line 925:

Code: Select all
if(MONTHLY_REPEAT_HACK)
   {
      // MJJ Hack to do verify that repeat interval is correct.
      $repeatinterval = $msgdata["repeatinterval"];
      if($repeatinterval > 10080)
      {
         $repeatinterval = 1440 * date("t");
         $msgdata = Sql_Fetch_Array_Query(
             sprintf('select *,date_add(embargo,interval %d minute) as newembargo,
            date_add(now(),interval %d minute) as newembargo2, date_add(embargo,interval %d          minute) > now() as isfuture
            from %s where id = %d and repeatuntil > now()',$repeatinterval,$repeatinterval,   $repeatinterval,
            $GLOBALS["tables"]["message"],$msgid));
      }
   }
 


send_core.php: at line 965
Code: Select all
if(MONTHLY_REPEAT_HACK)
   {
      $monthlyrepeat = 1440 * date("t", strtotime($embargo->GetDate()));
      echo $monthlyrepeat . " " . $embargo->GetDate() ;
   }


 at line 983:
   if(MONTHLY_REPEAT_HACK)
     {
         if(date("d", strtotime($embargo->GetDate())) < 29)
         {
             if ($repeatinterval == 10080) { $scheduling_content .= " SELECTED"; }
             $scheduling_content .= '>'.$GLOBALS['I18N']->get("week").'</option>
             <option value="'. $monthlyrepeat . '"';
            if ($repeatinterval > 10080) { $scheduling_content .= " SELECTED"; }
             $scheduling_content .= '>'.$GLOBALS['I18N']->get("month").'</option>
             </select>

             </td></tr>
             </td></tr>
             <tr><td>  '.$GLOBALS['I18N']->get("repeatuntil").':</td><td>'.$repeatuntil->showInput("repeatuntil","",$_POST["repeatuntil"]).'</td></tr>
             </td></tr>';

        }
     }   
     else
     {
        if ($repeatinterval == 10080) { $scheduling_content .= " SELECTED"; }
        $scheduling_content .= '>'.$GLOBALS['I18N']->get("week").'</option>
         </select>

         </td></tr>
         </td></tr>
         <tr><td>  '.$GLOBALS['I18N']->get("repeatuntil").':</td><td>'.$repeatuntil->showInput("repeatuntil","",$_POST["repeatuntil"]).'</td></tr>
    </td></tr>';
     }   
 

config.php
at the end of the file:
define("MONTHLY_REPEAT_HACK", 1);


Code: Select all

lan\en\send.php at line 48
  'month' => 'Month',



The changes are dependent on MONTHLY_REPEAT_HACK = 1 in the config.

Looking forward to (positive) feedback,

Mark

PS, tried to put the code in a zip... no joy...
mjj67
phpLister
 
Posts: 6
Joined: 9:17am, Fri 08 Sep, 2006
Location: United Kingdom

Can you tell me if this works? Also what Functions

Postby john060105 » 1:54pm, Thu 30 Aug, 2007

What functions do the code go into - it doesnt seem to match up with the lines you have - maybe put the bit of code just prior to pasting your code AND if we are to over-write or add to present code. thank you
john060105
phpList newbie
 
Posts: 1
Joined: 1:47pm, Thu 30 Aug, 2007

Postby oneguydoall » 12:50am, Tue 04 Sep, 2007

I'd like to use this hack, how ever I'm a little confused to where this code is to be placed:


Code: Select all
Code:


lan\en\send.php at line 48
  'month' => 'Month',



has anyone gotten this hack to work?

Thanks
oneguydoall
phpList newbie
 
Posts: 1
Joined: 5:27pm, Fri 10 Aug, 2007

Re: [mod] Monthly repeat hack to send messages

Postby H2B2 » 12:09am, Tue 18 Jan, 2011

A possible alternative is to use the repetition feature of phpList: http://docs.phplist.com/Repetition

The following setting might be worth a try.
Code: Select all
 #Start exclude dates for repetition.
#Creating monthly message on the 6th of each month and excluding all other days of the month.
$repeat_exclude = array(
array("format =>"%d", "values"=>array(01,02,03,04,05,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)),
);
#End exclude dates for repetition
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Re: [mod] Monthly repeat hack to send messages

Postby Blisk » 6:53pm, Mon 07 Nov, 2011

Is it possible to do that a yearly. So every year in certain month subscriber gets email.
Is possible with this mod to send a differend emails on differrend time to differend lists.
Blisk
phpLister
 
Posts: 10
Joined: 10:31am, Mon 07 Nov, 2011

Re: [mod] Monthly repeat hack to send messages

Postby liliplanet » 7:27am, Fri 27 Jan, 2012

as per H2B2's request ...

would it be possible to have repetition enabled as follows:

newsletterA(daily) = sent daily except Saturday, Sunday, Mondays
newsletterB(weekly) = sent weekly only Mondays

what I found is if:

Code: Select all
# exclude dates for repetition
$repeat_exclude = array(
  array("format" => "%a", "values" => array("Sun","Sat")),
);


just to clarify .. exclude dates for repetition per individual newsletter

newsletterA is also sent on a Monday. I only want newsletterB to be sent on Monday.

Most appreciate any reply.
liliplanet
PL Nut
 
Posts: 26
Joined: 2:38pm, Tue 31 Aug, 2004
Location: Cape Town


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

Who is online

Users browsing this forum: No registered users and 2 guests

cron