nolicense
The nolicense token is meant to be used for sections of code that involve licensing. Specifically if a server has a nolicense token in its feature_components the sections of code involving licensing restriction should be avoided.
The nolicense token can be found in both views and controllers.
View
cpa_ext_add_new.tt
hidden variables
[% IF SERVER_INFO.fc_ref.nolicense %] <input type="hidden" id="mobility_pack_ch" name="mobility_pack" value="1" [% IF USER_HAS_MOBILITY_PACK%]checked[% END %]> <input type="hidden" id="user_license" name="user_license" value="[% CURRENT_USER_LICENSE %]"> [% END %]
spacing
[% IF !SERVER_INFO.fc_ref.nolicense %]
[% spacerBlockMacro() %]
[% END %]
process ext licenses
[% IF !SERVER_INFO.fc_ref.nolicense %]
[% PROCESS "${EXTUSERS_DIR}cpa_ext_edit_ext_licensing.tt" %]
[% END %]
cpa_ext_edit_ext.tt
Analogous to add ext
Controller
users.pm
show_do_users() - add virtual extension
# In certain contexts we don't worrying about licensing # e.g. trixbox virtual or voicemail-only extensions if ( $vars->{'USER_LICENSE_AFTER'}->{'virt'} < 0 && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'nolicense'} && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'tbpro'}) { push @{ $vars->{MSG_ERROR} }, F::CPBase::t($vars, 'err_not_enough_ve_lic', 'You do not have enough Virtual Extension Licenses.'); }
show_do_users() - add voicemail-only extension
# Trixbox has free voicemail-only extensions while pbxtra does not. if ( $vars->{'USER_LICENSE_AFTER'}->{'vo'} < 0 && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'nolicense'} && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'tbpro'}) { push @{ $vars->{MSG_ERROR} }, F::CPBase::t($vars, 'err_not_enough_vm_lic', 'You do not have enough Voicemail-only License.'); }
prereq_adding - Count CURRENT_USER_LICENSE
# if server feature_components nolicense is set # figure out the highest possible if ($vars->{'SERVER_INFO'}->{'fc_ref'}->{'nolicense'}) { # get the correct user license my $ul = F::User::get_user_license_for_server($F::Globals::dbh, $q->param('sid')); # now split it based on "," # TODO: (FIX) This code relies on position of license tokens in a CSV string. # which is prone to error. For example, mobility is looked for in the second slot # but for the user license: 'high,standard,crm,mobility' # the mobility token is in the 4th slot. my @ul_tmp = split(/,/, $ul); my $highest_license = @ul_tmp[0]; my $mobility = 0; if (defined(@ul_tmp[1]) && @ul_tmp[1] eq "mobility") { $mobility = 1; } $vars->{"CURRENT_USER_LICENSE"} = $highest_license; $vars->{"USER_HAS_MOBILITY_PACK"} = $mobility; return; }
update_user_error_check - license checking
# check user licenses # only check if nolicense is not set # <licensing code /> if (!$vars->{'SERVER_INFO'}->{'fc_ref'}->{'nolicense'}) { my $license_type = $q->param('user_license'); if ($license_type eq 'standard' && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'cce'}) { push( @{ $vars->{MSG_ERROR} }, F::CPBase::t( $vars, 'err_cca_lic_cce', 'Call Center Agent User License requires Call Center module' ) ); } elsif ($license_type eq 'crm' && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'uae'}) { push( @{ $vars->{MSG_ERROR} }, F::CPBase::t($vars, 'err_ca_lic_crm', 'CRM Agent User License requires CRM module') ); } else { my $server_license_object = F::ServerLicense->new(server_id => $q->param('sid')); my $user_license_available = $server_license_object->count_server_license; my $user_license_used = F::User::get_total_user_license_used($F::Globals::dbh, $q->param('sid')); # update the low and high license used if ($vars->{'EDITION_PATH'} eq 'se/') { $user_license_used->{'low'} += $user_license_used->{'crm'}; $user_license_used->{'low'} += $user_license_used->{'standard'}; } else { $user_license_used->{'high'} += $user_license_used->{'crm'}; $user_license_used->{'high'} += $user_license_used->{'standard'}; } if ( $vars->{'OLD_USER_FC'} !~ $license_type && ($user_license_available->{$license_type} <= $user_license_used->{$license_type} || $user_license_available->{$license_type} eq '' || $user_license_available->{$license_type} == 0) ) { # special downgrade license from CRM or Call Center to normal # do not need to count normal licenses # Do not count 'vo' or 'virt' licenses when it's trixbox. if ( ( $vars->{'OLD_USER_FC'} =~ /crm|standard/ && $license_type ne 'standard' && $license_type ne 'crm' ) || ($vars->{'SERVER_INFO'}->{'fc_ref'}->{'tbpro'} && ($license_type eq 'virt' || $license_type eq 'vo')) ) { } else { push( @{ $vars->{MSG_ERROR} }, F::CPBase::t($vars, 'err_no_user_licenses', 'Not enough User Licenses') ); } } # check mobility pack # <licensing code /> for pbxtra only my $mobility_pack = $q->param('mobility_pack'); if ( $vars->{'OLD_USER_FC'} !~ /mobility/ && $mobility_pack == 1 && !$vars->{'SERVER_INFO'}->{'fc_ref'}->{'tbpro'}) { if ($user_license_available->{'mobility'} <= $user_license_used->{'mobility'}) { push( @{ $vars->{MSG_ERROR} }, F::CPBase::t( $vars, 'err_no_mob_addons', 'You do not have any available Mobility Add-Ons. You can purchase more by clicking the "buy license" link on the License Settings panel' ) ); } } } }
F::Upgrade::pbxtracore.pm
Showing changes from previous revision. Removed | Added
