Location: PHPKode > projects > NetOffice > netoffice/topics/addpost.php
<?php // $Revision: 1.7 $
/* vim: set expandtab ts=4 sw=4 sts=4: */

/**
 * $Id: addpost.php,v 1.7 2003/11/22 03:43:38 madbear Exp $
 * 
 * Copyright (c) 2003 by the NetOffice developers
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */

$checkSession = true;
require_once("../includes/library.php");

$tmpquery = "WHERE topic.id = '$id'";
$detailTopic = new request();
$detailTopic->openTopics($tmpquery);

$tmpquery = "WHERE pro.id = '" . $detailTopic->top_project[0] . "'";
$projectDetail = new request();
$projectDetail->openProjects($tmpquery);

if ($action == "add") {
    $tpm = convertData($tpm);
    autoLinks($tpm);
    $detailTopic->top_posts[0] = $detailTopic->top_posts[0] + 1;
    $tmpquery1 = "INSERT INTO " . $tableCollab["posts"] . "(topic,member,created,message) VALUES('$id','$idSession','$dateheure','$newText')";
    connectSql("$tmpquery1");
    $tmpquery2 = "UPDATE " . $tableCollab["topics"] . " SET last_post='$dateheure',posts='" . $detailTopic->top_posts[0] . "' WHERE id = '$id'";
    connectSql("$tmpquery2");

    if ($notifications == "true") {
        require_once("../topics/noti_newpost.php");
    } 
    header("Location: ../topics/viewtopic.php?id=$id&msg=add");
    exit;
} 

$idStatus = $detailTopic->top_status[0];
$idPublish = $detailTopic->top_published[0];

$tmpquery = "WHERE pos.topic = '" . $detailTopic->top_id[0] . "' ORDER BY pos.created DESC";
$listPosts = new request();
$listPosts->openPosts($tmpquery);
$comptListPosts = count($listPosts->pos_id);

if ($projectDetail->pro_org_id[0] == "1") {
    $projectDetail->pro_org_name[0] = $strings["none"];
} 

$bodyCommand = "onLoad=\"document.ptTForm.tpm.focus();\"";
require_once("../themes/" . THEME . "/header.php");

$blockPage = new block();
$blockPage->openBreadcrumbs();
$blockPage->itemBreadcrumbs($blockPage->buildLink("../projects/listprojects.php?", $strings["projects"], in));
$blockPage->itemBreadcrumbs($blockPage->buildLink("../projects/viewproject.php?id=" . $projectDetail->pro_id[0], $projectDetail->pro_name[0], in));
$blockPage->itemBreadcrumbs($blockPage->buildLink("../topics/listtopics.php?project=" . $projectDetail->pro_id[0], $strings["discussions"], in));
$blockPage->itemBreadcrumbs($detailTopic->top_subject[0]);
$blockPage->closeBreadcrumbs();

if ($msg != "") {
    require_once("../includes/messages.php");
    $blockPage->messagebox($msgLabel);
} 

$block1 = new block();

$block1->form = "ptT";
$block1->openForm("../topics/addpost.php?action=add&amp;id=" . $detailTopic->top_id[0] . "&amp;project=" . $detailTopic->top_project[0]);

if ($error != "") {
    $block1->headingError($strings["errors"]);
    $block1->contentError($error);
} 

$block1->heading($strings["post_to_discussion"] . " : " . $detailTopic->top_subject[0]);

$block1->openContent();
$block1->contentTitle($strings["info"]);

$block1->contentRow($strings["project"], $blockPage->buildLink("../projects/viewproject.php?id=" . $projectDetail->pro_id[0], $projectDetail->pro_name[0] . " (#" . $projectDetail->pro_id[0] . ")", in));
$block1->contentRow($strings["organization"], $projectDetail->pro_org_name[0]);
$block1->contentRow($strings["owner"], $blockPage->buildLink("../users/viewuser.php?id=" . $projectDetail->pro_mem_id[0], $projectDetail->pro_mem_name[0], in) . " (" . $blockPage->buildLink($projectDetail->pro_mem_email_work[0], $projectDetail->pro_mem_login[0], mail) . ")");

if ($sitePublish == "true") {
    $block1->contentRow($strings["published"], $statusPublish[$idPublish]);
} 

$block1->contentRow($strings["retired"], $statusTopicBis[$idStatus]);
$block1->contentRow($strings["posts"], $detailTopic->top_posts[0]);
$block1->contentRow($strings["last_post"], createDate($detailTopic->top_last_post[0], $timezoneSession));

$block1->contentTitle($strings["details"]);

$block1->contentRow($strings["message"], "<textarea rows=\"10\" style=\"width: 400px; height: 160px;\" name=\"tpm\" cols=\"47\"></textarea>");
$block1->contentRow("", "<input type=\"SUBMIT\" value=\"" . $strings["save"] . "\">");

$block1->contentTitle($strings["posts"]);

for ($i = 0;$i < $comptListPosts;$i++) {
    $block1->contentRow($strings["posted_by"], $blockPage->buildLink($listPosts->pos_mem_email_work[$i], $listPosts->pos_mem_name[$i], mail));

    if ($listPosts->pos_created[$i] > $lastvisiteSession) {
        $block1->contentRow($strings["when"], "<b>" . createDate($listPosts->pos_created[$i], $timezoneSession) . "</b>");
    } else {
        $block1->contentRow($strings["when"], createDate($listPosts->pos_created[$i], $timezoneSession));
    } 
    $block1->contentRow("", nl2br($listPosts->pos_message[$i]));
    $block1->contentRow("", "", "true");
} 

$block1->closeContent();
$block1->closeForm();

require_once("../themes/" . THEME . "/footer.php");

?>
Return current item: NetOffice