Пример #1
0
$display = DISP_PROFILE_FORM;
/*=====================================================================
CONTROLER Section
=====================================================================*/
$extraInfoDefList = get_userInfoExtraDefinitionList();
$userId = claro_get_current_user_id();
$userData = user_get_properties($userId);
$acceptedCmdList = array('exCCstatus', 'exRevoquation', 'reqCCstatus', 'reqRevoquation', 'editExtraInfo', 'exMoreInfo');
if (isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $acceptedCmdList)) {
    $cmd = $_REQUEST['cmd'];
} else {
    $cmd = '';
}
if (isset($_REQUEST['applyChange'])) {
    // Get params form the form
    $userData = user_initialise();
    if (get_conf('allow_profile_picture', true)) {
        // Handle user picture
        $pictureUpdated = user_handle_profile_picture($userData);
        if ($pictureUpdated['success']) {
            $userData['picture'] = $pictureUpdated['pictureName'];
            foreach ($pictureUpdated['messages'] as $success) {
                $dialogBox->success($success);
            }
        } else {
            foreach ($pictureUpdated['messages'] as $error) {
                $dialogBox->error($error);
            }
        }
    }
    // Manage password
Пример #2
0
/**
 * Display form to edit or add user to the platform.
 *
 * @param $userId int
 */
function user_html_form($userId = null)
{
    // If the user exists (given user id)
    if (!empty($userId)) {
        // Get user's general informations
        $userData = user_get_properties($userId);
        // Get user's skype account
        $userData['skype'] = get_user_property($userId, 'skype');
        // Get user's picture
        $picturePath = user_get_picture_path($userData);
        if ($picturePath && file_exists($picturePath)) {
            $pictureUrl = user_get_picture_url($userData);
        } else {
            $pictureUrl = '';
        }
        // Get current language
        $currentLanguage = !empty($userData['language']) ? $userData['language'] : language::current_language();
        // A few javascript
        $htmlHeadXtra[] = '<script type="text/javascript">
            function confirmation (name)
            {
                if (confirm("' . clean_str_for_javascript(get_lang('Are you sure to delete')) . '"+ name + "?"))
                {return true;}
                else
                {return false;}
            }
            
            $(document).ready(function(){
                $("#delete").click(function(){
                    return confirmation("' . $userData['firstname'] . " " . $userData['lastname'] . '");
                }).attr("href","adminuserdeleted.php?uidToEdit=' . $userId . '&cmd=exDelete");
            });
        </script>';
    } else {
        // Initialize user's data
        $userData = user_initialise();
        // No user's picture
        $pictureUrl = '';
        // Prefered language
        $currentLanguage = language::current_language();
    }
    // Editable fields
    if (empty($userId) || claro_is_platform_admin()) {
        $editableFields = array('name', 'official_code', 'login', 'password', 'email', 'phone', 'language', 'picture', 'skype');
        if (claro_is_platform_admin()) {
            $editableFields[] = 'authSource';
        }
    } else {
        $editableFields = AuthProfileManager::getUserAuthProfile($userId)->getEditableProfileFields();
        // get_conf('profile_editable');
        // pushClaroMessage(var_export($editableFields,true), 'debug');
    }
    if (!empty($_SERVER['HTTP_REFERER'])) {
        $cancelUrl = $_SERVER['HTTP_REFERER'];
    } else {
        $cancelUrl = $_SERVER['PHP_SELF'];
    }
    // Hack to prevent autocompletion of password fields from browser
    $htmlHeadXtra[] = '<script type="text/javascript">
        $(document).ready(
            function() {
                $("#password").val("");
            }
        );
    </script>';
    $template = new CoreTemplate('user_form.tpl.php');
    $template->assign('formAction', $_SERVER['PHP_SELF']);
    $template->assign('relayContext', claro_form_relay_context());
    $template->assign('cancelUrl', claro_htmlspecialchars(Url::Contextualize($cancelUrl)));
    $template->assign('editableFields', $editableFields);
    $template->assign('data', $userData);
    $template->assign('pictureUrl', $pictureUrl);
    $template->assign('currentLanguage', $currentLanguage);
    $template->assign('languages', get_language_to_display_list());
    return $template->render();
}