[geeklog-cvs] geeklog: Use the story class for "Mail Story to a Friend" and sl...
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Aug 9 07:03:22 EDT 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/648abfeded20
changeset: 7242:648abfeded20
user: Dirk Haun <dirk at haun-online.de>
date: Sun Aug 09 10:20:32 2009 +0200
description:
Use the story class for "Mail Story to a Friend" and slightly improved the formatting in the email
diffstat:
public_html/profiles.php | 61 +++++++++++++++++++-----------
1 files changed, 38 insertions(+), 23 deletions(-)
diffs (124 lines):
diff -r 594babfaeddc -r 648abfeded20 public_html/profiles.php
--- a/public_html/profiles.php Sat Aug 08 21:57:44 2009 +0200
+++ b/public_html/profiles.php Sun Aug 09 10:20:32 2009 +0200
@@ -290,6 +290,8 @@
{
global $_CONF, $_TABLES, $LANG01, $LANG08;
+ require_once $_CONF['path_system'] . 'lib-story.php';
+
$storyurl = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $sid);
if ($_CONF['url_rewrite']) {
$retval = COM_refresh($storyurl . '?msg=85');
@@ -314,12 +316,12 @@
return $retval;
}
- $sql = "SELECT uid,title,introtext,bodytext,commentcode,UNIX_TIMESTAMP(date) AS day,postmode FROM {$_TABLES['stories']} WHERE sid = '$sid'" . COM_getTopicSql('AND') . COM_getPermSql('AND');
- $result = DB_query($sql);
- if (DB_numRows($result) == 0) {
+ $story = new Story();
+ $result = $story->loadFromDatabase($sid, 'view');
+
+ if ($result != STORY_LOADED_OK) {
return COM_refresh($_CONF['site_url'] . '/index.php');
}
- $A = DB_fetchArray($result);
$shortmsg = COM_stripslashes ($shortmsg);
$mailtext = sprintf ($LANG08[23], $from, $fromemail) . LB;
@@ -336,25 +338,34 @@
$mailtext .= '------------------------------------------------------------'
. LB . LB
- . COM_undoSpecialChars (stripslashes ($A['title'])) . LB
- . strftime ($_CONF['date'], $A['day']) . LB;
+ . COM_undoSpecialChars($story->displayElements('title')) . LB
+ . strftime ($_CONF['date'], $story->DisplayElements('unixdate')) . LB;
if ($_CONF['contributedbyline'] == 1) {
- $author = COM_getDisplayName ($A['uid']);
+ $author = COM_getDisplayName($story->displayElements('uid'));
$mailtext .= $LANG01[1] . ' ' . $author . LB;
}
- if ($A['postmode'] === 'wikitext') {
- $mailtext .= LB
- . COM_undoSpecialChars(stripslashes(strip_tags(COM_renderWikiText($A['introtext'])))).LB.LB
- . COM_undoSpecialChars(stripslashes(strip_tags(COM_renderWikiText($A['bodytext'])))).LB.LB
- . '------------------------------------------------------------'.LB;
- } else {
- $mailtext .= LB
- . COM_undoSpecialChars(stripslashes(strip_tags($A['introtext']))).LB.LB
- . COM_undoSpecialChars(stripslashes(strip_tags($A['bodytext']))).LB.LB
- . '------------------------------------------------------------'.LB;
+
+ $introtext = $story->DisplayElements('introtext');
+ $bodytext = $story->DisplayElements('bodytext');
+ if ($story->DisplayElements('postmode') === 'wikitext') {
+ $introtext = COM_renderWikiText($introtext);
+ $bodytext = COM_renderWikiText($bodytext);
}
- if ($A['commentcode'] == 0) { // comments allowed
+ $introtext = COM_undoSpecialChars(strip_tags($introtext));
+ $bodytext = COM_undoSpecialChars(strip_tags($bodytext));
+
+ $introtext = str_replace(array("\012\015", "\015"), LB, $introtext);
+ $bodytext = str_replace(array("\012\015", "\015"), LB, $bodytext);
+
+ $mailtext .= LB . $introtext;
+ if (! empty($bodytext)) {
+ $mailtext .= LB . LB . $bodytext;
+ }
+ $mailtext .= LB . LB
+ . '------------------------------------------------------------' . LB;
+
+ if ($story->DisplayElements('commentcode') == 0) { // comments allowed
$mailtext .= $LANG08[24] . LB
. COM_buildUrl ($_CONF['site_url'] . '/article.php?story='
. $sid . '#comments');
@@ -366,7 +377,7 @@
$mailto = COM_formatEmailAddress ($to, $toemail);
$mailfrom = COM_formatEmailAddress ($from, $fromemail);
- $subject = COM_undoSpecialChars(strip_tags(stripslashes('Re: '.$A['title'])));
+ $subject = COM_undoSpecialChars(strip_tags('Re: '.$story->DisplayElements('title')));
$sent = COM_mail ($mailto, $subject, $mailtext, $mailfrom);
COM_updateSpeedlimit ('mail');
@@ -395,6 +406,8 @@
{
global $_CONF, $_TABLES, $_USER, $LANG08, $LANG_LOGIN;
+ require_once $_CONF['path_system'] . 'lib-story.php';
+
$retval = '';
if (COM_isAnonUser() && (($_CONF['loginrequired'] == 1) ||
@@ -417,9 +430,10 @@
return $retval;
}
- $result = DB_query("SELECT COUNT(*) AS count FROM {$_TABLES['stories']} WHERE sid = '$sid'" . COM_getTopicSql('AND') . COM_getPermSql('AND'));
- $A = DB_fetchArray($result);
- if ($A['count'] == 0) {
+ $story = new Story();
+ $result = $story->loadFromDatabase($sid, 'view');
+
+ if ($result != STORY_LOADED_OK) {
return COM_refresh($_CONF['site_url'] . '/index.php');
}
@@ -438,11 +452,12 @@
$mail_template = new Template($_CONF['path_layout'] . 'profiles');
$mail_template->set_file('form', 'contactauthorform.thtml');
- $mail_template->set_var( 'xhtml', XHTML );
+ $mail_template->set_var('xhtml', XHTML);
$mail_template->set_var('site_url', $_CONF['site_url']);
$mail_template->set_var('site_admin_url', $_CONF['site_admin_url']);
$mail_template->set_var('layout_url', $_CONF['layout_url']);
$mail_template->set_var('start_block_mailstory2friend', COM_startBlock($LANG08[17]));
+ $mail_template->set_var('story_title', $story->displayElements('title'));
$mail_template->set_var('lang_fromname', $LANG08[20]);
$mail_template->set_var('name', $from);
$mail_template->set_var('lang_fromemailaddress', $LANG08[21]);
More information about the geeklog-cvs
mailing list