Changeset 432


Ignore:
Timestamp:
06/23/12 14:48:56 (12 years ago)
Author:
grenoya
Message:
  • add the possibility to use 'distrib' parameter to set and unset functions
  • inform about the 'list' command when the user tries to set without giving a value
File:
1 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm

    r422 r432  
    202202            private_reply => 1, 
    203203            message => [ 
    204                 "What must I set ?" 
     204                "What must I set ? possible parameters are : " .  
     205                    "'distribution', 'release' and 'arch'." 
    205206            ] 
    206207        } 
    207208    }  
    208209     
    209     # if the variable is not 'distribution', 'release' or 'arch', Sophie 
     210    # if the variable is not 'distribution', 'distrib', 'release' or 'arch', Sophie 
    210211    # complains and stop 
    211212    if ($var ne "distribution" && $var ne "release" && $var ne "arch") { 
     213        # in order not to implement 'distrib' on the server, $var is changes 
     214        # into 'distribution' 
     215        if ($var eq "distrib") { 
     216            $var = "distribution"; 
     217        } else { 
     218            return $c->stash->{xmlrpc} = { 
     219                private_reply => 1, 
     220                message => [ 
     221                    "'$var' is not valid ! possible parameters are : " .  
     222                        "'distribution', 'release' and 'arch'." 
     223                ] 
     224            } 
     225        } 
     226    } 
     227 
     228    # if there is no value to give to the variable, Sophie ask and stop 
     229    if (!$val) { 
     230        # the message will depend on the actual settings of the user: the answer 
     231        # contains the command to ask Sophie the possibilities 
     232        my $msgtmp = "To what must I set $var ? (use 'list"; 
     233        my $msgfin = "' to see the possibilities)"; 
     234 
     235        if ($var ne "distribution") { 
     236            # the message is built using the user's pref 
     237            my $res = $c->forward('/user/fetchdata', [ $reqspec->{from}, ]); 
     238            my $owndistrib = $res->{"distribution"} || '(none)'; 
     239            if ($var eq "release" && $owndistrib eq '(none)') { 
     240                    $msgtmp = "Release depends on Distribution. Use 'list" . 
     241                        "' to see the possibilities"; 
     242                    $msgfin = ""; 
     243            } else { 
     244                $msgtmp .= " ".$owndistrib; 
     245 
     246                if ($var eq "arch") { 
     247                    my $ownrelease = $res->{"release"} || '(none)'; 
     248                    if ($ownrelease eq '(none)') { 
     249                        $msgtmp = "Arch depends on Release. Use 'list " . 
     250                            $owndistrib."' to see the possibilities"; 
     251                        $msgfin = ""; 
     252                    } else { 
     253                        $msgtmp .= " ".$ownrelease; 
     254                    } 
     255                } 
     256            } 
     257        } 
     258 
    212259        return $c->stash->{xmlrpc} = { 
    213260            private_reply => 1, 
    214261            message => [ 
    215                 "'$var' is not valid ! possible parameters are : " .  
    216                 "'distribution', 'release' and 'arch'." 
    217             ] 
    218         } 
    219     } 
    220  
    221     # if there is no value to give to the variable, Sophie ask and stop 
    222     if (!$val) { 
    223         return $c->stash->{xmlrpc} = { 
    224             private_reply => 1, 
    225             message => [ 
    226                 "To what must I set $var ?" 
     262                $msgtmp.$msgfin 
    227263            ] 
    228264        } 
     
    263299    }  
    264300     
    265     # if the variable is not 'distribution', 'release' or 'arch', Sophie 
     301    # if the variable is not 'distribution', 'distrib', 'release' or 'arch', Sophie 
    266302    # complains and stop 
    267303    if ($var ne "distribution" && $var ne "release" && $var ne "arch") { 
    268         return $c->stash->{xmlrpc} = { 
    269             private_reply => 1, 
    270             message => [ 
    271                 "'$var' is not valid ! possible parameters are : " . 
    272                 "'distribution', 'release' and 'arch'." 
    273             ] 
     304        # in order not to implement 'distrib' on the server, $var is changes 
     305        # into 'distribution' 
     306        if ($var eq "distrib") { 
     307            $var = "distribution"; 
     308        } else { 
     309            return $c->stash->{xmlrpc} = { 
     310                private_reply => 1, 
     311                message => [ 
     312                    "'$var' is not valid ! possible parameters are : " . 
     313                    "'distribution', 'release' and 'arch'." 
     314                ] 
     315            } 
    274316        } 
    275317    } 
Note: See TracChangeset for help on using the changeset viewer.