/**
  * Get the direct reportees for a user.
  *
  * @param $user_id
  * @return array
  */
 protected function getUserReportees($user_id)
 {
     $db = DBManagerFactory::getInstance();
     $sql = sprintf("SELECT id, user_name, first_name, last_name, title, reports_to_id FROM users WHERE (reports_to_id = '%s' OR id = '%s') AND " . User::getLicensedUsersWhere(), $user_id, $user_id);
     $result = $db->query($sql);
     $reportees = array();
     while ($row = $db->fetchByAssoc($result)) {
         $reportees[$row['id']] = $row['user_name'];
         //If the row matches the manager user reverse the order of the array so that the manager is first
         if ($row['id'] == $user_id) {
             $reportees = array_reverse($reportees, true);
         }
     }
     return $reportees;
 }
Example #2
0
    function display()
    {
        global $current_user, $app_list_strings;
        //lets set the return values
        if (isset($_REQUEST['return_module'])) {
            $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
        }
        $this->ss->assign('IS_ADMIN', $current_user->is_admin ? true : false);
        //make sure we can populate user type dropdown.  This usually gets populated in predisplay unless this is a quickeditform
        if (!isset($this->fieldHelper)) {
            $this->fieldHelper = UserViewHelper::create($this->ss, $this->bean, 'EditView');
            $this->fieldHelper->setupAdditionalFields();
        }
        if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
            $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
            $this->ss->assign('RETURN_ACTION', $_REQUEST['return_action']);
            $this->ss->assign('RETURN_ID', $_REQUEST['record']);
            $this->bean->id = "";
            $this->bean->user_name = "";
            $this->ss->assign('ID', '');
        } else {
            if (isset($_REQUEST['return_module'])) {
                $this->ss->assign('RETURN_MODULE', $_REQUEST['return_module']);
            } else {
                $this->ss->assign('RETURN_MODULE', $this->bean->module_dir);
            }
            $return_id = isset($_REQUEST['return_id']) ? $_REQUEST['return_id'] : $this->bean->id;
            if (isset($return_id)) {
                $return_action = isset($_REQUEST['return_action']) ? $_REQUEST['return_action'] : 'DetailView';
                $this->ss->assign('RETURN_ID', $return_id);
                $this->ss->assign('RETURN_ACTION', $return_action);
            }
        }
        ///////////////////////////////////////////////////////////////////////////////
        ////	REDIRECTS FROM COMPOSE EMAIL SCREEN
        if (isset($_REQUEST['type']) && (isset($_REQUEST['return_module']) && $_REQUEST['return_module'] == 'Emails')) {
            $this->ss->assign('REDIRECT_EMAILS_TYPE', $_REQUEST['type']);
        }
        ////	END REDIRECTS FROM COMPOSE EMAIL SCREEN
        ///////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////
        ////	NEW USER CREATION ONLY
        if (empty($this->bean->id)) {
            $this->ss->assign('SHOW_ADMIN_CHECKBOX', 'height="30"');
            $this->ss->assign('NEW_USER', '1');
        } else {
            $this->ss->assign('NEW_USER', '0');
            $this->ss->assign('NEW_USER_TYPE', 'DISABLED');
            $this->ss->assign('REASSIGN_JS', "return confirmReassignRecords();");
        }
        ////	END NEW USER CREATION ONLY
        ///////////////////////////////////////////////////////////////////////////////
        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)) {
            if (empty($this->bean->id)) {
                $license_users = $admin->settings['license_users'];
                if ($license_users != '') {
                    $license_seats_needed = count(get_user_array(false, "", "", false, null, " AND " . User::getLicensedUsersWhere(), false)) - $license_users;
                } else {
                    $license_seats_needed = -1;
                }
                if ($license_seats_needed >= 0) {
                    displayAdminError(translate('WARN_LICENSE_SEATS_USER_CREATE', 'Administration') . translate('WARN_LICENSE_SEATS2', 'Administration'));
                    if (isset($_SESSION['license_seats_needed'])) {
                        unset($_SESSION['license_seats_needed']);
                    }
                    //die();
                }
            }
        }
        // FIXME: Translate error prefix
        if (isset($_REQUEST['error_string'])) {
            $this->ss->assign('ERROR_STRING', '<span class="error">Error: ' . $_REQUEST['error_string'] . '</span>');
        }
        if (isset($_REQUEST['error_password'])) {
            $this->ss->assign('ERROR_PASSWORD', '<span id="error_pwd" class="error">Error: ' . $_REQUEST['error_password'] . '</span>');
        }
        // Build viewable versions of a few fields for non-admins
        if (!empty($this->bean->id)) {
            if (!empty($this->bean->status)) {
                $this->ss->assign('STATUS_READONLY', $app_list_strings['user_status_dom'][$this->bean->status]);
            }
            if (!empty($this->bean->employee_status)) {
                $this->ss->assign('EMPLOYEE_STATUS_READONLY', $app_list_strings['employee_status_dom'][$this->bean->employee_status]);
            }
            if (!empty($this->bean->reports_to_id)) {
                $reportsToUserField = "<input type='text' name='reports_to_name' id='reports_to_name' value='{$this->bean->reports_to_name}' disabled>\n";
                $reportsToUserField .= "<input type='hidden' name='reports_to_id' id='reports_to_id' value='{$this->bean->reports_to_id}'>";
                $this->ss->assign('REPORTS_TO_READONLY', $reportsToUserField);
            }
            if (!empty($this->bean->title)) {
                $this->ss->assign('TITLE_READONLY', $this->bean->title);
            }
            if (!empty($this->bean->department)) {
                $this->ss->assign('DEPT_READONLY', $this->bean->department);
            }
        }
        $processSpecial = false;
        $processFormName = '';
        if (isset($this->fieldHelper->usertype) && ($this->fieldHelper->usertype == 'GROUP' || $this->fieldHelper->usertype == 'PORTAL_ONLY')) {
            $this->ev->formName = 'EditViewGroup';
            $processSpecial = true;
            $processFormName = 'EditViewGroup';
        }
        //Bug#51609 Replace {php} code block in EditViewHeader.tpl
        $action_button = array();
        $APP = $this->ss->get_template_vars('APP');
        $PWDSETTINGS = $this->ss->get_template_vars('PWDSETTINGS');
        $REGEX = $this->ss->get_template_vars('REGEX');
        $CHOOSER_SCRIPT = $this->ss->get_template_vars('CHOOSER_SCRIPT');
        $REASSIGN_JS = $this->ss->get_template_vars('REASSIGN_JS');
        $RETURN_ACTION = $this->ss->get_template_vars('RETURN_ACTION');
        $RETURN_MODULE = $this->ss->get_template_vars('RETURN_MODULE');
        $RETURN_ID = $this->ss->get_template_vars('RETURN_ID');
        $minpwdlength = !empty($PWDSETTINGS['minpwdlength']) ? $PWDSETTINGS['minpwdlength'] : '';
        $maxpwdlength = !empty($PWDSETTINGS['maxpwdlength']) ? $PWDSETTINGS['maxpwdlength'] : '';
        $action_button_header[] = <<<EOD
                    <input type="button" id="SAVE_HEADER" title="{$APP['LBL_SAVE_BUTTON_TITLE']}" accessKey="{$APP['LBL_SAVE_BUTTON_KEY']}"
                          class="button primary" onclick="var _form = \$('#EditView')[0]; if (!set_password(_form,newrules('{$minpwdlength}','{$maxpwdlength}','{$REGEX}'))) return false; if (!Admin_check()) return false; _form.action.value='Save'; {$CHOOSER_SCRIPT} {$REASSIGN_JS} if(verify_data(EditView)) _form.submit();"
                          name="button" value="{$APP['LBL_SAVE_BUTTON_LABEL']}">
