예제 #1
0
function pathos_users_create($formvalues)
{
    // Update the user object (at this point we are not dealing with profile
    // extensions, just the basic object).
    $u = pathos_users_update($formvalues, null);
    // The username is not included in the update method, so we define it here.
    $u->username = $formvalues['username'];
    // Make an md5 checksum hash of the password for storage.  That way no
    // one can know a password without being told.
    $u->password = md5($formvalues['pass1']);
    // Set the acting admin flag if we need to.
    global $user;
    $u->is_acting_admin = isset($formvalues['is_acting_admin']) && $user->is_admin == 1 ? 1 : 0;
    // Insert the user object into the database, and save the ID.
    global $db;
    $u->id = $db->insertObject($u, 'user');
    // Calculate Group Memeberships for newly created users.  Any groups that
    // are marked as 'inclusive' automatically pick up new users.  This is the part
    // of the code that goes out, finds those groups, and makes the new user a member
    // of them.
    $memb = null;
    $memb->member_id = $u->id;
    // Also need to process the groupcodes, for promotional signup
    $code_where = '';
    if (isset($formvalues['groupcode']) && $formvalues['groupcode'] != '') {
        $code_where = " OR code='" . $formvalues['groupcode'] . "'";
    }
    foreach ($db->selectObjects('group', 'inclusive=1' . $code_where) as $g) {
        $memb->group_id = $g->id;
        $db->insertObject($memb, 'groupmembership');
    }
    // Return the newly created user object (complete with ID) to the caller.
    return $u;
}
예제 #2
0
# without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU
# General Public License along with Exponent; if
# not, write to:
#
# Free Software Foundation, Inc.,
# 59 Temple Place,
# Suite 330,
# Boston, MA 02111-1307  USA
#
# $Id: saveprofile.php,v 1.7 2005/04/18 15:24:22 filetreefrog Exp $
##################################################
if (!defined('PATHOS')) {
    exit('');
}
if ($user) {
    if (!defined('SYS_USERS')) {
        require_once 'subsystems/users.php';
    }
    $user = pathos_users_update($_POST, $user);
    $user = pathos_users_saveUser($user);
    $user = pathos_users_saveProfileExtensions($_POST, $user, false);
    $_SESSION[SYS_SESSION_KEY]['user'] = $user;
    pathos_flow_redirect();
} else {
    echo SITE_403_HTML;
}
// Part of the User Management category
if (!defined('PATHOS')) {
    exit('');
}
if (pathos_permissions_check('user_management', pathos_core_makeLocation('administrationmodule'))) {
    #if ($user && $user->is_acting_admin == 1) {
    if (!defined('SYS_USERS')) {
        require_once BASE . 'subsystems/users.php';
    }
    if (!defined('SYS_SECURITY')) {
        require_once BASE . 'subsystems/security.php';
    }
    if (isset($_POST['id'])) {
        // Existing user profile edit
        $u = pathos_users_getUserById($_POST['id']);
        $u = pathos_users_update($_POST, $u);
        pathos_users_saveUser($u);
        pathos_flow_redirect();
    } else {
        pathos_lang_loadDictionary('modules', 'loginmodule');
        if (pathos_users_getUserByName($_POST['username']) != null) {
            $post = $_POST;
            unset($post['username']);
            $post['_formError'] = TR_LOGINMODULE_USERNAMETAKEN;
            pathos_sessions_set('last_POST', $post);
            header('Location: ' . $_SERVER['HTTP_REFERER']);
        } else {
            if ($_POST['pass1'] != $_POST['pass2']) {
                $post = $_POST;
                unset($post['pass1']);
                unset($post['pass2']);