X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=banana%2Fspool.inc.php;h=d8171fe867bd300c71a03c1762cba419f45861b8;hb=e81634dbab2415d81ea22e8b7b43a6c5e6e49931;hp=2df59e4d22a04ca58861fa5eea948fe502e2746b;hpb=c42efe2f093bae5e429288c6a39df6ff9357a88f;p=banana.git diff --git a/banana/spool.inc.php b/banana/spool.inc.php index 2df59e4..d8171fe 100644 --- a/banana/spool.inc.php +++ b/banana/spool.inc.php @@ -7,7 +7,7 @@ * Copyright: See COPYING files that comes with this distribution ********************************************************************************/ -if(!function_exists('_file_put_contents')) { +if(!function_exists('file_put_contents')) { function file_put_contents($filename, $data) { $fp = fopen($filename, 'w'); @@ -83,6 +83,8 @@ class BananaSpool var $ids; /** thread starts */ var $roots; + /** test validity */ + var $valid = true; /** constructor * @param $_group STRING group name @@ -94,22 +96,29 @@ class BananaSpool global $banana; $this->group = $_group; $groupinfo = $banana->nntp->group($_group); - if (!$groupinfo) { return ($this = null); } + if (!$groupinfo) { + $this->valid = false; + return null; + } $this->_readFromFile(); $do_save = false; - $first = $banana->maxspool ? max($groupinfo[2]-$banana->maxspool, $groupinfo[1]) : $groupinfo[1]; - $last = $groupinfo[2]; + $first = $banana->maxspool ? max($groupinfo[2] - $banana->maxspool, $groupinfo[1]) : $groupinfo[1]; + $last = $groupinfo[2]; + if ($this->version == BANANA_SPOOL_VERSION && is_array($this->overview)) { - for ($id = min(array_keys($this->overview)); $id<$first; $id++) { - $this->delid($id, false); - $do_save = true; + $mids = array_keys($this->overview); + foreach ($mids as $id) { + if (($first <= $last && ($id < $first || $id > $last)) + || ($first > $last && $id < $first && $id > $last)) + { + $this->delid($id, false); + $do_save = true; + } } if (!empty($this->overview)) { $first = max(array_keys($this->overview))+1; - } else { - return; } } else { unset($this->overview, $this->ids); @@ -130,7 +139,10 @@ class BananaSpool { $file = $this->_spoolfile(); if (file_exists($file)) { - $this = unserialize(file_get_contents($file)); + $temp = unserialize(file_get_contents($file)); + foreach (get_object_vars($temp) as $key=>$val) { + $this->$key = $val; + } } } @@ -145,7 +157,7 @@ class BananaSpool $this->roots[] = $id; } } - + file_put_contents($file, serialize($this)); } @@ -301,16 +313,16 @@ class BananaSpool function _to_html($_id, $_index, $_first=0, $_last=0, $_ref="", $_pfx_node="", $_pfx_end="", $_head=true) { - $spfx_f = 'o'; - $spfx_n = '*'; - $spfx_Tnd = '+'; - $spfx_Lnd = '`'; - $spfx_snd = '-'; - $spfx_T = '+'; - $spfx_L = '`'; - $spfx_s = '-'; - $spfx_e = ' '; - $spfx_I = '|'; + $spfx_f = makeImg('k1', 'o', 21, 9); + $spfx_n = makeImg('k2', '*', 21, 9); + $spfx_Tnd = makeImg('T-direct', '+', 21, 12); + $spfx_Lnd = makeImg('L-direct', '`', 21, 12); + $spfx_snd = makeImg('s-direct', '-', 21, 5); + $spfx_T = makeImg('T', '+', 21, 12); + $spfx_L = makeImg('L', '`', 21, 12); + $spfx_s = makeImg('s', '-', 21, 5); + $spfx_e = makeImg('e', ' ', 21, 12); + $spfx_I = makeImg('I', '|', 21, 12); if ($_index + $this->overview[$_id]->desc < $_first || $_index > $_last) { return; @@ -326,10 +338,17 @@ class BananaSpool $res .= "" ."
$_pfx_node".($hc?($_head?$spfx_f:($this->overview[$_id]->parent_direct?$spfx_s:$spfx_snd)):$spfx_n) ."
"; + $subject = $this->overview[$_id]->subject; + if (strlen($subject) == 0) { + $subject = _b_('(pas de sujet)'); + } if ($_index == $_ref) { - $res .= ''.htmlentities($this->overview[$_id]->subject).''; + $res .= ''.htmlentities($subject).''; } else { - $res .= "".htmlentities($this->overview[$_id]->subject).''; + $res .= makeHREF(Array('group' => $this->group, + 'artid' => $_id), + htmlentities($subject), + htmlentities($subject)); } $res .= "\n".formatFrom($this->overview[$_id]->from)."\n"; @@ -385,6 +404,16 @@ class BananaSpool $res .= ''._b_('Aucun message dans ce forum').''; } + global $banana; + if (is_object($banana->groups)) { + $res .= '' + . $banana->groups->to_html() + . ''; + } + $res .= '' + . makeHREF(Array('subscribe' => 1), _b_('GĂ©rer mes abonnements')) + . ''; + return $res .= ''; } @@ -420,4 +449,5 @@ class BananaSpool } } +// vim:set et sw=4 sts=4 ts=4 ?>