exit('');
}
if (pathos_permissions_check('user_management', pathos_core_makeLocation('administrationmodule'))) {
    if (!defined('SYS_USERS')) {
        require_once BASE . 'subsystems/users.php';
    }
    if (!defined('SYS_FORMS')) {
        require_once BASE . 'subsystems/forms.php';
    }
    pathos_forms_initialize();
    $u = pathos_users_getUserById($_GET['id']);
    if ($u == null) {
        $u->is_admin = 0;
        $u->is_acting_admin = 0;
    }
    $u = pathos_users_getFullProfile($u);
    $form = pathos_users_form($u);
    $form->meta('module', 'administrationmodule');
    $form->meta('action', 'umgr_saveuser');
    if ($user->is_admin == 1 && $u->is_admin == 0) {
        // Super user editting a 'lesser' user.
        pathos_lang_loadDictionary('modules', 'administrationmodule');
        $form->registerBefore('submit', 'is_acting_admin', TR_ADMINISTRATIONMODULE_ISADMIN, new checkboxcontrol($u->is_acting_admin, true));
    }
    $template = new template('administrationmodule', '_umgr_editprofile', $loc);
    $template->assign('form_html', $form->toHTML());
    $template->assign('is_edit', isset($u->id) ? 1 : 0);
    $template->output();
} else {
    echo SITE_403_HTML;
}
Exemple #2
0
function pathos_users_form($user = null)
{
    pathos_lang_loadDictionary('subsystems', 'users');
    pathos_lang_loadDictionary('standard', 'core');
    // FIXME: Forms Subsystem may not be initialized at this point.
    // FIXME:
    $form = new form();
    if (isset($user->id)) {
        // Store the user object's id, if it exists.
        // This is now an edit form.
        $form->meta('id', $user->id);
    } else {
        // If the user object has no id, then this is a new user form.
        // Populate the empty user object with default attributes,
        // so that the calls to $form->register can confidently dereference
        // thes attributes.
        $user->firstname = '';
        $user->lastname = '';
        $user->email = '';
        $user->recv_html = 1;
        ##		$user->home_section = 0;
        // Username and Password can only be specified for a new user.  To change the password,
        // a different form is used (part of the loginmodule)
        $form->register('username', TR_USERSSUBSYSTEM_DESIREDUSERNAME, new textcontrol());
        $form->register('pass1', TR_USERSSUBSYSTEM_PASSWORD, new passwordcontrol());
        $form->register('pass2', TR_USERSSUBSYSTEM_CONFIRM, new passwordcontrol());
        $form->register(null, '', new htmlcontrol('<br />'));
        $form->register('groupcode', 'Signup Code', new textcontrol());
        $form->register(null, '', new htmlcontrol('<br />'));
    }
    // Register the basic user profile controls.
    $form->register('firstname', TR_USERSSUBSYSTEM_FIRSTNAME, new textcontrol($user->firstname));
    $form->register('lastname', TR_USERSSUBSYSTEM_LASTNAME, new textcontrol($user->lastname));
    $form->register(null, '', new htmlcontrol('<br />'));
    $form->register('email', TR_USERSSUBSYSTEM_EMAIL, new textcontrol($user->email));
    $form->register('recv_html', TR_USERSSUBSYSTEM_RECVHTML, new checkboxcontrol($user->recv_html, true));
    $form->register(null, '', new htmlcontrol('<br />'));
    ##	// Register the nav hierarhcy dropdown for home section.
    ##	$hier = navigationmodule::hierarchyDropDownControlArray();
    ##	$hier[0] = '&lt;None&gt;';
    ##	$form->register('home_section','Home Page',new dropdowncontrol($user->home_section,$hier));
    $form->register(null, '', new htmlcontrol('<br />'));
    // Pull in form data for all active profile extensions.
    // First, we have to clear delete extensions, so that we don't try to include
    // or use previously active extensions that have been disabled.
    pathos_users_clearDeletedExtensions();
    // Include all class files for active profile extensions.
    pathos_users_includeProfileExtensions();
    // Store the users full profile in a temporary object.
    $tmpu = pathos_users_getFullProfile($user);
    // Pull the database object in from the global scope.
    global $db;
    // Retrieve a list of the active profile extensions, and sort them by rank so that
    // the form controls get added to the form in order.
    $exts = $db->selectObjects('profileextension');
    if (!defined('SYS_SORTING')) {
        require_once BASE . 'subsystems/sorting.php';
    }
    usort($exts, 'pathos_sorting_byRankAscending');
    foreach ($exts as $ext) {
        // Modify the form object by passing it through each profile extension,
        // each of which may or may not register new controls.
        $form = call_user_func(array($ext->extension, 'modifyForm'), $form, $tmpu);
    }
    // Add the submit button and return the complete form object to the caller.
    $form->register('submit', '', new buttongroupcontrol(TR_CORE_SAVE, '', TR_CORE_CANCEL));
    return $form;
}