Update of /cvsroot/phpslash/phpslash-ft/class
In directory usw-pr-cvs1:/tmp/cvs-serv1464/phpslash-ft/class
Modified Files:
Story.class
Added Files:
Story_admin.class
Log Message:
Story_admin class
--- NEW FILE: Story_admin.class ---
<?php
/* $Id: Story_admin.class,v 1.1 2002/06/01 16:11:46 joestewart Exp $ */
/*
* Class: Story_admin
*
* Layer: Final (Admin)
* Desc.: An Administraion class for Story
*
* NOTES/TO-DO:
* - Inherited member variables are optional; I left them in as a
* reminder -- Costas
*/
/* First let's bring in my parent class - moved to config.php3 jvs 11/11/2001 */
// require($_PSL[classdir] . '/Story_base.class');
class Story_admin extends Story_base {
/*
* MEMBER VARIABLES
*/
var $parent_name = "Story_base";
var $template;
// var $db;
var $auth;
var $perm;
var $psl;
/*
* CONSTRUCTORS
*/
function Story_admin () {
global $auth, $perm, $_PSL;
// call base class constructor
$this->Story_base();
// $this->db = new slashDB;
$this->perm = $perm;
$this->auth = $auth;
$this->psl = $_PSL;
/*
* Templates
*/
$template_ary = array(
"printStory" => "story.tpl",
"liststory" => "storyList.tpl",
"newstory" => "storyNew.tpl",
"indexstory" => "storyIndex.tpl",
"relatedlinks" => "storyRelated.tpl"
);
$this->template = new Template($this->psl['templatedir'], "remove");
$this->template->debug = 0;
$this->template->set_file($template_ary);
// $this->template->set_unknowns("comment");
$this->template->halt_on_error = "report";
$this->template->set_var( array(
'ROOTDIR' => $this->psl['rooturl'],
'IMAGEDIR' => $this->psl['imageurl']
));
}
/*
* METHODS
*/
function deleteStory($story_id) {
// gotta get the story user_id
$story_ary = $this->extractStory($story_id, "Full");
$user_id = $story_ary['user_id'];
if((!$this->perm->have_perm('story,storyeditor')) AND
( $user_id != $this->auth->auth['uid'])) {
return false;
}
echo "The storyid is: $story_id<BR>\n";
$comment = new Comment;
$deleted_comments = $comment->delete("0",$story_id);
echo "You deleted $deleted_comments comments<BR>\n";
$section_del = "DELETE
FROM psl_section_lut
WHERE story_id = '$story_id'";
$topic_del = "DELETE
FROM psl_topic_lut
WHERE story_id = '$story_id'";
$story_del = "DELETE
FROM psl_story
WHERE story_id = '$story_id'";
if ($this->db->query($section_del)) {
$section_count = $this->db->affected_rows();
echo "removed $section_count section pointer(s)<BR>\n";
}
if ($this->db->query($topic_del)) {
$topic_count = $this->db->affected_rows();
echo "removed $topic_count topic pointer(s)<BR>\n";
}
if ($this->db->query($story_del)) {
$story_count = $this->db->affected_rows();
echo "removed the story<BR>\n";
}
return true;
}
/* function to allow a story Preview */
function showStory($ary) {
$story = new Story;
$titlebar = getTitlebar("100%",$ary[title]);
/* assume only one topic */
$this->template->set_var(array(
'rows' => "",
'alsoblock' => ""
));
if ($this->template->get_var("row") == "") {
$this->template->set_block("printStory","row","rows");
$this->template->set_block("printStory","alsotext","alsoblock");
}
/* need to get story author_name as it's not passed in array */
$q = "SELECT psl_author.author_name
FROM psl_author
WHERE psl_author.author_id = '$ary[author_id]'";
$this->db->query($q);
$this->db->next_record();
$story_author_name = $this->db->Record['author_name'];
$ary['title'] = clean($ary['title']);
/*
* we get the time from the array if it's valid. else we generate it.
*/
if ($ary['datetime'] == "") {
if( $ary['story_date'] ) {
$ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']);
} else {
$ary['datetime'] = date("Y-m-d H:i:s");
}
}
$q = "SELECT date_format('$ary[datetime]',$this->article_dateformat) AS datef";
$this->db->query($q);
$this->db->next_record();
$datef = $this->db->f("datef");
if (!$datef) {
$datef = date( "l F j @ h:i A");
}
/* only the topic_id is passed in the topic_id_ary
* so we need to get the other topic info
*/
$topic_id_ary = $ary['topic_id_ary'];
$i = 0;
$q = "SELECT psl_topic.topic_name,
psl_topic.image,
psl_topic.width,
psl_topic.height,
psl_topic.alt_text
FROM psl_topic
WHERE psl_topic.topic_id = '$topic_id_ary[$i]'";
$this->db->query($q);
$this->db->next_record();
# set the formatting options for display only
if ($ary['content'] == "exttrans") {
$ary['intro_text'] = htmlentities($ary['intro_text']);
$ary['body_text'] = htmlentities($ary['body_text']);
}
if ($ary['content'] == "plain" or $ary['content'] == "exttrans") {
$ary['intro_text'] = nl2br($ary['intro_text']);
$ary['intro_text'] = ereg_replace("<br><br>","<br>",$ary['intro_text']);
$ary['body_text'] = nl2br($ary['body_text']);
$ary['body_text'] = ereg_replace("<br><br>","<br>",$ary['body_text']);
}
$this->template->set_var(array(
'TITLEBAR' => $titlebar,
'TITLE' => stripslashes($ary['title']),
'INTRO_TEXT' => stripslashes($ary['intro_text']),
'BODY_TEXT' => stripslashes($ary['body_text']),
'DEPT' => $ary['dept'],
'URL' => $ary['url'],
'NAME' => $story_author_name,
'DATEF' => $datef,
# 'TOPIC_ID' => urlencode($ary['topic_name']),
'TOPIC_ID' => $topic_id_ary[0],
'TOPIC_NAME' => $this->db->Record['topic_name'],
'TOPICIMAGE' => $this->db->Record['image'],
'TOPICWIDTH' => $this->db->Record['width'],
'TOPICHEIGHT' => $this->db->Record['height'],
'ALTTEXT' => $this->db->Record['alt_text'],
'ARROWS' => ""
));
if (is_array($topic_id_ary)) {
if( count($topic_id_ary) > 1) {
$this->template->parse("alsoblock", "alsotext", true);
}
for ($i = 1 ; $i < count($topic_id_ary) ; $i++) {
$q = "SELECT psl_topic.topic_name,
psl_topic.image,
psl_topic.width,
psl_topic.height,
psl_topic.alt_text
FROM psl_topic
WHERE psl_topic.topic_id = '$topic_id_ary[$i]'";
$this->db->query($q);
$this->db->next_record();
$list_topic_name = $this->db->Record['topic_name'];
$this->template->set_var(array(
'LIST_TOPIC_ID' => $topic_id_ary[$i],
'LIST_TOPIC_NAME' => $list_topic_name,
'LIST_TOPIC_URL' => $topic_id_ary[$i]
));
$this->template->parse("rows", "row", true);
}
}
$this->template->parse('OUT', "printStory");
$this->template->p('OUT');
$this->template->set_var(array(
'rows' => "",
'alsoblock' => ""
));
}
/*
* Displays a list of stories
* Do we need this anywhere outside of admin????
*/
function listStory($ary, $first) {
$author_id = $ary['author_id'];
$topic_id = $ary['topic_id'];
$section_id = $ary['section_id'];
$cmt_list = 10; /* num of stories to display before the "more" link */
$q = "SELECT story.hits,
story.story_id,
story.title,
author.author_name,
commentcount.count AS commentcount,
date_format(time,$this->admin_dateformat) AS df
FROM psl_story story,
psl_author author,";
if ($topic_id) {
$q .= " psl_topic_lut, ";
}
if ($section_id) {
$q .= " psl_section_lut, ";
}
$q .= " psl_commentcount commentcount
WHERE story.story_id = commentcount.count_id
AND author.author_id = story.user_id ";
$user_id = $this->auth->auth[uid];
// if you're not a storyeditor, then you can only view your own stories.
if (!$this->perm->have_perm("story,storyeditor")) {
$q .= "AND '$user_id' = story.user_id
AND '$user_id' = author.author_id ";
}
if ($author_id) {
$q .= "AND '$author_id' = story.user_id ";
}
if ($topic_id) {
$q .= "AND story.story_id = psl_topic_lut.story_id ";
$q .= "AND '$topic_id' = psl_topic_lut.topic_id ";
}
if ($section_id) {
$q .= "AND story.story_id = psl_section_lut.story_id ";
$q .= "AND '$section_id' = psl_section_lut.section_id ";
}
$q .= "ORDER BY time DESC";
$this->db->query($q);
$count = 0;
$this->template->set_block("liststory", "row", "rows");
$this->template->set_block("liststory", "row2", "rows2");
$author = new Author;
$topic = new Topic;
$section = new Section;
$author_array = $author->getAuthors();
$topic_array = $topic->getTopics();
$section_array = $section->getSections();
$this->template->set_block("liststory", "each_author", "authors");
$this->template->set_var(array(
"AUTHOR_ID" => "",
"AUTHOR_NAME" => "".pslgetText("All Authors")."",
"SELECTED" => ""
));
$this->template->parse("authors", "each_author", "true");
while (list(, $cur_Author) = @each($author_array)) {
$this->template->set_var(array(
"AUTHOR_ID" => $cur_Author['id'],
"AUTHOR_NAME" => $cur_Author['name'],
"SELECTED" => ""
));
if ($author_id == $cur_Author['id']) {
$this->template->set_var(array(
"SELECTED" => "selected=\"selected\""
));
}
$this->template->parse("authors", "each_author", "true");
}
$this->template->set_block("liststory", "each_topic", "topics");
$this->template->set_var(array(
"TOPIC_ID" => "",
"TOPIC_NAME" => "".pslgetText("All Topics")."",
"SELECTED" => ""
));
$this->template->parse("topics", "each_topic", "true");
while (list(, $cur_Topic) = each($topic_array)) {
$this->template->set_var(array(
"TOPIC_NAME" => $cur_Topic[name],
"TOPIC_ID" => $cur_Topic[id],
"SELECTED" => ""
));
if ($cur_Topic[id] == $topic_id) {
$this->template->set_var(array(
"SELECTED" => "selected=\"selected\""
));
}
$this->template->parse("topics", "each_topic", "true");
}
$this->template->set_block("liststory", "each_section", "sections");
$this->template->set_var(array(
"SECTION_ID" => "",
"SECTION_NAME" => "".pslgetText("All Sections")."",
"SELECTED" => ""
));
$this->template->parse("sections", "each_section", "true");
while (list(, $cur_Section) = each($section_array)) {
$this->template->set_var(array(
"SECTION_NAME" => $cur_Section[name],
"SECTION_ID" => $cur_Section[id],
"SELECTED" => ""
));
if ($cur_Section['id'] == $section_id) {
$this->template->set_var(array(
"SELECTED" => "selected=\"selected\""
));
}
$this->template->parse("sections", "each_section", "true");
}
$this->template->set_var(array(
'ACTION_URL' => $this->psl['phpself'],
'TOPIC_SELECT' => $topic_select_html,
'SECTION_SELECT' => $section_select_html,
'AUTHOR_SELECT' => $author_select_html
));
while ($this->db->next_record()) {
$story_id = $this->db->Record["story_id"];
$count++;
if ( ($count > $first) and ($count <= ($first+$cmt_list)) ) {
$view_url = $this->psl['rooturl'] . "/article.php3?story_id=$story_id";
$modify_url = $this->psl['adminurl'] . "/storyAdmin.php3?submit=edit&story_id=$story_id";
$delete_url = $this->psl['adminurl'] . "/storyAdmin.php3?submit=delete&story_id=$story_id";
$this->template->set_var(array(
'COUNT' => $count,
'VIEWURL' => $view_url,
'MODIFYURL' => $modify_url,
'DELETEURL' => $delete_url,
'TITLE' => $this->db->Record["title"],
'AUTHOR' => $this->db->Record["author_name"],
'HITS' => $this->db->Record["hits"],
'COMMENTCOUNT' => $this->db->Record["commentcount"],
'DATE' => $this->db->Record["df"]
));
if ($i%2 == 0) {
$this->template->parse("rows","row","true");
} else {
$this->template->parse("rows","row2","true");
}
$i++;
}
}
$first += $cmt_list;
$left = $count - $first;
$this->template->set_var(array(
'MORE_LINK' => ""
));
if ($count > $first) {
$this->template->set_var(array(
'MORE_LINK' => "<a href=\"" . $this->psl['phpself'] . "?submit=modify" . $this->psl['amp'] .
"author_id=" . $author_id . $this->psl['amp'] .
"topic_id=" . $topic_id . $this->psl['amp'] .
"section_id=" . $section_id . $this->psl['amp'] .
"next=$first\">$left " . pslgetText("More")."</a>"
));
}
$this->template->parse('OUT', array("liststory"));
$this->template->p('OUT');
}
function newStory($ary,$data_source) {
global $author_id,$author_name;
# global $debug;
# $debug = true;
# debug("Story::newStory", $ary);
# debug("Story::newStory::topic_ary", $ary[topic_id_ary]);
# debug("Story::newStory::section_ary", $ary[section_id_ary]);
// echo "<B>Data_Source: $data_source</B><BR><BR>\n";
$this->template->set_block("newstory","topic_row","topic_rows");
$this->template->set_block("newstory","section_row","section_rows");
$this->template->set_block("newstory","author_row","author_rows");
$story_id = $ary['story_id'];
// echo "We're in newStory. Story_id: $story_id<BR>\n";
$this->template->set_var('PLAIN_CHKBOX',"");
$this->template->set_var('HTML_CHKBOX',"CHECKED");
$this->template->set_var('EXTTRANS_CHKBOX',"");
$this->template->set_block("newstory","datetime_row","datetime_rows");
$this->template->set_block("newstory","year_row","year_rows");
$this->template->set_block("newstory","month_row","month_rows");
$this->template->set_block("newstory","day_row","day_rows");
$this->template->set_block("newstory","hour_row","hour_rows");
$this->template->set_block("newstory","minute_row","minute_rows");
$this->template->set_block("newstory","second_row","second_rows");
$this->template->set_block("newstory","datetimeset_row","datetimeset_rows");
if ($data_source == "array") { /* this is what happens during a preview */
// clean() is supposed to handle arrays, but the topic/section arrays
// always got mangled after the clean function. so we're doing one by one.
$ary['dept'] = clean($ary['dept']);
$ary['intro_text'] = clean($ary['intro_text']);
$ary['body_text'] = clean($ary['body_text']);
$ary['title'] = clean($ary['title']);
if( $ary['story_date'] ) {
$ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']);
} else {
$ary['datetime'] = date("Y-m-d H:i:s");
}
$this->template->set_var(array(
'DEPT' => $ary['dept'],
'INTROTEXT' => $ary['intro_text'],
'BODYTEXT' => $ary['body_text'],
'TITLE' => $ary['title'],
'TIME' => $ary['datetime'],
'AUTHOR_ID' => $author_id,
'AUTHOR_NAME' => $author_name
));
// $this->template->set_block("newstory","datetime_row","datetime_rows");
if (!$this->perm->have_perm("story,storyeditor")) {
$this->template->set_var(array(
'TYPE' => "hidden",
'TIME_VALUE' => $ary['datetime']
));
$this->template->parse("datetime_rows","datetime_row",true);
} else {
$datetime = split( ' ', $ary['datetime']);
$story_date = split( '-', $datetime[0]);
$story_time = split( ':', $datetime[1]);
// setup year select box
for( $i=1998; $i<2009; $i++) {
$this->template->set_var(array(
'SELECTED' => '',
'STORYYEAR' => $i
));
if( $i == $story_date[0]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("year_rows","year_row",true);
}
// setup month select box
for( $i=1; $i<=12; $i++) {
$this->template->set_var(array(
'SELECTED' => '',
'STORYMONTH' => sprintf( "%02d", $i)
));
if( $i == $story_date[1]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("month_rows","month_row",true);
}
// setup day select box
for( $i=1; $i<=31; $i++) {
$this->template->set_var(array(
'SELECTED' => '',
'STORYDAY' => sprintf( "%02d", $i)
));
if( $i == $story_date[2]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("day_rows","day_row",true);
}
// setup hour select box
for( $i=1; $i<=24; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYHOUR' => $i
));
if( $i == $story_time[0]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("hour_rows","hour_row",true);
}
// setup minute select box
for( $i=1; $i<=60; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYMINUTE' => sprintf( "%02d", $i)
));
if( $i == $story_time[1]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("minute_rows","minute_row",true);
}
// setup seconds select box
for( $i=1; $i<=60; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYSECOND' => sprintf( "%02d", $i)
));
if( $i == $story_time[2]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("second_rows","second_row",true);
}
$this->template->parse("datetimeset_rows","datetimeset_row",true);
}
if ($ary['content'] == "plain") {
$this->template->set_var('PLAIN_CHKBOX',"CHECKED");
$this->template->set_var('HTML_CHKBOX',"");
$this->template->set_var('EXTTRANS_CHKBOX',"");
} elseif ($ary['content'] == "exttrans") {
$this->template->set_var('PLAIN_CHKBOX',"");
$this->template->set_var('HTML_CHKBOX',"");
$this->template->set_var('EXTTRANS_CHKBOX',"CHECKED");
} else {
$this->template->set_var('PLAIN_CHKBOX',"");
$this->template->set_var('HTML_CHKBOX',"CHECKED");
$this->template->set_var('EXTTRANS_CHKBOX',"");
}
$topic_ary = $ary['topic_id_ary'];
$section_ary = $ary['section_id_ary'];
$user_id = $this->auth->auth['uid'];
if ( $ary['author_id'] != "") {
$user_id = $ary['author_id'];
}
} elseif ($data_source == "database") { /* this is a story from the DB */
/*
* Get the topic_id's for this story into an array
*/
$q = "SELECT psl_topic.topic_id
FROM psl_topic,psl_topic_lut
WHERE psl_topic_lut.story_id = '$story_id'
AND psl_topic.topic_id = psl_topic_lut.topic_id";
$this->db->query($q);
$i = 0;
while ($this->db->next_record()) {
$topic_ary[$i] = $this->db->Record['topic_id'];
// echo "ARY[ $i ] : $topic_ary[$i]<BR>\n";
$i++;
}
/*
* Get the section_id's for this story into an array
*/
$q = "SELECT psl_section.section_id
FROM psl_section,psl_section_lut
WHERE psl_section_lut.story_id = '$story_id'
AND psl_section.section_id = psl_section_lut.section_id";
$this->db->query($q);
$i = 0;
while ($this->db->next_record()) {
$section_ary[$i] = $this->db->Record['section_id'];
$i++;
}
/* Trying to save a query, I pulled this from outside this if statement */
$this->db->query("SELECT * from psl_story WHERE story_id = '$story_id'");
$this->db->next_record();
$this->template->set_var(array(
'DEPT' => stripslashes($this->db->Record['dept']),
'INTROTEXT' => htmlspecialchars(stripslashes($this->db->Record['intro_text'])),
'BODYTEXT' => htmlspecialchars(stripslashes($this->db->Record['body_text'])),
'TITLE' => stripslashes($this->db->Record['title']),
'TIME' => $this->db->Record['time'],
'AUTHOR_ID' => $this->db->Record['user_id']
# 'AUTHOR_NAME' => $author_name,
));
$user_id = $this->db->Record['user_id'];
// Normal users can't edit another user's stories
if((!$this->perm->have_perm('story,storyeditor')) AND
( $user_id != $this->auth->auth['uid'])) {
return false;
}
/* if storyeditor, enable setting of date, otherwise display date */
if (!$this->perm->have_perm("story,storyeditor")) {
$this->template->set_var(array(
'TYPE' => "hidden",
'TIME_VALUE' => $this->db->Record['time']
));
$this->template->parse("datetime_rows","datetime_row",true);
} else {
$datetime = split( ' ', $this->db->Record['time']);
$story_date = split( '-', $datetime[0]);
$story_time = split( ':', $datetime[1]);
// setup year select box
for( $i=1998; $i<2009; $i++) {
$this->template->set_var(array(
'SELECTED' => '',
'STORYYEAR' => $i
));
if( $i == $story_date[0]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("year_rows","year_row",true);
}
// setup month select box
for( $i=1; $i<=12; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYMONTH' => sprintf( "%02d", $i)
));
if( $i == $story_date[1]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("month_rows","month_row",true);
}
// setup day select box
for( $i=1; $i<=31; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYDAY' => sprintf( "%02d", $i)
));
if( $i == $story_date[2]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("day_rows","day_row",true);
}
// setup hour select box
for( $i=1; $i<=24; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYHOUR' => $i
));
if( $i == $story_time[0]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("hour_rows","hour_row",true);
}
// setup minute select box
for( $i=1; $i<=60; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYMINUTE' => sprintf( "%02d", $i)
));
if( $i == $story_time[1]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("minute_rows","minute_row",true);
}
// setup seconds select box
for( $i=1; $i<=60; $i++) {
$this->template->set_var(array(
'TYPE' => 'select',
'SELECTED' => '',
'STORYSECOND' => sprintf( "%02d", $i)
));
if( $i == $story_time[2]) {
$this->template->set_var('SELECTED', "selected=\"selected\"");
}
$this->template->parse("second_rows","second_row",true);
}
$this->template->parse("datetimeset_rows","datetimeset_row",true);
}
}
$this->template->set_var(array(
'ACTION_URL' => "storyAdmin.php3",
# 'AUTHOR_ID' => $author_id,
# 'AUTHOR_NAME' => $author_name,
'STORY_ID' => $story_id
));
$this->db->query("SELECT topic_id,
topic_name
FROM psl_topic
ORDER BY topic_name");
while ($this->db->next_record()) {
$this->template->set_var(array(
'TOPIC_ID' => $this->db->Record['topic_id'],
'TOPIC_NAME' => $this->db->Record['topic_name']
));
$this->template->set_var('SELECTED',"");
for ($i = 0 ; $i < count($topic_ary) ; $i++) {
$array = $topic_ary[$i];
$dbname = $this->db->Record['topic_id'];
if ($topic_ary[$i] == $this->db->Record['topic_id']) {
$this->template->set_var('SELECTED',"SELECTED");
}
}
$this->template->parse("topic_rows","topic_row",true);
}
$this->db->query("SELECT section_id,
section_name
FROM psl_section
ORDER BY section_name");
while ($this->db->next_record()) {
$this->template->set_var(array(
'SECTION_ID' => $this->db->Record['section_id'],
'SECTION_NAME' => $this->db->Record['section_name']
));
$this->template->set_var('SELECTED',"");
for ($i = 0 ; $i < count($section_ary) ; $i++) {
if ($section_ary[$i] == $this->db->Record['section_id']) {
$this->template->set_var('SELECTED',"SELECTED");
}
}
$this->template->parse("section_rows","section_row",true);
}
if (!$this->perm->have_perm("story,storyeditor")) {
$this->template->set_var(array(
'AUTHOR_ID' => $this->auth->auth['uid'],
'AUTHOR_NAME' => $this->auth->auth['uname']
));
# $this->template->set_var('AUTHOR_SELECTED',"");
$this->template->set_var('AUTHOR_SELECTED',"SELECTED");
$this->template->parse("author_rows","author_row",true);
} else {
$q = "SELECT author_id,
author_name
FROM psl_author ";
$q .= " ORDER BY author_name ";
$this->db->query($q);
while ($this->db->next_record()) {
$this->template->set_var(array(
AUTHOR_ID => $this->db->Record['author_id'],
AUTHOR_NAME => $this->db->Record['author_name']
));
$this->template->set_var('AUTHOR_SELECTED',"");
if ($this->db->Record['author_id'] == $user_id ){
$this->template->set_var('AUTHOR_SELECTED',"SELECTED");
}
$this->template->parse("author_rows","author_row",true);
}
}
$description = sprintf( "%s (%s) added new story %s as userid %s", $this->auth->auth['uname'], $this->auth->auth['uid'], $story_id, $user_id);
logwrite("Story Admin", $description);
$this->template->parse('OUT',array("newstory"));
$this->template->p('OUT');
return true;
}
}
?>
Index: Story.class
===================================================================
RCS file: /cvsroot/phpslash/phpslash-ft/class/Story.class,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** Story.class 22 Apr 2002 14:56:09 -0000 1.34
--- Story.class 1 Jun 2002 16:11:46 -0000 1.35
***************
*** 10,14 ****
*
* NOTES/TO-DO:
- * - All globals must go.
* - Inherited member variables are optional; I left them in as a
* reminder -- Costas
--- 10,13 ----
***************
*** 555,741 ****
} /* end of function getStories */
-
- function deleteStory($story_id) {
-
- // gotta get the story user_id
- $story_ary = $this->extractStory($story_id, "Full");
- $user_id = $story_ary['user_id'];
-
- if((!$this->perm->have_perm('story,storyeditor')) AND
- ( $user_id != $this->auth->auth['uid'])) {
- return false;
- }
-
- echo "The storyid is: $story_id<BR>\n";
- $comment = new Comment;
- $deleted_comments = $comment->delete("0",$story_id);
- echo "You deleted $deleted_comments comments<BR>\n";
-
- $section_del = "DELETE
- FROM psl_section_lut
- WHERE story_id = '$story_id'";
-
- $topic_del = "DELETE
- FROM psl_topic_lut
- WHERE story_id = '$story_id'";
-
- $story_del = "DELETE
- FROM psl_story
- WHERE story_id = '$story_id'";
-
- if ($this->db->query($section_del)) {
- $section_count = $this->db->affected_rows();
- echo "removed $section_count section pointer(s)<BR>\n";
- }
- if ($this->db->query($topic_del)) {
- $topic_count = $this->db->affected_rows();
- echo "removed $topic_count topic pointer(s)<BR>\n";
- }
- if ($this->db->query($story_del)) {
- $story_count = $this->db->affected_rows();
- echo "removed the story<BR>\n";
- }
- return true;
- }
-
- /* function to allow a story Preview */
-
- function showStory($ary) {
-
- $story = new Story;
-
- $titlebar = getTitlebar("100%",$ary[title]);
-
- /* assume only one topic */
- $this->template->set_var(array(
- 'rows' => "",
- 'alsoblock' => ""
- ));
-
-
- if ($this->template->get_var("row") == "") {
- $this->template->set_block("printStory","row","rows");
- $this->template->set_block("printStory","alsotext","alsoblock");
- }
-
- /* need to get story author_name as it's not passed in array */
- $q = "SELECT psl_author.author_name
- FROM psl_author
- WHERE psl_author.author_id = '$ary[author_id]'";
-
- $this->db->query($q);
- $this->db->next_record();
-
- $story_author_name = $this->db->Record['author_name'];
- $ary['title'] = clean($ary['title']);
-
- /*
- * we get the time from the array if it's valid. else we generate it.
- */
- if ($ary['datetime'] == "") {
- if( $ary['story_date'] ) {
- $ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']);
- } else {
- $ary['datetime'] = date("Y-m-d H:i:s");
- }
- }
-
- $q = "SELECT date_format('$ary[datetime]',$this->article_dateformat) AS datef";
- $this->db->query($q);
- $this->db->next_record();
- $datef = $this->db->f("datef");
-
- if (!$datef) {
- $datef = date( "l F j @ h:i A");
-
- }
-
- /* only the topic_id is passed in the topic_id_ary
- * so we need to get the other topic info
- */
- $topic_id_ary = $ary['topic_id_ary'];
-
- $i = 0;
-
- $q = "SELECT psl_topic.topic_name,
- psl_topic.image,
- psl_topic.width,
- psl_topic.height,
- psl_topic.alt_text
- FROM psl_topic
- WHERE psl_topic.topic_id = '$topic_id_ary[$i]'";
-
- $this->db->query($q);
- $this->db->next_record();
-
- # set the formatting options for display only
- if ($ary['content'] == "exttrans") {
- $ary['intro_text'] = htmlentities($ary['intro_text']);
- $ary['body_text'] = htmlentities($ary['body_text']);
- }
-
- if ($ary['content'] == "plain" or $ary['content'] == "exttrans") {
- $ary['intro_text'] = nl2br($ary['intro_text']);
- $ary['intro_text'] = ereg_replace("<br><br>","<br>",$ary['intro_text']);
- $ary['body_text'] = nl2br($ary['body_text']);
- $ary['body_text'] = ereg_replace("<br><br>","<br>",$ary['body_text']);
- }
-
-
- $this->template->set_var(array(
- 'TITLEBAR' => $titlebar,
- 'TITLE' => stripslashes($ary['title']),
- 'INTRO_TEXT' => stripslashes($ary['intro_text']),
- 'BODY_TEXT' => stripslashes($ary['body_text']),
- 'DEPT' => $ary['dept'],
- 'URL' => $ary['url'],
- 'NAME' => $story_author_name,
- 'DATEF' => $datef,
- # 'TOPIC_ID' => urlencode($ary['topic_name']),
- 'TOPIC_ID' => $topic_id_ary[0],
- 'TOPIC_NAME' => $this->db->Record['topic_name'],
- 'TOPICIMAGE' => $this->db->Record['image'],
- 'TOPICWIDTH' => $this->db->Record['width'],
- 'TOPICHEIGHT' => $this->db->Record['height'],
- 'ALTTEXT' => $this->db->Record['alt_text'],
- 'ARROWS' => ""
- ));
-
- if (is_array($topic_id_ary)) {
-
- if( count($topic_id_ary) > 1) {
- $this->template->parse("alsoblock", "alsotext", true);
- }
- for ($i = 1 ; $i < count($topic_id_ary) ; $i++) {
-
- $q = "SELECT psl_topic.topic_name,
- psl_topic.image,
- psl_topic.width,
- psl_topic.height,
- psl_topic.alt_text
- FROM psl_topic
- WHERE psl_topic.topic_id = '$topic_id_ary[$i]'";
-
- $this->db->query($q);
- $this->db->next_record();
- $list_topic_name = $this->db->Record['topic_name'];
- $this->template->set_var(array(
- 'LIST_TOPIC_ID' => $topic_id_ary[$i],
- 'LIST_TOPIC_NAME' => $list_topic_name,
- 'LIST_TOPIC_URL' => $topic_id_ary[$i]
- ));
- $this->template->parse("rows", "row", true);
- }
- }
- $this->template->parse('OUT', "printStory");
- $this->template->p('OUT');
-
- $this->template->set_var(array(
- 'rows' => "",
- 'alsoblock' => ""
- ));
-
- }
-
function emailStory($story_id, $action) {
--- 554,557 ----
***************
*** 825,1419 ****
return $emailform;
}
-
- /*
- * Displays a list of stories
- * Do we need this anywhere outside of admin????
- */
- function listStory($ary, $first) {
-
- $author_id = $ary['author_id'];
- $topic_id = $ary['topic_id'];
- $section_id = $ary['section_id'];
-
- $cmt_list = 10; /* num of stories to display before the "more" link */
-
- $q = "SELECT story.hits,
- story.story_id,
- story.title,
- author.author_name,
- commentcount.count AS commentcount,
- date_format(time,$this->admin_dateformat) AS df
- FROM psl_story story,
- psl_author author,";
- if ($topic_id) {
- $q .= " psl_topic_lut, ";
- }
- if ($section_id) {
- $q .= " psl_section_lut, ";
- }
- $q .= " psl_commentcount commentcount
- WHERE story.story_id = commentcount.count_id
- AND author.author_id = story.user_id ";
-
- $user_id = $this->auth->auth[uid];
- // if you're not a storyeditor, then you can only view your own stories.
- if (!$this->perm->have_perm("story,storyeditor")) {
- $q .= "AND '$user_id' = story.user_id
- AND '$user_id' = author.author_id ";
- }
- if ($author_id) {
- $q .= "AND '$author_id' = story.user_id ";
- }
- if ($topic_id) {
- $q .= "AND story.story_id = psl_topic_lut.story_id ";
- $q .= "AND '$topic_id' = psl_topic_lut.topic_id ";
- }
- if ($section_id) {
- $q .= "AND story.story_id = psl_section_lut.story_id ";
- $q .= "AND '$section_id' = psl_section_lut.section_id ";
- }
- $q .= "ORDER BY time DESC";
-
- $this->db->query($q);
-
- $count = 0;
- $this->template->set_block("liststory", "row", "rows");
- $this->template->set_block("liststory", "row2", "rows2");
-
-
- $author = new Author;
- $topic = new Topic;
- $section = new Section;
- $author_array = $author->getAuthors();
- $topic_array = $topic->getTopics();
- $section_array = $section->getSections();
-
-
-
- $this->template->set_block("liststory", "each_author", "authors");
- $this->template->set_var(array(
- "AUTHOR_ID" => "",
- "AUTHOR_NAME" => "".pslgetText("All Authors")."",
- "SELECTED" => ""
- ));
- $this->template->parse("authors", "each_author", "true");
- while (list(, $cur_Author) = @each($author_array)) {
- $this->template->set_var(array(
- "AUTHOR_ID" => $cur_Author['id'],
- "AUTHOR_NAME" => $cur_Author['name'],
- "SELECTED" => ""
- ));
- if ($author_id == $cur_Author['id']) {
- $this->template->set_var(array(
- "SELECTED" => "selected=\"selected\""
- ));
- }
- $this->template->parse("authors", "each_author", "true");
- }
-
- $this->template->set_block("liststory", "each_topic", "topics");
- $this->template->set_var(array(
- "TOPIC_ID" => "",
- "TOPIC_NAME" => "".pslgetText("All Topics")."",
- "SELECTED" => ""
- ));
- $this->template->parse("topics", "each_topic", "true");
- while (list(, $cur_Topic) = each($topic_array)) {
- $this->template->set_var(array(
- "TOPIC_NAME" => $cur_Topic[name],
- "TOPIC_ID" => $cur_Topic[id],
- "SELECTED" => ""
- ));
- if ($cur_Topic[id] == $topic_id) {
- $this->template->set_var(array(
- "SELECTED" => "selected=\"selected\""
- ));
- }
- $this->template->parse("topics", "each_topic", "true");
- }
-
- $this->template->set_block("liststory", "each_section", "sections");
- $this->template->set_var(array(
- "SECTION_ID" => "",
- "SECTION_NAME" => "".pslgetText("All Sections")."",
- "SELECTED" => ""
- ));
- $this->template->parse("sections", "each_section", "true");
- while (list(, $cur_Section) = each($section_array)) {
- $this->template->set_var(array(
- "SECTION_NAME" => $cur_Section[name],
- "SECTION_ID" => $cur_Section[id],
- "SELECTED" => ""
- ));
- if ($cur_Section['id'] == $section_id) {
- $this->template->set_var(array(
- "SELECTED" => "selected=\"selected\""
- ));
- }
- $this->template->parse("sections", "each_section", "true");
- }
-
- $this->template->set_var(array(
- 'ACTION_URL' => $this->psl['phpself'],
- 'TOPIC_SELECT' => $topic_select_html,
- 'SECTION_SELECT' => $section_select_html,
- 'AUTHOR_SELECT' => $author_select_html
- ));
-
- while ($this->db->next_record()) {
-
- $story_id = $this->db->Record["story_id"];
- $count++;
-
- if ( ($count > $first) and ($count <= ($first+$cmt_list)) ) {
-
- $view_url = $this->psl['rooturl'] . "/article.php3?story_id=$story_id";
- $modify_url = $this->psl['adminurl'] . "/storyAdmin.php3?submit=edit&story_id=$story_id";
- $delete_url = $this->psl['adminurl'] . "/storyAdmin.php3?submit=delete&story_id=$story_id";
-
- $this->template->set_var(array(
- 'COUNT' => $count,
- 'VIEWURL' => $view_url,
- 'MODIFYURL' => $modify_url,
- 'DELETEURL' => $delete_url,
- 'TITLE' => $this->db->Record["title"],
- 'AUTHOR' => $this->db->Record["author_name"],
- 'HITS' => $this->db->Record["hits"],
- 'COMMENTCOUNT' => $this->db->Record["commentcount"],
- 'DATE' => $this->db->Record["df"]
- ));
- if ($i%2 == 0) {
- $this->template->parse("rows","row","true");
- } else {
- $this->template->parse("rows","row2","true");
- }
- $i++;
- }
- }
-
- $first += $cmt_list;
- $left = $count - $first;
- $this->template->set_var(array(
- 'MORE_LINK' => ""
- ));
- if ($count > $first) {
- $this->template->set_var(array(
- 'MORE_LINK' => "<a href=\"" . $this->psl['phpself'] . "?submit=modify" . $this->psl['amp'] .
- "author_id=" . $author_id . $this->psl['amp'] .
- "topic_id=" . $topic_id . $this->psl['amp'] .
- "section_id=" . $section_id . $this->psl['amp'] .
- "next=$first\">$left " . pslgetText("More")."</a>"
- ));
- }
-
- $this->template->parse('OUT', array("liststory"));
- $this->template->p('OUT');
-
- }
-
-
- function newStory($ary,$data_source) {
-
- global $author_id,$author_name;
-
- # global $debug;
- # $debug = true;
- # debug("Story::newStory", $ary);
- # debug("Story::newStory::topic_ary", $ary[topic_id_ary]);
- # debug("Story::newStory::section_ary", $ary[section_id_ary]);
-
- // echo "<B>Data_Source: $data_source</B><BR><BR>\n";
-
- $this->template->set_block("newstory","topic_row","topic_rows");
- $this->template->set_block("newstory","section_row","section_rows");
- $this->template->set_block("newstory","author_row","author_rows");
-
- $story_id = $ary['story_id'];
-
- // echo "We're in newStory. Story_id: $story_id<BR>\n";
-
- $this->template->set_var('PLAIN_CHKBOX',"");
- $this->template->set_var('HTML_CHKBOX',"CHECKED");
- $this->template->set_var('EXTTRANS_CHKBOX',"");
-
- $this->template->set_block("newstory","datetime_row","datetime_rows");
- $this->template->set_block("newstory","year_row","year_rows");
- $this->template->set_block("newstory","month_row","month_rows");
- $this->template->set_block("newstory","day_row","day_rows");
- $this->template->set_block("newstory","hour_row","hour_rows");
- $this->template->set_block("newstory","minute_row","minute_rows");
- $this->template->set_block("newstory","second_row","second_rows");
- $this->template->set_block("newstory","datetimeset_row","datetimeset_rows");
-
- if ($data_source == "array") { /* this is what happens during a preview */
-
- // clean() is supposed to handle arrays, but the topic/section arrays
- // always got mangled after the clean function. so we're doing one by one.
- $ary['dept'] = clean($ary['dept']);
- $ary['intro_text'] = clean($ary['intro_text']);
- $ary['body_text'] = clean($ary['body_text']);
- $ary['title'] = clean($ary['title']);
- if( $ary['story_date'] ) {
- $ary['datetime'] = implode( '-', $ary['story_date']) ." ". implode( ':',$ary['story_time']);
- } else {
- $ary['datetime'] = date("Y-m-d H:i:s");
- }
- $this->template->set_var(array(
- 'DEPT' => $ary['dept'],
- 'INTROTEXT' => $ary['intro_text'],
- 'BODYTEXT' => $ary['body_text'],
- 'TITLE' => $ary['title'],
- 'TIME' => $ary['datetime'],
- 'AUTHOR_ID' => $author_id,
- 'AUTHOR_NAME' => $author_name
- ));
- // $this->template->set_block("newstory","datetime_row","datetime_rows");
- if (!$this->perm->have_perm("story,storyeditor")) {
- $this->template->set_var(array(
- 'TYPE' => "hidden",
- 'TIME_VALUE' => $ary['datetime']
- ));
- $this->template->parse("datetime_rows","datetime_row",true);
- } else {
- $datetime = split( ' ', $ary['datetime']);
- $story_date = split( '-', $datetime[0]);
- $story_time = split( ':', $datetime[1]);
-
- // setup year select box
- for( $i=1998; $i<2009; $i++) {
- $this->template->set_var(array(
- 'SELECTED' => '',
- 'STORYYEAR' => $i
- ));
- if( $i == $story_date[0]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("year_rows","year_row",true);
- }
- // setup month select box
- for( $i=1; $i<=12; $i++) {
- $this->template->set_var(array(
- 'SELECTED' => '',
- 'STORYMONTH' => sprintf( "%02d", $i)
- ));
- if( $i == $story_date[1]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("month_rows","month_row",true);
- }
-
- // setup day select box
- for( $i=1; $i<=31; $i++) {
- $this->template->set_var(array(
- 'SELECTED' => '',
- 'STORYDAY' => sprintf( "%02d", $i)
- ));
- if( $i == $story_date[2]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("day_rows","day_row",true);
- }
-
- // setup hour select box
- for( $i=1; $i<=24; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYHOUR' => $i
- ));
- if( $i == $story_time[0]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("hour_rows","hour_row",true);
- }
-
- // setup minute select box
- for( $i=1; $i<=60; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYMINUTE' => sprintf( "%02d", $i)
- ));
- if( $i == $story_time[1]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("minute_rows","minute_row",true);
- }
-
- // setup seconds select box
- for( $i=1; $i<=60; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYSECOND' => sprintf( "%02d", $i)
- ));
- if( $i == $story_time[2]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("second_rows","second_row",true);
- }
- $this->template->parse("datetimeset_rows","datetimeset_row",true);
- }
-
- if ($ary['content'] == "plain") {
- $this->template->set_var('PLAIN_CHKBOX',"CHECKED");
- $this->template->set_var('HTML_CHKBOX',"");
- $this->template->set_var('EXTTRANS_CHKBOX',"");
- } elseif ($ary['content'] == "exttrans") {
- $this->template->set_var('PLAIN_CHKBOX',"");
- $this->template->set_var('HTML_CHKBOX',"");
- $this->template->set_var('EXTTRANS_CHKBOX',"CHECKED");
- } else {
- $this->template->set_var('PLAIN_CHKBOX',"");
- $this->template->set_var('HTML_CHKBOX',"CHECKED");
- $this->template->set_var('EXTTRANS_CHKBOX',"");
- }
-
- $topic_ary = $ary['topic_id_ary'];
- $section_ary = $ary['section_id_ary'];
-
- $user_id = $this->auth->auth['uid'];
- if ( $ary['author_id'] != "") {
- $user_id = $ary['author_id'];
- }
- } elseif ($data_source == "database") { /* this is a story from the DB */
-
- /*
- * Get the topic_id's for this story into an array
- */
- $q = "SELECT psl_topic.topic_id
- FROM psl_topic,psl_topic_lut
- WHERE psl_topic_lut.story_id = '$story_id'
- AND psl_topic.topic_id = psl_topic_lut.topic_id";
- $this->db->query($q);
- $i = 0;
- while ($this->db->next_record()) {
- $topic_ary[$i] = $this->db->Record['topic_id'];
- // echo "ARY[ $i ] : $topic_ary[$i]<BR>\n";
- $i++;
- }
-
- /*
- * Get the section_id's for this story into an array
- */
- $q = "SELECT psl_section.section_id
- FROM psl_section,psl_section_lut
- WHERE psl_section_lut.story_id = '$story_id'
- AND psl_section.section_id = psl_section_lut.section_id";
- $this->db->query($q);
- $i = 0;
-
- while ($this->db->next_record()) {
- $section_ary[$i] = $this->db->Record['section_id'];
- $i++;
- }
-
- /* Trying to save a query, I pulled this from outside this if statement */
- $this->db->query("SELECT * from psl_story WHERE story_id = '$story_id'");
- $this->db->next_record();
-
- $this->template->set_var(array(
- 'DEPT' => stripslashes($this->db->Record['dept']),
- 'INTROTEXT' => htmlspecialchars(stripslashes($this->db->Record['intro_text'])),
- 'BODYTEXT' => htmlspecialchars(stripslashes($this->db->Record['body_text'])),
- 'TITLE' => stripslashes($this->db->Record['title']),
- 'TIME' => $this->db->Record['time'],
- 'AUTHOR_ID' => $this->db->Record['user_id']
- # 'AUTHOR_NAME' => $author_name,
-
- ));
- $user_id = $this->db->Record['user_id'];
-
- // Normal users can't edit another user's stories
- if((!$this->perm->have_perm('story,storyeditor')) AND
- ( $user_id != $this->auth->auth['uid'])) {
- return false;
- }
-
- /* if storyeditor, enable setting of date, otherwise display date */
- if (!$this->perm->have_perm("story,storyeditor")) {
- $this->template->set_var(array(
- 'TYPE' => "hidden",
- 'TIME_VALUE' => $this->db->Record['time']
- ));
- $this->template->parse("datetime_rows","datetime_row",true);
- } else {
- $datetime = split( ' ', $this->db->Record['time']);
- $story_date = split( '-', $datetime[0]);
- $story_time = split( ':', $datetime[1]);
-
- // setup year select box
- for( $i=1998; $i<2009; $i++) {
- $this->template->set_var(array(
- 'SELECTED' => '',
- 'STORYYEAR' => $i
- ));
-
- if( $i == $story_date[0]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("year_rows","year_row",true);
- }
-
- // setup month select box
- for( $i=1; $i<=12; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYMONTH' => sprintf( "%02d", $i)
- ));
- if( $i == $story_date[1]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("month_rows","month_row",true);
- }
-
- // setup day select box
- for( $i=1; $i<=31; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYDAY' => sprintf( "%02d", $i)
- ));
- if( $i == $story_date[2]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("day_rows","day_row",true);
- }
-
- // setup hour select box
- for( $i=1; $i<=24; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYHOUR' => $i
- ));
- if( $i == $story_time[0]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("hour_rows","hour_row",true);
- }
-
- // setup minute select box
- for( $i=1; $i<=60; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYMINUTE' => sprintf( "%02d", $i)
- ));
- if( $i == $story_time[1]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("minute_rows","minute_row",true);
- }
-
- // setup seconds select box
- for( $i=1; $i<=60; $i++) {
- $this->template->set_var(array(
- 'TYPE' => 'select',
- 'SELECTED' => '',
- 'STORYSECOND' => sprintf( "%02d", $i)
- ));
- if( $i == $story_time[2]) {
- $this->template->set_var('SELECTED', "selected=\"selected\"");
- }
- $this->template->parse("second_rows","second_row",true);
- }
- $this->template->parse("datetimeset_rows","datetimeset_row",true);
- }
-
- }
-
- $this->template->set_var(array(
- 'ACTION_URL' => "storyAdmin.php3",
- # 'AUTHOR_ID' => $author_id,
- # 'AUTHOR_NAME' => $author_name,
- 'STORY_ID' => $story_id
- ));
-
-
- $this->db->query("SELECT topic_id,
- topic_name
- FROM psl_topic
- ORDER BY topic_name");
- while ($this->db->next_record()) {
- $this->template->set_var(array(
- 'TOPIC_ID' => $this->db->Record['topic_id'],
- 'TOPIC_NAME' => $this->db->Record['topic_name']
- ));
-
- $this->template->set_var('SELECTED',"");
- for ($i = 0 ; $i < count($topic_ary) ; $i++) {
-
- $array = $topic_ary[$i];
- $dbname = $this->db->Record['topic_id'];
-
- if ($topic_ary[$i] == $this->db->Record['topic_id']) {
- $this->template->set_var('SELECTED',"SELECTED");
- }
- }
-
- $this->template->parse("topic_rows","topic_row",true);
- }
-
- $this->db->query("SELECT section_id,
- section_name
- FROM psl_section
- ORDER BY section_name");
- while ($this->db->next_record()) {
- $this->template->set_var(array(
- 'SECTION_ID' => $this->db->Record['section_id'],
- 'SECTION_NAME' => $this->db->Record['section_name']
- ));
-
- $this->template->set_var('SELECTED',"");
- for ($i = 0 ; $i < count($section_ary) ; $i++) {
- if ($section_ary[$i] == $this->db->Record['section_id']) {
- $this->template->set_var('SELECTED',"SELECTED");
- }
- }
-
- $this->template->parse("section_rows","section_row",true);
- }
-
- if (!$this->perm->have_perm("story,storyeditor")) {
- $this->template->set_var(array(
- 'AUTHOR_ID' => $this->auth->auth['uid'],
- 'AUTHOR_NAME' => $this->auth->auth['uname']
- ));
-
- # $this->template->set_var('AUTHOR_SELECTED',"");
- $this->template->set_var('AUTHOR_SELECTED',"SELECTED");
- $this->template->parse("author_rows","author_row",true);
-
- } else {
- $q = "SELECT author_id,
- author_name
- FROM psl_author ";
- $q .= " ORDER BY author_name ";
-
- $this->db->query($q);
-
- while ($this->db->next_record()) {
- $this->template->set_var(array(
- AUTHOR_ID => $this->db->Record['author_id'],
- AUTHOR_NAME => $this->db->Record['author_name']
- ));
- $this->template->set_var('AUTHOR_SELECTED',"");
- if ($this->db->Record['author_id'] == $user_id ){
- $this->template->set_var('AUTHOR_SELECTED',"SELECTED");
- }
-
- $this->template->parse("author_rows","author_row",true);
- }
-
- }
- $description = sprintf( "%s (%s) added new story %s as userid %s", $this->auth->auth['uname'], $this->auth->auth['uid'], $story_id, $user_id);
- logwrite("Story Admin", $description);
- $this->template->parse('OUT',array("newstory"));
- $this->template->p('OUT');
- return true;
- }
-
}
?>
--- 641,644 ----
|