Introduction
Your class will inherit several useful methods, such as get_caller_username()
, from the Cpanel::AdminBin::Script::Call
module.
Inherited methods
Your class will inherit the following methods:
Method |
Description |
get_caller_domains() |
The method returns an array of the domains that the user who called the function owns. Note: This includes the user's primary domain. |
get_caller_former_domains_that_remain_unused() |
This method returns an array of the domains that the caller no longer owns. |
get_caller_uid() |
This method returns the UID of the user who called the function. |
get_caller_username() |
This method returns the username of the user who called the function. |
get_caller_homedir() |
This method returns the home directory of the user who called the function. |
get_action() |
This method returns the name of the function that the user called. |
verify_that_caller_owns_domain($domain) |
This method checks whether the user who called the function owns the $domaindomain. If the caller does not own the domain, an exception is thrown. |
user_has_feature_or_die($feature) |
This method checks whether the user has the necessary $feature feature to call the function. If the caller does not have access to the feature, an exception is thrown. |
Example
The following example demonstrates the inherited methods:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#an arrayref of owned domains, including the account’s primary domain my $domains_ar = $self->get_caller_domains(); #an arrayref of formerly-owned domains that the caller no longer owns my $old_domains_ar = $self->get_caller_former_domains_that_remain_unused(); my $uid = $self->get_caller_uid(); my $username = $self->get_caller_username(); my $homedir = $self->get_caller_homedir(); #i.e., home directory #the function that the user requested to run my $action = $self->get_action(); $self->verify_that_caller_owns_domain($domain); #die()s if not $self->user_has_feature_or_die($feature); #die()s if not |