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);
     }
 }
Example #2
0
    $user_type_label = $mod_strings['LBL_ADMIN_USER'];
    $usertype = 'Administrator';
}
if (!empty($focus->is_group) && $focus->is_group == 1) {
    $user_type_label = $mod_strings['LBL_GROUP_USER'];
    $usertype = 'GroupUser';
}
$xtpl->assign("USER_TYPE", $usertype);
$xtpl->assign("USER_TYPE_LABEL", $user_type_label);
// adding custom fields:
require_once 'modules/DynamicFields/templates/Files/DetailView.php';
$buttons = "<div id='pwd_sent' class='error'>";
if (isset($_REQUEST['pwd_set']) && $_REQUEST['pwd_set'] != 0) {
    if ($_REQUEST['pwd_set'] == '4') {
        require_once 'modules/Users/password_utils.php';
        $buttons .= canSendPassword();
    } else {
        $buttons .= $mod_strings['LBL_NEW_USER_PASSWORD_' . $_REQUEST['pwd_set']];
    }
} else {
    //IF FOCUS USER IS LOCKOUT
    if ($focus->getPreference('lockout') == '1') {
        $buttons .= $mod_strings['ERR_USER_IS_LOCKED_OUT'];
    } else {
        $buttons .= "<br>";
    }
}
$buttons .= "</div></td><tr/><tr><td>";
if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && !empty($sugar_config['default_user_name']) && $sugar_config['default_user_name'] == $focus->user_name && isset($sugar_config['lock_default_user_name']) && $sugar_config['lock_default_user_name']) {
    $buttons .= "<input title='" . $app_strings['LBL_EDIT_BUTTON_TITLE'] . "' accessKey='" . $app_strings['LBL_EDIT_BUTTON_KEY'] . "' class='button' onclick=\"this.form.return_module.value='Users'; this.form.return_action.value='DetailView'; this.form.return_id.value='{$focus->id}'; this.form.action.value='EditView'\" type='submit' name='Edit' value='  " . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "  '>  ";
} elseif (is_admin($current_user) || is_admin_for_module($GLOBALS['current_user'], 'Users') && !$focus->is_admin || $_REQUEST['record'] == $current_user->id) {
Example #3
0
if (!empty($focus->is_group) && $focus->is_group == 1) {
    $user_type_label = $mod_strings['LBL_GROUP_USER'];
    $usertype = 'GroupUser';
    $sugar_smarty->assign('IS_GROUP_OR_PORTAL', '1');
}
$sugar_smarty->assign("USER_TYPE", $usertype);
$sugar_smarty->assign("USER_TYPE_LABEL", $user_type_label);
// adding custom fields:
$xtpl = $sugar_smarty;
require_once 'modules/DynamicFields/templates/Files/DetailView.php';
$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 .= $mod_strings['LBL_NEW_USER_PASSWORD_' . $_REQUEST['pwd_set']];
        $msgGood = true;
    }
} else {
    //IF FOCUS USER IS LOCKOUT
    if ($focus->getPreference('lockout') == '1') {
        $errors .= $mod_strings['ERR_USER_IS_LOCKED_OUT'];
    }
}
$sugar_smarty->assign("ERRORS", $errors);
$sugar_smarty->assign("ERROR_MESSAGE", $msgGood ? $mod_strings['LBL_PASSWORD_SENT'] : $mod_strings['LBL_CANNOT_SEND_PASSWORD']);
$buttons = "";
if ((is_admin($current_user) || $_REQUEST['record'] == $current_user->id) && !empty($sugar_config['default_user_name']) && $sugar_config['default_user_name'] == $focus->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='{$focus->id}'; this.form.action.value='EditView'\" type='submit' name='Edit' value='" . $app_strings['LBL_EDIT_BUTTON_LABEL'] . "'>  ";
 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']));
 }