Changeset 381


Ignore:
Timestamp:
09/29/11 18:11:47 (13 years ago)
Author:
nanardon
Message:
  • add unset bot function
  • fix default setting deletion
Location:
server/trunk/web/lib/Sophie/Controller
Files:
2 edited

Legend:

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

    r379 r381  
    174174=head2 set [distribution|release|arch] value 
    175175 
    176 Set default search value 
     176Set default search value (see also: unset) 
    177177 
    178178=cut 
     
    185185    return $c->stash->{xmlrpc} = { 
    186186        private_reply => 1, 
    187         message => [ "$var set to: " . ($val || '(none)') ], 
     187        message => [ 
     188            "$var set to: " . ($val || '(none)'), 
     189            ($c->forward('/distrib/exists', [ 
     190                    $c->forward('/user/fetchdata', [ $reqspec->{from}, ]) ]) 
     191                ? () 
     192                : ("warning: your setting does not match any distribution") 
     193            ), 
     194        ] 
     195    }; 
     196} 
     197 
     198=head2 unset [distribution|release|arch] 
     199 
     200Unset default search value (see also: set) 
     201 
     202=cut 
     203 
     204sub unset : XMLRPC { 
     205    my ( $self, $c, $reqspec, $var ) = @_; 
     206 
     207    $c->forward('/user/update_data', [ $reqspec->{from}, { $var => undef } ]); 
     208     
     209    return $c->stash->{xmlrpc} = { 
     210        private_reply => 1, 
     211        message => [ "$var set to: (none)" ], 
    188212    }; 
    189213} 
     
    213237        }; 
    214238    } else { 
    215         warn my $own = $c->forward('_fmt_question', [$res]); 
    216         warn my $applied = $c->forward('_fmt_question', [$reqspec]); 
     239        my $own = $c->forward('_fmt_question', [$res]); 
     240        my $applied = $c->forward('_fmt_question', [$reqspec]); 
     241 
    217242        return $c->stash->{xmlrpc} = { 
    218243            message => [ sprintf('your setting is: %s%s', 
     
    222247                    : '' 
    223248                ) 
    224             ) ], 
     249            ), 
     250            ($c->forward('/distrib/exists', [ $res ]) 
     251                ? () 
     252                : ("warning: your setting does not match any distribution") 
     253            ) 
     254            ], 
    225255        } 
    226256    } 
  • server/trunk/web/lib/Sophie/Controller/User.pm

    r289 r381  
    111111 
    112112    foreach (keys %$data) { 
    113         $prev_data->{$_} = $data->{$_}; 
     113        if (defined($data->{$_})) { 
     114            $prev_data->{$_} = $data->{$_}; 
     115        } else { 
     116            delete($prev_data->{$_}); 
     117        } 
    114118    } 
    115119 
Note: See TracChangeset for help on using the changeset viewer.