/[drupal]/contributions/modules/registration_role/registration_role.module
ViewVC logotype

Contents of /contributions/modules/registration_role/registration_role.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Sat Mar 14 15:56:08 2009 UTC (8 months, 1 week ago) by agaric
Branch: MAIN
CVS Tags: HEAD
Branch point for: DRUPAL-6--1
Changes since 1.2: +21 -17 lines
File MIME type: text/x-php
Syncing HEAD with the latest code from Drupal 6 port contributed by dwees in issue http://drupal.org/node/343559
1 <?php
2 /* $Id: registration_role.module,v 1.2.2.2 2007/08/03 11:22:10 agaric Exp $ */
3
4 // untested Drupal 5 version
5 // auto-assign role at registration
6 // Registration Role
7
8 /* based on
9 http://drupal.org/node/28379#comment-132430
10 code snippet by Pauly Jura
11 This module actually does less than the snippet
12 */
13
14 /**
15 * Implementation of hook_help().
16 *
17 */
18 function registration_role_help($section='') {
19 $output = '';
20 switch ($section) {
21 case "admin/modules#description":
22 $output = t("Auto-assign role at registration.");
23 break;
24 }
25 return $output;
26 }
27
28 /**
29 * Implementation of hook_menu().
30 *
31 * This is the Drupal 5 way but it should work for 4.7 settings
32 */
33 function registration_role_menu() {
34 $items = array();
35
36 $items['admin/user/registration_role'] = array(
37 'title' => t('Registration role'),
38 'description' => t('Assign users an extra role at signup.'),
39 'page callback' => 'drupal_get_form',
40 'page arguments' => array('registration_role_admin_settings'),
41 'access arguments' => array('administer users'),
42 );
43
44 return $items;
45 }
46
47 /**
48 * Define the settings form.
49 */
50 function registration_role_admin_settings() {
51 $roles = user_roles(TRUE);
52 unset($roles['2']);
53 $form['registration_role_roles'] = array(
54 '#type' => 'radios',
55 '#title' => t('Select role to automatically assign to new users'),
56 '#options' => $roles,
57 '#default_value' => variable_get('registration_role_roles', ''),
58 '#description' => t('The selected role will be assigned to new registrants from now on. Be sure this role does not have any privileges you fear giving out without reviewing who receives it.'),
59 );
60 // $form['array_filter'] = array('#type' => 'hidden');
61 // Drupal 5, mysterious, needed for multiple check box values using settings hook
62 return system_settings_form($form);
63 }
64
65 /**
66 * Implementation of hook_user().
67 *
68 * Catch every registration and insert role
69 */
70 function registration_role_user($op, &$edit, &$user, $category=null) {
71 if ($op == "insert" && $rid = variable_get('registration_role_roles', '')){
72 // get the role in question
73 $roles = user_roles(TRUE);
74
75 // add it to the user
76 $edit['roles'][$rid] = $roles[$rid];
77 }
78 }

  ViewVC Help
Powered by ViewVC 1.1.2