コード例 #1
0
ファイル: Save.php プロジェクト: jglaine/sugar761-ent
    $prefix = $focus->get_config_prefix($key);
    if (in_array($prefix[0], $focus->config_categories)) {
        if ($prefix[0] == "license") {
            if ($prefix[1] == "expire_date") {
                global $timedate;
                $val = $timedate->swap_formats($val, $timedate->get_date_format(), $timedate->dbDayFormat);
            } else {
                if ($prefix[1] == "key") {
                    $val = trim($val);
                    // bug 16860 tyoung - trim whitespace from the start and end of the licence key value
                }
            }
        }
        $focus->saveSetting($prefix[0], $prefix[1], $val);
    }
}
if (isset($_POST['license_key'])) {
    loadLicense(true);
    check_now(get_sugarbeat());
}
unset($_SESSION['license_seats_needed']);
unset($_SESSION['LICENSE_EXPIRES_IN']);
unset($_SESSION['VALIDATION_EXPIRES_IN']);
unset($_SESSION['HomeOnly']);
apiLoadSystemStatus(true);
// Lock down access to the application for sidecar modules until
// we have a license validation available.
if (!authenticateDownloadKey() && !ocLicense()) {
    $_SESSION['HomeOnly'] = true;
}
header("Location: index.php?action={$_POST['return_action']}&module={$_POST['return_module']}");
コード例 #2
0
ファイル: User.php プロジェクト: jglaine/sugar761-ent
 function save($check_notify = false)
 {
     $isUpdate = !empty($this->id) && !$this->new_with_id;
     // this will cause the logged in admin to have the licensed user count refreshed
     if (isset($_SESSION)) {
         unset($_SESSION['license_seats_needed']);
     }
     $query = "SELECT count(id) as total from users WHERE " . self::getLicensedUsersWhere();
     global $sugar_flavor;
     $admin = Administration::getSettings();
     if (isset($sugar_flavor) && $sugar_flavor != null && ($sugar_flavor == 'CE' || isset($admin->settings['license_enforce_user_limit']) && $admin->settings['license_enforce_user_limit'] == 1)) {
         // Begin Express License Enforcement Check
         // this will cause the logged in admin to have the licensed user count refreshed
         if (isset($_SESSION['license_seats_needed'])) {
             unset($_SESSION['license_seats_needed']);
         }
         if ($this->portal_only != 1 && $this->is_group != 1 && (empty($this->fetched_row) || $this->fetched_row['status'] == 'Inactive' || $this->fetched_row['status'] == '') && $this->status == 'Active') {
             global $sugar_flavor;
             //if((isset($sugar_flavor) && $sugar_flavor != null) && ($sugar_flavor=='CE')){
             $license_users = $admin->settings['license_users'];
             if ($license_users != '') {
                 global $db;
                 //$query = "SELECT count(id) as total from users WHERE status='Active' AND deleted=0 AND is_group=0 AND portal_only=0";
                 $result = $db->query($query, true, "Error filling in user array: ");
                 $row = $db->fetchByAssoc($result);
                 $license_seats_needed = $row['total'] - $license_users;
             } else {
                 $license_seats_needed = -1;
             }
             if ($license_seats_needed >= 0) {
                 // displayAdminError( translate('WARN_LICENSE_SEATS_MAXED', 'Administration'). ($license_seats_needed + 1) . translate('WARN_LICENSE_SEATS2', 'Administration')  );
                 if (isset($_REQUEST['action']) && $_REQUEST['action'] != 'MassUpdate' && $_REQUEST['action'] != 'Save') {
                     die(translate('WARN_LICENSE_SEATS_EDIT_USER', 'Administration') . ' ' . translate('WARN_LICENSE_SEATS2', 'Administration'));
                 } else {
                     if (isset($_REQUEST['action'])) {
                         // When this is not set, we're coming from the installer.
                         $sv = new SugarView();
                         $sv->init('Users');
                         $sv->renderJavascript();
                         $sv->displayHeader();
                         $sv->errors[] = translate('WARN_LICENSE_SEATS_EDIT_USER', 'Administration') . ' ' . translate('WARN_LICENSE_SEATS2', 'Administration');
                         $sv->displayErrors();
                         $sv->displayFooter();
                         die;
                     }
                 }
             }
             //}
         }
     }
     // End Express License Enforcement Check
     // wp: do not save user_preferences in this table, see user_preferences module
     $this->user_preferences = '';
     // if this is an admin user, do not allow is_group or portal_only flag to be set.
     if ($this->is_admin) {
         $this->is_group = 0;
         $this->portal_only = 0;
     }
     // set some default preferences when creating a new user
     $setNewUserPreferences = empty($this->id) || !empty($this->new_with_id);
     // If the 'Primary' team changed then the team widget has set 'team_id' to a new value and we should
     // assign the same value to default_team because User module uses it for setting the 'Primary' team
     if (!empty($this->team_id)) {
         $this->default_team = $this->team_id;
     }
     // track the current reports to id to be able to use it if it has changed
     $old_reports_to_id = isset($this->fetched_row['reports_to_id']) ? $this->fetched_row['reports_to_id'] : '';
     parent::save($check_notify);
     $GLOBALS['sugar_config']['disable_team_access_check'] = true;
     if ($this->status != 'Reserved' && !$this->portal_only) {
         // If this is not an update, then make sure the new user logic is executed.
         if (!$isUpdate) {
             // If this is a new user, make sure to add them to the appriate default teams
             if (!$this->team_exists) {
                 $team = BeanFactory::getBean('Teams');
                 $team->new_user_created($this);
             }
         } else {
             if (empty($GLOBALS['sugar_config']['noPrivateTeamUpdate'])) {
                 //if this is an update, then we need to ensure we keep the user's
                 //private team name and name_2 in sync with their name.
                 $team_id = $this->getPrivateTeamID();
                 if (!empty($team_id)) {
                     $team = BeanFactory::getBean('Teams', $team_id);
                     Team::set_team_name_from_user($team, $this);
                     $team->save();
                 }
             }
         }
     }
     // If reports to has changed, call update team memberships to correct the membership tree
     if ($old_reports_to_id != $this->reports_to_id) {
         $this->update_team_memberships($old_reports_to_id);
     }
     // set some default preferences when creating a new user
     if ($setNewUserPreferences) {
         $this->setPreference('reminder_time', 1800);
         if (!$this->getPreference('calendar_publish_key')) {
             $this->setPreference('calendar_publish_key', create_guid());
         }
     }
     $this->savePreferencesToDB();
     //CurrentUserApi needs a consistent timestamp/format of the data modified for hash purposes.
     $this->hashTS = $this->date_modified;
     // In case this new/updated user changes the system status, reload it here
     apiLoadSystemStatus(true);
     return $this->id;
 }