EOD;
        $action_button_header[] = <<<EOD
                    <input\ttitle="{$APP['LBL_CANCEL_BUTTON_TITLE']}" id="CANCEL_HEADER" accessKey="{$APP['LBL_CANCEL_BUTTON_KEY']}"
                              class="button" onclick="var _form = \$('#EditView')[0]; _form.action.value='{$RETURN_ACTION}'; _form.module.value='{$RETURN_MODULE}'; _form.record.value='{$RETURN_ID}'; _form.submit()"
                              type="button" name="button" value="{$APP['LBL_CANCEL_BUTTON_LABEL']}">
EOD;
        $action_button_header = array_merge($action_button_header, $this->ss->get_template_vars('BUTTONS_HEADER'));
        $this->ss->assign('ACTION_BUTTON_HEADER', $action_button_header);
        $action_button_footer[] = <<<EOD
                    <input type="button" id="SAVE_FOOTER" title="{$APP['LBL_SAVE_BUTTON_TITLE']}" accessKey="{$APP['LBL_SAVE_BUTTON_KEY']}"
                          class="button primary" onclick="var _form = \$('#EditView')[0]; if (!set_password(_form,newrules('{$minpwdlength}','{$maxpwdlength}','{$REGEX}'))) return false; if (!Admin_check()) return false; _form.action.value='Save'; {$CHOOSER_SCRIPT} {$REASSIGN_JS} if(verify_data(EditView)) _form.submit();"
                          name="button" value="{$APP['LBL_SAVE_BUTTON_LABEL']}">
