| 1 |
<?php
|
| 2 |
// $Id: mass_url.module,v 1.4 2004/11/24 10:20:18 wazdog Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* Implementation of hook_help().
|
| 6 |
*/
|
| 7 |
|
| 8 |
function mass_url_help($section) {
|
| 9 |
switch ($section) {
|
| 10 |
case 'admin/modules#description':
|
| 11 |
return t('Enables automatic URL aliases for usernames.');
|
| 12 |
}
|
| 13 |
}
|
| 14 |
|
| 15 |
/**
|
| 16 |
* Implementation of hook_menu().
|
| 17 |
*/
|
| 18 |
|
| 19 |
function mass_url_menu($may_cache) {
|
| 20 |
$items = array();
|
| 21 |
|
| 22 |
if (arg(0) == ('user' || 'blog') && !is_numeric(arg(1))) {
|
| 23 |
$url_isname = arg(1);
|
| 24 |
}
|
| 25 |
|
| 26 |
// if ($may_cache) {
|
| 27 |
$items[] = array('path' => 'user/'. $url_isname,
|
| 28 |
'title' => t('user'),
|
| 29 |
'callback' => '_mass_url_user_page',
|
| 30 |
'access' => TRUE,
|
| 31 |
'type' => MENU_CALLBACK);
|
| 32 |
|
| 33 |
$items[] = array('path' => 'blog/'. $url_isname,
|
| 34 |
'title' => t('user blog'),
|
| 35 |
'callback' => '_mass_url_user_page',
|
| 36 |
'access' => TRUE,
|
| 37 |
'type' => MENU_CALLBACK);
|
| 38 |
// }
|
| 39 |
|
| 40 |
return $items;
|
| 41 |
}
|
| 42 |
|
| 43 |
/**
|
| 44 |
* Menu callback; displays user's account or blog page.
|
| 45 |
*/
|
| 46 |
|
| 47 |
function _mass_url_user_page() {
|
| 48 |
//global $user;
|
| 49 |
|
| 50 |
$page_type = urldecode(arg(0));
|
| 51 |
$url_username = urldecode(arg(1));
|
| 52 |
|
| 53 |
if ($url_username == ('login')) {
|
| 54 |
user_page();
|
| 55 |
return;
|
| 56 |
}
|
| 57 |
else if ($url_username == ('register')) {
|
| 58 |
user_page();
|
| 59 |
return;
|
| 60 |
}
|
| 61 |
else if ($url_username == ('password')) {
|
| 62 |
user_page();
|
| 63 |
return;
|
| 64 |
}
|
| 65 |
else if ($url_username == ('help')) {
|
| 66 |
user_help_page();
|
| 67 |
return;
|
| 68 |
}
|
| 69 |
else {
|
| 70 |
$result = db_query("SELECT * FROM {users} WHERE name = '%s'", $url_username);
|
| 71 |
}
|
| 72 |
|
| 73 |
if (db_num_rows($result) == 1) {
|
| 74 |
$user_rec = db_fetch_object($result);
|
| 75 |
$url_id = $user_rec->uid;
|
| 76 |
|
| 77 |
if ($page_type == 'user') {
|
| 78 |
print user_view($url_id);
|
| 79 |
}
|
| 80 |
else if ($page_type == 'blog') {
|
| 81 |
blog_page_user($url_id);
|
| 82 |
}
|
| 83 |
}
|
| 84 |
/* else if (module_exist('search')) {
|
| 85 |
// Still no matches, so return a full-text search.
|
| 86 |
search_view($url_name);
|
| 87 |
}*/
|
| 88 |
else {
|
| 89 |
drupal_not_found();
|
| 90 |
//$output .= 'No user exists with that name.';
|
| 91 |
//drupal_set_title(t('Error'));
|
| 92 |
//print theme('page', $output);
|
| 93 |
}
|
| 94 |
}
|
| 95 |
|
| 96 |
?>
|