#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Support::Command::Client;

#
# This class is intended to be a base class for all support
# commands that require a client id
#

use strict;
use warnings;

use lib '/app/tools/support/lib';
use Support::Command::Submit;
use base 'Support::Command::Submit';

use constant kClientRequiredTemplate => '/app/tools/support/templates/client_required.xsl';
use constant kMsgClientRequired      => 'client_required';

sub execute {
    my $self = shift;

    my $response = $self->SUPER::execute(@_);
    return if ($response);

    unless ( Common::RSApp::GetClientID() ) {
        return return $self->clientRequiredResponse();
    }

    return undef;
}

sub clientRequiredResponse {
    my ($self) = @_;
    $self->addMessageXML( type => "error", code => kMsgClientRequired );
    return RSApache::Response::XSLT->new( $self->{xml}, kClientRequiredTemplate );
}

###
1;    # Play nicely.
###
