Ejemplo n.º 1
0
 function preDisplay()
 {
     global $current_user, $app_strings, $sugar_config;
     if (!isset($this->bean->id)) {
         // No reason to set everything up just to have it fail in the display() call
         return;
     }
     parent::preDisplay();
     $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
     $viewHelper->setupAdditionalFields();
     $errors = "";
     $msgGood = false;
     if (isset($_REQUEST['pwd_set']) && $_REQUEST['pwd_set'] != 0) {
         if ($_REQUEST['pwd_set'] == '4') {
             require_once 'modules/Users/password_utils.php';
             $errors .= canSendPassword();
         } else {
             $errors .= translate('LBL_NEW_USER_PASSWORD_' . $_REQUEST['pwd_set'], 'Users');
             $msgGood = true;
         }
     } else {
         //IF BEAN USER IS LOCKOUT
         if ($this->bean->getPreference('lockout') == '1') {
             $errors .= translate('ERR_USER_IS_LOCKED_OUT', 'Users');
         }
     }
     $this->ss->assign("ERRORS", $errors);
     $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT', 'Users') : translate('LBL_CANNOT_SEND_PASSWORD', 'Users'));
     $buttons = "";
     if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && !empty($sugar_config['default_user_name']) && $sugar_config['default_user_name'] == $this->bean->user_name && isset($sugar_config['lock_default_user_name']) && $sugar_config['lock_default_user_name']) {
         $buttons .= "<input id='edit_button' title='" . $app_strings['LBL_EDIT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_EDIT_BUTTON_KEY'] . "' class='button primary' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='" . $this->bean->id . "'; this.form.action.value='EditView'\" type='submit' name='Edit' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>  ";
     } elseif (is_admin($current_user) || $GLOBALS['current_user']->isAdminForModule('Users') && !$this->bean->is_admin || $_REQUEST['record'] == $current_user->id) {
         $buttons .= "<input id='edit_button' title='" . $app_strings['LBL_EDIT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_EDIT_BUTTON_KEY'] . "' class='button primary' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='" . $this->bean->id . "'; this.form.action.value='EditView'\" type='submit' name='Edit' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>  ";
         if (is_admin($current_user) || $GLOBALS['current_user']->isAdminForModule('Users')) {
             if (!$current_user->is_group) {
                 $buttons .= "<input title='" . $app_strings['LBL_DUPLICATE_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_DUPLICATE_BUTTON_KEY'] . "' class='button' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.action.value='EditView'\" type='submit' name='Duplicate' value='" . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . "'>  ";
                 if ($this->bean->id != $current_user->id) {
                     $buttons .= "<input type='button' class='button' onclick='confirmDelete();' value='" . $app_strings['LBL_DELETE_BUTTON_LABEL'] . "' /> ";
                 }
                 if (!$this->bean->portal_only && !$this->bean->is_group && !$this->bean->external_auth_only && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']) {
                     $buttons .= "<input title='" . translate('LBL_GENERATE_PASSWORD_BUTTON_TITLE', 'Users') . "' accessKey='" . translate('LBL_GENERATE_PASSWORD_BUTTON_KEY', 'Users') . "' class='button' LANGUAGE=javascript onclick='generatepwd(\"" . $this->bean->id . "\");' type='button' name='password' value='" . translate('LBL_GENERATE_PASSWORD_BUTTON_LABEL', 'Users') . "'>  ";
                 }
             }
         }
     }
     $this->ss->assign('EDITBUTTONS', $buttons);
     $show_roles = !($this->bean->is_group == '1' || $this->bean->portal_only == '1');
     $this->ss->assign('SHOW_ROLES', $show_roles);
     //Mark whether or not the user is a group or portal user
     $this->ss->assign('IS_GROUP_OR_PORTAL', $this->bean->is_group == '1' || $this->bean->portal_only == '1' ? true : false);
     if ($show_roles) {
         ob_start();
         echo "<div>";
         require_once 'modules/ACLRoles/DetailUserRole.php';
         echo "</div></div>";
         $role_html = ob_get_contents();
         ob_end_clean();
         $this->ss->assign('ROLE_HTML', $role_html);
     }
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 3
0
 function preDisplay()
 {
     global $current_user, $app_strings, $sugar_config;
     if (!isset($this->bean->id)) {
         // No reason to set everything up just to have it fail in the display() call
         return;
     }
     if (!$current_user->isAdminForModule('Users') && !$current_user->isDeveloperForModule('Users') && $this->bean->id != $current_user->id) {
         ACLController::displayNoAccess(true);
         sugar_cleanup(true);
     }
     parent::preDisplay();
     //used constructor instead of Static create method as it doesn't support SugarCE 6.5
     //by Hatim Alam
     $viewHelper = new UserViewHelper($this->ss, $this->bean, 'DetailView');
     $viewHelper->setupAdditionalFields();
     $errors = "";
     $msgGood = false;
     if (isset($_REQUEST['pwd_set']) && $_REQUEST['pwd_set'] != 0) {
         if ($_REQUEST['pwd_set'] == '4') {
             require_once 'modules/Users/password_utils.php';
             $errors .= canSendPassword();
         } else {
             $errors .= translate('LBL_NEW_USER_PASSWORD_' . $_REQUEST['pwd_set'], 'Users');
             $msgGood = true;
         }
     } else {
         //IF BEAN USER IS LOCKOUT
         if ($this->bean->getPreference('lockout') == '1') {
             $errors .= translate('ERR_USER_IS_LOCKED_OUT', 'Users');
         }
     }
     $this->ss->assign("ERRORS", $errors);
     $this->ss->assign("ERROR_MESSAGE", $msgGood ? translate('LBL_PASSWORD_SENT', 'Users') : translate('LBL_CANNOT_SEND_PASSWORD', 'Users'));
     $buttons = array();
     if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && !empty($sugar_config['default_user_name']) && $sugar_config['default_user_name'] == $this->bean->user_name && isset($sugar_config['lock_default_user_name']) && $sugar_config['lock_default_user_name']) {
         $buttons[] = "<input id='edit_button' accessKey='" . $app_strings['LBL_EDIT_BUTTON_KEY'] . "' name='Edit' title='" . $app_strings['LBL_EDIT_BUTTON_TITLE'] . "' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='" . $this->bean->id . "'; this.form.action.value='EditView'\" type='submit' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>";
     } elseif (is_admin($current_user) || $GLOBALS['current_user']->isAdminForModule('Users') && !$this->bean->is_admin || $_REQUEST['record'] == $current_user->id) {
         $buttons[] = "<input title='" . $app_strings['LBL_EDIT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_EDIT_BUTTON_KEY'] . "' name='Edit' id='edit_button' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='" . $this->bean->id . "'; this.form.action.value='EditView'\" type='submit' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>";
         if (is_admin($current_user) || $GLOBALS['current_user']->isAdminForModule('Users')) {
             if (!$current_user->is_group) {
                 $buttons[] = "<input id='duplicate_button' title='" . $app_strings['LBL_DUPLICATE_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_DUPLICATE_BUTTON_KEY'] . "' class='button' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.isDuplicate.value=true; this.form.action.value='EditView'\" type='submit' name='Duplicate' value='" . $app_strings['LBL_DUPLICATE_BUTTON_LABEL'] . "'>";
                 if ($this->bean->id != $current_user->id) {
                     $buttons[] = "<input id='delete_button' type='button' class='button' onclick='confirmDelete();' value='" . $app_strings['LBL_DELETE_BUTTON_LABEL'] . "' />";
                 }
                 if (!$this->bean->portal_only && !$this->bean->is_group && !$this->bean->external_auth_only && isset($sugar_config['passwordsetting']['SystemGeneratedPasswordON']) && $sugar_config['passwordsetting']['SystemGeneratedPasswordON']) {
                     $buttons[] = "<input title='" . translate('LBL_GENERATE_PASSWORD_BUTTON_TITLE', 'Users') . "' class='button' LANGUAGE=javascript onclick='generatepwd(\"" . $this->bean->id . "\");' type='button' name='password' value='" . translate('LBL_GENERATE_PASSWORD_BUTTON_LABEL', 'Users') . "'>";
                 }
             }
         }
     }
     //add sudo user button for login and logout
     if ($current_user->id != $this->bean->id) {
         $buttons[] = "<input type='submit' onclick=\"this.form.module.value='Users';this.form.action.value='sudo_login_user'\" class='button' id='sudo_login_user' value='" . translate('LBL_USER_LOGIN_AS', 'Users') . " {$this->bean->user_name}'/>";
     } else {
         if ($current_user->id == $this->bean->id && !empty($_SESSION['original_sudo_user_id'])) {
             $buttons[] = "<input type='submit' onclick=\"this.form.module.value='Users';this.form.action.value='sudo_logout_user'\" class='button' id='sudo_logout_user' value='" . translate('LBL_USER_LOGIN_BACK_AS', 'Users') . " {$_SESSION[original_sudo_user_name]}'/>";
         }
     }
     $buttons = array_merge($buttons, $this->ss->get_template_vars('BUTTONS_HEADER'));
     $this->ss->assign('EDITBUTTONS', $buttons);
     $show_roles = !($this->bean->is_group == '1' || $this->bean->portal_only == '1');
     $this->ss->assign('SHOW_ROLES', $show_roles);
     //Mark whether or not the user is a group or portal user
     $this->ss->assign('IS_GROUP_OR_PORTAL', $this->bean->is_group == '1' || $this->bean->portal_only == '1' ? true : false);
     if ($show_roles) {
         ob_start();
         echo "<div>";
         require_once 'modules/ACLRoles/DetailUserRole.php';
         echo "</div></div>";
         $file = SugarAutoLoader::loadExtension("userpage");
         if ($file) {
             include $file;
         }
         $role_html = ob_get_contents();
         ob_end_clean();
         $this->ss->assign('ROLE_HTML', $role_html);
     }
     // Tell the template to render the javascript that requests new metadata
     // after a user preference change
     $this->ss->assign('refreshMetadata', !empty($_REQUEST['refreshMetadata']));
 }