if (!($course = get_record('course', 'id', $cm->course))) {
    error('Course is misconfigured');
}
if (!($netpublish = get_record('netpublish', 'id', $cm->instance))) {
    error('Course module is incorrect');
}
confirm_sesskey($skey);
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
if (!has_capability('mod/netpublish:movearticle', $context)) {
    error(get_string('errorpermissionmove', 'netpublish'));
}
if (!($sections = netpublish_get_sections($netpublish->id))) {
    $sections = array();
}
$movingarticle = netpublish_get_article($articleid);
$strfrontpage = !empty($sections) && !empty($sections[key($sections)]->frontpagename) ? $sections[key($sections)]->frontpagename : (!($frontpage = get_record("netpublish_first_section_names", "publishid", $netpublish->id)) ? get_string("frontpage", "netpublish") : $frontpage->name);
$sections[0] = new stdClass();
$sections[0]->id = 0;
$sections[0]->publishid = $netpublish->id;
$sections[0]->fullname = $strfrontpage;
$sections[0]->parentid = 0;
ksort($sections);
//print_header();
if ($course->category) {
    $navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
}
// Get strings
$strnetpublishes = get_string("modulenameplural", "netpublish");
$strnetpublish = get_string("modulename", "netpublish");
$strcreated = get_string("created", "netpublish");
     echo "<strong>" . $strpublished . "</strong>: " . userdate($articles[key($articles)]->timepublished) . "</p>\n";
     echo stripslashes($articles[key($articles)]->intro);
     if (empty($mod->fullpage)) {
         echo "<p><a href=\"view.php?id={$cm->id}&amp;section={$section}&amp;article=" . $articles[key($articles)]->id . "\">";
         echo $strreadmore . "</a></p>\n";
     } else {
         echo stripslashes($articles[key($articles)]->content);
         echo "<p style=\"font-size: x-small;\">(";
         echo $strcreated;
         echo ": " . userdate($articles[key($articles)]->timecreated);
         echo " " . $strmodified . ": " . userdate($articles[key($articles)]->timemodified) . ")</p>\n";
     }
 } else {
     if (!$frontpage) {
         /// display a single article on the page (the first in current section
         $thearticle = netpublish_get_article($article);
         // Edit buttons
         netpublish_print_actionbuttons($cm, $thearticle, $USER->id, $course->id, true);
         echo "<h2>" . stripslashes($thearticle->title) . "</h2>\n";
         //if ( $_GET['id'] != 15832 ) { // (nadavkav) orit tati hack. do not forget to remove after 9.3.2010
         echo "<div class=\"authors\"><strong>" . $strauthor . "</strong>: " . s($thearticle->firstname) . " " . s($thearticle->lastname);
         netpublish_print_authors($thearticle->authors);
         echo "<br />\n";
         echo "<strong>" . $strpublished . "</strong>: " . userdate($thearticle->timepublished) . "</div>\n";
         //}
         echo stripslashes($thearticle->intro);
         echo stripslashes($thearticle->content);
         echo "<p style=\"font-size: x-small;\">(";
         echo $strcreated;
         echo ": " . userdate($thearticle->timecreated);
         echo " " . $strmodified . ": " . userdate($thearticle->timemodified) . ")</p>\n";
        error("Course Module ID was incorrect");
    }
}
// Construct objects used in Moodle
netpublish_set_std_classes($cm, $course, $mod, $info);
unset($info);
require_login($course->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$strauthor = get_string("by", "netpublish");
$strpublished = get_string("published", "netpublish");
$strnotpublished = get_string("notpublished", "netpublish");
$strcreated = get_string("created", "netpublish");
$strmodified = get_string("modified");
$strpublishes = get_string("modulenameplural", "netpublish");
$strpreview = get_string("preview", "netpublish");
$strpending = get_string("pendingarticles", "netpublish");
$objarticle = netpublish_get_article($article, $statusid);
if ($course->category) {
    $navigation = "<a href=\"../../course/view.php?id={$course->id}\">{$course->shortname}</a> ->";
}
$navigation .= "<a href=\"index.php?id={$course->id}\">{$strpublishes}</a> -> ";
$navigation .= "<a href=\"view.php?id={$cm->id}\">{$mod->name}</a> -> ";
$navigation .= "<a href=\"drafts.php?id={$cm->id}\">{$strpending}</a> -> {$strpreview}";
$icons = $CFG->wwwroot . '/pix/t';
$editbutton = '<img src="' . $icons . '/edit.gif" alt="edit" title="edit" />';
$deletebutton = '<img src="' . $icons . '/delete.gif" alt="delete" title="delete" />';
print_header_simple("{$course->shortname}: {$mod->name}", "{$course->fullname}", "{$navigation} ");
print_simple_box_start("center", "100%");
include_once 'preview.html';
print_simple_box_end();
print_footer($course);