MB Publishing Webmaster Resource ::
View previous topic :: View next topic
Author
Message
Colocation Site Admin Joined: Jan 07, 2004 Posts: 412
Posted: Thu Jul 21, 2005 11:06 am Post subject: E-mail Notifications Stories
Below is part of the code found in admin/modules/stories.php
What addition is needed to enable an automated e-mail to be sent to the submitter upon admin publishing the story.
Presumably some definitions can be set up in a language file for the e-mail contents ... but for the actual e-mail to be sent to the user?
Code:
function postStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
global $aid, $ultramode, $prefix, $dbi;
if ($automated == 1) {
if ($day < 10) {
$day = "0$day";
}
if ($month < 10) {
$month = "0$month";
}
$sec = "00";
$date = "$year-$month-$day $hour:$min:$sec";
if ($uid == 1) $author = "";
if ($hometext == $bodytext) $bodytext = "";
$subject = stripslashes(FixQuotes($subject));
$hometext = stripslashes(FixQuotes($hometext));
$bodytext = stripslashes(FixQuotes($bodytext));
$notes = stripslashes(FixQuotes($notes));
$result = sql_query("insert into ".$prefix."_autonews values (NULL, '$catid', '$aid', '$subject', '$date', '$hometext', '$bodytext', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm')", $dbi);
if (!$result) {
return;
}
if ($uid == 1) {
} else {
sql_query("update ".$prefix."_users set counter=counter+1 where user_id='$uid'", $dbi);
}
sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
if ($ultramode) {
ultramode();
}
sql_query("delete from ".$prefix."_queue where qid=$qid", $dbi);
Header("Location: admin.php?op=submissions");
} else {
if ($uid == 1) $author = "";
if ($hometext == $bodytext) $bodytext = "";
$subject = stripslashes(FixQuotes($subject));
$hometext = stripslashes(FixQuotes($hometext));
$bodytext = stripslashes(FixQuotes($bodytext));
$notes = stripslashes(FixQuotes($notes));
if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
$haspoll = 1;
$timeStamp = time();
$pollTitle = FixQuotes($pollTitle);
if(!sql_query("INSERT INTO ".$prefix."_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', 0, '$alanguage', '0')", $dbi)) {
return;
}
$object = sql_fetch_object(sql_query("SELECT pollID FROM ".$prefix."_poll_desc WHERE pollTitle='$pollTitle'", $dbi), $dbi);
$id = $object->pollID;
for($i = 1; $i <= sizeof($optionText); $i++) {
if($optionText[$i] != "") {
$optionText[$i] = FixQuotes($optionText[$i]);
}
if(!sql_query("INSERT INTO ".$prefix."_poll_data (pollID, optionText, optionCount, voteID) VALUES ($id, '$optionText[$i]', 0, $i)", $dbi)) {
return;
}
}
} else {
$haspoll = 0;
$id = 0;
}
$result = sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0')", $dbi);
$result = sql_query("select sid from ".$prefix."_stories WHERE title='$subject' order by time DESC limit 0,1", $dbi);
list($artid) = sql_fetch_row($result, $dbi);
sql_query("UPDATE ".$prefix."_poll_desc SET artid='$artid' WHERE pollID='$id'", $dbi);
if (!$result) {
return;
}
if ($uid == 1) {
} else {
sql_query("update ".$prefix."_users set counter=counter+1 where user_id='$uid'", $dbi);
}
sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
if ($ultramode) {
ultramode();
}
deleteStory($qid);
}
}
Back to top
Humpa Site Admin Joined: Feb 05, 2004 Posts: 23
Posted: Thu Jul 21, 2005 11:34 am Post subject:
Try this:
Code:
function postStory($automated, $year, $day, $month, $hour, $min, $qid, $uid, $author, $subject, $hometext, $bodytext, $topic, $notes, $catid, $ihome, $alanguage, $acomm, $pollTitle, $optionText) {
global $aid, $ultramode, $prefix, $dbi;
if ($automated == 1) {
if ($day < 10) {
$day = "0$day";
}
if ($month < 10) {
$month = "0$month";
}
$sec = "00";
$date = "$year-$month-$day $hour:$min:$sec";
if ($uid == 1) $author = "";
if ($hometext == $bodytext) $bodytext = "";
$subject = stripslashes(FixQuotes($subject));
$hometext = stripslashes(FixQuotes($hometext));
$bodytext = stripslashes(FixQuotes($bodytext));
$notes = stripslashes(FixQuotes($notes));
$result = sql_query("insert into ".$prefix."_autonews values (NULL, '$catid', '$aid', '$subject', '$date', '$hometext', '$bodytext', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm')", $dbi);
if (!$result) {
return;
}
if ($uid == 1) {
} else {
sql_query("update ".$prefix."_users set counter=counter+1 where user_id='$uid'", $dbi);
}
sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
if ($ultramode) {
ultramode();
}
sql_query("delete from ".$prefix."_queue where qid=$qid", $dbi);
Header("Location: admin.php?op=submissions");
} else {
if ($uid == 1) $author = "";
if ($hometext == $bodytext) $bodytext = "";
$subject = stripslashes(FixQuotes($subject));
$hometext = stripslashes(FixQuotes($hometext));
$bodytext = stripslashes(FixQuotes($bodytext));
$notes = stripslashes(FixQuotes($notes));
if (($pollTitle != "") AND ($optionText[1] != "") AND ($optionText[2] != "")) {
$haspoll = 1;
$timeStamp = time();
$pollTitle = FixQuotes($pollTitle);
if(!sql_query("INSERT INTO ".$prefix."_poll_desc VALUES (NULL, '$pollTitle', '$timeStamp', 0, '$alanguage', '0')", $dbi)) {
return;
}
$object = sql_fetch_object(sql_query("SELECT pollID FROM ".$prefix."_poll_desc WHERE pollTitle='$pollTitle'", $dbi), $dbi);
$id = $object->pollID;
for($i = 1; $i <= sizeof($optionText); $i++) {
if($optionText[$i] != "") {
$optionText[$i] = FixQuotes($optionText[$i]);
}
if(!sql_query("INSERT INTO ".$prefix."_poll_data (pollID, optionText, optionCount, voteID) VALUES ($id, '$optionText[$i]', 0, $i)", $dbi)) {
return;
}
}
} else {
$haspoll = 0;
$id = 0;
}
$result = sql_query("insert into ".$prefix."_stories values (NULL, '$catid', '$aid', '$subject', now(), '$hometext', '$bodytext', '0', '0', '$topic', '$author', '$notes', '$ihome', '$alanguage', '$acomm', '$haspoll', '$id', '0', '0')", $dbi);
$result = sql_query("select sid from ".$prefix."_stories WHERE title='$subject' order by time DESC limit 0,1", $dbi);
list($artid) = sql_fetch_row($result, $dbi);
sql_query("UPDATE ".$prefix."_poll_desc SET artid='$artid' WHERE pollID='$id'", $dbi);
if (!$result) {
return;
}
if ($uid == 1) {
} else {
sql_query("update ".$prefix."_users set counter=counter+1 where user_id='$uid'", $dbi);
$result_email = mysql_query("select * from ".$prefix."_users where user_id='$uid'");
$row = mysql_fetch_array($result_email);
$user_email = $row['user_email'];
$humpa_subject = "Your Press Release";
$notify_message = "Congratulations your press release has been published and can be seen at the following url:\n"
."http://www.malebits.com/article$artid.html\n\n"
."Kind regards MB Publishing http://www.malebits.com\n\nNOTE: Do not reply to this e-mail. It is sent from a robot and not monitored by a human.";
mail($user_email, $humpa_subject, $notify_message, "From: noreply@yourdomain6867ty65e.com ");
}
sql_query("update ".$prefix."_authors set counter=counter+1 where aid='$aid'", $dbi);
if ($ultramode) {
ultramode();
}
deleteStory($qid);
}
}
Back to top
Colocation Site Admin Joined: Jan 07, 2004 Posts: 412
Posted: Thu Jul 21, 2005 11:56 am Post subject: Job Done
Cracking work Humpa!
Functions perfectly - "buts" seem to be not evident.
Users will now recieve e-mail notifications when articles have been published.
Back to top
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum