diff --git a/includes/conf.php b/includes/conf.php index 74bb1f0612315eb3a977f9132d85462f0f315c62..9014e7500e6e6b98ca12fed2401d02cf1332a156 100644 --- a/includes/conf.php +++ b/includes/conf.php @@ -21,22 +21,6 @@ # If required, update PHP's include path to include your PEAR directory: // ini_set("include_path", ".:/path/to/pear"); -# -# Themes: -# -$themes = array("UnConeD" => array( - "themes/unconed/unconed.theme", - "Internet explorer, Netscape, Opera"), - "Marvin" => array( - "themes/marvin/marvin.theme", - "Internet explorer, Netscape, Opera"), - "Stone Age" => array( - "themes/example/example.theme", - "Internet explorer, Netscape, Opera, Lynx"), - "Goofy" => array( - "themes/goofy/goofy.theme", - "Internet explorer, Netscape, Opera")); - # # Languages / translation / internationalization: # The first language listed in this associative array will diff --git a/includes/module.inc b/includes/module.inc index 8f53e85914ae87f2ecb071c15fec461777a9292c..92a4b26bf715071586320c94a3c8001b0d7de396 100644 --- a/includes/module.inc +++ b/includes/module.inc @@ -3,6 +3,10 @@ // initialize modules: function module_init() { + require_once("modules/user.module"); + require_once("modules/drupal.module"); + require_once("modules/system.module"); + require_once("modules/watchdog.module"); module_list(); } @@ -38,21 +42,13 @@ function module_list() { static $list; if (!$list) { - if ($handle = @opendir("modules")) { - $list = array(); - while ($file = readdir($handle)) { - if (".module" == substr($file, -7)) { - $filename = substr($file, 0, -7); - $list[$filename] = $filename; - include "modules/$filename.module"; - } - } - closedir($handle); - asort($list); - } - else { - $list = array(); + $list = array("drupal" => "drupal", "system" => "system", "user" => "user", "watchdog" => "watchdog"); + $result = db_query("SELECT name, filename FROM system WHERE type = 'module' AND status = '1' ORDER BY name"); + while ($module = db_fetch_object($result)) { + $list[$module->name] = $module->name; + @include_once "modules/$module->filename"; } + asort($list); } return $list; @@ -109,4 +105,4 @@ function module_rehash($name) { } } -?> +?> \ No newline at end of file diff --git a/includes/theme.inc b/includes/theme.inc index fa13e2236f5b2c36e02fa6541d08e22df9b41e37..40aa23d35288cc90e657f5784e05a5491feb4548 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -1,8 +1,21 @@ ". variable_get(site_name, "drupal") .""; $output .= ""; $output .= " "; - $output .= " "; + $output .= " "; } if ($node->body) { @@ -607,7 +607,7 @@ function book_admin_view_line($node, $depth = 0) { $output .= " "; $output .= " "; $output .= " "; - //TODO: get this link to work. Must pass $nid along so it is received by book_node_link() + //TODO: get this link to work. Must pass $nid along so it is received by book_node_link() //$output .= " "; $output .= " "; $output .= ""; @@ -635,7 +635,7 @@ function book_admin_view($nid, $depth = 0) { $output .= "

". check_output($node->title) ."

"; $output .= "
"; @@ -68,18 +81,35 @@ function footer() { } -function theme_init() { - global $user, $themes; +function theme_list() { + static $list; - if ($user->theme && file_exists($themes[$theme_name = $user->theme][0])) { - include_once $themes[$theme_name][0]; + if (!$list) { + $list = array(); + $result = db_query("SELECT * FROM system where type = 'theme' AND status = '1' ORDER BY name"); + while ($theme = db_fetch_object($result)) { + $list[$theme->name] = $theme; + } } - else { - include_once $themes[$theme_name = variable_get("theme_default", key($themes))][0]; + + return $list; +} + +function theme_init() { + global $user; + + $themes = theme_list(); + $name = $user->theme ? $user->theme : variable_get("theme_default", 0); + if (is_object($themes[$name])) { + include_once($themes[$name]->filename); + $theme_class = "Theme_$user->theme"; + @$obj =& new $theme_class; + return $obj; } - $theme_class = 'Theme_'. $theme_name; - return new $theme_class(); + watchdog("warning", "No valid themes enabled."); + @$obj =& new BaseTheme; + return $obj; } function theme_blocks($region, &$theme) { diff --git a/index.php b/index.php index 7c925a878269597db6d42ec89238a8c48bdb8a8f..b9c0a285f4526c900ee28f9e9d123e11541a7380 100644 --- a/index.php +++ b/index.php @@ -5,8 +5,14 @@ page_header(); -eval(variable_get("site_frontpage_extra", "") .";"); -module_invoke(variable_get("site_frontpage", "node"), "page"); +if (module_hook(variable_get("site_frontpage", "node"), "page")) { + eval(variable_get("site_frontpage_extra", "") .";"); + module_invoke(variable_get("site_frontpage", "node"), "page"); +} +else { + $theme->header(); + $theme->footer(); +} page_footer(); diff --git a/modules/blog.module b/modules/blog.module index 4036f154f71950f5b828d7248edbbe14520489b2..f2d59e67e62b9332d579b60dac125629ecd8a126 100644 --- a/modules/blog.module +++ b/modules/blog.module @@ -178,7 +178,7 @@ function blog_page_user($uid = 0, $date = 0, $all = 0) { $output .= "uid\" title=\"". t("Show recent blogs by this user") ."\">". t("show recent blogs") .""; } - $theme->box(sprintf(t("%s's blog"), $account->name), $output); + $theme->box(strtr(t("%u's blog"), array("%u" => $account->name)), $output); } function blog_page_last() { @@ -302,7 +302,7 @@ function blog_link($type, $node = 0, $main) { $links[] = "nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit this blog") .""; } else { - $links[] = "uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". sprintf(t("%s's blog"), $node->name) .""; + $links[] = "uid\" title=\"". strtr(t("Read %u's latest blog entries."), array("%u" => $node->name)) ."\">". strtr(t("%u's blog"), array("%u", $node->name)) .""; } } diff --git a/modules/blog/blog.module b/modules/blog/blog.module index 4036f154f71950f5b828d7248edbbe14520489b2..f2d59e67e62b9332d579b60dac125629ecd8a126 100644 --- a/modules/blog/blog.module +++ b/modules/blog/blog.module @@ -178,7 +178,7 @@ function blog_page_user($uid = 0, $date = 0, $all = 0) { $output .= "uid\" title=\"". t("Show recent blogs by this user") ."\">". t("show recent blogs") .""; } - $theme->box(sprintf(t("%s's blog"), $account->name), $output); + $theme->box(strtr(t("%u's blog"), array("%u" => $account->name)), $output); } function blog_page_last() { @@ -302,7 +302,7 @@ function blog_link($type, $node = 0, $main) { $links[] = "nid\" title=\"". t("Edit this blog entry.") ."\">". t("edit this blog") .""; } else { - $links[] = "uid\" title=\"". sprintf(t("Read %s's latest blog entries."), $node->name) ."\">". sprintf(t("%s's blog"), $node->name) .""; + $links[] = "uid\" title=\"". strtr(t("Read %u's latest blog entries."), array("%u" => $node->name)) ."\">". strtr(t("%u's blog"), array("%u", $node->name)) .""; } } diff --git a/modules/book.module b/modules/book.module index 759d5e3dd67392ec8bae7bfc1f988e60300a6a50..f23ba1d06d84490f22281d59377550791c85620b 100644 --- a/modules/book.module +++ b/modules/book.module @@ -390,7 +390,7 @@ function book_view($node, $main = 0) { $output .= "
$location

". check_output($node->title) ."". ($node->body ? "
". sprintf(t("Last updated by %s on %s"), format_name($node), format_date($node->created)) ." " : "") ."
". check_output($node->title) ."". ($node->body ? "
". strtr(t("Last updated by %u on %d"), array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") ."
nid\">". check_output($node->title) ."
$revisionnid\">". t("edit node") ."nid&op=Edit+book+outline\">". t("edit book outline") ."nid\">". t("delete node") ."
"; - //TODO: change colspan below to 3 after adding new link in book_admin_view_line() + //TODO: change colspan below to 3 after adding new link in book_admin_view_line() $output .= " "; $output .= book_admin_view_line($node); $output .= book_admin_view_book($nid); @@ -686,7 +686,7 @@ function book_admin() { */ $links = book_admin_links(); - + print "". implode(" · ", $links) ."
"; switch ($op) { @@ -712,7 +712,7 @@ function book_admin() { function book_help() { ?> - +

The Collaborative Book is a magnificient mechanism for organizing content authored by many users. You may use it to organize a Manual (e.g. Drupal Handbook), to maintain an FAQ, or to manage any outline-like content. Books can have @@ -792,6 +792,6 @@ function book_help() { diff --git a/modules/book/book.module b/modules/book/book.module index 759d5e3dd67392ec8bae7bfc1f988e60300a6a50..f23ba1d06d84490f22281d59377550791c85620b 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -390,7 +390,7 @@ function book_view($node, $main = 0) { $output .= "

"; $output .= " "; - $output .= " "; + $output .= " "; } if ($node->body) { @@ -607,7 +607,7 @@ function book_admin_view_line($node, $depth = 0) { $output .= " "; $output .= " "; $output .= " "; - //TODO: get this link to work. Must pass $nid along so it is received by book_node_link() + //TODO: get this link to work. Must pass $nid along so it is received by book_node_link() //$output .= " "; $output .= " "; $output .= ""; @@ -635,7 +635,7 @@ function book_admin_view($nid, $depth = 0) { $output .= "

". check_output($node->title) ."

"; $output .= "
titlerevoperations
$location

". check_output($node->title) ."". ($node->body ? "
". sprintf(t("Last updated by %s on %s"), format_name($node), format_date($node->created)) ." " : "") ."
". check_output($node->title) ."". ($node->body ? "
". strtr(t("Last updated by %u on %d"), array("%u" => format_name($node), "%d" => format_date($node->created))) ." " : "") ."
nid\">". check_output($node->title) ."
$revisionnid\">". t("edit node") ."nid&op=Edit+book+outline\">". t("edit book outline") ."nid\">". t("delete node") ."
"; - //TODO: change colspan below to 3 after adding new link in book_admin_view_line() + //TODO: change colspan below to 3 after adding new link in book_admin_view_line() $output .= " "; $output .= book_admin_view_line($node); $output .= book_admin_view_book($nid); @@ -686,7 +686,7 @@ function book_admin() { */ $links = book_admin_links(); - + print "". implode(" · ", $links) ."
"; switch ($op) { @@ -712,7 +712,7 @@ function book_admin() { function book_help() { ?> - +

The Collaborative Book is a magnificient mechanism for organizing content authored by many users. You may use it to organize a Manual (e.g. Drupal Handbook), to maintain an FAQ, or to manage any outline-like content. Books can have @@ -792,6 +792,6 @@ function book_help() { diff --git a/modules/drupal.module b/modules/drupal.module index 2609a78b2a3eb4f2fabe0e4e21775d9354564fb7..da8536141ed3f9a47fcfda17f1b231826ee8d3cd 100644 --- a/modules/drupal.module +++ b/modules/drupal.module @@ -110,8 +110,9 @@ function drupal_auth($username, $password, $server) { $message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string"))); + // TODO remove hard coded Port 80 + // TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed $client = new xmlrpc_client("/xmlrpc.php", $server, 80); - $result = $client->send($message, 5); if ($result && !$result->faultCode()) { $value = $result->value(); @@ -131,11 +132,29 @@ function drupal_page() { function drupal_auth_help() { $site = variable_get("site_name", "this web site"); - $output = " -

Drupal is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single Drupal ID.

-

So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an email address: username@server. An example of valid Drupal ID is mwlily@www.drupal.org.

"; + $output = "

Drupal is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single Drupal ID.

\n"; + $output .= "

So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an email address: username@server. An example of valid Drupal ID is mwlily@www.drupal.org.

"; + + return strtr(t($output), array("%s" => "$site")); +} - return sprintf(t($output), $site, $site); +function drupal_user($type, $edit, $user) { + global $HTTP_HOST; + + $module = "drupal"; + $name = module_invoke($module, "info", "name"); + switch ($type) { + case "view_private": + $result = user_get_authname($user, $module); + if ($result) { + $output .= form_item("$name ID", $result); + } + else { + // TODO: use a variation of path_uri() instead of $HTTP_HOST below + $output .= form_item("$name ID", "$user->name@$HTTP_HOST"); + } + return $output; + } } ?> \ No newline at end of file diff --git a/modules/drupal/drupal.module b/modules/drupal/drupal.module index 2609a78b2a3eb4f2fabe0e4e21775d9354564fb7..da8536141ed3f9a47fcfda17f1b231826ee8d3cd 100644 --- a/modules/drupal/drupal.module +++ b/modules/drupal/drupal.module @@ -110,8 +110,9 @@ function drupal_auth($username, $password, $server) { $message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string"))); + // TODO remove hard coded Port 80 + // TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed $client = new xmlrpc_client("/xmlrpc.php", $server, 80); - $result = $client->send($message, 5); if ($result && !$result->faultCode()) { $value = $result->value(); @@ -131,11 +132,29 @@ function drupal_page() { function drupal_auth_help() { $site = variable_get("site_name", "this web site"); - $output = " -

Drupal is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single Drupal ID.

-

So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an email address: username@server. An example of valid Drupal ID is mwlily@www.drupal.org.

"; + $output = "

Drupal is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single Drupal ID.

\n"; + $output .= "

So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an email address: username@server. An example of valid Drupal ID is mwlily@www.drupal.org.

"; + + return strtr(t($output), array("%s" => "$site")); +} - return sprintf(t($output), $site, $site); +function drupal_user($type, $edit, $user) { + global $HTTP_HOST; + + $module = "drupal"; + $name = module_invoke($module, "info", "name"); + switch ($type) { + case "view_private": + $result = user_get_authname($user, $module); + if ($result) { + $output .= form_item("$name ID", $result); + } + else { + // TODO: use a variation of path_uri() instead of $HTTP_HOST below + $output .= form_item("$name ID", "$user->name@$HTTP_HOST"); + } + return $output; + } } ?> \ No newline at end of file diff --git a/modules/jabber.module b/modules/jabber.module index c16f1f4193a632e529c0860004adceb028458568..d9417176f475e8799807256b18198e7017c7e7cc 100644 --- a/modules/jabber.module +++ b/modules/jabber.module @@ -12,7 +12,7 @@ function jabber_info($field = 0) { } } -function startElement($parser, $name, $attributes) { +function jabber_start($parser, $name, $attributes) { global $jabber; if ($attributes["ID"]) { @@ -24,10 +24,10 @@ function startElement($parser, $name, $attributes) { } } -function endElement($parser, $name) { +function jabber_end($parser, $name) { } -function characterData($parser, $data) { +function jabber_data($parser, $data) { global $jabber; $jabber["data"] = $data; @@ -77,8 +77,8 @@ function jabber_auth($username, $password, $server) { if ($session) { $xml_parser = xml_parser_create(); - xml_set_element_handler($xml_parser, "startElement", "endElement"); - xml_set_character_data_handler($xml_parser, "characterData"); + xml_set_element_handler($xml_parser, "jabber_start", "jabber_end"); + xml_set_character_data_handler($xml_parser, "jabber_data"); /* ** Switch the given socket descriptor '$session' to non-blocking mode: @@ -153,7 +153,24 @@ function jabber_auth_help() {

You may login to %s using a Jabber ID. The format of a Jabber ID is the same as an email address: name@server An example of valid Jabber ID is mwlily@jabber.com.

Jabber is an open source instant messaging system designed to give the power of choice and freedom back to the users of instant messaging. By creating an extensible and powerful server and protocol, Jabber has succeeded in this goal. Not only does Jabber allow its users to use (and create) clients for numerous platforms, but it allows people to communicate to whomever they want in the way which is most convenient for them.

"; - return sprintf(t($output), $site); + return strtr(t($output), array("%s" => "$site")); +} + +function jabber_user($type, $edit, $user) { + $module = "jabber"; + $name = module_invoke($module, "info", "name"); + switch ($type) { + case "view_private": + $result = user_get_authname($user, $module); + $output .= form_item("$name ID", $result); + return $output; + case "edit_form": + $result = user_get_authname($user, $module); + $output .= form_textfield("$name ID", "authname_" . $module, $result, 30, 55, strtr(t("You may login to %s using a valid %id."), array("%s" => variable_get("site_name", "this web site"), "%id" => "$name ID"), "")); + return $output; + case "edit_validate": + return user_validate_authmap($user, $edit["authname_$module"], $module); + } } ?> \ No newline at end of file diff --git a/modules/node.module b/modules/node.module index 321299e0e5a6053759e2078741e17f9db3ff44c1..3bd254eb9d80b573ec294226dac75fe2a25c1914 100644 --- a/modules/node.module +++ b/modules/node.module @@ -458,7 +458,7 @@ function node_admin_edit($node) { $output .= "
titlerevoperations
"; $output .= " "; foreach ($node->revisions as $key => $revision) { - $output .= " "; + $output .= " "; } $output .= "
older revisionsoperations
". sprintf(t("revision #%d revised by %s on %s"), $key, format_name(user_load(array("uid" => $revision["uid"]))), format_date($revision["timestamp"], "small")) . ($revision["history"] ? "
". $revision["history"] ."" : "") ."
nid&revision=$key\">". t("view revision") ."nid&revision=$key\">". t("rollback revision") ."nid&revision=$key\">". t("delete revision") ."
". strtr(t("revision #%r revised by %u on %d"), array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "
". $revision["history"] ."" : "") ."
nid&revision=$key\">". t("view revision") ."nid&revision=$key\">". t("rollback revision") ."nid&revision=$key\">". t("delete revision") ."
"; } @@ -741,7 +741,7 @@ function node_validate($node, &$error) { $node->uid = $account->uid; } else { - $error["name"] = "
". sprintf(t("The name '%s' does not exist."), $node->name) ."
"; + $error["name"] = "
". strtr(t("The name '%u' does not exist."), array ("%u" => $node->name)) ."
"; } /* @@ -898,7 +898,7 @@ function node_add($type) { foreach (module_list() as $name) { if (module_hook($name, "node") && node_access("create", array("type" => $name))) { $output .= "
  • "; - $output .= " ". module_invoke($name, "node", "name") .""; + $output .= " ". module_invoke($name, "node", "name") .""; $output .= "
    ". module_invoke($name, "node", "description") ."
    "; $output .= "
  • "; } diff --git a/modules/node/node.module b/modules/node/node.module index 321299e0e5a6053759e2078741e17f9db3ff44c1..3bd254eb9d80b573ec294226dac75fe2a25c1914 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -458,7 +458,7 @@ function node_admin_edit($node) { $output .= ""; $output .= " "; foreach ($node->revisions as $key => $revision) { - $output .= " "; + $output .= " "; } $output .= "
    older revisionsoperations
    ". sprintf(t("revision #%d revised by %s on %s"), $key, format_name(user_load(array("uid" => $revision["uid"]))), format_date($revision["timestamp"], "small")) . ($revision["history"] ? "
    ". $revision["history"] ."" : "") ."
    nid&revision=$key\">". t("view revision") ."nid&revision=$key\">". t("rollback revision") ."nid&revision=$key\">". t("delete revision") ."
    ". strtr(t("revision #%r revised by %u on %d"), array("%r" => $key, "%u" => format_name(user_load(array("uid" => $revision["uid"]))), "%d" => format_date($revision["timestamp"], "small"))) . ($revision["history"] ? "
    ". $revision["history"] ."" : "") ."
    nid&revision=$key\">". t("view revision") ."nid&revision=$key\">". t("rollback revision") ."nid&revision=$key\">". t("delete revision") ."
    "; } @@ -741,7 +741,7 @@ function node_validate($node, &$error) { $node->uid = $account->uid; } else { - $error["name"] = "
    ". sprintf(t("The name '%s' does not exist."), $node->name) ."
    "; + $error["name"] = "
    ". strtr(t("The name '%u' does not exist."), array ("%u" => $node->name)) ."
    "; } /* @@ -898,7 +898,7 @@ function node_add($type) { foreach (module_list() as $name) { if (module_hook($name, "node") && node_access("create", array("type" => $name))) { $output .= "
  • "; - $output .= " ". module_invoke($name, "node", "name") .""; + $output .= " ". module_invoke($name, "node", "name") .""; $output .= "
    ". module_invoke($name, "node", "description") ."
    "; $output .= "
  • "; } diff --git a/modules/system.module b/modules/system.module index c8cdc99aecfde8d0f0a403b8b4234f87c0b3de04..a18faad5c21d3570d2d46162436a64aecc1917b7 100644 --- a/modules/system.module +++ b/modules/system.module @@ -32,11 +32,15 @@ function system_link($type) { $links[] = "settings and filters"; } + /*if ($type == "admin" && user_access("administer modules and themes")) { + $links[] = "modules and themes"; + }*/ + return $links ? $links : array(); } function system_view_options() { - global $conf, $cmodes, $corder, $themes; + global $conf, $cmodes, $corder; // general settings: $output .= "

    General settings

    \n"; $output .= form_textfield("Name", "site_name", variable_get("site_name", "drupal"), 55, 55, "The name of this website."); @@ -66,14 +70,14 @@ function system_view_options() { // comment settings: $output .= "

    Comment settings

    \n"; - $output .= form_select("Default display mode", "default_comment_mode", $conf[default_comment_mode], $cmodes, "The default mode in which comments are displayed."); - $output .= form_select("Default display order", "default_comment_order", $conf[default_comment_order], $corder, "The default order in which comments are displayed."); + $output .= form_select("Default display mode", "default_comment_mode", $conf["default_comment_mode"], $cmodes, "The default mode in which comments are displayed."); + $output .= form_select("Default display order", "default_comment_order", $conf["default_comment_order"], $corder, "The default order in which comments are displayed."); for ($count = -1; $count < 6; $count++) $threshold[$count] = "Filter - $count"; $output .= "
    \n"; // layout settings: $output .= "

    Layout settings

    \n"; - foreach ($themes as $key=>$value) $options .= "\n"; + foreach (theme_list() as $key=>$value) $options .= "\n"; $output .= form_item("Default theme", "", "The default theme as seen by visitors or anonymous users."); $output .= "
    \n"; @@ -127,31 +131,138 @@ function system_view($type) { return form($form); } +/** +* Module configuration +* +* @author Kjartan Mannes +* @group system.module +* @return string module list +*/ function system_modules() { + $result = db_query("SELECT name, status FROM system WHERE type = 'module'"); + $status = array(); + while ($module = db_fetch_object($result)) { + $status[$module->name] = $module->status; + } + db_query("DELETE FROM system WHERE type = 'module'"); + + if ($handle = @opendir("modules")) { + $modules = array(); + while ($file = readdir($handle)) { + if (".module" == substr($file, -7)) { + $name = substr($file, 0, -7); + $modules[$name] = array("filename" => "$file", "status" => $status[$name]); + include_once("modules/$file"); + } + } + closedir($handle); + asort($modules); + } + + $required = array("user", "drupal", "system", "watchdog"); + $output .= "\n"; - $output .= " \n"; - foreach (module_list() as $name) { - $output .= " \n"; + $output .= " \n"; + foreach ($modules as $name => $module) { + $output .= " \n"; + if (!in_array($name, $required)) { + db_query("INSERT INTO system SET name = '$name', type = 'module', filename = '$module[filename]', status = '$module[status]'"); + } } - $output .= "
    moduleoperations
    $name". (module_hook($name, "page") ? "view" : " ") ."". (module_hook($name, "admin") ? "admin" : " ") ."
    moduledescriptionstatusoperations
    $name". check_output(module_invoke($name, "system", "description")) ."". (in_array($name, $required) ? "Enabled" : form_select("", "status][$name", $module["status"], array(t("Disabled"), t("Enabled")))) ."". (module_hook($name, "page") ? "view" : " ") ."". (module_hook($name, "admin") ? "admin" : " ") ."
    \n"; + $output .= "
    \n"; + $output .= form_submit("Save module settings"); - return $output; + return form($output); +} + +/** +* Theme configuration +* +* This function handles the Drupal themes and lets the site administrator enable or disable them as they wish. +* +* @author Kjartan Mannes +* @package system.module +* @return string theme list +*/ +function system_themes() { + $result = db_query("SELECT * FROM system WHERE type = 'theme' ORDER BY filename"); + $status = array(); + while ($theme = db_fetch_object($result)) { + $_themes[$theme->name] = $theme; + } + + if ($handle = @opendir("themes")) { + $themes = array(); + while ($dir = readdir($handle)) { + if (!substr_count($dir, ".") && is_dir("themes/$dir")) { + if ($handle2 = @opendir("themes/$dir")) { + while ($file = readdir($handle2)) { + if (".theme" == substr($file, -6)) { + include_once("themes/$dir/$file"); + $name = substr($file, 0, -6); + $_theme = "theme_$name"; + if (class_exists($_theme)) { + $_theme =& new $_theme; + $_themes[$name]->filename = "themes/$dir/$file"; + if (method_exists($_theme, "system")) { + $_themes[$name]->displayname = $_theme->system("name"); + $_themes[$name]->author = $_theme->system("author"); + if (empty($_themes[$name]->description)) { + $_themes[$name]->description = $_theme->system("description"); + } + } + + $themes[$name] = $_themes[$name]; + unset($_theme); + } + } + } + closedir($handle2); + } + } + } + closedir($handle); + asort($themes); + } + + db_query("DELETE FROM system WHERE type = 'theme'"); + + $output .= "\n"; + $output .= " \n"; + foreach ($themes as $name => $theme) { + $output .= " \n"; + db_query("INSERT INTO system SET name = '$name', type = 'theme', filename = '$theme->filename', status = '$theme->status', description = '$theme->description'"); + } + $output .= "
    themenamedescriptionauthorstatus
    $name$theme->displayname". form_textfield("", "$name][description", $theme->description, 40, 255)."$theme->author". form_select("", "$name][status", $theme->status, array(t("Disabled"), t("Enabled"))) ."

    \n"; + $output .= form_submit("Save theme settings"); + + return form($output); } function system_admin() { global $edit, $op, $type; - if (user_access("administer settings and filters")) { - print "site settings | content filters | modules | help
    \n"; + print "site settings | content filters | modules | themes | help
    \n"; switch ($op) { case "help": system_help(); break; + case "Save module settings": + foreach ($edit["status"] as $name => $status) { + db_query("UPDATE system SET status = '$status' WHERE name = '$name'"); + } case "modules": print system_modules(); break; + case "Save theme settings": + foreach ($edit as $name => $settings) { + db_query("UPDATE system SET status = '". check_query($settings["status"]) ."', description = '". check_query($settings["description"]) ."' WHERE name = '$name'"); + } + case "themes": + print system_themes(); + break; case "Reset to defaults": print status(system_default($edit)); print system_view($type); diff --git a/modules/system/system.module b/modules/system/system.module index c8cdc99aecfde8d0f0a403b8b4234f87c0b3de04..a18faad5c21d3570d2d46162436a64aecc1917b7 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -32,11 +32,15 @@ function system_link($type) { $links[] = "settings and filters"; } + /*if ($type == "admin" && user_access("administer modules and themes")) { + $links[] = "modules and themes"; + }*/ + return $links ? $links : array(); } function system_view_options() { - global $conf, $cmodes, $corder, $themes; + global $conf, $cmodes, $corder; // general settings: $output .= "

    General settings

    \n"; $output .= form_textfield("Name", "site_name", variable_get("site_name", "drupal"), 55, 55, "The name of this website."); @@ -66,14 +70,14 @@ function system_view_options() { // comment settings: $output .= "

    Comment settings

    \n"; - $output .= form_select("Default display mode", "default_comment_mode", $conf[default_comment_mode], $cmodes, "The default mode in which comments are displayed."); - $output .= form_select("Default display order", "default_comment_order", $conf[default_comment_order], $corder, "The default order in which comments are displayed."); + $output .= form_select("Default display mode", "default_comment_mode", $conf["default_comment_mode"], $cmodes, "The default mode in which comments are displayed."); + $output .= form_select("Default display order", "default_comment_order", $conf["default_comment_order"], $corder, "The default order in which comments are displayed."); for ($count = -1; $count < 6; $count++) $threshold[$count] = "Filter - $count"; $output .= "
    \n"; // layout settings: $output .= "

    Layout settings

    \n"; - foreach ($themes as $key=>$value) $options .= "\n"; + foreach (theme_list() as $key=>$value) $options .= "\n"; $output .= form_item("Default theme", "", "The default theme as seen by visitors or anonymous users."); $output .= "
    \n"; @@ -127,31 +131,138 @@ function system_view($type) { return form($form); } +/** +* Module configuration +* +* @author Kjartan Mannes +* @group system.module +* @return string module list +*/ function system_modules() { + $result = db_query("SELECT name, status FROM system WHERE type = 'module'"); + $status = array(); + while ($module = db_fetch_object($result)) { + $status[$module->name] = $module->status; + } + db_query("DELETE FROM system WHERE type = 'module'"); + + if ($handle = @opendir("modules")) { + $modules = array(); + while ($file = readdir($handle)) { + if (".module" == substr($file, -7)) { + $name = substr($file, 0, -7); + $modules[$name] = array("filename" => "$file", "status" => $status[$name]); + include_once("modules/$file"); + } + } + closedir($handle); + asort($modules); + } + + $required = array("user", "drupal", "system", "watchdog"); + $output .= "\n"; - $output .= " \n"; - foreach (module_list() as $name) { - $output .= " \n"; + $output .= " \n"; + foreach ($modules as $name => $module) { + $output .= " \n"; + if (!in_array($name, $required)) { + db_query("INSERT INTO system SET name = '$name', type = 'module', filename = '$module[filename]', status = '$module[status]'"); + } } - $output .= "
    moduleoperations
    $name". (module_hook($name, "page") ? "view" : " ") ."". (module_hook($name, "admin") ? "admin" : " ") ."
    moduledescriptionstatusoperations
    $name". check_output(module_invoke($name, "system", "description")) ."". (in_array($name, $required) ? "Enabled" : form_select("", "status][$name", $module["status"], array(t("Disabled"), t("Enabled")))) ."". (module_hook($name, "page") ? "view" : " ") ."". (module_hook($name, "admin") ? "admin" : " ") ."
    \n"; + $output .= "
    \n"; + $output .= form_submit("Save module settings"); - return $output; + return form($output); +} + +/** +* Theme configuration +* +* This function handles the Drupal themes and lets the site administrator enable or disable them as they wish. +* +* @author Kjartan Mannes +* @package system.module +* @return string theme list +*/ +function system_themes() { + $result = db_query("SELECT * FROM system WHERE type = 'theme' ORDER BY filename"); + $status = array(); + while ($theme = db_fetch_object($result)) { + $_themes[$theme->name] = $theme; + } + + if ($handle = @opendir("themes")) { + $themes = array(); + while ($dir = readdir($handle)) { + if (!substr_count($dir, ".") && is_dir("themes/$dir")) { + if ($handle2 = @opendir("themes/$dir")) { + while ($file = readdir($handle2)) { + if (".theme" == substr($file, -6)) { + include_once("themes/$dir/$file"); + $name = substr($file, 0, -6); + $_theme = "theme_$name"; + if (class_exists($_theme)) { + $_theme =& new $_theme; + $_themes[$name]->filename = "themes/$dir/$file"; + if (method_exists($_theme, "system")) { + $_themes[$name]->displayname = $_theme->system("name"); + $_themes[$name]->author = $_theme->system("author"); + if (empty($_themes[$name]->description)) { + $_themes[$name]->description = $_theme->system("description"); + } + } + + $themes[$name] = $_themes[$name]; + unset($_theme); + } + } + } + closedir($handle2); + } + } + } + closedir($handle); + asort($themes); + } + + db_query("DELETE FROM system WHERE type = 'theme'"); + + $output .= "\n"; + $output .= " \n"; + foreach ($themes as $name => $theme) { + $output .= " \n"; + db_query("INSERT INTO system SET name = '$name', type = 'theme', filename = '$theme->filename', status = '$theme->status', description = '$theme->description'"); + } + $output .= "
    themenamedescriptionauthorstatus
    $name$theme->displayname". form_textfield("", "$name][description", $theme->description, 40, 255)."$theme->author". form_select("", "$name][status", $theme->status, array(t("Disabled"), t("Enabled"))) ."

    \n"; + $output .= form_submit("Save theme settings"); + + return form($output); } function system_admin() { global $edit, $op, $type; - if (user_access("administer settings and filters")) { - print "site settings | content filters | modules | help
    \n"; + print "site settings | content filters | modules | themes | help
    \n"; switch ($op) { case "help": system_help(); break; + case "Save module settings": + foreach ($edit["status"] as $name => $status) { + db_query("UPDATE system SET status = '$status' WHERE name = '$name'"); + } case "modules": print system_modules(); break; + case "Save theme settings": + foreach ($edit as $name => $settings) { + db_query("UPDATE system SET status = '". check_query($settings["status"]) ."', description = '". check_query($settings["description"]) ."' WHERE name = '$name'"); + } + case "themes": + print system_themes(); + break; case "Reset to defaults": print status(system_default($edit)); print system_view($type); diff --git a/modules/user.module b/modules/user.module index e90c2e7021f2c3689ddeb82658de392d526a5a6b..2f7e93b1c1f4ea15713b1795eb079fdae1e8508f 100644 --- a/modules/user.module +++ b/modules/user.module @@ -187,16 +187,12 @@ function user_validate_mail($mail) { } } -function user_validate_authmaps($account, $edit) { - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - $result = db_query("SELECT COUNT(*) from authmap WHERE uid != '$account->uid' && authname = '". $edit["authname_$module"] . "'"); - if (db_result($result) > 0) { - $info = module_invoke($module, "info"); - return sprintf(t("The %s ID %s is already taken."), ucfirst($info["name"]), "". $edit["authname_$module"] .""); - } +function user_validate_authmap($account, $authname, $module) { + $result = db_query("SELECT COUNT(*) from authmap WHERE uid != '$account->uid' && authname = '$authname'"); + if (db_result($result) > 0) { + $name = module_invoke($module, "info", "name"); + return strtr(t("The %u ID %s is already taken."), array("%u" => ucfirst($name), "%s" => "$authname")); } - } } function user_password($min_length = 6) { @@ -240,7 +236,6 @@ function user_access($string) { } function user_mail($mail, $subject, $message, $header) { - // print "
    subject: $subject
    header: $header
    $message
    "; if (variable_get("smtp_library", "") && file_exists(variable_get("smtp_library", ""))) { include_once variable_get("smtp_library", ""); return user_mail_wrapper($mail, $subject, $message, $header); @@ -321,7 +316,7 @@ function user_help() { reports which help you manage your users. The following pages are available:

    add new user

    -

    If your site blocks is completely private, and doesn't allow registration for +

    If your site is completely private, and doesn't allow registration for any old web user (see Settings for this feature), then you'll need to add new users manually. This web page allows any administrator to register a new user.

    @@ -433,8 +428,13 @@ function user_help() { } ?>


    - User Preferences

    -

    Coming soonish.

    + User Preferences and Profile +

    Drupal comes with a set of user preferences and profile which a user may edit by + clicking on the user account link. Of course, a user must be logged into reach those pages. + There, users will find a page for changing their preferred timezone, language, username, email address, password, theme, signature, homepage, and distributed authentication names. + Changes made here take effect immediately. Also, administrators may make profile and preferences changes in the Admin Center on behalf of their users.

    +

    Module developers are provided several hooks for adding custom fields to the user view/edit pages. These hooks are described in the Developer section of the Drupal Handbook. For an example, see the jabber_user() function in /modules/jabber.module. +

    ". t("Password") .":

    \n"; $output .= "". t("Remember me") ."
    \n"; $output .= "
    \n"; - if (variable_get("account_register", 1)) $output .= " ". t("REGISTER") ."\n"; - $output .= "\n"; $output .= "\n"; + if (variable_get("account_register", 1)) { + $output .= "» ". t("Register") ."\n"; + } + $output .= "
    » " . t("New password") . "
    "; + $output .= "\n"; + $block[1]["content"] = $output; } @@ -513,7 +517,7 @@ function user_link($type) { } if ($type == "menu.settings") { - $links[] = "". t("account settings") .""; + $links[] = "". t("edit account") .""; } if ($type == "menu.misc") { @@ -553,20 +557,25 @@ function user_xmlrpc() { /*** Authentication methods ************************************************/ -function user_get_authmaps($account = NULL, $authname = NULL) { +function user_get_authname($account, $module) { /* - ** Accepts an user object, $account, or an DA name and returns an - ** associtive array of modules and DA names. + ** Called by authentication modules in order to edit/view their authmap information. */ - if (!$account) { //called at external login - $result = db_query("SELECT authname, module FROM authmap WHERE authname = '$authname'"); - } - else { //called from user_edit, user_view,, admin_user_edit - $result = db_query("SELECT authname, module FROM authmap WHERE uid = '$account->uid'"); - } + $result = db_query("SELECT authname FROM authmap WHERE uid = '$account->uid' && module = '$module'"); + return db_result($result); +} + +function user_get_authmaps($authname = NULL) { + + /* + ** Accepts an user object, $account, or an DA name and returns an + ** associtive array of modules and DA names. Called at external login. + */ + + $result = db_query("SELECT authname, module FROM authmap WHERE authname = '$authname'"); if (db_num_rows($result) > 0) { while ($authmap = db_fetch_object($result)) { $authmaps[$authmap->module] = $authmap->authname; @@ -624,7 +633,7 @@ function user_help_da() { on logging into %s in the same manner, and he will always be logged into the same account.

    "; - $output = sprintf(t($output), $site, $site, $site, $site, $site, $site); + $output = strtr(t($output), array("%s" => $site)); foreach (module_list() as $module) { if (module_hook($module, "auth")) { @@ -659,7 +668,7 @@ function user_login($edit = array()) { } if (user_deny("user", $edit["name"])) { - $error = sprintf(t("The name '%s' has been denied access."), $edit["name"]); + $error = strtr(t("The name '%s' has been denied access."), array("%s" => $edit["name"])); } else if ($edit["name"] && $edit["pass"]) { @@ -687,13 +696,13 @@ function user_login($edit = array()) { ** When possible, determine corrosponding external auth source. Invoke source, and login user if successful: */ - if (!$user && $server && $result = user_get_authmaps("", "$name@$server")) { + if (!$user && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); watchdog("user", "external load: $name@$server, module: " . key($result)); } else { - $error = sprintf(t("Invalid password for %s."), "$name@$server"); + $error = strtr(t("Invalid password for %s."), array("%s" => "$name@$server")); } } @@ -746,7 +755,7 @@ function user_login($edit = array()) { } else { if (!$error) { - $error = sprintf(t("Sorry. Unrecognized username or password. Have you %sforgotten your password%s?"),"",""); + $error = sprintf(t("Sorry. Unrecognized username or password. Have you %sforgotten your password%s?"), "", ""); } if ($server) { watchdog("user", "failed login for '$name@$server': $error"); @@ -769,9 +778,12 @@ function user_login($edit = array()) { ** Display login form: */ - $output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, sprintf(t("Enter your %s username, or an ID from one of our affiliates: %s."), variable_get("site_name", "local"), implode(", ", user_auth_help_links()))); + $output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, strtr(t("Enter your %s username, or an ID from one of our affiliates: %a."), array("%s" => variable_get("site_name", "local"), "%a" => implode(", ", user_auth_help_links())))); $output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username.")); + $output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0); $output .= form_submit(t("Log in")); + $output .= "

    » " . t("E-mail new password") . "
    "; + $output .= "» " . t("Create new account") . "

    "; return form($output); } @@ -801,12 +813,12 @@ function user_logout() { function user_pass($edit = array()) { if ($edit["name"]) { - $account = db_fetch_object(db_query("SELECT uid FROM users WHERE name = '". check_input($edit["name"]) . "'")); - if (!$account) $error = sprintf(t("Sorry. The username %s is not recognized."), $edit["name"]); - } + $account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE name = '". check_input($edit["name"]) . "'")); + if (!$account) $error = strtr(t("Sorry. The username %s is not recognized."), array("%s" => $edit["name"])); + } else if ($edit["mail"]) { - $account = db_fetch_object(db_query("SELECT uid FROM users WHERE mail = '". check_input($edit["mail"]) ."'")); - if (!$account) $error = sprintf(t("Sorry. The e-mail address %s is not recognized."), $edit["mail"]); + $account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE mail = '". check_input($edit["mail"]) ."'")); + if (!$account) $error = strtr(t("Sorry. The e-mail address %s is not recognized."), array("%s" => $edit["mail"])); } if ($account) { @@ -823,14 +835,19 @@ function user_pass($edit = array()) { ** Mail new password: */ - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nyou requested us to e-mail you a new password for your account at %s. You can now login using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + global $HTTP_HOST; + $variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => $HTTP_HOST, "%mailto" => $account->mail); + $subject = strtr(variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), $variables); + $body = strtr(variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); + $headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"; + user_mail($account->mail, $subject, $body, $headers); - watchdog("user", "mail password: '". $edit["name"] ."' <". $edit["mail"] .">"); + watchdog("user", "mail password: '". $account->name ."' <". $account->mail .">"); return t("Your password and further instructions have been sent to your e-mail address."); } else { - + // Display error message if necessary. if ($error) { $output .= "

    ". check_output($error) ."

    "; @@ -840,16 +857,27 @@ function user_pass($edit = array()) { ** Display form: */ - $output .= sprintf(t("%sEnter your username %sor%s your email address.%s"), "

    ", "", "", "

    "); + $output .= "

    ". sprintf(t("Enter your username %sor%s your email address."), "", "") ."

    "; $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64); $output .= form_submit(t("E-mail new password")); + $output .= "

    » " . t("Log in") . "
    "; + $output .= "» " . t("Create new account") . "

    "; return form($output); } } function user_register($edit = array()) { + global $user; + + /* + ** If we are already logged on, go to the user page instead. + */ + + if ($user->uid) { + drupal_goto("module.php?mod=user&op=edit"); + } if ($edit["name"] && $edit["mail"]) { if ($error = user_validate_name($edit["name"])) { @@ -859,16 +887,16 @@ function user_register($edit = array()) { // do nothing } else if (user_deny("user", $edit["name"])) { - $error = sprintf(t("The name '%s' has been denied access."), $edit["name"]); + $error = strtr(t("The name '%s' has been denied access."), array("%s" => $edit["name"])); } else if (user_deny("mail", $edit["mail"])) { - $error = sprintf(t("The e-mail address '%s' has been denied access."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' has been denied access."), array("%s" => $edit["mail"])); } else if (db_num_rows(db_query("SELECT name FROM users WHERE LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if (db_num_rows(db_query("SELECT mail FROM users WHERE LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else if (variable_get("user_register", 1) == 0) { $error = t("Public registrations have been disabled by the site administrator."); @@ -899,52 +927,64 @@ function user_register($edit = array()) { $from = variable_get("site_mail", ini_get("sendmail_from")); $pass = user_password(); + // create new user account, noting whether administrator approval is required if (variable_get("user_register", 1) == 1) { - /* - ** Create new user account, no administrator approval required: - */ - - user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 1), $data)); - - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nsomoneone signed up for a user account on %s and supplied this e-mail address as their contact. If it wasn't you, just ignore this mail but if it was you, you can now login using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 1), $data)); } else { - /* - ** Create new user account, administrator approval required: - */ - - user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 0), $data)); - - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nsomoneone signed up for a user account on %s and supplied this e-mail address as their contact. If it wasn't you, just ignore this mail but if it was you, you can login as soon a site administrator approved your request using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 0), $data)); } - return t("Your password and further instructions have been sent to your e-mail address."); + $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => $HTTP_HOST, "%mailto" => $edit["mail"]); + + //the first user may login immediately, and receives a customized welcome email. + if ($user->uid == 1) { + user_mail($edit["mail"], strtr(t("drupal user account details for %s"), array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %utimodule.php?mod=user&op=edit\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + // This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password + $output .= "

    Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.

    Your password is $pass. You may change your password on the next page.

    Please login below.

    "; + $output .= form_hidden("name", $user->name); + $output .= form_hidden("pass", $pass); + $output .= form_submit(t("Log in")); + return form($output); + } + else { + global $HTTP_HOST; + $subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables); + $body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nnThank you for registering at %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); + user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + return t("Your password and further instructions have been sent to your e-mail address."); + } } else { - if ($error) { $output .= "

    ". check_output($error) ."

    "; } + } - $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); - $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("Your e-mail address: a password and instructions will be sent to this e-mail address so make sure it is accurate.")); - foreach (module_list() as $module) { - if (module_hook($module, "user")) { - $output .= module_invoke($module, "user", "register_form", $edit, $user); - } + // display the registration form + $affiliates = user_auth_help_links(); + if (array_count_values($affiliates) > 1) { + $affiliates = implode(", ", $affiliates); + $output .= "

    " . strtr(t("Note: If you have an account with one of our affiliates (%s), you may login now instead of registering."), array("%s" => $affiliates)) ."

    "; + } + $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate.")); + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $output .= module_invoke($module, "user", "register_form", $edit, $user); } - $output .= form_submit(t("Create new account")); - - return form($output); } + $output .= form_submit(t("Create new account")); + + return form($output); } function user_delete() { global $edit, $user; - + if ($edit["confirm"]) { - watchdog(user,"$user->name deactivated her own account."); + watchdog(user,"$user->name deactivated her own account."); db_query("UPDATE users SET mail = 'deleted', status='0' WHERE uid = '$user->uid'"); $output .= t("Your account has been deactivated."); } @@ -958,7 +998,7 @@ function user_delete() { } function user_edit($edit = array()) { - global $HTTP_HOST, $themes, $user, $languages; + global $themes, $user, $languages; if ($user->uid) { if ($edit["name"]) { @@ -969,13 +1009,10 @@ function user_edit($edit = array()) { // do nothing } else if (db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$user->uid' AND LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if ($edit["mail"] && db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$user->uid' AND LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); - } - else if ($error = user_validate_authmaps($user, $edit)) { - // do nothing + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else if ($user->uid) { foreach (module_list() as $module) { @@ -1014,7 +1051,7 @@ function user_edit($edit = array()) { $user = user_save($user, array_merge($edit, $data)); - $output .= sprintf(t("Your user information changes have been saved."), "

    ", "

    "); + $output .= t("Your user information changes have been saved."); } } } @@ -1026,13 +1063,6 @@ function user_edit($edit = array()) { $output .= form_textfield(t("Username"), "name", $user->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); $output .= form_textfield(t("E-mail address"), "mail", $user->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); - $result = user_get_authmaps($user); - foreach (module_list() as $module) { - if ($module != "drupal" && module_hook($module, "auth")) { - $output .= form_textfield(module_invoke($module, "info", "name") . " ID", "authname_" . $module, $result[$module], 30, 55, sprintf(t("You may login to %s using a valid %s."), variable_get("site_name", "this web site"), "". module_invoke($module, "info", "name") ." ID", "")); - } - } - foreach (module_list() as $module) { if (module_hook($module, "user")) { $output .= module_invoke($module, "user", "edit_form", $edit, $user); @@ -1040,7 +1070,9 @@ function user_edit($edit = array()) { } $output .= form_textfield(t("Homepage"), "homepage", $user->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\".")); - foreach ($themes as $key => $value) $options .= "\n"; + foreach (theme_list() as $key => $value) { + $options .= "$value[type]\n"; + } $output .= form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; $output .= form_select(t("Timezone"), "timezone", $user->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); @@ -1048,7 +1080,7 @@ function user_edit($edit = array()) { $output .= form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."
    ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $output .= form_item(t("Password"), " ", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.")); $output .= form_submit(t("Save user information")); - + $output = form($output); } @@ -1064,7 +1096,7 @@ function user_menu() { } function user_view($uid = 0) { - global $theme, $user, $HTTP_HOST; + global $theme, $user; if (!$uid) { $uid = $user->uid; @@ -1073,17 +1105,6 @@ function user_view($uid = 0) { if ($user->uid && $user->uid == $uid) { $output .= form_item(t("Name"), check_output("$user->name ($user->init)")); $output .= form_item(t("E-mail address"), check_output($user->mail)); - $result = user_get_authmaps($user); - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - if ($module != "drupal") { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($result[$module])); - } - else { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($user->name) . "@$HTTP_HOST"); - } - } - } foreach (module_list() as $module) { if (module_hook($module, "user")) { @@ -1134,8 +1155,9 @@ function user_page() { break; case t("Create new account"): case "register": + $output = user_register($edit); $theme->header(); - $theme->box(t("Create new account"), user_register($edit)); + $theme->box(t("Create new account"), $output); $theme->footer(); break; case t("Log in"): @@ -1145,7 +1167,7 @@ function user_page() { $theme->box(t("Log in"), $output); $theme->footer(); break; - case t("Delete account"): + case t("Delete account"): case t("delete"); $output = user_delete(); $theme->header(); @@ -1153,7 +1175,7 @@ function user_page() { $theme->box(t("Delete account"), $output); $theme->footer(); break; - case t("Save user information"): + case t("Save user information"): case "edit": $output = user_edit($edit); $theme->header(); @@ -1184,6 +1206,10 @@ function user_page() { function user_conf_options() { $output .= form_select("Public registrations", "user_register", variable_get("user_register", 1), array("Only site administrators can create new user accounts.", "Visitors can create accounts and no administrator approval is required.", "Visitors can create accounts but administrator approval is required.")); $output .= form_textfield("Password words", "user_password", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"), 55, 256, "A comma separated list of short words that can be concatenated to generate human-readable passwords."); + $output .= form_textfield("Welcome e-mail subject", "user_mail_welcome_subject", variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), 80, 180, "Customize the Subject of your welcome email, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textarea("Welcome e-mail body", "user_mail_welcome_body", variable_get("user_mail_welcome_body", t("%username,\n\nnThank you for registering at %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the Body of the welcome email, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textfield("Forgotten password e-mail subject", "user_mail_pass_subject", variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), 80, 180, "Customize the Subject of your Forgotten Password email. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textarea("Forgotten password e-mail body", "user_mail_pass_body", variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the Body of the Forgotten Password email. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); return $output; } @@ -1224,10 +1250,10 @@ function user_admin_create($edit = array()) { // do nothing } else if (db_num_rows(db_query("SELECT name FROM users WHERE LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if (db_num_rows(db_query("SELECT mail FROM users WHERE LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else { $success = 1; @@ -1317,10 +1343,12 @@ function user_admin_access($edit = array()) { } -function user_roles() { +function user_roles($membersonly = 0) { $result = db_query("SELECT * FROM role ORDER BY name"); while ($role = db_fetch_object($result)) { - $roles[$role->name] = $role->name; + if (!$membersonly || ($membersonly && $role->name != "anonymous user")) { + $roles[$role->name] = $role->name; + } } return $roles; } @@ -1431,12 +1459,43 @@ function user_admin_role($edit = array()) { } function user_admin_edit($edit = array()) { - global $op, $id, $HTTP_HOST; + global $op, $id, $themes; if ($account = user_load(array("uid" => $id))) { if ($op == "Save account") { - $account = user_save($account, $edit); + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $result = module_invoke($module, "user", "edit_validate", $edit, $account); + } + if (is_array($result)) { + $data = array_merge($data, $result); + } + elseif (is_string($result)) { + $error = $result; + break; + } + } + // TODO: this display/edit/validate should be moved to a new profile.module implementing the _user hooks + if ($error = user_validate_name($edit["name"])) { + // do nothing + } + else if ($error = user_validate_mail($edit["mail"])) { + // do nothing + } + else if (db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$account->uid' AND LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); + } + else if ($edit["mail"] && db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$account->uid' AND LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); + } + if (!$error) { + $account = user_save($account, $edit); + $output .= "

    " . t("Your user information changes have been saved.") . "

    "; + } + else { + $output .= "

    ". check_output($error) ."

    "; + } } else if ($op == "Delete account") { if ($edit["status"] == 0) { @@ -1449,37 +1508,36 @@ function user_admin_edit($edit = array()) { } } - if (!$output) { + /* + ** Display user form: + */ + + $output .= form_item("User ID", check_output($account->uid)); + $output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); - /* - ** Display user form: - */ + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $output .= module_invoke($module, "user", "edit_form", $edit, $account); + } + } - $output .= form_item("User ID", check_output($account->uid)); - $output .= form_item(t("Name"), check_output("$account->name ($account->init)")); - $output .= form_item(t("E-mail address"), format_email($account->mail)); - $result = user_get_authmaps($account); + $output .= form_textfield(t("Homepage"), "homepage", $account->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\".")); + foreach ($themes as $key => $value) $options .= "\n"; + $output .= form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); + for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; + $output .= form_select(t("Timezone"), "timezone", $account->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); + $output .= form_select(t("Language"), "language", $account->language, $languages, t("Selecting a different language will change the language of the site.")); + $output .= form_textarea(t("Signature"), "signature", $account->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."
    ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - if ($module != "drupal") { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($result[$module])); - } - else { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($account->name) ."@$HTTP_HOST"); - } - } - } + $output .= form_select("Status", "status", $account->status, array("blocked", "active")); + $output .= form_select("Role", "role", $account->role, user_roles(1)); - $output .= form_item(t("Theme"), check_output("$account->theme")); - $output .= form_select("Status", "status", $account->status, array("blocked", "active")); - $output .= form_select("Role", "role", $account->role, user_roles()); + $output .= form_submit("Save account"); + $output .= form_submit("Delete account"); - $output .= form_submit("Save account"); - $output .= form_submit("Delete account"); + $output = form($output); - $output = form($output); - } } else { $output = "no such user"; @@ -1491,7 +1549,10 @@ function user_admin_edit($edit = array()) { function user_admin_account() { global $query; - $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "non-regular users")); + $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users")); + foreach (user_roles(1) as $key => $value) { + $queries[] = array("WHERE role = '$value' ORDER BY uid DESC", $value . "s"); + } $result = db_query("SELECT uid, name, timestamp FROM users ". $queries[$query ? $query : 0][0] ." LIMIT 50"); @@ -1520,7 +1581,6 @@ function admin_access_init() { if (!$role) db_query("INSERT INTO role (name) VALUES ('authenticated user')"); } - function user_admin() { global $edit, $id, $op, $user; @@ -1543,7 +1603,6 @@ function user_admin() { $links[] = "user permissions"; $links[] = "search account"; $links[] = "settings"; - // $links[] = "auth modules"; $links[] = "help"; print "". implode(" · ", $links) ."
    "; diff --git a/modules/user/user.module b/modules/user/user.module index e90c2e7021f2c3689ddeb82658de392d526a5a6b..2f7e93b1c1f4ea15713b1795eb079fdae1e8508f 100644 --- a/modules/user/user.module +++ b/modules/user/user.module @@ -187,16 +187,12 @@ function user_validate_mail($mail) { } } -function user_validate_authmaps($account, $edit) { - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - $result = db_query("SELECT COUNT(*) from authmap WHERE uid != '$account->uid' && authname = '". $edit["authname_$module"] . "'"); - if (db_result($result) > 0) { - $info = module_invoke($module, "info"); - return sprintf(t("The %s ID %s is already taken."), ucfirst($info["name"]), "". $edit["authname_$module"] .""); - } +function user_validate_authmap($account, $authname, $module) { + $result = db_query("SELECT COUNT(*) from authmap WHERE uid != '$account->uid' && authname = '$authname'"); + if (db_result($result) > 0) { + $name = module_invoke($module, "info", "name"); + return strtr(t("The %u ID %s is already taken."), array("%u" => ucfirst($name), "%s" => "$authname")); } - } } function user_password($min_length = 6) { @@ -240,7 +236,6 @@ function user_access($string) { } function user_mail($mail, $subject, $message, $header) { - // print "
    subject: $subject
    header: $header
    $message
    "; if (variable_get("smtp_library", "") && file_exists(variable_get("smtp_library", ""))) { include_once variable_get("smtp_library", ""); return user_mail_wrapper($mail, $subject, $message, $header); @@ -321,7 +316,7 @@ function user_help() { reports which help you manage your users. The following pages are available:

    add new user

    -

    If your site blocks is completely private, and doesn't allow registration for +

    If your site is completely private, and doesn't allow registration for any old web user (see Settings for this feature), then you'll need to add new users manually. This web page allows any administrator to register a new user.

    @@ -433,8 +428,13 @@ function user_help() { } ?>


    - User Preferences

    -

    Coming soonish.

    + User Preferences and Profile +

    Drupal comes with a set of user preferences and profile which a user may edit by + clicking on the user account link. Of course, a user must be logged into reach those pages. + There, users will find a page for changing their preferred timezone, language, username, email address, password, theme, signature, homepage, and distributed authentication names. + Changes made here take effect immediately. Also, administrators may make profile and preferences changes in the Admin Center on behalf of their users.

    +

    Module developers are provided several hooks for adding custom fields to the user view/edit pages. These hooks are described in the Developer section of the Drupal Handbook. For an example, see the jabber_user() function in /modules/jabber.module. +

    ". t("Password") .":

    \n"; $output .= "". t("Remember me") ."
    \n"; $output .= "
    \n"; - if (variable_get("account_register", 1)) $output .= " ". t("REGISTER") ."\n"; - $output .= "\n"; $output .= "\n"; + if (variable_get("account_register", 1)) { + $output .= "» ". t("Register") ."\n"; + } + $output .= "
    » " . t("New password") . "
    "; + $output .= "\n"; + $block[1]["content"] = $output; } @@ -513,7 +517,7 @@ function user_link($type) { } if ($type == "menu.settings") { - $links[] = "". t("account settings") .""; + $links[] = "". t("edit account") .""; } if ($type == "menu.misc") { @@ -553,20 +557,25 @@ function user_xmlrpc() { /*** Authentication methods ************************************************/ -function user_get_authmaps($account = NULL, $authname = NULL) { +function user_get_authname($account, $module) { /* - ** Accepts an user object, $account, or an DA name and returns an - ** associtive array of modules and DA names. + ** Called by authentication modules in order to edit/view their authmap information. */ - if (!$account) { //called at external login - $result = db_query("SELECT authname, module FROM authmap WHERE authname = '$authname'"); - } - else { //called from user_edit, user_view,, admin_user_edit - $result = db_query("SELECT authname, module FROM authmap WHERE uid = '$account->uid'"); - } + $result = db_query("SELECT authname FROM authmap WHERE uid = '$account->uid' && module = '$module'"); + return db_result($result); +} + +function user_get_authmaps($authname = NULL) { + + /* + ** Accepts an user object, $account, or an DA name and returns an + ** associtive array of modules and DA names. Called at external login. + */ + + $result = db_query("SELECT authname, module FROM authmap WHERE authname = '$authname'"); if (db_num_rows($result) > 0) { while ($authmap = db_fetch_object($result)) { $authmaps[$authmap->module] = $authmap->authname; @@ -624,7 +633,7 @@ function user_help_da() { on logging into %s in the same manner, and he will always be logged into the same account.

    "; - $output = sprintf(t($output), $site, $site, $site, $site, $site, $site); + $output = strtr(t($output), array("%s" => $site)); foreach (module_list() as $module) { if (module_hook($module, "auth")) { @@ -659,7 +668,7 @@ function user_login($edit = array()) { } if (user_deny("user", $edit["name"])) { - $error = sprintf(t("The name '%s' has been denied access."), $edit["name"]); + $error = strtr(t("The name '%s' has been denied access."), array("%s" => $edit["name"])); } else if ($edit["name"] && $edit["pass"]) { @@ -687,13 +696,13 @@ function user_login($edit = array()) { ** When possible, determine corrosponding external auth source. Invoke source, and login user if successful: */ - if (!$user && $server && $result = user_get_authmaps("", "$name@$server")) { + if (!$user && $server && $result = user_get_authmaps("$name@$server")) { if (module_invoke(key($result), "auth", $name, $pass, $server)) { $user = user_external_load("$name@$server"); watchdog("user", "external load: $name@$server, module: " . key($result)); } else { - $error = sprintf(t("Invalid password for %s."), "$name@$server"); + $error = strtr(t("Invalid password for %s."), array("%s" => "$name@$server")); } } @@ -746,7 +755,7 @@ function user_login($edit = array()) { } else { if (!$error) { - $error = sprintf(t("Sorry. Unrecognized username or password. Have you %sforgotten your password%s?"),"",""); + $error = sprintf(t("Sorry. Unrecognized username or password. Have you %sforgotten your password%s?"), "", ""); } if ($server) { watchdog("user", "failed login for '$name@$server': $error"); @@ -769,9 +778,12 @@ function user_login($edit = array()) { ** Display login form: */ - $output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, sprintf(t("Enter your %s username, or an ID from one of our affiliates: %s."), variable_get("site_name", "local"), implode(", ", user_auth_help_links()))); + $output .= form_textfield(t("Username"), "name", $edit["name"], 20, 64, strtr(t("Enter your %s username, or an ID from one of our affiliates: %a."), array("%s" => variable_get("site_name", "local"), "%a" => implode(", ", user_auth_help_links())))); $output .= form_password(t("Password"), "pass", $pass, 20, 64, t("Enter the password that accompanies your username.")); + $output .= form_checkbox(t("Remember me"), "remember_me", 1, 0, 0); $output .= form_submit(t("Log in")); + $output .= "

    » " . t("E-mail new password") . "
    "; + $output .= "» " . t("Create new account") . "

    "; return form($output); } @@ -801,12 +813,12 @@ function user_logout() { function user_pass($edit = array()) { if ($edit["name"]) { - $account = db_fetch_object(db_query("SELECT uid FROM users WHERE name = '". check_input($edit["name"]) . "'")); - if (!$account) $error = sprintf(t("Sorry. The username %s is not recognized."), $edit["name"]); - } + $account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE name = '". check_input($edit["name"]) . "'")); + if (!$account) $error = strtr(t("Sorry. The username %s is not recognized."), array("%s" => $edit["name"])); + } else if ($edit["mail"]) { - $account = db_fetch_object(db_query("SELECT uid FROM users WHERE mail = '". check_input($edit["mail"]) ."'")); - if (!$account) $error = sprintf(t("Sorry. The e-mail address %s is not recognized."), $edit["mail"]); + $account = db_fetch_object(db_query("SELECT uid, name, mail FROM users WHERE mail = '". check_input($edit["mail"]) ."'")); + if (!$account) $error = strtr(t("Sorry. The e-mail address %s is not recognized."), array("%s" => $edit["mail"])); } if ($account) { @@ -823,14 +835,19 @@ function user_pass($edit = array()) { ** Mail new password: */ - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nyou requested us to e-mail you a new password for your account at %s. You can now login using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + global $HTTP_HOST; + $variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => $HTTP_HOST, "%mailto" => $account->mail); + $subject = strtr(variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), $variables); + $body = strtr(variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); + $headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"; + user_mail($account->mail, $subject, $body, $headers); - watchdog("user", "mail password: '". $edit["name"] ."' <". $edit["mail"] .">"); + watchdog("user", "mail password: '". $account->name ."' <". $account->mail .">"); return t("Your password and further instructions have been sent to your e-mail address."); } else { - + // Display error message if necessary. if ($error) { $output .= "

    ". check_output($error) ."

    "; @@ -840,16 +857,27 @@ function user_pass($edit = array()) { ** Display form: */ - $output .= sprintf(t("%sEnter your username %sor%s your email address.%s"), "

    ", "", "", "

    "); + $output .= "

    ". sprintf(t("Enter your username %sor%s your email address."), "", "") ."

    "; $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64); $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64); $output .= form_submit(t("E-mail new password")); + $output .= "

    » " . t("Log in") . "
    "; + $output .= "» " . t("Create new account") . "

    "; return form($output); } } function user_register($edit = array()) { + global $user; + + /* + ** If we are already logged on, go to the user page instead. + */ + + if ($user->uid) { + drupal_goto("module.php?mod=user&op=edit"); + } if ($edit["name"] && $edit["mail"]) { if ($error = user_validate_name($edit["name"])) { @@ -859,16 +887,16 @@ function user_register($edit = array()) { // do nothing } else if (user_deny("user", $edit["name"])) { - $error = sprintf(t("The name '%s' has been denied access."), $edit["name"]); + $error = strtr(t("The name '%s' has been denied access."), array("%s" => $edit["name"])); } else if (user_deny("mail", $edit["mail"])) { - $error = sprintf(t("The e-mail address '%s' has been denied access."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' has been denied access."), array("%s" => $edit["mail"])); } else if (db_num_rows(db_query("SELECT name FROM users WHERE LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if (db_num_rows(db_query("SELECT mail FROM users WHERE LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else if (variable_get("user_register", 1) == 0) { $error = t("Public registrations have been disabled by the site administrator."); @@ -899,52 +927,64 @@ function user_register($edit = array()) { $from = variable_get("site_mail", ini_get("sendmail_from")); $pass = user_password(); + // create new user account, noting whether administrator approval is required if (variable_get("user_register", 1) == 1) { - /* - ** Create new user account, no administrator approval required: - */ - - user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 1), $data)); - - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nsomoneone signed up for a user account on %s and supplied this e-mail address as their contact. If it wasn't you, just ignore this mail but if it was you, you can now login using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 1), $data)); } else { - /* - ** Create new user account, administrator approval required: - */ - - user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 0), $data)); - - user_mail($edit["mail"], t("user account details"), sprintf(t("%s,\n\nsomoneone signed up for a user account on %s and supplied this e-mail address as their contact. If it wasn't you, just ignore this mail but if it was you, you can login as soon a site administrator approved your request using the following username and password:\n\n username: %s\n password: %s\n\n\n-- %s team"), $edit["name"], variable_get("site_name", "drupal"), $edit["name"], $pass, variable_get("site_name", "drupal")), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + $user = user_save("", array_merge(array("name" => $edit["name"], "pass" => $pass, "init" => $edit["mail"], "mail" => $edit["mail"], "role" => "authenticated user", "status" => 0), $data)); } - return t("Your password and further instructions have been sent to your e-mail address."); + $variables = array("%username" => $edit["name"], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => path_uri(), "%uri_brief" => $HTTP_HOST, "%mailto" => $edit["mail"]); + + //the first user may login immediately, and receives a customized welcome email. + if ($user->uid == 1) { + user_mail($edit["mail"], strtr(t("drupal user account details for %s"), array("%s" => $edit["name"])), strtr(t("%username,\n\nYou may now login to %uri using the following username and password:\n\n username: %username\n password: %password\n\nAfter logging in, you may wish to visit the following pages:\n\nAdministration: %uriadmin.php\nEdit user account: %utimodule.php?mod=user&op=edit\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + // This should not be t()'ed. No point as its only shown once in the sites lifetime, and it would be bad to store the password + $output .= "

    Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via email, so please configure your email settings using the Administration pages.

    Your password is $pass. You may change your password on the next page.

    Please login below.

    "; + $output .= form_hidden("name", $user->name); + $output .= form_hidden("pass", $pass); + $output .= form_submit(t("Log in")); + return form($output); + } + else { + global $HTTP_HOST; + $subject = strtr(variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), $variables); + $body = strtr(variable_get("user_mail_welcome_body", t("%username,\n\nnThank you for registering at %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %urimodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), $variables); + user_mail($edit["mail"], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); + return t("Your password and further instructions have been sent to your e-mail address."); + } } else { - if ($error) { $output .= "

    ". check_output($error) ."

    "; } + } - $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); - $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("Your e-mail address: a password and instructions will be sent to this e-mail address so make sure it is accurate.")); - foreach (module_list() as $module) { - if (module_hook($module, "user")) { - $output .= module_invoke($module, "user", "register_form", $edit, $user); - } + // display the registration form + $affiliates = user_auth_help_links(); + if (array_count_values($affiliates) > 1) { + $affiliates = implode(", ", $affiliates); + $output .= "

    " . strtr(t("Note: If you have an account with one of our affiliates (%s), you may login now instead of registering."), array("%s" => $affiliates)) ."

    "; + } + $output .= form_textfield(t("Username"), "name", $edit["name"], 30, 64, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("E-mail address"), "mail", $edit["mail"], 30, 64, t("A password and instructions will be sent to this e-mail address, so make sure it is accurate.")); + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $output .= module_invoke($module, "user", "register_form", $edit, $user); } - $output .= form_submit(t("Create new account")); - - return form($output); } + $output .= form_submit(t("Create new account")); + + return form($output); } function user_delete() { global $edit, $user; - + if ($edit["confirm"]) { - watchdog(user,"$user->name deactivated her own account."); + watchdog(user,"$user->name deactivated her own account."); db_query("UPDATE users SET mail = 'deleted', status='0' WHERE uid = '$user->uid'"); $output .= t("Your account has been deactivated."); } @@ -958,7 +998,7 @@ function user_delete() { } function user_edit($edit = array()) { - global $HTTP_HOST, $themes, $user, $languages; + global $themes, $user, $languages; if ($user->uid) { if ($edit["name"]) { @@ -969,13 +1009,10 @@ function user_edit($edit = array()) { // do nothing } else if (db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$user->uid' AND LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if ($edit["mail"] && db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$user->uid' AND LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); - } - else if ($error = user_validate_authmaps($user, $edit)) { - // do nothing + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else if ($user->uid) { foreach (module_list() as $module) { @@ -1014,7 +1051,7 @@ function user_edit($edit = array()) { $user = user_save($user, array_merge($edit, $data)); - $output .= sprintf(t("Your user information changes have been saved."), "

    ", "

    "); + $output .= t("Your user information changes have been saved."); } } } @@ -1026,13 +1063,6 @@ function user_edit($edit = array()) { $output .= form_textfield(t("Username"), "name", $user->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); $output .= form_textfield(t("E-mail address"), "mail", $user->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); - $result = user_get_authmaps($user); - foreach (module_list() as $module) { - if ($module != "drupal" && module_hook($module, "auth")) { - $output .= form_textfield(module_invoke($module, "info", "name") . " ID", "authname_" . $module, $result[$module], 30, 55, sprintf(t("You may login to %s using a valid %s."), variable_get("site_name", "this web site"), "". module_invoke($module, "info", "name") ." ID", "")); - } - } - foreach (module_list() as $module) { if (module_hook($module, "user")) { $output .= module_invoke($module, "user", "edit_form", $edit, $user); @@ -1040,7 +1070,9 @@ function user_edit($edit = array()) { } $output .= form_textfield(t("Homepage"), "homepage", $user->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\".")); - foreach ($themes as $key => $value) $options .= "\n"; + foreach (theme_list() as $key => $value) { + $options .= "$value[type]\n"; + } $output .= form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; $output .= form_select(t("Timezone"), "timezone", $user->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); @@ -1048,7 +1080,7 @@ function user_edit($edit = array()) { $output .= form_textarea(t("Signature"), "signature", $user->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."
    ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); $output .= form_item(t("Password"), " ", t("Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.")); $output .= form_submit(t("Save user information")); - + $output = form($output); } @@ -1064,7 +1096,7 @@ function user_menu() { } function user_view($uid = 0) { - global $theme, $user, $HTTP_HOST; + global $theme, $user; if (!$uid) { $uid = $user->uid; @@ -1073,17 +1105,6 @@ function user_view($uid = 0) { if ($user->uid && $user->uid == $uid) { $output .= form_item(t("Name"), check_output("$user->name ($user->init)")); $output .= form_item(t("E-mail address"), check_output($user->mail)); - $result = user_get_authmaps($user); - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - if ($module != "drupal") { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($result[$module])); - } - else { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($user->name) . "@$HTTP_HOST"); - } - } - } foreach (module_list() as $module) { if (module_hook($module, "user")) { @@ -1134,8 +1155,9 @@ function user_page() { break; case t("Create new account"): case "register": + $output = user_register($edit); $theme->header(); - $theme->box(t("Create new account"), user_register($edit)); + $theme->box(t("Create new account"), $output); $theme->footer(); break; case t("Log in"): @@ -1145,7 +1167,7 @@ function user_page() { $theme->box(t("Log in"), $output); $theme->footer(); break; - case t("Delete account"): + case t("Delete account"): case t("delete"); $output = user_delete(); $theme->header(); @@ -1153,7 +1175,7 @@ function user_page() { $theme->box(t("Delete account"), $output); $theme->footer(); break; - case t("Save user information"): + case t("Save user information"): case "edit": $output = user_edit($edit); $theme->header(); @@ -1184,6 +1206,10 @@ function user_page() { function user_conf_options() { $output .= form_select("Public registrations", "user_register", variable_get("user_register", 1), array("Only site administrators can create new user accounts.", "Visitors can create accounts and no administrator approval is required.", "Visitors can create accounts but administrator approval is required.")); $output .= form_textfield("Password words", "user_password", variable_get("user_password", "foo,bar,guy,neo,tux,moo,sun,asm,dot,god,axe,geek,nerd,fish,hack,star,mice,warp,moon,hero,cola,girl,fish,java,perl,boss,dark,sith,jedi,drop,mojo"), 55, 256, "A comma separated list of short words that can be concatenated to generate human-readable passwords."); + $output .= form_textfield("Welcome e-mail subject", "user_mail_welcome_subject", variable_get("user_mail_welcome_subject", t("User account details for %username at %site")), 80, 180, "Customize the Subject of your welcome email, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textarea("Welcome e-mail body", "user_mail_welcome_body", variable_get("user_mail_welcome_body", t("%username,\n\nnThank you for registering at %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the Body of the welcome email, which is sent to new members upon registering. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textfield("Forgotten password e-mail subject", "user_mail_pass_subject", variable_get("user_mail_pass_subject", t("Replacement login information for %username at %site")), 80, 180, "Customize the Subject of your Forgotten Password email. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); + $output .= form_textarea("Forgotten password e-mail body", "user_mail_pass_body", variable_get("user_mail_pass_body", t("%username,\n\nHere is your new password for %site. You may now login to %urlmodule.php?mod=login using the following username and password:\n\nusername: %username\npassword: %password\n\nAfter logging in, you may wish to change your password at %pathmodule.php?mod=user&op=edit\n\nYour new %site membership also enables to you to login to other Drupal powered web sites (e.g. http://www.drop.org) without registering. Just use the following Drupal ID and password:\n\nDrupal ID: %username@%uri_brief\npassword: %password\n\n\n-- %site team")), 70, 10, "Customize the Body of the Forgotten Password email. Available variables are: %username, %site, %password, %uri, %uri_brief, %mailto"); return $output; } @@ -1224,10 +1250,10 @@ function user_admin_create($edit = array()) { // do nothing } else if (db_num_rows(db_query("SELECT name FROM users WHERE LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { - $error = sprintf(t("The name '%s' is already taken."), $edit["name"]); + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); } else if (db_num_rows(db_query("SELECT mail FROM users WHERE LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { - $error = sprintf(t("The e-mail address '%s' is already taken."), $edit["mail"]); + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); } else { $success = 1; @@ -1317,10 +1343,12 @@ function user_admin_access($edit = array()) { } -function user_roles() { +function user_roles($membersonly = 0) { $result = db_query("SELECT * FROM role ORDER BY name"); while ($role = db_fetch_object($result)) { - $roles[$role->name] = $role->name; + if (!$membersonly || ($membersonly && $role->name != "anonymous user")) { + $roles[$role->name] = $role->name; + } } return $roles; } @@ -1431,12 +1459,43 @@ function user_admin_role($edit = array()) { } function user_admin_edit($edit = array()) { - global $op, $id, $HTTP_HOST; + global $op, $id, $themes; if ($account = user_load(array("uid" => $id))) { if ($op == "Save account") { - $account = user_save($account, $edit); + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $result = module_invoke($module, "user", "edit_validate", $edit, $account); + } + if (is_array($result)) { + $data = array_merge($data, $result); + } + elseif (is_string($result)) { + $error = $result; + break; + } + } + // TODO: this display/edit/validate should be moved to a new profile.module implementing the _user hooks + if ($error = user_validate_name($edit["name"])) { + // do nothing + } + else if ($error = user_validate_mail($edit["mail"])) { + // do nothing + } + else if (db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$account->uid' AND LOWER(name) = LOWER('". $edit["name"] ."')")) > 0) { + $error = strtr(t("The name '%s' is already taken."), array("%s" => $edit["name"])); + } + else if ($edit["mail"] && db_num_rows(db_query("SELECT uid FROM users WHERE uid != '$account->uid' AND LOWER(mail) = LOWER('". $edit["mail"] ."')")) > 0) { + $error = strtr(t("The e-mail address '%s' is already taken."), array("%s" => $edit["mail"])); + } + if (!$error) { + $account = user_save($account, $edit); + $output .= "

    " . t("Your user information changes have been saved.") . "

    "; + } + else { + $output .= "

    ". check_output($error) ."

    "; + } } else if ($op == "Delete account") { if ($edit["status"] == 0) { @@ -1449,37 +1508,36 @@ function user_admin_edit($edit = array()) { } } - if (!$output) { + /* + ** Display user form: + */ + + $output .= form_item("User ID", check_output($account->uid)); + $output .= form_textfield(t("Username"), "name", $account->name, 30, 55, t("Your full name or your prefered username: only letters, numbers and spaces are allowed.")); + $output .= form_textfield(t("E-mail address"), "mail", $account->mail, 30, 55, t("Insert a valid e-mail address. All e-mails from the system will be sent to this address. The e-mail address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by e-mail.")); - /* - ** Display user form: - */ + foreach (module_list() as $module) { + if (module_hook($module, "user")) { + $output .= module_invoke($module, "user", "edit_form", $edit, $account); + } + } - $output .= form_item("User ID", check_output($account->uid)); - $output .= form_item(t("Name"), check_output("$account->name ($account->init)")); - $output .= form_item(t("E-mail address"), format_email($account->mail)); - $result = user_get_authmaps($account); + $output .= form_textfield(t("Homepage"), "homepage", $account->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\".")); + foreach ($themes as $key => $value) $options .= "\n"; + $output .= form_item(t("Theme"), "", t("Selecting a different theme will change the look and feel of the site.")); + for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")"; + $output .= form_select(t("Timezone"), "timezone", $account->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate.")); + $output .= form_select(t("Language"), "language", $account->language, $languages, t("Selecting a different language will change the language of the site.")); + $output .= form_textarea(t("Signature"), "signature", $account->signature, 70, 3, t("Your signature will be publicly displayed at the end of your comments.") ."
    ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", ""))); - foreach (module_list() as $module) { - if (module_hook($module, "auth")) { - if ($module != "drupal") { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($result[$module])); - } - else { - $output .= form_item(module_invoke($module, "info", "name") . " ID", check_output($account->name) ."@$HTTP_HOST"); - } - } - } + $output .= form_select("Status", "status", $account->status, array("blocked", "active")); + $output .= form_select("Role", "role", $account->role, user_roles(1)); - $output .= form_item(t("Theme"), check_output("$account->theme")); - $output .= form_select("Status", "status", $account->status, array("blocked", "active")); - $output .= form_select("Role", "role", $account->role, user_roles()); + $output .= form_submit("Save account"); + $output .= form_submit("Delete account"); - $output .= form_submit("Save account"); - $output .= form_submit("Delete account"); + $output = form($output); - $output = form($output); - } } else { $output = "no such user"; @@ -1491,7 +1549,10 @@ function user_admin_edit($edit = array()) { function user_admin_account() { global $query; - $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "non-regular users")); + $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users")); + foreach (user_roles(1) as $key => $value) { + $queries[] = array("WHERE role = '$value' ORDER BY uid DESC", $value . "s"); + } $result = db_query("SELECT uid, name, timestamp FROM users ". $queries[$query ? $query : 0][0] ." LIMIT 50"); @@ -1520,7 +1581,6 @@ function admin_access_init() { if (!$role) db_query("INSERT INTO role (name) VALUES ('authenticated user')"); } - function user_admin() { global $edit, $id, $op, $user; @@ -1543,7 +1603,6 @@ function user_admin() { $links[] = "user permissions"; $links[] = "search account"; $links[] = "settings"; - // $links[] = "auth modules"; $links[] = "help"; print "". implode(" · ", $links) ."
    "; diff --git a/themes/example/example.theme b/themes/example/example.theme index 90c22e5cd629099b7ccc8eec7480fceaf8439b19..aca89d1ae8ea7f0217210a52272513b52a466ff3 100644 --- a/themes/example/example.theme +++ b/themes/example/example.theme @@ -1,8 +1,16 @@ \ No newline at end of file diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme index b0562c068b60463ee7314f86ba1df720bed9c595..786e06646ca6991bd44b17a851bb1bb910757fdb 100644 --- a/themes/goofy/goofy.theme +++ b/themes/goofy/goofy.theme @@ -17,6 +17,14 @@ class Theme_goofy extends BaseTheme { var $foreground = "#000000"; var $background = "#FFFFFF"; + function system($field) { + $system["name"] = "Goofy"; + $system["author"] = "Steven Wittens"; + $system["description"] = "Internet explorer, Netscape, Opera"; + + return $system[$field]; + } + function header($title = "") { ?> diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme index bfed08274114347a2f777db478f9ced56d239a1b..4978acaaf407f72539c341aba6a0bd336ee8f8b9 100644 --- a/themes/marvin/marvin.theme +++ b/themes/marvin/marvin.theme @@ -18,6 +18,14 @@ class Theme_marvin extends BaseTheme { var $foreground = "#000000"; var $background = "#EAEAEA"; + function system($field) { + $system["name"] = "Marvin"; + $system["author"] = "Dries Buytaerts"; + $system["description"] = "Internet explorer, Netscape, Opera"; + + return $system[$field]; + } + function header($title = "") { global $HTTP_USER_AGENT; ?> diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme index 78f4b3f46e4e9cedf070efaab1f296138b2f9bab..2ffaf7e29edb99170f9e1c500c803a48588c48d2 100644 --- a/themes/unconed/unconed.theme +++ b/themes/unconed/unconed.theme @@ -37,6 +37,14 @@ class Theme_unconed extends BaseTheme { var $bgcolor3 = "#D7D7D7"; var $fgcolor3 = "#000000"; + function system($field) { + $system["name"] = "UnConeD"; + $system["author"] = "Steven Wittens"; + $system["description"] = "Internet explorer, Netscape, Opera"; + + return $system[$field]; + } + function header($title = "") { srand((double)microtime()*1000000); ?> diff --git a/update.php b/update.php index 4b51f010d51e4557c2e173a47e36c76f76af5460..838f09c1280cd0ade921effd215122a197c6f8c0 100644 --- a/update.php +++ b/update.php @@ -26,7 +26,7 @@ // Define the various updates in an array("date : comment" => "function"); $mysql_updates = array( "2001-10-10" => "update_1", - "2001-10-12 : Pearification" => "update_2", + "2001-10-12 : pearification" => "update_2", "2001-10-14" => "update_3", "2001-10-16" => "update_4", "2001-10-17" => "update_5", @@ -34,7 +34,7 @@ "2001-11-01" => "update_7", "2001-11-02" => "update_8", "2001-11-04" => "update_9", - "2001-11-17: distributed authentication" => "update_10", + "2001-11-17 : distributed authentication" => "update_10", "2001-12-01" => "update_11", "2001-12-06" => "update_12", "2001-12-09" => "update_13", @@ -48,7 +48,8 @@ "2002-01-30" => "update_21", "2002-02-19" => "update_22", "2002-03-05" => "update_23", - "2002-04-08" => "update_24" + "2002-04-08" => "update_24", + "2002-03-11 : modules/themes web config" => "update_25" ); // Update functions @@ -345,6 +346,14 @@ function update_24() { update_sql("UPDATE site SET threshold = '50';"); } +function update_25() { + update_sql("CREATE TABLE `system` (filename varchar(255) NOT NULL default '', name varchar(255) NOT NULL default '', type varchar(255) NOT NULL default '', description varchar(255) NOT NULL default '', status int(2) NOT NULL default '0', PRIMARY KEY (filename));"); + update_sql("REPLACE system SET name = 'drupal', type = 'module', filename = 'drupal.module', status = '1';"); + update_sql("REPLACE system SET name = 'system', type = 'module', filename = 'system.module', status = '1';"); + update_sql("REPLACE system SET name = 'user', type = 'module', filename = 'user.module', status = '1';"); + update_sql("REPLACE system SET name = 'watchdog', type = 'module', filename = 'watchdog.module', status = '1';"); +} + /* ** System functions */