Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
quotas_oneuser.php
Go to the documentation of this file.
1 <?php
2 
3 require_once("../class/config.php");
4 if (!defined("QUOTASONE")) return;
5 
6 //FIXME missing getfield for $mode
7 if (!isset($mode)) { # when included from adm_login, mode is not set
8  $mode = 0;
9 }
10 // $mode = 4; // Pour Debuguer le mode "graphique" des quotas
11 ?>
12 <center>
13 
14 <h3 style="text-align:center;"><?php printf(_("<b>%s</b> account"),$mem->user["login"]); ?></h3>
15 
16 <div style="width: 600px">
17 
18 <!-- Webspaces -->
19 
20 <?php
21 
22  $totalweb = $quota->getquota('web');
23  if ( $totalweb['u'] > 0 ) {
24  $t=$quota->get_size_unit($totalweb['u'] * 1024);
25  echo "<p>"._("quota_web")." "; // use quota_web because it's the magically translated string
26  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
27  echo "</p>";
28  }
29 ?>
30 
31 <!-- Mails -->
32 
33 <table class="tedit" width="100%">
34 <thead>
35 <tr>
36  <th><?php __("Domains"); ?></th>
37  <th><?php __("Emails"); ?></th>
38  <th><?php __("Space"); ?></th>
39 </tr>
40 </thead>
41 <tbody>
42 <?php
43 
44  $domaines_user = $dom->enum_domains($mem->user["uid"]);
46  foreach ($domaines_user as $domaine) {
47  $mstmp = $quota->get_size_mail_sum_domain($domaine);
48  $totalmail+=$mstmp;
49  }
50 
51  $t=$quota->get_size_unit($totalmail);
52 
53  foreach ($domaines_user as $domaine) {
54  $alias_sizes = $quota->get_size_mail_details_domain($domaine);
55  $domsize = 0;
56  foreach ($alias_sizes as $e) {
57  if($e['size'] > 0) {
58  $domsize += $e['size'];
59  echo "<tr><td>{$domaine}</td>";
60  echo "<td>".str_replace("_","@",$e["alias"])."</td>";
61  echo "<td"; if ($mode!=2) echo " style=\"text-align: right\""; echo ">";
62  $ms = $quota->get_size_unit($e['size']);
63  if ($totalmail) {
64  $pc=intval(100*($e['size']/$totalmail));
65  } else {
66  $pc=0;
67  }
68  if ($mode==0) {
69  echo sprintf("%.1f", $ms['size'])."&nbsp;".$ms['unit'];
70  } elseif ($mode==1) {
71  echo sprintf("%.1f", $pc)."&nbsp;%";
72  } else {
73  $quota->quota_displaybar($pc);
74  }
75  echo "</td></tr>";
76  }
77  }
78 
79  $d = $quota->get_size_unit($domsize);
80 
81  if ($totalmail) {
82  $tpc = intval(100 * $domsize / $totalmail);
83  } else {
84  $tpc = 0;
85  }
86  if (count($alias_sizes) > 0) {
87  echo "<tr><td><i>". _('Total'). " {$domaine}</i></td><td></td>";
88  echo "<td";
89  if ($mode!=2) echo " style=\"text-align: right\"";
90  echo "><i>";
91  if ($mode==0) {
92  echo sprintf("%.1f", $d['size'])."&nbsp;".$d['unit'];
93  } elseif ($mode==1) {
94  echo sprintf("%.1f", $tpc)."&nbsp;%";
95  } else {
96  $quota->quota_displaybar($tpc);
97  }
98  echo "</i></td></tr>";
99  }
100 }
101 ?>
102 </tbody>
103 </table>
104 
105 <p>&nbsp;</p>
106 <!-- Databases -->
107 
108 <?php
109  $totaldb = $quota->get_size_db_sum_user($mem->user["login"]);
110 
111  $t = $quota->get_size_unit($totaldb);
112  echo "<p>"._("Databases:")." ";
113  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
114  echo "</p>";
115 ?>
116 
117 <table class="tedit" width="100%">
118 <thead>
119 <tr>
120  <th width='50%'><?php __("DB"); ?></th>
121  <th width='50%'><?php __("Space"); ?></th>
122 </tr>
123 </thead>
124 <tbody>
125 <?php
126 
127  $db_sizes = $quota->get_size_db_details_user($mem->user["login"]);
128  foreach ($db_sizes as $d) {
129  echo "<tr><td>".$d["db"]."</td><td";
130  if ($mode!=2) echo " style=\"text-align: right\"";
131  echo ">";
132  $ds = $quota->get_size_unit($d["size"]);
133  if ($totaldb) {
134  $pc=intval(100*$d['size']/$totaldb);
135  } else {
136  $pc=0;
137  }
138  if (isset($mode) && $mode==0) {
139  echo sprintf("%.1f", $ds['size'])."&nbsp;".$ds['unit'];
140  } elseif (isset($mode) &&$mode==1) {
141  echo sprintf("%.1f", $pc)."&nbsp;%";
142  } else {
143  $quota->quota_displaybar(2*$pc, 0);
144  }
145  echo "</td></tr>";
146  }
147 ?>
148 </tbody>
149 </table>
150 
151 <!-- Mailing lists -->
152 
153 <?php
154  $totallist = $quota->get_size_mailman_sum_user($c["uid"]);
155  if ($totallist) {
156  // $totalweb is in KB, so we call get_size_unit() with it in Bytes
157  $t=$quota->get_size_unit($totallist * 1024);
158  echo "<p>"._("Mailman lists:")." ";
159  echo sprintf("%.1f", $t['size'])."&nbsp;".$t['unit'];
160  echo "</p>";
161 ?>
162 
163 <table class="tedit" width='60%'>
164 <thead>
165 <tr>
166  <th><?php __("Lists"); ?></th>
167  <th><?php __("Space"); ?></th>
168 </tr>
169 </thead>
170 <tbody>
171 <?php
172 
173  $mailman_size = $quota->get_size_mailman_details_user($mem->user["uid"]);
174  foreach ($mailman_size as $d) {
175  echo "<tr><td>".$d["list"]."</td><td";
176  if ($mode!=2) echo " style=\"text-align: right\"";
177  echo ">";
178  $ds = $quota->get_size_unit($d["size"] * 1024);
179  if ($totallist) {
180  $pc=intval(100*$ds['size']/$totallist);
181  } else {
182  $pc=0;
183  }
184  if ($mode==0) {
185  echo sprintf("%.1f", $ds['size'])."&nbsp;".$ds['unit'];
186  } elseif ($mode==1) {
187  echo sprintf("%.1f", $pc)."&nbsp;%";
188  } else {
189  $quota->quota_displaybar($pc);
190  }
191  echo "</td></tr>";
192  }
193 ?>
194 </tbody>
195 </table>
196 
197  <?php } /* totallist */ ?>
198 </div>
199 </center>