コード例 #1
0
 public static function is_valid()
 {
     $result = AddonBoilerplateOutfittersLicense::isValid('AddonBoilerplate');
     if ($result !== true) {
         //The license didn't validate as the subscription has expired for the user. Handle it how you would like below
         $admin = BeanFactory::getBean('Administration');
         $admin->retrieveSettings('addonboilerplate');
         $last_sent = $admin->settings['addonboilerplate_licenseemail'];
         $elapsed = 60 * 60;
         if (empty($last_sent) || $last_sent + $elapsed < time()) {
             $admin->saveSetting('addonboilerplate', 'licenseemail', time());
             require_once 'modules/AddonBoilerplate/includes/classes/AddonBoilerplate/Helper.php';
             global $sugar_config, $sugar_version, $sugar_flavor;
             $error_email = AddonBoilerplate_Helper::get_error_email_address();
             /**
                             //send email to the admin user
                             $email_to = $error_email;
                             $subject =  '[CRITICAL] AddonBoilerplate is no longer functioning';
                             $bodyHTML= "
             The license was unable to validate. Please log into your SugarCRM instance, go to Admin->AddonBoilerplate->License Configuration and validate your license.
             
             Site: ".$sugar_config['site_url']."
             SugarCRM Version: ".$sugar_version."
             SugarCRM Edition: ".$sugar_flavor."
             AddonBoilerplate Version: ".AddonBoilerplate_Helper::get_addonboilerplate_version();
                     
                             AddonBoilerplate_Helper::send_email($email_to,$subject,$bodyHTML,'*****@*****.**');
             */
             return $result;
         }
     }
     return $result;
 }
コード例 #2
0
} else {
    if ($_REQUEST['method'] == 'change') {
        AddonBoilerplateOutfittersLicense::change();
    } else {
        if ($_REQUEST['method'] == 'add') {
            AddonBoilerplateOutfittersLicense::add();
        } else {
            if ($_REQUEST['method'] == 'test') {
                //optional param: user_id - test if a specific user has access to the add-on
                //Sugar 6: /index.php?module=SampleLicenseAddon&action=outfitterscontroller&method=test&to_pdf=1
                //Sugar 7: #bwc/index.php?module=SampleLicenseAddon&action=outfitterscontroller&method=test&to_pdf=1
                $user_id = null;
                if (!empty($_REQUEST['user_id'])) {
                    $user_id = $_REQUEST['user_id'];
                }
                $validate_license = AddonBoilerplateOutfittersLicense::isValid($currentModule, $user_id, true);
                if ($validate_license !== true) {
                    echo "License did NOT validate.<br/><br/>Reason: " . $validate_license;
                    $validated = AddonBoilerplateOutfittersLicense::doValidate($currentModule);
                    if (is_array($validated['result'])) {
                        echo "<br/><br/>Key validation = " . !empty($validated['result']['validated']);
                        require 'modules/' . $currentModule . '/license/config.php';
                        if ($outfitters_config['validate_users'] == true) {
                            echo "<br/>User validation = " . !empty($validated['result']['validated_users']);
                            echo "<br/>Licensed User Count = " . $validated['result']['licensed_user_count'];
                            echo "<br/>Current User Count = " . $validated['result']['user_count'];
                            if ($validated['result']['user_count'] > $validated['result']['licensed_user_count']) {
                                echo "<br/><br/>Additional Users Required = " . ($validated['result']['user_count'] - $validated['result']['licensed_user_count']);
                            }
                        }
                    }