rename classes + bugfixes
[banana.git] / subscribe.php
1 <?php
2 /********************************************************************************
3 * subscribe.php : subscriptions page
4 * ---------------
5 *
6 * This file is part of the banana distribution
7 * Copyright: See COPYING files that comes with this distribution
8 ********************************************************************************/
9
10 require_once("include/session.inc.php");
11 require_once("include/misc.inc.php");
12 require_once("include/password.inc.php");
13 require_once("include/NetNNTP.inc.php");
14 require_once("include/groups.inc.php");
15 require_once("include/format.inc.php");
16 require_once("include/config.inc.php");
17 require_once("include/profile.inc.php");
18 require_once("include/subscribe.inc.php");
19 require_once("include/error.inc.php");
20
21 $profile=getprofile();
22 require_once("include/header.inc.php");
23
24 $nntp = new nntp($news['server']);
25 if (!$nntp) error("nntpsock");
26 if ($news['user']!="anonymous") {
27 $result = $nntp->authinfo($news["user"],$news["pass"]);
28 if (!$result) error("nntpauth");
29 }
30 $groups = new BananaGroups($nntp,2);
31 ?>
32
33 <h1>
34 <?php echo _b_('Abonnements'); ?>
35 </h1>
36
37 <?php
38
39 if (isset($_POST['subscribe']) && isset($_POST['action'])
40 && $_POST['action']=="OK") {
41 update_subscriptions($_POST['subscribe']);
42 $profile['subscribe']=$_POST['subscribe'];
43 }
44
45 if (!sizeof($groups->overview)) error("nntpgroups");
46
47 displayshortcuts();
48 ?>
49
50 <form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
51 <table class="<?php echo $css["bicol"];?>" cellspacing="0" cellpadding="2">
52 <tr>
53 <th>
54 <?php echo _b_('Total'); ?>
55 </th>
56 <th>
57 <?php echo _b_('Abonné'); ?>
58 </th>
59 <th>
60 <?php echo _b_('Nom'); ?>
61 </th>
62 <th>
63 <?php echo _b_('Description'); ?>
64 </th>
65 </tr>
66 <?php
67 $pair = true;
68 foreach ($groups->overview as $g => $d) {
69 $pair = !$pair;
70 $groupinfo = $nntp->group($g);
71 $newarts = $nntp->newnews($profile['lastnews'],$g);
72 ?>
73 <tr class="<?php echo ($pair?$css["pair"]:$css["impair"]);?>" >
74 <td class="<?php echo $css["total"]; ?>">
75 <?php echo $groupinfo[0]; ?>
76 </td>
77 <td class="<?php echo $css["unread"]; ?>">
78 <input type="checkbox" name="subscribe[]" value="<?php echo $g;?>"
79 <?php echo (in_array($g,$profile['subscribe'])?'checked="checked"'
80 :'');?> />
81 </td>
82 <td class="<?php echo $css["group"]; ?>">
83 <?php echo "<a href=\"thread.php?group=$g\">$g</a>";?>
84 </td>
85 <td class="<?php echo $css["description"]; ?>">
86 <?php echo $d[0];?>
87 </td>
88 </tr>
89 <?php
90 }
91 ?>
92 <tr class="<?php echo (!$pair?$css["pair"]:$css["impair"]); ?>">
93 <td colspan="4" class="bouton">
94 <input type="submit" name="action" value="OK" />
95 </td>
96 </tr>
97 </table>
98 </form>
99 <?php
100
101 displayshortcuts();
102
103 $nntp->quit();
104 require_once("include/footer.inc.php");
105 ?>