cvs: pear /Forum/lib/classes/db NNTPStandard.php

From: Date: Mon, 29 Oct 2001 21:23:19 +0000
Subject: cvs: pear /Forum/lib/classes/db NNTPStandard.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-1189@lists.php.net to get a copy of this message
mog Mon Oct 29 16:23:19 2001 EDT Modified files: /pear/Forum/lib/classes/db NNTPStandard.php Log: NNTP stuff. Index: pear/Forum/lib/classes/db/NNTPStandard.php diff -u pear/Forum/lib/classes/db/NNTPStandard.php:1.1 pear/Forum/lib/classes/db/NNTPStandard.php:1.2 --- pear/Forum/lib/classes/db/NNTPStandard.php:1.1 Sat Oct 27 08:12:29 2001 +++ pear/Forum/lib/classes/db/NNTPStandard.php Mon Oct 29 16:23:19 2001 @@ -13,10 +13,18 @@ var $db=FALSE; function connect() { + /* $this->db = new ForumNNTP("news1.telia.com"); if(PEAR::isError($this->db)) { return $this->db; } + */ + if(!is_object($this->db)) { + require_once("Net_NNTP/NNTP.php"); + $this->db = new Net_NNTP; + $this->db->connect("news.php.net"); + $this->db->_debug = 1; + } } /** @@ -119,8 +127,18 @@ case FORUM_FLAT: case FORUM_FLAT_FLOAT: $this->connect(); - my_var_dump($rows = $this->process_headers($this->db->xover($forum_id,$from,$to))); - return $rows; + $group = $this->db->select_group($forum_id); + + if($group["first"] > $from) { + print "from changed from $from to $group[first]"; + $from = $group["first"]; + } + if($group["last"] < $from+$to) { + print "to changed from $to to $group[last]-$from"; + $to = $group["last"]; + } + + return $this->process_headers($this->db->get_overview($from,$from+$to)); default: trigger_error("Unhandled \$whattoget: $whattoget",E_USER_ERROR); @@ -134,14 +152,31 @@ "message_id" => 0, "parent_id" => 0, ); - foreach($rows as $row) { - if(empty($row["References"])) $row["References"] = 0; + foreach($rows as $msgid => $roww) { + $row =& $rows[$msgid]; + + if(isset($row["message_id"]) && $row["message_id"] == 0) { continue; } + + $rows[$row["Message-ID"]]["user_id"] = NULL; + $rows[$row["Message-ID"]]["message_id"] = $row["Message-ID"]; + $rows[$row["Message-ID"]]["subject"] = $row["Subject"]; + $rows[$row["Message-ID"]]["author"] = $row["From"]; + $rows[$row["Message-ID"]]["timestamp"] = strtotime($row["Date"]); + $rows[$row["Message-ID"]]["thread_id"] = $row["Message-ID"]; + if(empty($row["References"])) { + $rows[$row["Message-ID"]]["parent_id"] = 0; + $rows[$row["Message-ID"]]["References"] = 0; + } + + if(!isset($rows[$row["References"]])) { - trigger_error("Orphan message (id: $row[message_id]), parent (id: $row[parent_id]) does not exist", E_USER_WARNING); + trigger_error("Orphan message (id: ".$row["Message-ID"]."), parent (id: $row[parent_id]) does not exist", E_USER_WARNING); } $rows[$row["References"]]["replies"][] = $row["Message-ID"]; $rows[$row["References"]]["replies_left"] += 1; + unset($row); } + my_var_dump($rows); return($rows); } @@ -212,7 +247,19 @@ */ function get_forums($parent_id="") { $this->connect(); - $group = $this->db->group("telia.internet.news.test"); + $groups=array(); + foreach($this->db->get_groups(NNTP_ALL) as $group) { + $groups[$group["group"]] = array( + "forum_id" => $group["group"], + "name" => $group["group"], + "count" => $group["last"] - $group["first"], + "description" => $group["desc"], + "last_post" => $group["last"] + ); + } + return $groups; + + /* return array( "telia.internet.news.test" => array( "forum_id" => $group[3], @@ -223,10 +270,8 @@ "last_post" => $group[2], ) ); + */ trigger_error("TODO",E_USER_ERROR); - global $FORUM; - $SQL="SELECT * FROM $FORUM[FORUM_TABLE] WHERE parent_id=$parent_id AND active='Y'"; - return $this->get_rows_by_field($SQL, "forum_id"); } /**

« previous php.pear.cvs (#1189) next »