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

Contents of /contributions/modules/person/person.module

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


Revision 1.2 - (show annotations) (download) (as text)
Fri Apr 27 14:45:31 2007 UTC (2 years, 7 months ago) by claudiucristea
Branch: MAIN
CVS Tags: DRUPAL-5--1-0, HEAD
Changes since 1.1: +4 -3 lines
File MIME type: text/x-php
* LICENSE.txt added
* Small changes
1 <?php
2 /* $Id: person.module,v 1.1 2007/04/27 13:32:32 claudiucristea Exp $ */
3
4 /**
5 * Display help and module information
6 * @param section which section of the site we're displaying help
7 * @return help text for section
8 */
9 function person_help($section = '') {
10
11 $output = '';
12
13 switch ($section) {
14 case "admin/help#person":
15 $output = '<p>'. t("This module allows you to create and administer nodes of type 'person'. This type of node holds data that describe a person like: first and last name, gender, personal data, career infos, etc."). '</p>';
16 $output .= '<p>'. t("Person node will create a new linked node for each new user. In case of user deletion the related node will be deleted as well. This type of Person nodes can be deleted only if the related user is deleted."). '</p>';
17 $output .= '<p>'. t("Standalone Person nodes can also be created. These nodes are not linked to Drupal users and can be deleted as any other node types."). '</p>';
18 break;
19 }
20
21 return $output;
22 } // function person_help
23
24 /**
25 * Valid permissions for this module
26 * @return array An array of valid permissions for the person module
27 */
28 function person_perm() {
29 return array('create person nodes', 'edit person nodes', 'delete person nodes', 'edit own person node');
30 } // function person_perm()
31
32 /**
33 * Module configuration function
34 * @return array An array with system setting form
35 */
36 function person_admin() {
37 $js = <<<EOS
38 $(document).ready(
39 function () {
40 $('input#edit-person-autodelete').change(
41 function() {
42 var checked = $('input#edit-person-autodelete').attr('checked');
43 if (!checked) {
44 $('input#edit-person-autodelete-force').attr('checked', false);
45 }
46 $('input#edit-person-autodelete-force').attr('disabled', !checked);
47 }
48 );
49 }
50 );
51 EOS;
52
53 drupal_add_js(
54 $js,
55 'inline'
56 );
57
58 $person_autodelete = variable_get('person_autodelete', TRUE);
59 $form['person_autocreate'] = array(
60 '#type' => 'checkbox',
61 '#title' => t('Create a Person node when a new user is registered'),
62 '#default_value' => variable_get('person_autocreate', TRUE),
63 '#description' => t("Tell if a new Person node must be created when a new user is created on the system.")
64 );
65 $form['person_autodelete'] = array(
66 '#type' => 'checkbox',
67 '#title' => t('Delete the Person node when the related user is deleted'),
68 '#default_value' => $person_autodelete,
69 '#description' => t("Tell if we must delete the Person node object when the related user is deleted."),
70 );
71 $form['person_autodelete_force'] = array(
72 '#type' => 'checkbox',
73 '#title' => t('Prevent direct deleting of linked nodes'),
74 '#default_value' => variable_get('person_autodelete_force', TRUE),
75 '#description' => t("Do not allow direct deletion of Person nodes that are linked to users. If checked the Person node could be deleted only by deleting the related user."),
76 '#disabled' => !$person_autodelete,
77 );
78 return system_settings_form($form);
79 } // function person_admin()
80
81 /**
82 * Menu items provided by module
83 * @return array An array of menu items
84 */
85 function person_menu() {
86
87 $items = array();
88
89 $items[] = array(
90 'path' => 'admin/settings/person',
91 'title' => t('Person node settings'),
92 'description' => t('Fine tune and setup the behavior of Person node module'),
93 'callback' => 'drupal_get_form',
94 'callback arguments' => 'person_admin',
95 'access' => user_access('access administration pages'),
96 'type' => MENU_NORMAL_ITEM,
97 );
98
99 return $items;
100 } // function person_menu()
101
102 ?>

  ViewVC Help
Powered by ViewVC 1.1.2