コード例 #3
0
/**
 * Check if system status is OK
 * @param string $forceReload
 * @return array|true True on OK or array with system status problem
 */
function apiCheckSystemStatus($forceReload = false)
{
    global $sugar_config, $sugar_flavor, $db;
    if (!isset($sugar_config['installer_locked']) || $sugar_config['installer_locked'] == false) {
        return array('level' => 'admin_only', 'message' => 'WARN_INSTALLER_LOCKED', 'url' => 'install.php');
    }
    // If they are missing session variables force a reload
    $sessionCheckNotExists = array('VALIDATION_EXPIRES_IN', 'LICENSE_EXPIRES_IN', 'EXCEEDING_OC_LICENSES');
    $sessionCheckExists = array('HomeOnly', 'INVALID_LICENSE');
    foreach ($sessionCheckNotExists as $key) {
        if (!isset($_SESSION[$key])) {
            $forceReload = true;
        }
    }
    foreach ($sessionCheckExists as $key) {
        if (!empty($_SESSION[$key])) {
            $forceReload = true;
        }
    }
    $systemStatus = apiLoadSystemStatus($forceReload);
    // Don't allow maintenanceMode to override license failures
    if ($systemStatus === true && !empty($GLOBALS['sugar_config']['maintenanceMode'])) {
        $url = 'maintenance.php';
        if ($GLOBALS['sugar_config']['maintenanceMode'] !== true) {
            $url = $GLOBALS['sugar_config']['maintenanceMode'];
        }
        return array('level' => 'maintenance', 'message' => 'EXCEPTION_MAINTENANCE', 'url' => $url);
    }
    return $systemStatus;
}