| 1 | package Aut::UI::Console; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | # $Id: Console.pm,v 1.4 2004/04/10 09:33:58 cvs Exp $ | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Term::ReadKey; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Locale::Framework; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Aut; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Aut::Ticket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | ##################################################### | ||||||||||||||||||||||||||||
| 12 | # Instantiation/Initialization | ||||||||||||||||||||||||||||
| 13 | ##################################################### | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 2 | my $class=shift; | |||||||||||||||||||||||||||
| 17 | 2 | my $self; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 2 | $self->{"levels"}=undef; | |||||||||||||||||||||||||||
| 20 | 2 | $self->{"admin"}=undef; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 2 | bless $self,$class; | |||||||||||||||||||||||||||
| 23 | 2 | return $self; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1 | ▶ | sub initialize { | ||||||||||||||||||||||||||
|
Subroutine
initialize: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 27 | 1 | my $self=shift; | |||||||||||||||||||||||||||
| 28 | 1 | my $levels=shift; | |||||||||||||||||||||||||||
| 29 | 1 | my $adminlevel=shift; | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | $self->{"levels"}=$levels; | |||||||||||||||||||||||||||
| 32 | 1 | $self->{"admin"}=$adminlevel; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | ##################################################### | ||||||||||||||||||||||||||||
| 36 | # Messages | ||||||||||||||||||||||||||||
| 37 | ##################################################### | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | ▶ | sub message_ok { | ||||||||||||||||||||||||||
|
Subroutine
message_ok: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 40 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 41 | 0 | my $text=shift; | |||||||||||||||||||||||||||
| 42 | 0 | print "$text\n\n"._T("Press enter to continue").">>"; | |||||||||||||||||||||||||||
| 43 | 0 | ReadMode(2); | |||||||||||||||||||||||||||
| 44 | 0 | ReadLine(0); | |||||||||||||||||||||||||||
| 45 | 0 | ReadMode(0); | |||||||||||||||||||||||||||
| 46 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 0 | ▶ | sub message { | ||||||||||||||||||||||||||
|
Subroutine
message: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 50 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 51 | 0 | my $text=shift; | |||||||||||||||||||||||||||
| 52 | 0 | print "$text\n"; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | ##################################################### | ||||||||||||||||||||||||||||
| 56 | # Password/Account related | ||||||||||||||||||||||||||||
| 57 | ##################################################### | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub ask_pass { | ||||||||||||||||||||||||||
|
Subroutine
ask_pass: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 60 | 1 | my $self=shift; | |||||||||||||||||||||||||||
| 61 | 1 | my $aut=shift; | |||||||||||||||||||||||||||
| 62 | 1 | my $text=shift; | |||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 1 | print "$text >>"; | |||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 1 | ReadMode(2); | |||||||||||||||||||||||||||
| 67 | 1 | my $pass=ReadLine(0); | |||||||||||||||||||||||||||
| 68 | 1 | chomp $pass; | |||||||||||||||||||||||||||
| 69 | 1 | ReadMode(0); | |||||||||||||||||||||||||||
| 70 | 1 | print "\n"; | |||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 1 | ▶ | if ($pass eq "") { $pass=undef; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | return $pass; | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 0 | ▶ | sub login { | ||||||||||||||||||||||||||
|
Subroutine
login: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 78 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 79 | 0 | my $aut=shift; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ($aut->has_accounts()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | my $ticket; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 0 | print _T("login")."\n\n"; | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 0 | for (1..3) { | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | print _T("account")." >>"; | |||||||||||||||||||||||||||
| 89 | 0 | ReadMode(1); | |||||||||||||||||||||||||||
| 90 | 0 | my $account=ReadLine(0); | |||||||||||||||||||||||||||
| 91 | 0 | ReadMode(0); | |||||||||||||||||||||||||||
| 92 | 0 | chomp $account; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 0 | my $pass=$self->ask_pass($aut,_T("password")); | |||||||||||||||||||||||||||
| 95 | 0 | $ticket=$aut->ticket_get($account,$pass); | |||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ($ticket->valid()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 98 | 0 | last; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||
| 101 | 0 | print _T("Invalid account/password combination")."\n"; | |||||||||||||||||||||||||||
| 102 | 0 | print _T("Reported error: "),$aut->last_error(),"\n\n"; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | 0 | return $ticket; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||
| 109 | 0 | return undef; | |||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | ▶ | sub logout { | ||||||||||||||||||||||||||
|
Subroutine
logout: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 115 | 0 | my $aut=shift; | |||||||||||||||||||||||||||
| 116 | 0 | my $ticket=shift; | |||||||||||||||||||||||||||
| 117 | 0 | return 1; | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | 0 | ▶ | sub change_pass { | ||||||||||||||||||||||||||
|
Subroutine
change_pass: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 121 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 122 | 0 | my $aut=shift; | |||||||||||||||||||||||||||
| 123 | 0 | my $ticket=shift; | |||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 0 | my $account=$ticket->account(); | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 128 | 0 | print _T("Change password for $account")."\n"; | |||||||||||||||||||||||||||
| 129 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 0 | my $oldpass=$self->ask_pass($aut,_T("Old password ")); | |||||||||||||||||||||||||||
| 132 | 0 | my $newpass=$self->ask_pass($aut,_T("New password ")); | |||||||||||||||||||||||||||
| 133 | 0 | my $again =$self->ask_pass($aut,_T("Again ")); | |||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 0 | my $pass=$ticket->pass(); | |||||||||||||||||||||||||||
| 136 | 0 | ▶ | if ($pass ne $oldpass) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 137 | 0 | $self->message_ok(_T("You didn't give a valid (old) password")); | |||||||||||||||||||||||||||
| 138 | 0 | return 0; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | else { | ||||||||||||||||||||||||||||
| 141 | 0 | ▶ | if ($newpass ne $again) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 142 | 0 | $self->message_ok(_T("New passswords don't match")); | |||||||||||||||||||||||||||
| 143 | 0 | return 0; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | else { | ||||||||||||||||||||||||||||
| 146 | 0 | my $msg=$aut->check_pass($newpass); | |||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ($msg ne "") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | 0 | $self->message_ok($msg); | |||||||||||||||||||||||||||
| 149 | 0 | return 0; | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||
| 152 | 0 | $ticket->set_pass($newpass); | |||||||||||||||||||||||||||
| 153 | 0 | $aut->ticket_update($ticket); | |||||||||||||||||||||||||||
| 154 | 0 | return 1; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | ##################################################### | ||||||||||||||||||||||||||||
| 162 | # Administration | ||||||||||||||||||||||||||||
| 163 | ##################################################### | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub admin { | ||||||||||||||||||||||||||
|
Subroutine
admin: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 167 | 0 | my $aut=shift; | |||||||||||||||||||||||||||
| 168 | 0 | my $ticket=shift; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 0 | my $choice=""; | |||||||||||||||||||||||||||
| 171 | 0 | ▶ | while ($choice ne "0") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 173 | 0 | print _T("Account Administration")."\n"; | |||||||||||||||||||||||||||
| 174 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 175 | 0 | print "1. "._T("Add an account")."\n"; | |||||||||||||||||||||||||||
| 176 | 0 | print "2. "._T("Change password for an account")."\n"; | |||||||||||||||||||||||||||
| 177 | 0 | print "3. "._T("Change rights for an account")."\n"; | |||||||||||||||||||||||||||
| 178 | 0 | print "4. "._T("Delete an account")."\n"; | |||||||||||||||||||||||||||
| 179 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 180 | 0 | print "0. "._T("End")."\n\n"; | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 0 | ReadMode(1); | |||||||||||||||||||||||||||
| 183 | 0 | print ">>";$choice=ReadLine(0); | |||||||||||||||||||||||||||
| 184 | 0 | chomp $choice; | |||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||
| 186 | 0 | ▶ | if ($choice eq "1") { | ||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||
| 187 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 188 | 0 | print _T("account ").">>";my $account=ReadLine(0);chomp $account; | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | if ($account eq "") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 190 | 0 | print _T(" Empty account, aborting")."\n"; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | else { | ||||||||||||||||||||||||||||
| 193 | 0 | print _T(" Checking existence of ").$account,"\n"; | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($aut->exists($account)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | $self->message_ok( _T(" Account already exists, aborting")); | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | else { | ||||||||||||||||||||||||||||
| 198 | 0 | my $pass=$self->ask_pass($aut,_T("password ")); | |||||||||||||||||||||||||||
| 199 | 0 | my $passagain=$self->ask_pass($aut,_T("password (again)")); | |||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | 0 | my $msg=$aut->check_pass($pass); | |||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ($pass eq "") { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 204 | 0 | $self->message_ok(_T(" Empty password, aborting")); | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | elsif ($pass ne $passagain) { | ||||||||||||||||||||||||||||
| 207 | 0 | $self->message_ok(_T(" Given passwords are not equal, aborting")); | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | elsif ($msg ne "") { | ||||||||||||||||||||||||||||
| 210 | 0 | $self->message_ok(" $msg"); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | else { | ||||||||||||||||||||||||||||
| 213 | 0 | my $rights=$self->choose_rights(); | |||||||||||||||||||||||||||
| 214 | 0 | ▶ | if (not defined $rights) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 215 | 0 | $self->message_ok(_T(" No rights given, aborting")); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | else { | ||||||||||||||||||||||||||||
| 218 | 0 | my $ticket=new Aut::Ticket($account,$pass); | |||||||||||||||||||||||||||
| 219 | 0 | $ticket->set_rights($rights); | |||||||||||||||||||||||||||
| 220 | 0 | print _T(" Creating account: "),$account,_T(", rights: "),$rights; | |||||||||||||||||||||||||||
| 221 | 0 | $aut->ticket_create($ticket); | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||
| 224 | } | ||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||
| 227 | elsif ($choice eq "2") { | ||||||||||||||||||||||||||||
| 228 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 229 | 0 | print _T("Change password for an account\n"); | |||||||||||||||||||||||||||
| 230 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 231 | 0 | $self->list_accounts($aut); | |||||||||||||||||||||||||||
| 232 | 0 | print _T("account ").">>";my $account=ReadLine(0);chomp $account; | |||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ($aut->exists($account)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 234 | 0 | my $pass=$self->ask_pass($aut,_T("password ")); | |||||||||||||||||||||||||||
| 235 | 0 | my $passagain=$self->ask_pass($aut,_T("password (again)")); | |||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 0 | my $msg=$aut->check_pass($pass); | |||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | if ($pass eq "") { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 240 | 0 | $self->message_ok(_T(" Empty password, aborting")); | |||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||
| 242 | elsif ($pass ne $passagain) { | ||||||||||||||||||||||||||||
| 243 | 0 | $self->message_ok(_T(" Given passwords are not equal, aborting")); | |||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||
| 245 | elsif ($msg ne "") { | ||||||||||||||||||||||||||||
| 246 | 0 | $self->message_ok(" $msg"); | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | else { # Try to change the password | ||||||||||||||||||||||||||||
| 249 | 0 | my $ticket=$aut->ticket_admin_get($account); | |||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ($ticket->valid()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | 0 | print _T(" Changing password to new one")."\n"; | |||||||||||||||||||||||||||
| 252 | 0 | $ticket->set_pass($pass); | |||||||||||||||||||||||||||
| 253 | 0 | print _T(" Updating ticket")."\n"; | |||||||||||||||||||||||||||
| 254 | 0 | $aut->ticket_update($ticket); | |||||||||||||||||||||||||||
| 255 | 0 | print _T(" Done\n"); | |||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | elsif ($choice eq "3") { | ||||||||||||||||||||||||||||
| 261 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 262 | 0 | print _T("Change rights for an account")."\n"; | |||||||||||||||||||||||||||
| 263 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 264 | 0 | $self->list_accounts($aut); | |||||||||||||||||||||||||||
| 265 | 0 | print _T("account ").">>";my $account=ReadLine(0);chomp $account; | |||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ($aut->exists($account)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 267 | 0 | my $rights=$self->choose_rights(); | |||||||||||||||||||||||||||
| 268 | 0 | ▶ | if (defined $rights) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | 0 | my $ticket=$aut->ticket_admin_get($account); | |||||||||||||||||||||||||||
| 270 | 0 | ▶ | if ($ticket->valid()) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 271 | 0 | print _T(" Changing rights to $rights\n"); | |||||||||||||||||||||||||||
| 272 | 0 | $ticket->set_rights($rights); | |||||||||||||||||||||||||||
| 273 | 0 | print _T(" Updating ticket\n"); | |||||||||||||||||||||||||||
| 274 | 0 | $aut->ticket_update($ticket); | |||||||||||||||||||||||||||
| 275 | 0 | print _T(" Done\n"); | |||||||||||||||||||||||||||
| 276 | } | ||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||
| 280 | elsif ($choice eq "4") { | ||||||||||||||||||||||||||||
| 281 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 282 | 0 | print _T("Remove an account")."\n"; | |||||||||||||||||||||||||||
| 283 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 284 | 0 | $self->list_accounts($aut); | |||||||||||||||||||||||||||
| 285 | 0 | print _T("account ").">>";my $account=ReadLine(0);chomp $account; | |||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 0 | ▶ | if ($account eq $ticket->account()) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 288 | 0 | $self->message_ok(_T("You cannot delete yourself")); | |||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||
| 290 | elsif ($aut->exists($account)) { | ||||||||||||||||||||||||||||
| 291 | 0 | print _T("Remove account yes/no? ").">>";my $yesno=ReadLine(0);chomp $yesno; | |||||||||||||||||||||||||||
| 292 | 0 | ▶ | if (lc($yesno) eq "yes") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 0 | print _T(" Removing account: ").$account."\n"; | |||||||||||||||||||||||||||
| 294 | 0 | my $ticket=new Aut::Ticket($account,""); | |||||||||||||||||||||||||||
| 295 | 0 | $aut->ticket_remove($ticket); | |||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||
| 297 | else { | ||||||||||||||||||||||||||||
| 298 | 0 | $self->message_ok(_T("You need to answer a full 'yes' to get accounts removed")); | |||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 0 | ▶ | sub list_accounts { | ||||||||||||||||||||||||||
|
Subroutine
list_accounts: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 306 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 307 | 0 | my $aut=shift; | |||||||||||||||||||||||||||
| 308 | 0 | my @accounts=$aut->list_accounts(); | |||||||||||||||||||||||||||
| 309 | 0 | my $perline=3; | |||||||||||||||||||||||||||
| 310 | 0 | my $cnt=0; | |||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 0 | for my $a (@accounts) { | |||||||||||||||||||||||||||
| 313 | 0 | printf("%-20s",$a); | |||||||||||||||||||||||||||
| 314 | 0 | $cnt+=1; | |||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ($cnt%$perline==0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||
| 319 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | 0 | ▶ | sub choose_rights { | ||||||||||||||||||||||||||
|
Subroutine
choose_rights: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 323 | 0 | my $self=shift; | |||||||||||||||||||||||||||
| 324 | 0 | my @rights=@{$self->{"levels"}}; | |||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 0 | my $nrights=@rights; | |||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 329 | 0 | print _T("Choose rights from menu")."\n"; | |||||||||||||||||||||||||||
| 330 | 0 | print "\n"; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | for (1..$nrights) { | |||||||||||||||||||||||||||
| 333 | 0 | print "$_. $rights[$_-1]\n"; | |||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | print ">>"; | |||||||||||||||||||||||||||
| 337 | 0 | my $choice=ReadLine(0);chomp $choice; | |||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | ▶ | if (($choice gt 0) and ($choice le $nrights)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$choice gt 0 and $choice le $nrights
MC/DC0%0/2
$choice gt 0 and $choice le $nrights
$choice gt 0
$choice le $nrights
Truth table0%0/3
A and B
A= $choice gt 0B= $choice le $nrights
| |||||||||||||||||||||||||||||
| 340 | 0 | return $rights[$choice-1]; | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | else { | ||||||||||||||||||||||||||||
| 343 | 0 | return undef; | |||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | 1 | 1; | |||||||||||||||||||||||||||
| 349 | __END__ | ||||||||||||||||||||||||||||