Changeset 1252


Ignore:
Timestamp:
01/21/12 16:26:54 (4 months ago)
Author:
aike
Message:
  • lib/Schulkonsole/Printer.pm, lib/Schulkonsole/Config.pm.in, lib/Schulkonsole/Error/Printer.pm, lib/Schulkonsole/Error.pm, src/util/wrapper-printer.pl.in, src/cgi-bin/start.in, shtml/start.shtml, doc/etc/schulkonsole/permissions.conf: Abfrage der Druckquota ueber linuxmuster-pk
Location:
schulkonsole/linuxmuster-schulkonsole/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • schulkonsole/linuxmuster-schulkonsole/trunk/doc/etc/schulkonsole/permissions.conf

    r1088 r1252  
    1212 
    1313[External Programs] 
    14 ALL=ovpn_check ovpn_create ovpn_download set_own_password 
     14ALL=ovpn_check ovpn_create ovpn_download set_own_password own_print_quota 
    1515teachers=internet_on_off intranet_on_off update_logins update_linbofs urlfilter_check urlfilter_on_off all_on all_on_at printer_on_off printer_allow_deny printer_info share_states shares_on_off ls_collect ls_handout handout collect room_reset edit_own_class_membership print_class set_passwords project_members project_create_drop project_join_no_join 
    1616domadmins=set_passwords print_teachers 
  • schulkonsole/linuxmuster-schulkonsole/trunk/lib/Schulkonsole/Config.pm.in

    r1238 r1252  
    100100        $_cmd_printer_reject 
    101101        $_cmd_printer_lpadmin 
     102        $_cmd_linuxmuster_pk 
    102103        $_cmd_sophomorix_teacher 
    103104        $_cmd_sophomorix_room 
     
    138139        PRINTERONOFFAPP 
    139140        PRINTERALLOWDENYAPP 
     141        PRINTERGETOWNQUOTAAPP 
    140142        SHARESTATESAPP 
    141143        SHARESONOFFAPP 
     
    281283C<printer_allow_deny> 
    282284 
    283 =item C<PRINTERQUOTAAPP> 
     285=item C<PRINTERGETOWNQUOTAAPP> 
    284286 
    285287C<printer_quota> 
     
    293295        PRINTERONOFFAPP => 7002, 
    294296        PRINTERALLOWDENYAPP => 7003, 
     297        PRINTERGETOWNQUOTAAPP => 7004, 
    295298}; 
    296299 
     
    913916Path to command to administrate printers C<lpadmin> 
    914917 
     918=item C<$_cmd_linuxmuster_pk> 
     919 
     920Path to command to query printer quotas C<linuxmuster-pk> 
     921 
    915922=item C<$_cmd_sophomorix_teacher> 
    916923 
     
    988995            $_cmd_printer_reject 
    989996            $_cmd_printer_lpadmin 
     997            $_cmd_linuxmuster_pk 
    990998            $_cmd_sophomorix_teacher 
    991999            $_cmd_sophomorix_room 
     
    11201128        PRINTERONOFFAPP() => 'printer_on_off', 
    11211129        PRINTERALLOWDENYAPP() => 'printer_allow_deny', 
     1130        PRINTERGETOWNQUOTAAPP() => 'own_print_quota', 
    11221131        SHARESTATESAPP() => 'share_states', 
    11231132        SHARESONOFFAPP() => 'shares_on_off', 
     
    11711180$_cmd_printer_lpadmin = '/usr/sbin/lpadmin'; 
    11721181$_cmd_printer_reject = '/usr/sbin/reject'; 
     1182$_cmd_linuxmuster_pk = '/usr/bin/linuxmuster-pk'; 
    11731183$_cmd_sophomorix_add = '/usr/sbin/sophomorix-add'; 
    11741184$_cmd_sophomorix_check = '/usr/sbin/sophomorix-check'; 
  • schulkonsole/linuxmuster-schulkonsole/trunk/lib/Schulkonsole/Error.pm

    r1238 r1252  
    232232        $this->{code} == Schulkonsole::Error::Printer::WRAPPER_INVALID_USER 
    233233                and return 'Ungueltiger Druckernutzer'; 
     234        $this->{code} == Schulkonsole::Error::Printer::WRAPPER_INVALID_PAGES 
     235                and return 'Ungueltige Daten fuer genutzte Druckquota'; 
     236        $this->{code} == Schulkonsole::Error::Printer::WRAPPER_INVALID_MAX_PAGES 
     237                and return 'Ungueltige Daten fuer Druckquota'; 
     238        $this->{code} == Schulkonsole::Error::Printer::WRAPPER_UNEXPECTED_DATA 
     239                and return 'Unerwartete Programmausgabe'; 
    234240        $this->{code} == Schulkonsole::Error::Sophomorix::WRAPPER_ON_UNDEFINED 
    235241                and return 'on muss 1 oder 0 sein'; 
  • schulkonsole/linuxmuster-schulkonsole/trunk/lib/Schulkonsole/Error/Printer.pm

    r1238 r1252  
    2020        WRAPPER_NO_PRINTERS 
    2121        WRAPPER_INVALID_USER 
     22        WRAPPER_INVALID_PAGES 
     23        WRAPPER_INVALID_MAX_PAGES 
     24        WRAPPER_UNEXPECTED_DATA 
    2225); 
    2326 
     
    3841        WRAPPER_NO_PRINTERS => 7000 -66, 
    3942        WRAPPER_INVALID_USER => 7000 -67, 
     43        WRAPPER_INVALID_PAGES => 7000 -68, 
     44        WRAPPER_INVALID_MAX_PAGES => 7000 -69, 
     45        WRAPPER_UNEXPECTED_DATA => 7000 -70, 
    4046}; 
    4147 
  • schulkonsole/linuxmuster-schulkonsole/trunk/lib/Schulkonsole/Printer.pm

    r1238 r1252  
    2121        printer_off 
    2222        printer_deny 
     23        own_quota 
    2324); 
    2425 
     
    328329 
    329330 
     331=head2 C<own_quota($id, $password)> 
     332 
     333Get print quota of user 
     334 
     335=head3 Parameters 
     336 
     337=over 
     338 
     339=item C<$id> 
     340 
     341The ID (not UID) of the user invoking the command 
     342 
     343=item C<$password> 
     344 
     345The password of the user invoking the command 
     346 
     347=back 
     348 
     349=head3 Description 
     350 
     351This wraps the commands  
     352C</usr/bin/linuxmuster-pk --user user -t>  
     353to get the number of printed pages  
     354and 
     355C</usr/bin/linuxmuster-pk --user user -m> 
     356maximum number of pages 
     357with C<user> = the UID of the user with ID C<$id>. 
     358 
     359Returns an array with number of printed pages and then the maximum number of  
     360pages. 
     361 
     362=cut 
     363 
     364sub own_quota { 
     365        my $id = shift; 
     366        my $password = shift; 
     367 
     368        my $pid = start_wrapper(Schulkonsole::Config::PRINTERGETOWNQUOTAAPP, 
     369                $id, $password, 
     370                \*SCRIPTOUT, \*SCRIPTIN, \*SCRIPTIN); 
     371 
     372 
     373        buffer_input(\*SCRIPTIN); 
     374 
     375        my ($pages, $max) = $input_buffer =~ /^(\d+)\t(\d+)$/; 
     376 
     377 
     378        stop_wrapper($pid, \*SCRIPTOUT, \*SCRIPTIN, \*SCRIPTIN); 
     379 
     380 
     381        die new Schulkonsole::Error( 
     382                Schulkonsole::Error::Printer::WRAPPER_UNEXPECTED_DATA, 
     383                $Schulkonsole::Config::_wrapper_printer) 
     384                unless defined $max; 
     385 
     386 
     387        return ($pages, $max); 
     388} 
     389 
     390 
     391 
     392 
     393 
    3303941; 
  • schulkonsole/linuxmuster-schulkonsole/trunk/shtml/start.shtml

    r578 r1252  
    11<html lang="de"> 
    22<head> 
    3 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> 
     3<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
    44<meta http-equiv="Content-Language" content="de"> 
    55<title><gettext>Schulkonsole</gettext> - <gettext>Startseite</gettext></title> 
     
    160160 
    161161 
     162<!--#if expr="$printquota" --> 
     163<table id="printquota"> 
     164<col width="30%"> 
     165<col width="70%"> 
     166 
     167<tr> 
     168 
     169<td><gettext>Seiten</gettext></td> 
     170 
     171<td> 
     172 
     173 
     174<p> 
     175    <gettext>Seiten:</gettext> 
     176    <!--#echo var="printquota{usage}" -->/<!--#echo var="printquota{limit}" --> 
     177    - <!--#echo var="printquota{percent}" -->% 
     178</p> 
     179 
     180 
     181<ul> 
     182<li> 
     183<span title="Druckseiten: ${printquota{usage}}/${printquota{limit}} ${printquota{percent}}%" style="width: ${printquota{percent_rounded}}%;">&nbsp;</span> 
     184</li> 
     185</ul> 
     186</td> 
     187 
     188</tr> 
     189</table> 
     190<!--#else --> 
     191<p>Keine Druckquota</p> 
     192<!--#endif --> 
     193 
     194 
     195 
     196 
    162197<hr> 
    163198 
  • schulkonsole/linuxmuster-schulkonsole/trunk/src/cgi-bin/start.in

    r304 r1252  
    164164use Schulkonsole::Info; 
    165165use Schulkonsole::OVPN; 
     166use Schulkonsole::Printer; 
    166167use Schulkonsole::Sophomorix; 
    167168 
     
    565566 
    566567 
     568eval { 
     569my ($usage, $limit) = Schulkonsole::Printer::own_quota($id, $password); 
     570 
     571my $usage_percent = $usage ? 
     572          sprintf('%.1f', 100 * $usage / $limit) 
     573        : 0; 
     574 
     575my $printquota = { 
     576        usage => $usage, 
     577        limit => $limit, 
     578        percent => $usage_percent, 
     579        percent_rounded => ($usage_percent < 100.0 ? 
     580                              int($usage_percent + 0.5) 
     581                            : 100), 
     582}; 
     583 
     584 
     585$sk_session->set_var('printquota', $printquota); 
     586}; 
     587if ($@) { 
     588        warn "$@\n"; 
     589} 
     590 
     591 
     592 
    567593my @projects; 
    568594my $projects = Schulkonsole::Info::groups_projects($sk_session->groups()); 
  • schulkonsole/linuxmuster-schulkonsole/trunk/src/util/wrapper-printer.pl.in

    r1247 r1252  
    253253        exit 0; 
    254254}; 
     255 
     256=head3 own_print_quota 
     257 
     258numeric constant: C<Schulkonsole::Config::PRINTERGETOWNQUOTAAPP> 
     259 
     260=head4 Description 
     261 
     262Get users own print quota 
     263 
     264=head4 Parameters from standard input 
     265 
     266None 
     267 
     268=cut 
     269 
     270$app_id == Schulkonsole::Config::PRINTERGETOWNQUOTAAPP and do { 
     271        my $opt_user = "--user \Q$$userdata{uid}\E"; 
     272 
     273 
     274        my $pages = `$Schulkonsole::Config::_cmd_linuxmuster_pk $opt_user -t` 
     275                or last SWITCH; 
     276 
     277        ($pages) = $pages =~ /^(\d+)$/; 
     278        exit (  Schulkonsole::Error::Printer::WRAPPER_INVALID_PAGES 
     279              - Schulkonsole::Error::Printer::WRAPPER_ERROR_BASE) 
     280                unless defined $pages; 
     281 
     282 
     283 
     284        my $max = `$Schulkonsole::Config::_cmd_linuxmuster_pk $opt_user -m` 
     285                or last SWITCH; 
     286 
     287        ($max) = $max =~ /^(\d+)$/; 
     288        exit (  Schulkonsole::Error::Printer::WRAPPER_INVALID_MAX_PAGES 
     289              - Schulkonsole::Error::Printer::WRAPPER_ERROR_BASE) 
     290                unless defined $max; 
     291 
     292 
     293 
     294        print "$pages\t$max\n"; 
     295 
     296 
     297        exit 0; 
     298}; 
    255299} 
    256300 
Note: See TracChangeset for help on using the changeset viewer.