<?php
/* $Id: rolesignup.module,v 1.2.4.1 2007/01/20 21:49:48 sym Exp $ */
/********************************************************************
* Drupal Hooks
********************************************************************/
/**
* Implementation of module_enable()
*/
function rolesignup_enable() {
}
/**
* Implementation of module_disable()
*/
function rolesignup_disable() {
}
/**
* Implementation of hook_menu()
*/
function rolesignup_menu() {
'user/register/role/%' =>
array(
'page callback' => 'role_register_page',
'page arguments' =>
array(3),
'title' =>
t('Register'),
)
);
}
/**
* Implementation of hook_perm()
*/
function rolesignup_perm() {
return array('register for role');
}
/**
* Implementation of hook_form_alter()
*/
//function rolesignup_form_alter(&$form, $form_state, $form_id) {
// if ($form_id == "user_register") {
// global $user;
// if (!user_access('administer users') && !$_SESSION['role']) {
// drupal_goto('user/register/role', drupal_get_destination());
// } else {
// $form['role'] = array(
// '#type' => 'value',
// '#value' => $_SESSION['role'],
// );
// }
// $form['rolelink'] = array(
// '#value' => theme('select_role'),
// '#weight' => -11,
// );
// }
//}
function role_register_page($string = NULL) {
}
/**
* Implementation of hook_user()
*/
function rolesignup_user($op, &$edit, &$account, $category = NULL) {
switch ($op) {
case 'insert':
db_query('INSERT INTO {users_roles} (uid, rid) VALUES (%d, %d)',
$account->
uid,
$_SESSION['role']);
}
break;
case 'register':
if(!$category || $category == "account") {
if (!$_SESSION['role']) {
}
$rolename = $roles[$_SESSION['role']];
$form["#prefix"] =
"<p class='messages role_select'>You are registering for the '".
ucwords(strtolower($rolename)).
"' Role.<br/></p>";
"#type" => "submit"
,
"#submit" =>
array("rolesignup_goto_role_selection")
,"#value" => "Change Role"
);
return $form;
}
break;
}
}
function rolesignup_goto_role_selection($form, &$form_state) {
$url = 'user/register/role/'.$_SESSION['role'];
unset($_SESSION['role']);
}
function rolelist_form($form_state = NULL, $roles, $string) {
$rid = $string;
} else {
$rid = $rids[0];
}
"#type" => "select"
,"#options" => $roles
,"#default_value" => $rid
,"#description" => "roles define the behaviour of your account."
,"#required" => TRUE
);
"#type" => "submit"
,"#value" => "Next"
);
return $form;
}
function rolelist_form_submit($form, &$form_state) {
$_SESSION['role'] = $form_state["values"]["role"];
}