Example #1
0
/**
 * Convert a regular lastname into the pseudo equivelant for student data privacy purpose
 *
 * @param string $email The users email address
 * @return string A pseudo lastname address
 */
function turnitintool_pseudolastname($email)
{
    global $CFG;
    $user = turnitintool_get_record('user', 'email', $email);
    $user_info = turnitintool_get_record('user_info_data', 'userid', $user->id, 'fieldid', $CFG->turnitin_pseudolastname);
    if ((!isset($user_info->data) or empty($user_info->data)) and $CFG->turnitin_pseudolastname != 0 and $CFG->turnitin_lastnamegen == 1) {
        $uniqueid = strtoupper(strrev(uniqid()));
        $userinfo = new stdClass();
        $userinfo->userid = $user->id;
        $userinfo->fieldid = $CFG->turnitin_pseudolastname;
        $userinfo->data = $uniqueid;
        if (isset($user_info->data)) {
            $userinfo->id = $user_info->id;
            turnitintool_update_record('user_info_data', $userinfo);
        } else {
            turnitintool_insert_record('user_info_data', $userinfo);
        }
    } else {
        if ($CFG->turnitin_pseudolastname != 0) {
            $uniqueid = isset($user_info->data) ? $user_info->data : 'Unset';
        } else {
            $uniqueid = get_string('user');
        }
    }
    return $uniqueid;
}
            $result = $tii->createUser($post, get_string('connecttesting', 'turnitintool'));
            $rcode = $tii->getRcode();
            $rmessage = $tii->getRmessage();
            $tiiuid = $tii->getUserID();
            $tii->endSession();
            turnitintool_header(NULL, NULL, $_SERVER["REQUEST_URI"], get_string("modulenameplural", "turnitintool"), $SITE->fullname);
            turnitintool_box_start('generalbox boxwidthwide boxaligncenter', 'general');
            if ($rcode >= API_ERROR_START or empty($rcode)) {
                if (empty($rmessage)) {
                    $rmessage = get_string('connecttestcommerror', 'turnitintool');
                }
                turnitintool_print_error('connecttesterror', 'turnitintool', $CFG->wwwroot . '/admin/module.php?module=turnitintool', $rmessage, __FILE__, __LINE__);
            } else {
                $data = new object();
                $data->userid = $USER->id;
                $data->turnitin_uid = $tiiuid;
                $data->turnitin_utp = $tii->utp;
                if ($tiiuser = turnitintool_get_record('turnitintool_users', 'userid', $USER->id)) {
                    $data->id = $tiiuser->id;
                    turnitintool_update_record('turnitintool_users', $data);
                } else {
                    turnitintool_insert_record('turnitintool_users', $data);
                }
                print_string('connecttestsuccess', 'turnitintool');
            }
            turnitintool_box_end();
            turnitintool_footer();
        }
    }
}
/* ?> */