EOD;
        $action_button_footer[] = <<<EOD
                    <input\ttitle="{$APP['LBL_CANCEL_BUTTON_TITLE']}" id="CANCEL_FOOTER" accessKey="{$APP['LBL_CANCEL_BUTTON_KEY']}"
                              class="button" onclick="var _form = \$('#EditView')[0]; _form.action.value='{$RETURN_ACTION}'; _form.module.value='{$RETURN_MODULE}'; _form.record.value='{$RETURN_ID}'; _form.submit()"
                              type="button" name="button" value="{$APP['LBL_CANCEL_BUTTON_LABEL']}">
EOD;
        $action_button_footer = array_merge($action_button_footer, $this->ss->get_template_vars('BUTTONS_FOOTER'));
        $this->ss->assign('ACTION_BUTTON_FOOTER', $action_button_footer);
        //if the request object has 'scrolltocal' set, then we are coming here from the tour window box and need to set flag to true
        // so that footer.tpl fires off script to scroll to calendar section
        if (!empty($_REQUEST['scrollToCal'])) {
            $this->ss->assign('scroll_to_cal', true);
        }
        $this->ev->process($processSpecial, $processFormName);
        echo $this->ev->display($this->showTitle);
    }
Example #3
0
 public function testgetLicensedUsersWhere()
 {
     $expected = "deleted=0 AND status='Active' AND user_name IS NOT NULL AND is_group=0 AND portal_only=0  AND LENGTH(user_name)>0";
     $actual = User::getLicensedUsersWhere();
     $this->assertSame($expected, $actual);
 }
Example #4
0
/**
 *  Get actual system status
 *  No caching, just check the system status
 */
