Commit f137b269 authored by Dries's avatar Dries

- Patch 4902 by Goba:

  + only adds an optional parameter to url() and l(), so individual links
    can be set to be absolute
  + modifies drupal_goto() to accept the parameters of url() without the
    $absolute parameter, so cleaner invocations can be used
  + rework of some code in node_feed, making it much better to look at
    (the current code uses foreach with an immediate brake to get the first
    key of the associative array, geeeeez)
  + added xml:base to the rss tag generated by node_feed()
  + set all user mail URLs to be absolute
  + fix a small fragmented URL in user.module
parent d795565c
...@@ -209,15 +209,17 @@ function drupal_get_headers() { ...@@ -209,15 +209,17 @@ function drupal_get_headers() {
* *
* @note This function ends the request. * @note This function ends the request.
* *
* @param $url A string containing a fully qualified URI. * @param $url A Drupal URL
* @param $query Query string component
* @param $fragment Fragment identifier
*/ */
function drupal_goto($url) { function drupal_goto($url = NULL, $query = NULL, $fragment = NULL) {
/* /*
** Translate & to simply & ** Translate & to simply & in the absolute URL
*/ */
$url = str_replace("&", "&", $url); $url = str_replace("&", "&", url($url, $query, $fragment, TRUE));
/* /*
** It is advised to use "drupal_goto()" instead of PHP's "header()" as ** It is advised to use "drupal_goto()" instead of PHP's "header()" as
...@@ -1028,7 +1030,7 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $ ...@@ -1028,7 +1030,7 @@ function form_weight($title = NULL, $name = "weight", $value = 0, $delta = 10, $
} }
/* @} */ /* @} */
function url($url = NULL, $query = NULL, $fragment = NULL) { function url($url = NULL, $query = NULL, $fragment = NULL, $absolute = NULL) {
global $base_url; global $base_url;
static $script; static $script;
...@@ -1050,39 +1052,41 @@ function url($url = NULL, $query = NULL, $fragment = NULL) { ...@@ -1050,39 +1052,41 @@ function url($url = NULL, $query = NULL, $fragment = NULL) {
$fragment = "#$fragment"; $fragment = "#$fragment";
} }
$base = ($absolute ? $base_url . '/' : '');
if (variable_get("clean_url", "0") == "0") { if (variable_get("clean_url", "0") == "0") {
if (isset($url)) { if (isset($url)) {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?q=$url&$query$fragment"; return "$base$script?q=$url&$query$fragment";
} }
else { else {
return "$base_url/$script?q=$url$fragment"; return "$base$script?q=$url$fragment";
} }
} }
else { else {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?$query$fragment"; return "$base$script?$query$fragment";
} }
else { else {
return "$base_url/$fragment"; return "$base$fragment";
} }
} }
} }
else { else {
if (isset($url)) { if (isset($url)) {
if (isset($query)) { if (isset($query)) {
return "$base_url/$url?$query$fragment"; return "$base$url?$query$fragment";
} }
else { else {
return "$base_url/$url$fragment"; return "$base$url$fragment";
} }
} }
else { else {
if (isset($query)) { if (isset($query)) {
return "$base_url/$script?$query$fragment"; return "$base$script?$query$fragment";
} }
else { else {
return "$base_url/$fragment"; return "$base$fragment";
} }
} }
} }
...@@ -1098,7 +1102,7 @@ function drupal_attributes($attributes = NULL) { ...@@ -1098,7 +1102,7 @@ function drupal_attributes($attributes = NULL) {
} }
} }
function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL) { function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = NULL) {
if ($url == $_GET['q']) { if ($url == $_GET['q']) {
if (isset($attributes['class'])) { if (isset($attributes['class'])) {
$attributes['class'] .= ' active'; $attributes['class'] .= ' active';
...@@ -1107,7 +1111,7 @@ function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL) ...@@ -1107,7 +1111,7 @@ function l($text, $url, $attributes = array(), $query = NULL, $fragment = NULL)
$attributes['class'] = 'active'; $attributes['class'] = 'active';
} }
} }
return "<a href=\"". url($url, $query, $fragment) ."\"". drupal_attributes($attributes) .">$text</a>"; return "<a href=\"". url($url, $query, $fragment, $absolute) ."\"". drupal_attributes($attributes) .">$text</a>";
} }
function field_get($string, $name) { function field_get($string, $name) {
......
...@@ -837,7 +837,7 @@ function comment_page() { ...@@ -837,7 +837,7 @@ function comment_page() {
case t("Moderate comments"): case t("Moderate comments"):
case t("Moderate comment"): case t("Moderate comment"):
comment_moderate($edit); comment_moderate($edit);
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
break; break;
case "reply": case "reply":
print theme("page", comment_reply(check_query(arg(3)), check_query(arg(2))), t("Add new comment")); print theme("page", comment_reply(check_query(arg(3)), check_query(arg(2))), t("Add new comment"));
...@@ -851,7 +851,7 @@ function comment_page() { ...@@ -851,7 +851,7 @@ function comment_page() {
print theme("page", $error_body, $error_title); print theme("page", $error_body, $error_title);
} }
else { else {
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
} }
break; break;
case t("Save settings"): case t("Save settings"):
...@@ -861,7 +861,7 @@ function comment_page() { ...@@ -861,7 +861,7 @@ function comment_page() {
$comments_per_page = $_POST["comments_per_page"]; $comments_per_page = $_POST["comments_per_page"];
comment_save_settings(check_query($mode), check_query($order), check_query($threshold), check_query($comments_per_page)); comment_save_settings(check_query($mode), check_query($order), check_query($threshold), check_query($comments_per_page));
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
break; break;
} }
} }
......
...@@ -837,7 +837,7 @@ function comment_page() { ...@@ -837,7 +837,7 @@ function comment_page() {
case t("Moderate comments"): case t("Moderate comments"):
case t("Moderate comment"): case t("Moderate comment"):
comment_moderate($edit); comment_moderate($edit);
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
break; break;
case "reply": case "reply":
print theme("page", comment_reply(check_query(arg(3)), check_query(arg(2))), t("Add new comment")); print theme("page", comment_reply(check_query(arg(3)), check_query(arg(2))), t("Add new comment"));
...@@ -851,7 +851,7 @@ function comment_page() { ...@@ -851,7 +851,7 @@ function comment_page() {
print theme("page", $error_body, $error_title); print theme("page", $error_body, $error_title);
} }
else { else {
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
} }
break; break;
case t("Save settings"): case t("Save settings"):
...@@ -861,7 +861,7 @@ function comment_page() { ...@@ -861,7 +861,7 @@ function comment_page() {
$comments_per_page = $_POST["comments_per_page"]; $comments_per_page = $_POST["comments_per_page"];
comment_save_settings(check_query($mode), check_query($order), check_query($threshold), check_query($comments_per_page)); comment_save_settings(check_query($mode), check_query($order), check_query($threshold), check_query($comments_per_page));
drupal_goto(url(comment_referer_load())); drupal_goto(comment_referer_load());
break; break;
} }
} }
......
...@@ -402,7 +402,7 @@ function forum_page() { ...@@ -402,7 +402,7 @@ function forum_page() {
if (arg(2) == 'new') { if (arg(2) == 'new') {
if ($nid = _forum_new($tid)) { if ($nid = _forum_new($tid)) {
drupal_goto(url("node/view/$nid")); drupal_goto("node/view/$nid");
} }
} }
......
...@@ -402,7 +402,7 @@ function forum_page() { ...@@ -402,7 +402,7 @@ function forum_page() {
if (arg(2) == 'new') { if (arg(2) == 'new') {
if ($nid = _forum_new($tid)) { if ($nid = _forum_new($tid)) {
drupal_goto(url("node/view/$nid")); drupal_goto("node/view/$nid");
} }
} }
......
...@@ -1011,19 +1011,22 @@ function node_feed($nodes = 0, $channel = array()) { ...@@ -1011,19 +1011,22 @@ function node_feed($nodes = 0, $channel = array()) {
*/ */
$item = node_load(array('nid' => $node->nid)); $item = node_load(array('nid' => $node->nid));
$link = url("node/view/$node->nid"); $link = url("node/view/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed))); $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed)));
} }
$output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $channel_defaults = array(
'version' => '0.92',
'title' => variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', ''),
'link' => $base_url,
'description' => variable_get('site_mission', ''),
'language' => (($key = reset(array_keys($languages))) ? $key : 'en')
);
$channel = array_merge($channel_defaults, $channel);
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
if (!$channel['version']) $channel['version'] = '0.92'; $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $channel["link"] . "\">\n";
if (!$channel['title']) $channel['title'] = variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', '');
if (!$channel['link']) $channel['link'] = $base_url;
if (!$channel['description']) $channel['description'] = variable_get('site_mission', '');
foreach ($languages as $key => $value) break;
if (!$channel['language']) $channel['language'] = $key ? $key : 'en';
$output .= "<rss version=\"". $channel["version"] . "\">\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']); $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n"; $output .= "</rss>\n";
......
...@@ -1011,19 +1011,22 @@ function node_feed($nodes = 0, $channel = array()) { ...@@ -1011,19 +1011,22 @@ function node_feed($nodes = 0, $channel = array()) {
*/ */
$item = node_load(array('nid' => $node->nid)); $item = node_load(array('nid' => $node->nid));
$link = url("node/view/$node->nid"); $link = url("node/view/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed))); $items .= format_rss_item($item->title, $link, ($item->teaser ? $item->teaser : $item->body), array('pubDate' => date('r', $item->changed)));
} }
$output .= "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; $channel_defaults = array(
'version' => '0.92',
'title' => variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', ''),
'link' => $base_url,
'description' => variable_get('site_mission', ''),
'language' => (($key = reset(array_keys($languages))) ? $key : 'en')
);
$channel = array_merge($channel_defaults, $channel);
$output = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
$output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n"; $output .= "<!DOCTYPE rss [<!ENTITY % HTMLlat1 PUBLIC \"-//W3C//ENTITIES Latin 1 for XHTML//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent\">]>\n";
if (!$channel['version']) $channel['version'] = '0.92'; $output .= "<rss version=\"". $channel["version"] . "\" xml:base=\"". $channel["link"] . "\">\n";
if (!$channel['title']) $channel['title'] = variable_get('site_name', 'drupal') .' - '. variable_get('site_slogan', '');
if (!$channel['link']) $channel['link'] = $base_url;
if (!$channel['description']) $channel['description'] = variable_get('site_mission', '');
foreach ($languages as $key => $value) break;
if (!$channel['language']) $channel['language'] = $key ? $key : 'en';
$output .= "<rss version=\"". $channel["version"] . "\">\n";
$output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']); $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
$output .= "</rss>\n"; $output .= "</rss>\n";
......
...@@ -341,7 +341,7 @@ function user_block($op = "list", $delta = 0) { ...@@ -341,7 +341,7 @@ function user_block($op = "list", $delta = 0) {
*/ */
if (empty($edit)) { if (empty($edit)) {
$edit["destination"] = url($_GET["q"]); $edit["destination"] = $_GET["q"];
} }
// NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set. // NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set.
...@@ -527,7 +527,7 @@ function user_login($edit = array(), $msg = "") { ...@@ -527,7 +527,7 @@ function user_login($edit = array(), $msg = "") {
*/ */
if ($user->uid) { if ($user->uid) {
drupal_goto(url('user')); drupal_goto('user');
} }
if (user_deny('user', $edit['name'])) { if (user_deny('user', $edit['name'])) {
...@@ -638,7 +638,7 @@ function user_login($edit = array(), $msg = "") { ...@@ -638,7 +638,7 @@ function user_login($edit = array(), $msg = "") {
*/ */
if (empty($edit)) { if (empty($edit)) {
$edit["destination"] = url($_GET["q"]); $edit["destination"] = $_GET["q"];
} }
$output .= form_hidden("destination", $edit["destination"]); $output .= form_hidden("destination", $edit["destination"]);
...@@ -687,7 +687,7 @@ function user_logout() { ...@@ -687,7 +687,7 @@ function user_logout() {
unset($user); unset($user);
} }
drupal_goto(url()); drupal_goto();
} }
function user_pass($edit = array()) { function user_pass($edit = array()) {
...@@ -716,7 +716,7 @@ function user_pass($edit = array()) { ...@@ -716,7 +716,7 @@ function user_pass($edit = array()) {
** Mail new password: ** Mail new password:
*/ */
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()), '%login_uri' => url('user/login'), '%edit_uri' => url('user/edit')); $variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
$subject = _user_mail_text("pass_subject", $variables); $subject = _user_mail_text("pass_subject", $variables);
$body = _user_mail_text("pass_body", $variables); $body = _user_mail_text("pass_body", $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"; $headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from";
...@@ -764,7 +764,7 @@ function user_register($edit = array()) { ...@@ -764,7 +764,7 @@ function user_register($edit = array()) {
*/ */
if ($user->uid) { if ($user->uid) {
drupal_goto(url("user/edit")); drupal_goto("user/edit");
} }
if (!(is_null($edit['name']) && is_null($edit['mail']))) { if (!(is_null($edit['name']) && is_null($edit['mail']))) {
...@@ -804,14 +804,14 @@ function user_register($edit = array()) { ...@@ -804,14 +804,14 @@ function user_register($edit = array()) {
$account = user_save("", array_merge(array('name' => $edit['name'], 'pass' => $pass, "init" => $edit['mail'], "mail" => $edit['mail'], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data)); $account = user_save("", array_merge(array('name' => $edit['name'], 'pass' => $pass, "init" => $edit['mail'], "mail" => $edit['mail'], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
watchdog('user', "new user: '". $edit['name'] ."' &lt;". $edit['mail'] ."&gt;", l(t("edit user"), "admin/user/edit/$account->uid")); watchdog('user', "new user: '". $edit['name'] ."' &lt;". $edit['mail'] ."&gt;", l(t("edit user"), "admin/user/edit/$account->uid"));
$variables = array("%username" => $edit['name'], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit['mail'], "%date" => format_date(time()), "%login_uri" => url('user/login'), "%edit_uri" => url("user/edit")); $variables = array("%username" => $edit['name'], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit['mail'], "%date" => format_date(time()), "%login_uri" => url('user/login', NULL, NULL, TRUE), "%edit_uri" => url("user/edit", NULL, NULL, TRUE));
//the first user may login immediately, and receives a customized welcome e-mail. //the first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) { if ($account->uid == 1) {
user_mail($edit['mail'], 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\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], 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\n%edit_uri\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 // 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 .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <strong>$pass</strong>. You may change your password on the next page.</p><p>Please login below.</p>"; $output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <strong>$pass</strong>. You may change your password on the next page.</p><p>Please login below.</p>";
$output .= form_hidden("destination", url("user/edit")); $output .= form_hidden("destination", "user/edit");
$output .= form_hidden('name', $account->name); $output .= form_hidden('name', $account->name);
$output .= form_hidden('pass', $pass); $output .= form_hidden('pass', $pass);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
...@@ -836,7 +836,7 @@ function user_register($edit = array()) { ...@@ -836,7 +836,7 @@ function user_register($edit = array()) {
$body = _user_mail_text("approval_body", $variables); $body = _user_mail_text("approval_body", $variables);
user_mail($edit['mail'], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid", NULL, NULL, TRUE))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address."); return t("Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address.");
} }
} }
...@@ -1710,7 +1710,7 @@ function julia_user(\$type, \$edit, &\$user) { ...@@ -1710,7 +1710,7 @@ function julia_user(\$type, \$edit, &\$user) {
return user_save(\$user, array(\"julia_favingredient\" => \$edit[\"julia_favingredient\"])); return user_save(\$user, array(\"julia_favingredient\" => \$edit[\"julia_favingredient\"]));
} }
} }
</pre>", array("%user-role" => url("admin/user/role"), "%user-permission" => url("admin/user/permission"), "%jabber" => "http://www.jabber.org", "%delphiforums" => "http://www.delphiforums.com", "%drupal" => "http://www.drupal.org", "%da-auth" => url("user/help#da"), "%php-sess" => "http://www.php.net/manual/en/ref.session.php", "%user-prefs" => url("user/edit"), "%admin-user" => url("admin/user"), "%da-devel" => "http://www.drupal.org/node/view/316", "%xml" => "http://www.xmlrpc.org", "%http-post" => "http://www.w3.org/Protocols/", "%soap" => "http://www.soapware.org", "%dis-module" => url("admin/system/modules"), "%blogger" => "http://www.blogger.com", "%blogger-source" => "http://cvs.drupal.org/viewcvs.cgi/contributions/modules/authentication/Bloggar/?cvsroot=contrib", "%contrib-cvs" => "http://cvs.drupal.org/viewcvs/contributions/?cvsroot=contrib", "%blogger-api" => "http://plant.blogger.com/API", "%cvs" => "http://cvs.drupal.org/viewcvs.cgi/contributions/README?rev=HEAD&amp;cvsroot=contrib&amp;content-type=text/vnd.viewcvs-markup", "%drupal-lists" => "http://drupal.org/mailing-lists", "%drupal-org" => "http://www.drupal.org", "%registration" => url("user/register"), "%user-acct" => url('user'), "%user-admin" => url("admin/user"), "%profile-module" => "http://cvs.drupal.org/viewcvs/drupal/modules/profile.module")); </pre>", array("%user-role" => url("admin/user/role"), "%user-permission" => url("admin/user/permission"), "%jabber" => "http://www.jabber.org", "%delphiforums" => "http://www.delphiforums.com", "%drupal" => "http://www.drupal.org", "%da-auth" => url("user/help", NULL, 'da'), "%php-sess" => "http://www.php.net/manual/en/ref.session.php", "%user-prefs" => url("user/edit"), "%admin-user" => url("admin/user"), "%da-devel" => "http://www.drupal.org/node/view/316", "%xml" => "http://www.xmlrpc.org", "%http-post" => "http://www.w3.org/Protocols/", "%soap" => "http://www.soapware.org", "%dis-module" => url("admin/system/modules"), "%blogger" => "http://www.blogger.com", "%blogger-source" => "http://cvs.drupal.org/viewcvs.cgi/contributions/modules/authentication/Bloggar/?cvsroot=contrib", "%contrib-cvs" => "http://cvs.drupal.org/viewcvs/contributions/?cvsroot=contrib", "%blogger-api" => "http://plant.blogger.com/API", "%cvs" => "http://cvs.drupal.org/viewcvs.cgi/contributions/README?rev=HEAD&amp;cvsroot=contrib&amp;content-type=text/vnd.viewcvs-markup", "%drupal-lists" => "http://drupal.org/mailing-lists", "%drupal-org" => "http://www.drupal.org", "%registration" => url("user/register"), "%user-acct" => url('user'), "%user-admin" => url("admin/user"), "%profile-module" => "http://cvs.drupal.org/viewcvs/drupal/modules/profile.module"));
foreach (module_list() as $module) { foreach (module_list() as $module) {
if (module_hook($module, "auth")) { if (module_hook($module, "auth")) {
......
...@@ -341,7 +341,7 @@ function user_block($op = "list", $delta = 0) { ...@@ -341,7 +341,7 @@ function user_block($op = "list", $delta = 0) {
*/ */
if (empty($edit)) { if (empty($edit)) {
$edit["destination"] = url($_GET["q"]); $edit["destination"] = $_GET["q"];
} }
// NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set. // NOTE: special care needs to be taken because on pages with forms, such as node and comment submission pages, the $edit variable might already be set.
...@@ -527,7 +527,7 @@ function user_login($edit = array(), $msg = "") { ...@@ -527,7 +527,7 @@ function user_login($edit = array(), $msg = "") {
*/ */
if ($user->uid) { if ($user->uid) {
drupal_goto(url('user')); drupal_goto('user');
} }
if (user_deny('user', $edit['name'])) { if (user_deny('user', $edit['name'])) {
...@@ -638,7 +638,7 @@ function user_login($edit = array(), $msg = "") { ...@@ -638,7 +638,7 @@ function user_login($edit = array(), $msg = "") {
*/ */
if (empty($edit)) { if (empty($edit)) {
$edit["destination"] = url($_GET["q"]); $edit["destination"] = $_GET["q"];
} }
$output .= form_hidden("destination", $edit["destination"]); $output .= form_hidden("destination", $edit["destination"]);
...@@ -687,7 +687,7 @@ function user_logout() { ...@@ -687,7 +687,7 @@ function user_logout() {
unset($user); unset($user);
} }
drupal_goto(url()); drupal_goto();
} }
function user_pass($edit = array()) { function user_pass($edit = array()) {
...@@ -716,7 +716,7 @@ function user_pass($edit = array()) { ...@@ -716,7 +716,7 @@ function user_pass($edit = array()) {
** Mail new password: ** Mail new password:
*/ */
$variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()), '%login_uri' => url('user/login'), '%edit_uri' => url('user/edit')); $variables = array("%username" => $account->name, "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $account->mail, "%date" => format_date(time()), '%login_uri' => url('user/login', NULL, NULL, TRUE), '%edit_uri' => url('user/edit', NULL, NULL, TRUE));
$subject = _user_mail_text("pass_subject", $variables); $subject = _user_mail_text("pass_subject", $variables);
$body = _user_mail_text("pass_body", $variables); $body = _user_mail_text("pass_body", $variables);
$headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"; $headers = "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from";
...@@ -764,7 +764,7 @@ function user_register($edit = array()) { ...@@ -764,7 +764,7 @@ function user_register($edit = array()) {
*/ */
if ($user->uid) { if ($user->uid) {
drupal_goto(url("user/edit")); drupal_goto("user/edit");
} }
if (!(is_null($edit['name']) && is_null($edit['mail']))) { if (!(is_null($edit['name']) && is_null($edit['mail']))) {
...@@ -804,14 +804,14 @@ function user_register($edit = array()) { ...@@ -804,14 +804,14 @@ function user_register($edit = array()) {
$account = user_save("", array_merge(array('name' => $edit['name'], 'pass' => $pass, "init" => $edit['mail'], "mail" => $edit['mail'], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data)); $account = user_save("", array_merge(array('name' => $edit['name'], 'pass' => $pass, "init" => $edit['mail'], "mail" => $edit['mail'], "rid" => _user_authenticated_id(), "status" => (variable_get("user_register", 1) == 1 ? 1 : 0)), $data));
watchdog('user', "new user: '". $edit['name'] ."' &lt;". $edit['mail'] ."&gt;", l(t("edit user"), "admin/user/edit/$account->uid")); watchdog('user', "new user: '". $edit['name'] ."' &lt;". $edit['mail'] ."&gt;", l(t("edit user"), "admin/user/edit/$account->uid"));
$variables = array("%username" => $edit['name'], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit['mail'], "%date" => format_date(time()), "%login_uri" => url('user/login'), "%edit_uri" => url("user/edit")); $variables = array("%username" => $edit['name'], "%site" => variable_get("site_name", "drupal"), "%password" => $pass, "%uri" => $base_url, "%uri_brief" => substr($base_url, strlen("http://")), "%mailto" => $edit['mail'], "%date" => format_date(time()), "%login_uri" => url('user/login', NULL, NULL, TRUE), "%edit_uri" => url("user/edit", NULL, NULL, TRUE));
//the first user may login immediately, and receives a customized welcome e-mail. //the first user may login immediately, and receives a customized welcome e-mail.
if ($account->uid == 1) { if ($account->uid == 1) {
user_mail($edit['mail'], 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\n%edit_uri\n\n--drupal"), $variables), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], 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\n%edit_uri\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 // 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 .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <strong>$pass</strong>. You may change your password on the next page.</p><p>Please login below.</p>"; $output .= "<p>Welcome to Drupal. You are user #1, which gives you full and immediate access. All future registrants will receive their passwords via e-mail, so please configure your e-mail settings using the Administration pages.</p><p> Your password is <strong>$pass</strong>. You may change your password on the next page.</p><p>Please login below.</p>";
$output .= form_hidden("destination", url("user/edit")); $output .= form_hidden("destination", "user/edit");
$output .= form_hidden('name', $account->name); $output .= form_hidden('name', $account->name);
$output .= form_hidden('pass', $pass); $output .= form_hidden('pass', $pass);
$output .= form_submit(t("Log in")); $output .= form_submit(t("Log in"));
...@@ -836,7 +836,7 @@ function user_register($edit = array()) { ...@@ -836,7 +836,7 @@ function user_register($edit = array()) {
$body = _user_mail_text("approval_body", $variables); $body = _user_mail_text("approval_body", $variables);
user_mail($edit['mail'], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail($edit['mail'], $subject, $body, "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid"))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from"); user_mail(variable_get("site_mail", ini_get("sendmail_from")), $subject, t("%u has applied for an account.\n\n%uri", array("%u" => $account->name, "%uri" => url("admin/user/edit/$account->uid", NULL, NULL, TRUE))), "From: $from\nReply-to: $from\nX-Mailer: Drupal\nReturn-path: $from\nErrors-to: $from");
return t("Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address."); return t("Thank you for applying for an account. Your account is currently pending approval by the site administrator.<br />In the meantime, your password and further instructions have been sent to your e-mail address.");
} }
} }
...@@ -1710,7 +1710,7 @@ function julia_user(\$type, \$edit, &\$user) { ...@@ -1710,7 +1710,7 @@ function julia_user(\$type, \$edit, &\$user) {
return user_save(\$user, array(\"julia_favingredient\" => \$edit[\"julia_favingredient\"])); return user_save(\$user, array(\"julia_favingredient\" => \$edit[\"julia_favingredient\"]));
} }
} }
</pre>", array("%user-role" => url("admin/user/role"), "%user-permission" => url("admin/user/permission"), "%jabber" => "http://www.jabber.org", "%delphiforums" => "http://www.delphiforums.com", "%drupal" => "http://www.drupal.org", "%da-auth" => url("user/help#da"), "%php-sess" => "http://www.php.net/manual/en/ref.session.php", "%user-prefs" => url("user/edit"), "%admin-user" => url("admin/user"), "%da-devel" => "http://www.drupal.org/node/view/316", "%xml" => "http://www.xmlrpc.org", "%http-post" => "http://www.w3.org/Protocols/", "%soap" => "http://www.soapware.org", "%dis-module" => url("admin/system/modules"), "%blogger" => "http://www.blogger.com", "%blogger-source" => "http://cvs.drupal.org/viewcvs.cgi/contributions/modules/authentication/Bloggar/?cvsroot=contrib", "%contrib-cvs" => "http://cvs.drupal.org/viewcvs/contributions/?cvsroot=contrib", "%blogger-api" => "http://plant.blogger.com/API", "%cvs" => "http://cvs.drupal.org/viewcvs.cgi/contributions/README?rev=HEAD&amp;cvsroot=contrib&amp;content-type=text/vnd.viewcvs-markup", "%drupal-lists" => "http://drupal.org/mailing-lists", "%drupal-org" => "http://www.drupal.org", "%registration" => url("user/register"), "%user-acct" => url('user'), "%user-admin" => url("admin/user"), "%profile-module" => "http://cvs.drupal.org/viewcvs/drupal/modules/profile.module")); </pre>", array("%user-role" => url("admin/user/role"), "%user-permission" => url("admin/user/permission"), "%jabber" => "http://www.jabber.org", "%delphiforums" => "http://www.delphiforums.com", "%drupal" => "http://www.drupal.org", "%da-auth" => url("user/help", NULL, 'da'), "%php-sess" => "http://www.php.net/manual/en/ref.session.php", "%user-prefs" => url("user/edit"), "%admin-user" => url("admin/user"), "%da-devel" => "http://www.drupal.org/node/view/316", "%xml" => "http://www.xmlrpc.org", "%http-post" => "http://www.w3.org/Protocols/", "%soap" => "http://www.soapware.org", "%dis-module" => url("admin/system/modules"), "%blogger" => "http://www.blogger.com", "%blogger-source" => "http://cvs.drupal.org/viewcvs.cgi/contributions/modules/authentication/Bloggar/?cvsroot=contrib", "%contrib-cvs" => "http://cvs.drupal.org/viewcvs/contributions/?cvsroot=contrib", "%blogger-api" => "http://plant.blogger.com/API", "%cvs" => "http://cvs.drupal.org/viewcvs.cgi/contributions/README?rev=HEAD&amp;cvsroot=contrib&amp;content-type=text/vnd.viewcvs-markup", "%drupal-lists" => "http://drupal.org/mailing-lists", "%drupal-org" => "http://www.drupal.org", "%registration" => url("user/register"), "%user-acct" => url('user'), "%user-admin" => url("admin/user"), "%profile-module" => "http://cvs.drupal.org/viewcvs/drupal/modules/profile.module"));
foreach (module_list() as $module) { foreach (module_list() as $module) {