summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc9
-rw-r--r--includes/theme.inc2
-rw-r--r--modules/blog.module13
-rw-r--r--modules/blog/blog.module13
-rw-r--r--modules/blogapi.module5
-rw-r--r--modules/blogapi/blogapi.module5
-rw-r--r--modules/forum.module9
-rw-r--r--modules/forum/forum.module9
-rw-r--r--modules/node.module7
-rw-r--r--modules/node/node.module7
-rw-r--r--modules/poll.module3
-rw-r--r--modules/poll/poll.module3
-rw-r--r--modules/statistics.module4
-rw-r--r--modules/statistics/statistics.module4
-rw-r--r--modules/taxonomy.module7
-rw-r--r--modules/taxonomy/taxonomy.module7
-rw-r--r--modules/throttle.module22
-rw-r--r--modules/throttle/throttle.module22
18 files changed, 107 insertions, 44 deletions
diff --git a/includes/common.inc b/includes/common.inc
index b7210f668..bae9c2554 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1613,7 +1613,6 @@ function drupal_attributes($attributes = array()) {
foreach ($attributes as $key => $value) {
$t[] = $key .'="'. check_plain($value) .'"';
}
-
return ' '. implode($t, ' ');
}
}
@@ -1974,6 +1973,14 @@ if (version_compare(phpversion(), '5.0') < 0) {
}
/**
+ * Add a <link> tag to the page's HEAD.
+ */
+function drupal_add_link($attributes) {
+ drupal_set_html_head('<link'. drupal_attributes($attributes) .">\n");
+}
+
+
+/**
* Add a JavaScript file to the output.
*
* The first time this function is invoked per page request,
diff --git a/includes/theme.inc b/includes/theme.inc
index 6f90399d7..fa3a646aa 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -501,7 +501,7 @@ function theme_links($links, $delimiter = ' | ') {
function theme_image($path, $alt = '', $title = '', $attributes = NULL, $getsize = TRUE) {
if (!$getsize || (file_exists($path) && (list($width, $height, $type, $image_attributes) = @getimagesize($path)))) {
$attributes = drupal_attributes($attributes);
- return "<img src=\"$path\" alt=\"$alt\" title=\"$title\" $image_attributes $attributes />";
+ return '<img src="'. check_url($path) .'" alt="'. check_plain($alt) .'" title="'. check_plain($title) .'" '. $image_attributes . $attributes .'/>';
}
}
diff --git a/modules/blog.module b/modules/blog.module
index bbf4e4d22..31d4689b5 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -148,7 +148,10 @@ function blog_page_user($uid) {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url("blog/$account->uid/feed"));
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/$account->uid/feed") .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS - %title', array('%title' => $title)),
+ 'href' => url("blog/$account->uid/feed")));
return $output;
}
else {
@@ -172,7 +175,10 @@ function blog_page_last() {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url('blog/feed'));
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS - blogs'),
+ 'href' => url("blog/feed")));
return $output;
}
@@ -195,7 +201,8 @@ function blog_form(&$node) {
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
- $node->body = "<a href=\"$item->link\">$item->title</a> - <em>". $item->description ."</em> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
+ // Note: $item->description has been validated on aggregation.
+ $node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
}
}
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index bbf4e4d22..31d4689b5 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -148,7 +148,10 @@ function blog_page_user($uid) {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url("blog/$account->uid/feed"));
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url("blog/$account->uid/feed") .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS - %title', array('%title' => $title)),
+ 'href' => url("blog/$account->uid/feed")));
return $output;
}
else {
@@ -172,7 +175,10 @@ function blog_page_last() {
$output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
$output .= theme('xml_icon', url('blog/feed'));
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - blogs" href="'. url('blog/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS - blogs'),
+ 'href' => url("blog/feed")));
return $output;
}
@@ -195,7 +201,8 @@ function blog_form(&$node) {
if ($iid && $item = db_fetch_object(db_query('SELECT i.*, f.title as ftitle, f.link as flink FROM {aggregator_item} i, {aggregator_feed} f WHERE i.iid = %d AND i.fid = f.fid', $iid))) {
$node->title = $item->title;
- $node->body = "<a href=\"$item->link\">$item->title</a> - <em>". $item->description ."</em> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
+ // Note: $item->description has been validated on aggregation.
+ $node->body = '<a href="'. check_url($item->link) .'">'. check_plain($item->title) .'</a> - <em>'. $item->description .'</em> [<a href="'. check_url($item->flink) .'">'. check_plain($item->ftitle) ."</a>]\n";
}
}
diff --git a/modules/blogapi.module b/modules/blogapi.module
index d836c27fd..3c6172837 100644
--- a/modules/blogapi.module
+++ b/modules/blogapi.module
@@ -530,7 +530,10 @@ function blogapi_menu($may_cache) {
$items = array();
if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
- drupal_set_html_head('<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . url('blogapi/rsd', NULL, NULL, TRUE) . '" />');
+ drupal_add_link(array('rel' => 'EditURI',
+ 'type' => 'application/rsd+xml',
+ 'title' => t('RSD'),
+ 'href' => url('blogapi/rsd', NULL, NULL, TRUE)));
}
if ($may_cache) {
diff --git a/modules/blogapi/blogapi.module b/modules/blogapi/blogapi.module
index d836c27fd..3c6172837 100644
--- a/modules/blogapi/blogapi.module
+++ b/modules/blogapi/blogapi.module
@@ -530,7 +530,10 @@ function blogapi_menu($may_cache) {
$items = array();
if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
- drupal_set_html_head('<link rel="EditURI" type="application/rsd+xml" title="RSD" href="' . url('blogapi/rsd', NULL, NULL, TRUE) . '" />');
+ drupal_add_link(array('rel' => 'EditURI',
+ 'type' => 'application/rsd+xml',
+ 'title' => t('RSD'),
+ 'href' => url('blogapi/rsd', NULL, NULL, TRUE)));
}
if ($may_cache) {
diff --git a/modules/forum.module b/modules/forum.module
index f117f6c80..6bb116511 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -825,7 +825,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output .= theme('forum_list', $forums, $parents, $tid);
if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url('taxonomy/term/'. $tid .'/0/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => 'RSS - '. $title,
+ 'href' => url('taxonomy/term/'. $tid .'/0/feed')));
$output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
$output .= theme('xml_icon', url("taxonomy/term/$tid/0/feed"));
@@ -858,7 +861,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
- $description .= " <div class=\"description\">$forum->description</div>\n";
+ $description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
}
$description .= "</div>\n";
@@ -877,7 +880,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
- $description .= " <div class=\"description\">$forum->description</div>\n";
+ $description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
}
$description .= "</div>\n";
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index f117f6c80..6bb116511 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -825,7 +825,10 @@ function theme_forum_display($forums, $topics, $parents, $tid, $sortby, $forum_p
$output .= theme('forum_list', $forums, $parents, $tid);
if ($tid && !in_array($tid, variable_get('forum_containers', array()))) {
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url('taxonomy/term/'. $tid .'/0/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => 'RSS - '. $title,
+ 'href' => url('taxonomy/term/'. $tid .'/0/feed')));
$output .= theme('forum_topic_list', $tid, $topics, $sortby, $forum_per_page);
$output .= theme('xml_icon', url("taxonomy/term/$tid/0/feed"));
@@ -858,7 +861,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
- $description .= " <div class=\"description\">$forum->description</div>\n";
+ $description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
}
$description .= "</div>\n";
@@ -877,7 +880,7 @@ function theme_forum_list($forums, $parents, $tid) {
$description .= ' <div class="name">'. l($forum->name, "forum/$forum->tid") ."</div>\n";
if ($forum->description) {
- $description .= " <div class=\"description\">$forum->description</div>\n";
+ $description .= ' <div class="description">'. check_plain($forum->description) ."</div>\n";
}
$description .= "</div>\n";
diff --git a/modules/node.module b/modules/node.module
index d03118ab6..15bbc9b24 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -782,7 +782,7 @@ function node_admin_nodes() {
foreach ($edit['nodes'] as $nid => $value) {
if ($value) {
$title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
- $extra .= '<li>'. form_hidden('nodes]['. $nid, 1) . $title .'</li>';
+ $extra .= '<li>'. form_hidden('nodes]['. $nid, 1) . check_plain($title) .'</li>';
}
}
$extra .= '</ul>';
@@ -1629,7 +1629,10 @@ function node_page_default() {
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed', NULL, NULL, TRUE) .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS'),
+ 'href' => url('node/feed', NULL, NULL, TRUE)));
$output = '';
while ($node = db_fetch_object($result)) {
diff --git a/modules/node/node.module b/modules/node/node.module
index d03118ab6..15bbc9b24 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -782,7 +782,7 @@ function node_admin_nodes() {
foreach ($edit['nodes'] as $nid => $value) {
if ($value) {
$title = db_result(db_query('SELECT title FROM {node} WHERE nid = %d', $nid));
- $extra .= '<li>'. form_hidden('nodes]['. $nid, 1) . $title .'</li>';
+ $extra .= '<li>'. form_hidden('nodes]['. $nid, 1) . check_plain($title) .'</li>';
}
}
$extra .= '</ul>';
@@ -1629,7 +1629,10 @@ function node_page_default() {
$result = pager_query(db_rewrite_sql('SELECT n.nid, n.sticky, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), variable_get('default_nodes_main', 10));
if (db_num_rows($result)) {
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS" href="'. url('node/feed', NULL, NULL, TRUE) .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => t('RSS'),
+ 'href' => url('node/feed', NULL, NULL, TRUE)));
$output = '';
while ($node = db_fetch_object($result)) {
diff --git a/modules/poll.module b/modules/poll.module
index a9139a2b8..412144023 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -95,11 +95,12 @@ function poll_validate(&$node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
$realchoices = 0;
+ // Renumber fields
+ $node->choice = array_values($node->choice);
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
}
-
if ($choice['chvotes'] < 0) {
form_set_error("choice][$i][chvotes", t('Negative values are not allowed.'));
}
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index a9139a2b8..412144023 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -95,11 +95,12 @@ function poll_validate(&$node) {
if (isset($node->title)) {
// Check for at least two options and validate amount of votes:
$realchoices = 0;
+ // Renumber fields
+ $node->choice = array_values($node->choice);
foreach ($node->choice as $i => $choice) {
if ($choice['chtext'] != '') {
$realchoices++;
}
-
if ($choice['chvotes'] < 0) {
form_set_error("choice][$i][chvotes", t('Negative values are not allowed.'));
}
diff --git a/modules/statistics.module b/modules/statistics.module
index 62db34e55..46e521b80 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -144,11 +144,11 @@ function statistics_access_log($aid) {
if ($access = db_fetch_object($result)) {
$output = '<table border="1" cellpadding="2" cellspacing="2">';
$output .= ' <tr><th>'. t('Page URL') ."</th><td>". l(url($access->path, NULL, NULL, TRUE), $access->url) ."</td></tr>";
- $output .= ' <tr><th>'. t('Page title') ."</th><td>$access->title</td></tr>";
+ $output .= ' <tr><th>'. t('Page title') .'</th><td>'. check_plain($access->title) .'</td></tr>';
$output .= ' <tr><th>'. t('Referrer') ."</th><td>". ($access->url ? l($access->url, $access->url) : '') ."</td></tr>";
$output .= ' <tr><th>'. t('Date') .'</th><td>'. format_date($access->timestamp, 'large') .'</td></tr>';
$output .= ' <tr><th>'. t('User') .'</th><td>'. format_name($access) .'</td></tr>';
- $output .= ' <tr><th>'. t('Hostname') ."</th><td>$access->hostname</td></tr>";
+ $output .= ' <tr><th>'. t('Hostname') .'</th><td>'. check_plain($access->hostname) .'</td></tr>';
$output .= '</table>';
return $output;
}
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 62db34e55..46e521b80 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -144,11 +144,11 @@ function statistics_access_log($aid) {
if ($access = db_fetch_object($result)) {
$output = '<table border="1" cellpadding="2" cellspacing="2">';
$output .= ' <tr><th>'. t('Page URL') ."</th><td>". l(url($access->path, NULL, NULL, TRUE), $access->url) ."</td></tr>";
- $output .= ' <tr><th>'. t('Page title') ."</th><td>$access->title</td></tr>";
+ $output .= ' <tr><th>'. t('Page title') .'</th><td>'. check_plain($access->title) .'</td></tr>';
$output .= ' <tr><th>'. t('Referrer') ."</th><td>". ($access->url ? l($access->url, $access->url) : '') ."</td></tr>";
$output .= ' <tr><th>'. t('Date') .'</th><td>'. format_date($access->timestamp, 'large') .'</td></tr>';
$output .= ' <tr><th>'. t('User') .'</th><td>'. format_name($access) .'</td></tr>';
- $output .= ' <tr><th>'. t('Hostname') ."</th><td>$access->hostname</td></tr>";
+ $output .= ' <tr><th>'. t('Hostname') .'</th><td>'. check_plain($access->hostname) .'</td></tr>';
$output .= '</table>';
return $output;
}
diff --git a/modules/taxonomy.module b/modules/taxonomy.module
index 6d6b7fb47..0662c0fca 100644
--- a/modules/taxonomy.module
+++ b/modules/taxonomy.module
@@ -373,7 +373,7 @@ function taxonomy_overview() {
$node_type = node_invoke($type, 'node_name');
$types[] = $node_type ? $node_type : $type;
}
- $rows[] = array('<strong>'.check_plain($vocabulary->name).'</strong>', implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('view terms'), "admin/taxonomy/$vocabulary->vid"));
+ $rows[] = array('<strong>'. check_plain($vocabulary->name) .'</strong>', implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('view terms'), "admin/taxonomy/$vocabulary->vid"));
// Show terms if non-free.
if (!$vocabulary->tags) {
@@ -1082,7 +1082,10 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
$breadcrumbs = array_reverse($breadcrumbs);
menu_set_location($breadcrumbs);
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => 'RSS - '. $title,
+ 'href' => url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed')));
$output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE));
$output .= theme('xml_icon', url("taxonomy/term/$rss_tids/$depth/feed"));
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index 6d6b7fb47..0662c0fca 100644
--- a/modules/taxonomy/taxonomy.module
+++ b/modules/taxonomy/taxonomy.module
@@ -373,7 +373,7 @@ function taxonomy_overview() {
$node_type = node_invoke($type, 'node_name');
$types[] = $node_type ? $node_type : $type;
}
- $rows[] = array('<strong>'.check_plain($vocabulary->name).'</strong>', implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('view terms'), "admin/taxonomy/$vocabulary->vid"));
+ $rows[] = array('<strong>'. check_plain($vocabulary->name) .'</strong>', implode(', ', $types), l(t('edit vocabulary'), "admin/taxonomy/edit/vocabulary/$vocabulary->vid"), l(t('add term'), "admin/taxonomy/add/term/$vocabulary->vid"), l(t('view terms'), "admin/taxonomy/$vocabulary->vid"));
// Show terms if non-free.
if (!$vocabulary->tags) {
@@ -1082,7 +1082,10 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') {
$breadcrumbs = array_reverse($breadcrumbs);
menu_set_location($breadcrumbs);
- drupal_set_html_head('<link rel="alternate" type="application/rss+xml" title="RSS - '. $title .'" href="'. url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed') .'" />');
+ drupal_add_link(array('rel' => 'alternate',
+ 'type' => 'application/rss+xml',
+ 'title' => 'RSS - '. $title,
+ 'href' => url('taxonomy/term/'. $rss_tids .'/'. $depth .'/feed')));
$output = taxonomy_render_nodes(taxonomy_select_nodes($tids, $operator, $depth, TRUE));
$output .= theme('xml_icon', url("taxonomy/term/$rss_tids/$depth/feed"));
diff --git a/modules/throttle.module b/modules/throttle.module
index 946e83bd7..a21569242 100644
--- a/modules/throttle.module
+++ b/modules/throttle.module
@@ -63,34 +63,42 @@ function throttle_exit() {
}
// update the throttle status
+ $message = '';
if ($max_users && $users > $max_users) {
if (!$throttle) {
variable_set('throttle_level', 1);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %users %user accessing site; throttle enabled.', array('%users' => "<em>$users</em>", '%user' => format_plural($users, 'user', 'users'))));
+ $message = format_plural($users,
+ '1 user accessing site; throttle enabled.',
+ '%count users accessing site; throttle enabled.');
}
}
elseif ($max_guests && $guests > $max_guests) {
if (!$throttle) {
variable_set('throttle_level', 1);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %guests %guest accessing site; throttle enabled.', array('%guests' => "<em>$guests</em>", '%guest' => format_plural($guests, 'guest', 'guests'))));
+ $message = format_plural($guests,
+ '1 guest accessing site; throttle enabled.',
+ '%count guests accessing site; throttle enabled.');
}
}
else {
if ($throttle) {
variable_set('throttle_level', 0);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %users %user, %guests %guest accessing site; throttle disabled.', array('%users' => "<em>$users</em>", '%user' => format_plural($users, 'user', 'users'), '%guests' => "<em>$guests</em>", '%guest' => format_plural($guests, 'guest', 'guests'))));
+ // Note: unorthodox format_plural() usage due to Gettext plural limitations.
+ $message = format_plural($users, '1 user', '%count users') .', ';
+ $message .= format_plural($guests, '1 guest accessing site; throttle disabled', '%count guests accessing site; throttle disabled');
}
}
+ if ($message) {
+ cache_clear_all();
+ watchdog('throttle', t('Throttle') .': '. $message);
+ }
}
}
function _throttle_validate($value, $form) {
if ($value != NULL) {
if (!is_numeric($value) || $value < 0) {
- form_set_error($form, t("'%value' is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $value)));
+ form_set_error($form, t("'%value' is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => theme('placeholder', $value))));
}
}
}
diff --git a/modules/throttle/throttle.module b/modules/throttle/throttle.module
index 946e83bd7..a21569242 100644
--- a/modules/throttle/throttle.module
+++ b/modules/throttle/throttle.module
@@ -63,34 +63,42 @@ function throttle_exit() {
}
// update the throttle status
+ $message = '';
if ($max_users && $users > $max_users) {
if (!$throttle) {
variable_set('throttle_level', 1);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %users %user accessing site; throttle enabled.', array('%users' => "<em>$users</em>", '%user' => format_plural($users, 'user', 'users'))));
+ $message = format_plural($users,
+ '1 user accessing site; throttle enabled.',
+ '%count users accessing site; throttle enabled.');
}
}
elseif ($max_guests && $guests > $max_guests) {
if (!$throttle) {
variable_set('throttle_level', 1);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %guests %guest accessing site; throttle enabled.', array('%guests' => "<em>$guests</em>", '%guest' => format_plural($guests, 'guest', 'guests'))));
+ $message = format_plural($guests,
+ '1 guest accessing site; throttle enabled.',
+ '%count guests accessing site; throttle enabled.');
}
}
else {
if ($throttle) {
variable_set('throttle_level', 0);
- cache_clear_all();
- watchdog('throttle', t('Throttle: %users %user, %guests %guest accessing site; throttle disabled.', array('%users' => "<em>$users</em>", '%user' => format_plural($users, 'user', 'users'), '%guests' => "<em>$guests</em>", '%guest' => format_plural($guests, 'guest', 'guests'))));
+ // Note: unorthodox format_plural() usage due to Gettext plural limitations.
+ $message = format_plural($users, '1 user', '%count users') .', ';
+ $message .= format_plural($guests, '1 guest accessing site; throttle disabled', '%count guests accessing site; throttle disabled');
}
}
+ if ($message) {
+ cache_clear_all();
+ watchdog('throttle', t('Throttle') .': '. $message);
+ }
}
}
function _throttle_validate($value, $form) {
if ($value != NULL) {
if (!is_numeric($value) || $value < 0) {
- form_set_error($form, t("'%value' is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => $value)));
+ form_set_error($form, t("'%value' is not a valid auto-throttle setting. Please enter a positive numeric value.", array('%value' => theme('placeholder', $value))));
}
}
}