function apiActualLoadSystemStatus()
{
    global $sugar_flavor, $db;
    checkSystemLicenseStatus();
    if (!isset($_SESSION['LICENSE_EXPIRES_IN'])) {
        // BEGIN CE-OD License User Limit Enforcement
        if (isset($sugar_flavor) && ($sugar_flavor == 'CE' || !empty($admin->settings['license_enforce_user_limit']))) {
            $query = "SELECT count(id) as total from users WHERE " . User::getLicensedUsersWhere();
            $result = $db->query($query, true, "Error filling in user array: ");
            $row = $db->fetchByAssoc($result);
            $admin = Administration::getSettings();
            $license_users = $admin->settings['license_users'];
            $license_seats_needed = $row['total'] - $license_users;
            if ($license_seats_needed > 0) {
                $_SESSION['EXCEEDS_MAX_USERS'] = 1;
                return array('level' => 'admin_only', 'message' => 'WARN_LICENSE_SEATS_MAXED', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
            }
        }
        // END CE-OD License User Limit Enforcement
    }
    // Only allow administrators because of altered license issue
    if (!empty($_SESSION['HomeOnly'])) {
        return array('level' => 'admin_only', 'message' => 'FATAL_LICENSE_ALTERED', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
    }
    if (!ocLicense()) {
        if (!empty($_SESSION['INVALID_LICENSE'])) {
            return array('level' => 'admin_only', 'message' => 'ERROR_LICENSE_VALIDATION', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
        }
        if (isset($_SESSION['LICENSE_EXPIRES_IN']) && $_SESSION['LICENSE_EXPIRES_IN'] != 'valid') {
            if ($_SESSION['LICENSE_EXPIRES_IN'] < -1) {
                return array('level' => 'admin_only', 'message' => 'ERROR_LICENSE_EXPIRED', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
            } else {
                if (isset($GLOBALS['current_user']->id) && $GLOBALS['current_user']->isAdmin()) {
                    // Not yet expired, but soon enough to warn
                    return array('level' => 'warning', 'message' => 'WARN_LICENSE_EXPIRED', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
                }
            }
        } elseif (isset($_SESSION['VALIDATION_EXPIRES_IN']) && $_SESSION['VALIDATION_EXPIRES_IN'] != 'valid') {
            if ($_SESSION['VALIDATION_EXPIRES_IN'] < -1) {
                return array('level' => 'admin_only', 'message' => 'ERROR_LICENSE_VALIDATION', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
            } else {
                if (isset($GLOBALS['current_user']->id) && $GLOBALS['current_user']->isAdmin()) {
                    // Not yet expired, but soon enough to warn
                    return array('level' => 'warning', 'message' => 'WARN_LICENSE_VALIDATION', 'url' => '#bwc/index.php?action=LicenseSettings&module=Administration');
                }
            }
        }
    }
    if (!empty($_SESSION['EXCEEDING_OC_LICENSES'])) {
        return array('level' => 'admin_only', 'message' => 'ERROR_EXCEEDING_OC_LICENSES', 'url' => '#bwc/index.php?module=Administration&action=ListViewOfflineClient');
    }
    return true;
}
Example #5
0
function getSystemInfo($send_usage_info = true)
{
    global $sugar_config;
    global $db, $administration, $timedate;
    $info = array();
    $info = getBaseSystemInfo($send_usage_info);
    if ($send_usage_info) {
        $info['application_key'] = $sugar_config['unique_key'];
        $info['php_version'] = phpversion();
        if (isset($_SERVER['SERVER_SOFTWARE'])) {
            $info['server_software'] = $_SERVER['SERVER_SOFTWARE'];
        }
        // if
        //get user count.
        $query = "SELECT count(*) as total from users WHERE " . User::getLicensedUsersWhere();
        $result = $db->getOne($query, false, 'fetching active users count');
        if ($result !== false) {
            $info['users'] = $result;
        }
        if (empty($administration)) {
            $administration = new Administration();
        }
        $administration->retrieveSettings('system');
        $info['system_name'] = !empty($administration->settings['system_name']) ? substr($administration->settings['system_name'], 0, 255) : '';
        $result = $db->getOne("select count(*) count from users where status='Active' and deleted=0 and is_admin='1'", false, 'fetching admin count');
        if ($result !== false) {
            $info['admin_users'] = $result;
        }
        $result = $db->getOne("select count(*) count from users", false, 'fetching all users count');
        if ($result !== false) {
            $info['registered_users'] = $result;
        }
        $lastMonth = $db->convert("'" . $timedate->getNow()->modify("-30 days")->asDb(false) . "'", 'datetime');
        if (!$send_usage_info) {
            $info['users_active_30_days'] = -1;
        } else {
            $info['users_active_30_days'] = $db->getOne("SELECT count( DISTINCT users.id ) user_count FROM tracker, users WHERE users.id = tracker.user_id AND  tracker.date_modified >= {$lastMonth}", false, 'fetching last 30 users count');
        }
        if (!$send_usage_info) {
            $info['latest_tracker_id'] = -1;
        } else {
            $id = $db->getOne("select id from tracker order by date_modified desc", false, 'fetching most recent tracker entry');
            if ($id !== false) {
                $info['latest_tracker_id'] = $id;
            }
        }
        $info['db_type'] = $sugar_config['dbconfig']['db_type'];
        $info['db_version'] = $db->version();
    }
    if (file_exists('distro.php')) {
        include 'distro.php';
        if (!empty($distro_name)) {
            $info['distro_name'] = $distro_name;
        }
    }
    $info['os'] = php_uname('s');
    $info['os_version'] = php_uname('r');
    $info['timezone_u'] = $GLOBALS['current_user']->getPreference('timezone');
    $info['timezone'] = date('e');
    if ($info['timezone'] == 'e') {
        $info['timezone'] = date('T');
    }
    return $info;
}
Example #6
0
                 setSystemState('LICENSE_KEY');
                 displayAdminError(translate('FATAL_VALIDATION_EXPIRED', 'Administration') . " [" . abs($_SESSION['VALIDATION_EXPIRES_IN']) . " day(s) ] .<br>   " . translate('FATAL_VALIDATION_EXPIRED2', 'Administration'));
             } else {
                 displayAdminError(translate('ERROR_VALIDATION_EXPIRED', 'Administration') . abs($_SESSION['VALIDATION_EXPIRES_IN']) . translate('ERROR_VALIDATION_EXPIRED2', 'Administration'));
             }
         } else {
             if ($_SESSION['VALIDATION_EXPIRES_IN'] >= 0) {
                 displayAdminError(translate('WARN_VALIDATION_EXPIRED', 'Administration') . $_SESSION['VALIDATION_EXPIRES_IN'] . translate('WARN_VALIDATION_EXPIRED2', 'Administration'));
             }
         }
     }
 }
 if (!isset($_SESSION['license_seats_needed'])) {
     $focus = Administration::getSettings();
     $license_users = isset($focus->settings['license_users']) ? $focus->settings['license_users'] : '';
     $_SESSION['license_seats_needed'] = $db->getOne("SELECT count(id) as total from users WHERE " . User::getLicensedUsersWhere()) - $license_users;
 }
 if ($_SESSION['license_seats_needed'] > 0) {
     displayAdminError(translate('WARN_LICENSE_SEATS', 'Administration') . $_SESSION['license_seats_needed'] . translate('WARN_LICENSE_SEATS2', 'Administration'));
 }
 //END REQUIRED CODE DO NOT MODIFY
 if (empty($GLOBALS['sugar_config']['admin_access_control'])) {
     if (isset($_SESSION['invalid_versions'])) {
         $invalid_versions = $_SESSION['invalid_versions'];
         foreach ($invalid_versions as $invalid) {
             displayAdminError(translate('WARN_UPGRADE', 'Administration') . $invalid['name'] . translate('WARN_UPGRADE2', 'Administration'));
         }
     }
     if (isset($_SESSION['available_version'])) {
         if ($_SESSION['available_version'] != $sugar_version) {
             displayAdminError(translate('WARN_UPGRADENOTE', 'Administration') . $_SESSION['available_version_description']);
Example #7
0
/**
 * upgradeUserPreferences
 * This method updates the user_preferences table and sets the pages/dashlets for users
 * which have ACL access to Trackers so that the Tracker dashlets are set in their user perferences
 *
 */
function upgradeUserPreferences()
{
    global $sugar_config, $sugar_version;
    $uw_strings = return_module_language($GLOBALS['current_language'], 'UpgradeWizard');
    $localization = Localization::getObject();
    $localeCoreDefaults = $localization->getLocaleConfigDefaults();
    // check the current system wide default_locale_name_format and add it to the list if it's not there
    if (empty($sugar_config['name_formats'])) {
        $sugar_config['name_formats'] = $localeCoreDefaults['name_formats'];
        if (!rebuildConfigFile($sugar_config, $sugar_version)) {
            $errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
        }
    }
    $currentDefaultLocaleNameFormat = $sugar_config['default_locale_name_format'];
    if ($localization->isAllowedNameFormat($currentDefaultLocaleNameFormat)) {
        upgradeLocaleNameFormat($currentDefaultLocaleNameFormat);
    } else {
        $sugar_config['default_locale_name_format'] = $localeCoreDefaults['default_locale_name_format'];
        if (!rebuildConfigFile($sugar_config, $sugar_version)) {
            $errors[] = $uw_strings['ERR_UW_CONFIG_WRITE'];
        }
        $localization->createInvalidLocaleNameFormatUpgradeNotice();
    }
    if (file_exists($cachedfile = sugar_cached('dashlets/dashlets.php'))) {
        require $cachedfile;
    } else {
        if (file_exists('modules/Dashboard/dashlets.php')) {
            require 'modules/Dashboard/dashlets.php';
        }
    }
    $upgradeTrackingDashlets = array('TrackerDashlet' => array('file' => 'modules/Trackers/Dashlets/TrackerDashlet/TrackerDashlet.php', 'class' => 'TrackerDashlet', 'meta' => 'modules/Trackers/Dashlets/TrackerDashlet/TrackerDashlet.meta.php', 'module' => 'Trackers'), 'MyModulesUsedChartDashlet' => array('file' => 'modules/Charts/Dashlets/MyModulesUsedChartDashlet/MyModulesUsedChartDashlet.php', 'class' => 'MyModulesUsedChartDashlet', 'meta' => 'modules/Charts/Dashlets/MyModulesUsedChartDashlet/MyModulesUsedChartDashlet.meta.php', 'module' => 'Trackers'), 'MyTeamModulesUsedChartDashlet' => array('file' => 'modules/Charts/Dashlets/MyTeamModulesUsedChartDashlet/MyTeamModulesUsedChartDashlet.php', 'class' => 'MyTeamModulesUsedChartDashlet', 'meta' => 'modules/Charts/Dashlets/MyTeamModulesUsedChartDashlet/MyTeamModulesUsedChartDashlet.meta.php', 'module' => 'Trackers'));
    $GLOBALS['mod_strings'] = return_module_language($GLOBALS['current_language'], 'Home');
    $ce_to_pro_or_ent = isset($_SESSION['upgrade_from_flavor']) && preg_match('/^SugarCE.*?(Pro|Ent|Corp|Ult)$/', $_SESSION['upgrade_from_flavor']);
    $db =& DBManagerFactory::getInstance();
    $result = $db->query("SELECT id FROM users WHERE " . User::getLicensedUsersWhere());
    while ($row = $db->fetchByAssoc($result)) {
        $current_user = new User();
        $current_user->retrieve($row['id']);
        // get the user's name locale format, check if it's in our list, add it if it's not, keep it as user's default
        $changed = false;
        $currentUserNameFormat = $current_user->getPreference('default_locale_name_format');
        if ($localization->isAllowedNameFormat($currentUserNameFormat)) {
            upgradeLocaleNameFormat($currentUserNameFormat);
        } else {
            $current_user->setPreference('default_locale_name_format', 's f l', 0, 'global');
            $changed = true;
        }
        if (!$current_user->getPreference('calendar_publish_key')) {
            // set publish key if not set already
            $current_user->setPreference('calendar_publish_key', create_guid());
            $changed = true;
        }
        //Set the user theme to be 'Sugar' theme since this is run for CE flavor conversions
        $userTheme = $current_user->getPreference('user_theme', 'global');
        //If theme is empty or if theme was set to Classic (Sugar5) or if this is a ce to pro/ent flavor upgrade change to RacerX theme
        if (empty($userTheme) || $userTheme == 'Sugar5' || $ce_to_pro_or_ent) {
            $changed = true;
            $current_user->setPreference('user_theme', 'RacerX', 0, 'global');
        }
        //Set the number of tabs by default to 7
        $maxTabs = $current_user->getPreference('max_tabs', 'global');
        if (empty($maxTabs)) {
            $changed = true;
            $current_user->setPreference('max_tabs', '7', 0, 'global');
        }
        //If preferences have changed, save before proceeding
        if ($changed) {
            $current_user->savePreferencesToDB();
        }
        $pages = $current_user->getPreference('pages', 'Home');
        if (empty($pages)) {
            continue;
        }
        $changed = false;
        $empty_dashlets = array();
        $dashlets = $current_user->getPreference('dashlets', 'Home');
        $dashlets = !empty($dashlets) ? $dashlets : $empty_dashlets;
        $existingDashlets = array();
        foreach ($dashlets as $id => $dashlet) {
            if (!empty($dashlet['className']) && !is_array($dashlet['className'])) {
                $existingDashlets[$dashlet['className']] = $dashlet['className'];
            }
        }
        if (ACLController::checkAccess('Trackers', 'view', false, 'Tracker')) {
            $trackingDashlets = array();
            foreach ($upgradeTrackingDashlets as $trackingDashletName => $entry) {
                if (empty($existingDashlets[$trackingDashletName])) {
                    $trackingDashlets[create_guid()] = array('className' => $trackingDashletName, 'fileLocation' => $entry['file'], 'options' => array());
                }
            }
            if (empty($trackingDashlets)) {
                continue;
            }
            $trackingColumns = array();
            $trackingColumns[0] = array();
            $trackingColumns[0]['width'] = '50%';
            $trackingColumns[0]['dashlets'] = array();
            foreach ($trackingDashlets as $guid => $dashlet) {
                array_push($trackingColumns[0]['dashlets'], $guid);
            }
            //Set the tracker dashlets to user preferences table
            $dashlets = array_merge($dashlets, $trackingDashlets);
            $current_user->setPreference('dashlets', $dashlets, 0, 'Home');
            //Set the dashlets pages to user preferences table
            $pageIndex = count($pages);
            $pages[$pageIndex]['columns'] = $trackingColumns;
            $pages[$pageIndex]['numColumns'] = '1';
            $pages[$pageIndex]['pageTitle'] = $GLOBALS['mod_strings']['LBL_HOME_PAGE_4_NAME'];
            $current_user->setPreference('pages', $pages, 0, 'Home');
            $changed = true;
        }
        //if
        // we need to force save the changes to disk, otherwise we lose them.
        if ($changed) {
            $current_user->savePreferencesToDB();
        }
    }
    //while
    /*
     * This section checks to see if the Tracker settings for the corresponding versions have been
     * disabled and the regular tracker (for breadcrumbs) enabled.  If so, then it will also disable
     * the tracking for the regular tracker.  Disabling the tracker (for breadcrumbs) will no longer prevent
     * breadcrumb tracking.  It will instead only track visible entries (see trackView() method in SugarView.php).
     * This has the benefit of reducing the tracking overhead and limiting it to only visible items.
     * For the CE version, we are checking to see that there are no entries enabled for PRO/ENT versions
     * we are checking for Tracker sessions, performance and queries.
     */
    if ($ce_to_pro_or_ent) {
        //Set tracker settings. Disable tracker session, performance and queries
        $category = 'tracker';
        $value = 1;
        $key = array('Tracker', 'tracker_sessions', 'tracker_perf', 'tracker_queries');
        $admin = new Administration();
        foreach ($key as $k) {
            $admin->saveSetting($category, $k, $value);
        }
    } else {
        $query = "select count(name) as total from config where category = 'tracker' and name = 'Tracker'";
        $results = $db->query($query);
        if (!empty($results)) {
            $row = $db->fetchByAssoc($results);
            $total = $row['total'];
            if ($GLOBALS['sugar_flavor'] == 'PRO' || $GLOBALS['sugar_flavor'] == 'ENT') {
                //Fix problem with having multiple tracker entries in config table
                if ($total > 1) {
                    $db->query("DELETE FROM config where category = 'tracker' and name = 'Tracker'");
                    $db->query("INSERT INTO config (category, name, value) VALUES ('tracker', 'Tracker', '1')");
                }
            } else {
                //We are assuming if the 'Tracker' setting is not disabled then we will just disable it
                if ($total == 0) {
                    $db->query("INSERT INTO config (category, name, value) VALUES ('tracker', 'Tracker', '1')");
                }
            }
        }
    }
    //Write the entries to cache/dashlets/dashlets.php
    if (file_exists($cachedfile = sugar_cached('dashlets/dashlets.php'))) {
        require $cachedfile;
        foreach ($upgradeTrackingDashlets as $id => $entry) {
            if (!isset($dashletsFiles[$id])) {
                $dashletsFiles[$id] = $entry;
            }
        }
        write_array_to_file("dashletsFiles", $dashletsFiles, $cachedfile);
    }
    //if
}
Example #8
0
if (isset($_COOKIE['loginErrorMessage'])) {
    if (!isset($_REQUEST['loginErrorMessage'])) {
        $_REQUEST['loginErrorMessage'] = $_COOKIE['loginErrorMessage'];
    }
    SugarApplication::setCookie('loginErrorMessage', '', time() - 42000, '/');
}
if (isset($_REQUEST['loginErrorMessage'])) {
    if (isset($mod_strings[$_REQUEST['loginErrorMessage']])) {
        echo "<p align='center' class='error' > " . $mod_strings[$_REQUEST['loginErrorMessage']] . "</p>";
    } else {
        if (isset($app_strings[$_REQUEST['loginErrorMessage']])) {
            echo "<p align='center' class='error' > " . $app_strings[$_REQUEST['loginErrorMessage']] . "</p>";
        }
    }
}
$query = "SELECT count(id) as total from users WHERE " . User::getLicensedUsersWhere();
// This section of code is a portion of the code referred
// to as Critical Control Software under the End User
// License Agreement.  Neither the Company nor the Users
// may modify any portion of the Critical Control Software.
if (!isset($_SESSION['LICENSE_EXPIRES_IN'])) {
    checkSystemLicenseStatus();
}
if (!ocLicense() && isset($_SESSION['LICENSE_EXPIRES_IN']) && $_SESSION['LICENSE_EXPIRES_IN'] != 'valid' && $_SESSION['LICENSE_EXPIRES_IN'] < -1) {
    echo " <p align='center' class='error' >" . $GLOBALS['app_strings']['ERROR_FULLY_EXPIRED'] . "</p>";
} elseif (!ocLicense() && isset($_SESSION['VALIDATION_EXPIRES_IN']) && $_SESSION['VALIDATION_EXPIRES_IN'] != 'valid' && $_SESSION['VALIDATION_EXPIRES_IN'] < -1) {
    echo "<p align='center' class='error' > " . $GLOBALS['app_strings']['ERROR_LICENSE_EXPIRED'] . "</p>";
}
//END REQUIRED CODE  DO NOT MODIFY
// BEGIN CE-OD License User Limit Enforcement
global $sugar_flavor;