--- index.php 2000/12/07 17:01:39 1.1 +++ index.php 2000/12/08 08:27:32 1.2 @@ -110,14 +110,15 @@ if (isset($GLOBALS[$what])) { $GLOBALS[$what]="true"; } else { - $GLOBALS[$what]="flase"; + $GLOBALS[$what]="false"; } } fix_checkbox("analitical"); fix_checkbox("solution"); - $dbh->dbh_do(fixsql("insert into poruke (thread_id,reply_id,osoba_id,sadrzaj,level,pos,analitical,solution) values ($thread_id,$reply_id,$osoba_id,'$sadrzaj',$level,'$pos',$analitical,$solution)")); + $sadrzaj=trim($sadrzaj); + $dbh->dbh_do(fixsql("insert into poruke (thread_id,reply_id,osoba_id,sadrzaj,level,pos,analitical,solution) values ($thread_id,$p,$osoba_id,'$sadrzaj',$level,'$pos',$analitical,$solution)")); $sth=$dbh->prepare("select currval('poruke_id_seq') as id"); $sth->execute(); @@ -125,6 +126,7 @@ if ($row=$sth->fetchrow_hash()) { $p=$row[id]; // poruka_id for later } + $what="show"; } elseif (isset($insert_newtopic)) { @@ -136,6 +138,7 @@ $sth->execute(); if ($row=$sth->fetchrow_hash()) { $t=$row[id]; // topic for later + $title=trim($title); $dbh->dbh_do(fixsql("insert into topics (id,title) values ($t,'$title')")); } } @@ -143,15 +146,24 @@ //----- end of inserts/updates... -if ($what=="reply" && isset($t)) { +if (($what=="reply" || $what="show") && isset($t)) { $sql_where=" and topics.id=$t"; } +if ($solution_room == 1) { + // don't limit just to topics starts + $sql_where.=" and poruke.thread_id=topics.id and poruke.thread_id!=0"; +} else { + // limit just to topics start + $sql_where.=" and poruke.id=topics.id and poruke.thread_id=0"; +} + $sth = $dbh->prepare("select topics.id as topic_id,title,sadrzaj,full_name,poruke.datum as datum from topics,poruke,osobe - where poruke.thread_id=0 and poruke.id=topics.id and poruke.osoba_id=osobe.id $sql_where $sql_poruke_where + where poruke.osoba_id=osobe.id $sql_where $sql_poruke_where order by datum asc "); + $sth->execute(); $topics=""; while ($row=$sth->fetchrow_hash()) { @@ -160,7 +172,7 @@ AUTHOR => $row[full_name], DATE => $row[datum], SADRZAJ => $row[sadrzaj], - COMMENTS => "comments>>", + COMMENTS => "comments>>", PHP_SELF => $PHP_SELF )); $tpl->parse(ROWS,".theader"); @@ -180,16 +192,23 @@ $l_ul.=""; } + // don't indent in solution room + if ($solution_room == 1) { $l_ul=$r_ul=""; } $tpl->assign( array( L_INDENT => $l_ul, R_INDENT => $r_ul )); $topic=trim(strip_tags($row2[topic])); - if (isset($p) && $p == $row2[id]) { + if (isset($p) && $p == $row2[id] && $what=="reply") { $topic="$topic..."; - $tpl->assign( array( P => $p )); - $tpl->parse(CHECKBOXES, ".checkboxes"); + $tpl->assign( array( P => $p, T => $t )); + if ($analitical_room == 1) { + $tpl->parse(CHECKBOXES, ".checkboxes"); + } $tpl->parse(REPLY, ".reply"); + } elseif (isset($p) && $p == $row2[id]) { + $topic="$topic..."; + $tpl->assign( array( P => $p, T => $t )); } else { if (!isset($p)) { $p=$t; } $tmp_t=$row2[thread_id]; @@ -216,7 +235,7 @@ // non-unroll topics $tpl->assign( array( SADRZAJ => $row[sadrzaj], - COMMENTS => "comments>>" + COMMENTS => "comments>>" )); # $tpl->parse(ROWS,".theader"); $tpl->parse(ROWS,".trow"); @@ -237,12 +256,16 @@ if ($what == "new") { $tpl->parse(MAIN, ".newtopic"); $tpl->assign(array( TITLE => "Start of new topic" )); +} elseif ($what == "show") { + $tpl->assign(array( + TITLE => "Select article for reply", + P => $p + )); } elseif ($what == "reply") { $tpl->assign(array( TITLE => "Reply to selected article", P => $p )); -# $tpl->parse(MAIN, ".reply"); } $tpl->parse(MAIN, "main");