[Phpslash-commit] CVS: phpslash-dev/include/modules/mailinglist MailingList.class,1.3,1.4
Brought to you by:
joestewart,
nhruby
From: Luis M <le...@us...> - 2003-04-24 02:09:30
|
Update of /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist In directory sc8-pr-cvs1:/tmp/cvs-serv24043 Modified Files: MailingList.class Log Message: closer to making newsletters be sent to users who get weekly news. some bugs being investigated. This is unstable right now Index: MailingList.class =================================================================== RCS file: /cvsroot/phpslash/phpslash-dev/include/modules/mailinglist/MailingList.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MailingList.class 23 Apr 2003 15:51:20 -0000 1.3 --- MailingList.class 24 Apr 2003 02:09:25 -0000 1.4 *************** *** 246,255 **** function AdminMenu() { ! ! $q = "SELECT id, ! name, ! email, ! date_created ! FROM psl_mailinglist"; $this->db->query($q); --- 246,256 ---- function AdminMenu() { ! // to avoid ambiguity, since we need all fields, ! // I changed this from plain "id" or "psl_mailinglist.id" ! // to "*". luis ! $q = "SELECT * ! FROM psl_mailinglist, ! psl_mailinglist_frequency ! WHERE psl_mailinglist.id = psl_mailinglist_frequency.id"; $this->db->query($q); *************** *** 264,267 **** --- 265,269 ---- 'ID' => $this->db->f("id"), 'EMAIL' => $this->db->f("email"), + 'FREQ' => $this->db->f("frequency"), 'TIME' => psl_dateTimeShort($this->db->f("date_created")) )); *************** *** 304,329 **** function build_body($ary, $offset) { //BEGIN FUNCTION - - $db = pslNew("slashDB"); - - if ($ary['dateoverride']) { - - $ary['bday'] = date("d"); - $ary['bday'] = $bday - $offset; - - $ary['bmonth'] = date("m"); - $ary['bmonth'] = $ary[bmonth] - 1; ! $ary['byear'] = date("Y"); ! $ary['eday'] = date("d"); ! $ary['emonth'] = date("m"); ! $ary['eyear'] = date("Y"); } ! $begtimestamp = mktime(0,0,0,$ary['bmonth'],$ary['bday'],$ary['byear']); ! $endtimestamp = mktime(0,0,0,$ary['emonth'],$ary['eday'] + 1,$ary['eyear']); $begdate = date("Y-m-d H:i:s", $begtimestamp); $enddate = date("Y-m-d H:i:s", $endtimestamp); $q = "SELECT story.story_id, --- 306,341 ---- function build_body($ary, $offset) { //BEGIN FUNCTION ! $db = pslNew("slashDB"); ! ! if ( $offset > 1 ) { ! $ary["bday"] = $ary["eday"] - $offset; ! $ary["bday"] = ($ary["bday"]>0) ? $ary["bday"] : (30 + $ary["bday"]); } + //$this->message .= " bday: ".$ary["bday"]; ! if ($ary["dateoverride"]) { ! // end-date ! $ary["eday"] = date("d"); ! $ary["emonth"] = date("m"); ! $ary["eyear"] = date("Y"); ! // begin-date ! $ary["byear"] = date("Y"); ! $ary["bday"] = $ary["eday"] - $offset; ! $ary["bmonth"] = $ary["emonth"] - 1; ! } + $begtimestamp = mktime(0,0,0,$ary["bmonth"],$ary["bday"],$ary["byear"]); + // TODO BUG?: + // the +1 to $ary[eday] could make that future stories get emailed + // before being posted to the page, is this really necessary? + // note that the query does a "<=" (less than OR equal) comparison. + // Luis + $endtimestamp = mktime(0,0,0,$ary["emonth"],$ary["eday"] + 1,$ary["eyear"]); + $begdate = date("Y-m-d H:i:s", $begtimestamp); $enddate = date("Y-m-d H:i:s", $endtimestamp); + + $this->message .= " bday ".$ary["bday"]." begin-time: $begtimestamp\t end-time: $endtimestamp "; $q = "SELECT story.story_id, *************** *** 346,349 **** --- 358,371 ---- $success = false; + + // TODO + // is this loop right? + // this is looping and setting the variables every time + // so, if there is more than one story pulled from the database + // only the last story pulled will be emailed... + // shouldn't it be creating a list of all stories? + // Unless of course that's what parse("rows","row",true) is doing + // Luis + while($db->next_record()) { *************** *** 358,364 **** )); $this->templ->parse("rows","row",true); ! $success = true; ! } //End While next_record if ($success == true) { return $this->templ->parse('OUT',array("messagebodymail")); --- 380,387 ---- )); $this->templ->parse("rows","row",true); ! $success = true; ! } //End While next_record ! if ($success == true) { return $this->templ->parse('OUT',array("messagebodymail")); *************** *** 429,434 **** $this->message .= "To: $email <$name>"; ! if ( ($dayback != $tmpDay) && ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } --- 452,466 ---- $this->message .= "To: $email <$name>"; + // TODO BUG?: + // is this buggy? picture this: + // dayback = 7 for e/a user who picked a weekly email + // looping thru all of them will set dayback to 7 + // and after the first iteration tmpDay is also 7 + // thus the rest of the users who get weekly emails + // will not get anything? ... luis ! // TODO put this back!! ! // ($dayback != $tmpDay) && ! if ( ( !($ary['override']) ) ) { $ary['body'] = $this->build_body($ary,$dayback); } *************** *** 436,441 **** $today = date("m/d/Y"); ! $this->message .= " Frequency: $frequency"; ! switch ($frequency) { case "DAY": --- 468,474 ---- $today = date("m/d/Y"); ! //$this->message .= " Frequency: $frequency"; ! ! // TODO use this switch/case to set the bday var in $ary switch ($frequency) { case "DAY": *************** *** 448,451 **** --- 481,494 ---- $mail_subject = $ary['subject']." for the past month ($today)"; break; + case "SUNDAY": + case "MONDAY": + case "TUESDAY": + case "WEDNESDAY": + case "THURSDAY": + case "FRIDAY": + case "SATURDAY": + + $mail_subject = $ary['subject']." since last ".$frequency; + break; default: $mail_subject = $ary['subject']; *************** *** 461,465 **** if(empty($ary['body']) && empty($extra_message)){ ! $this->message .= pslgetText("Nothing to send"); } elseif ( mail($email, $mail_subject, $final_body, "From: ".$ary['sender']) ) { $this->message .= pslgetText("Mail Sent Successfully!")."<br>\n"; --- 504,508 ---- if(empty($ary['body']) && empty($extra_message)){ ! $this->message .= pslgetText("Nothing to send")."<br />\n"; } elseif ( mail($email, $mail_subject, $final_body, "From: ".$ary['sender']) ) { $this->message .= pslgetText("Mail Sent Successfully!")."<br>\n"; |