Esempio n. 1
0
<?php

// This controller handles most interactions with the DIY
$diy_action = $_PORTAL['activity'];
$diy_id = $_PORTAL['action'];
// prefer to use a uuid if one is specified and the project settings desire it
if ($portal_config['diy_use_uuid'] == 'yes') {
    $uuid = portal_lookup_diy_uuid($diy_id);
    if ($uuid != '') {
        $diy_id = $uuid;
    }
}
$student_id = @$_PORTAL['params']['student'];
// These actions require logging into the DIY first, so we'll do that
if (@$_SESSION['is_logged_in'] == 'yes') {
    portal_setup_diy_session();
    //$member_id = @$_SESSION['diy_member_id'];
    //if (!$member_id) {
    $member_id = portal_get_diy_member_id($_SESSION['portal']['member_id']);
    //trigger_error('SESSION: ' . $_SESSION['portal']['member_id'] . '; Lookup: ' . $member_id);
    //trigger_error($_MYSTERY['rails_dbh']->last_query);
    if ($member_id == '') {
        $member_id = 1;
    }
    //}
} else {
    // Use the anonymous member
    $member_id = 1;
}
// some of the actions require an interface, so we'll set it up just in case
$interface_id = @$_SESSION['portal']['member_interface'];
Esempio n. 2
0
function portal_process_member_registration($request)
{
    // this function will register a member in the portal
    global $_PORTAL;
    // look for an email address - if not specified, student or old school teacher, generate a unique one
    if (trim(@$request['email']) == '') {
        $request['email'] = 'no-email-' . uniqid(md5(rand()), true);
    }
    if ($request['first_name'] == '') {
        $_PORTAL['errors'][] = 'You must specify a First Name.';
    }
    if ($request['last_name'] == '') {
        $_PORTAL['errors'][] = 'You must specify a First Name.';
    }
    if ($request['password'] == '') {
        $_PORTAL['errors'][] = 'You must specify a Password.';
    }
    if (strlen($request['password']) < 4 || strlen($request['password']) > 40) {
        $_PORTAL['errors'][] = 'Your password must be between 4 and 40 characters long.';
    }
    if (count($_PORTAL['errors']) > 0) {
        return 0;
    }
    // Check to see if this member is already in our system. If so, bail out.
    $query = 'SELECT member_id FROM portal_members WHERE member_email = ?';
    $params = array(@$request['email']);
    $results = mystery_select_query($query, $params, 'portal_dbh');
    if (count($results) > 0) {
        $_PORTAL['errors'][] = 'A person has already registered in the system with that email address. Please try signing in instead.  If you don\'t know your password, please contact <a href="mailto:webmaster@concord.org">webmaster@concord.org</a>.';
        return 0;
    } else {
        // get a unique username for this user
        $request['username'] = portal_get_unique_username($request['first_name'], $request['last_name'], $request['email']);
        $_REQUEST['username'] = $request['username'];
        // allows us to display it to the user
        $fixed_username = strtolower($request['username']);
        $fixed_password_ue = strtolower($request['password']);
        $fixed_password = md5($fixed_password_ue);
        // maybe we need to add the portal record first so we can set up the username
        $cc_member_id = portal_get_cc_member_id($request['first_name'], $request['last_name'], $request['email'], $request['username'], $request['password']);
        // create the member in the ITSI DIY by creating a session
        portal_setup_diy_session($fixed_username, $fixed_password_ue);
        $diy_member_id = portal_get_diy_member_id_from_db($fixed_username);
        portal_update_diy_member_info($diy_member_id, $request['first_name'], $request['last_name'], $request['email'], $request['member_interface']);
        $sds_member_id = portal_get_sds_member_id_from_db($diy_member_id);
        // add the member to the portal database
        $data = array();
        $data['member_username'] = $fixed_username;
        $data['member_password'] = $fixed_password;
        $data['member_password_ue'] = $request['password'];
        $data['member_first_name'] = $request['first_name'];
        $data['member_last_name'] = $request['last_name'];
        $data['member_email'] = $request['email'];
        $data['member_type'] = $request['type'];
        $data['member_school'] = $request['school_id'];
        $data['member_grade'] = @$request['grade_level'];
        $data['cc_member_id'] = $cc_member_id;
        $data['diy_member_id'] = $diy_member_id;
        $data['sds_member_id'] = $sds_member_id;
        $data['member_interface'] = $request['member_interface'];
        $data['member_source'] = @$request['source'];
        $data['creation_date'] = date('Y-m-d H:i:s');
        $member_id = mystery_insert_query('portal_members', $data, 'member_id', 'portal_dbh');
        if ($member_id < 1) {
            $_PORTAL['errors'][] = 'Could not create new member.  Please contact <a href="mailto:webmaster@concord.org">webmaster@concord.org</a>';
        }
    }
    return $member_id;
}