Commit 9d6c6d68 authored by Nancy Wichmann's avatar Nancy Wichmann
Browse files

Added feature to show real name in node displays.

parent a2314370
; $Id$
The RealName module allows the admin to choose fields from teh user profile
The RealName module allows the admin to choose fields from the user profile
that will be used to add a "realname" element (method) to a user object.
Hook_user is used to automatically add this to any user object that is loaded.
......
......@@ -26,4 +26,5 @@ function realname_uninstall() {
variable_del('realname_sep');
variable_del('realname_fields');
variable_del('realname_theme');
variable_del('realname_nodeapi');
}
......@@ -14,6 +14,19 @@
//* Drupal Hooks
//********************************************************************/
/**
* Implementation of hook_help().
*/
function realname_help($path, $args = null) {
switch ($path) {
case 'admin/user/realname':
return t('This page displays the status of and settings for the RealName module.');
case 'admin/help#realname':
return t('This simple module adds a "realname" element (method) to a user object when that object is loaded.');
}
}
/**
* Implementation of hook_menu().
*/
......@@ -50,19 +63,31 @@ function realname_user($op, &$edit, &$account, $category = null) {
}
/**
* Implementation of hook_help().
* Implementation of hook_nodeapi().
*/
function realname_help($path, $args = null) {
switch ($path) {
case 'admin/user/realname':
return t('This page displays the status of and settings for the RealName module.');
case 'admin/help#realname':
return t('This simple module adds a "realname" element (method) to a user object when that object is loaded.');
function realname_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if (!variable_get('realname_nodeapi', false)) {
return;
}
switch ($op) {
case 'load':
// Node is being loaded.
// Save the username that is already there.
$node->realname_save = $node->name;
$account = user_load(array('uid' => $node->uid));
$node->name = realname_make_name($account);
break;
case 'prepare':
// Node is about to be edited.
// Reset the username or save will fail.
if (isset($node->realname_save)) {
$node->name = $node->realname_save;
}
break;
}
}
//********************************************************************
//* Module Functions
//********************************************************************
......@@ -201,6 +226,13 @@ function realname_admin_settings() {
'#default_value' => variable_get('realname_theme', false),
);
$form['realname_nodeapi'] = array(
'#type' => 'checkbox',
'#title' => '<strong>'. t('Show realname in nodes') .'</strong>',
'#description' => t('If this option is selected, the "Real name" will be used on node displays.'),
'#default_value' => variable_get('realname_nodeapi', false),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
......@@ -233,6 +265,7 @@ function realname_admin_settings_submit($form_id, $form_values) {
variable_set('realname_fields', $realname_fields);
variable_set('realname_sep', $form_values['realname_sep']);
variable_set('realname_theme', $form_values['realname_theme']);
variable_set('realname_nodeapi', $form_values['realname_nodeapi']);
drupal_set_message(t('Configuration has been updated.'), 'status');
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment