Commit 4b0b2d02 authored by Dries's avatar Dries

- Patch by Steven: removed redundant permission checks.  These are no longer
  required thanks to the new 404 handling.
parent ae5136e5
......@@ -19,12 +19,7 @@ function admin_link($type) {
}
function admin_admin() {
if (user_access("access administration pages")) {
print theme("page", watchdog_overview("actions"));
}
else {
print theme("page", message_access());
}
print theme("page", watchdog_overview("actions"));
}
?>
......@@ -613,59 +613,53 @@ function aggregator_tag() {
function aggregator_admin() {
$edit = $_POST["edit"];
if (user_access("administer news feeds")) {
switch ($_POST["op"] ? $_POST["op"] : arg(3)) {
case "add":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle();
}
else {
$output = aggregator_form_feed();
}
break;
case "edit":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle(aggregator_get_bundle(arg(5)));
}
else {
$output = aggregator_form_feed(aggregator_get_feed(arg(5)));
}
break;
case "remove":
aggregator_remove(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "update":
aggregator_refresh(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "tag":
$output = aggregator_tag();
break;
case t("Save attributes"):
aggregator_save_attributes($edit);
$output .= aggregator_tag();
break;
case t("Delete"):
$edit["title"] = 0;
// fall through:
case t("Submit"):
if (arg(4) == "bundle") {
aggregator_save_bundle($edit);
}
else {
aggregator_save_feed($edit);
}
// fall through:
default:
$output .= aggregator_view();
}
print theme("page", $output);
}
else {
print theme("page", message_access());
switch ($_POST["op"] ? $_POST["op"] : arg(3)) {
case "add":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle();
}
else {
$output = aggregator_form_feed();
}
break;
case "edit":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle(aggregator_get_bundle(arg(5)));
}
else {
$output = aggregator_form_feed(aggregator_get_feed(arg(5)));
}
break;
case "remove":
aggregator_remove(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "update":
aggregator_refresh(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "tag":
$output = aggregator_tag();
break;
case t("Save attributes"):
aggregator_save_attributes($edit);
$output .= aggregator_tag();
break;
case t("Delete"):
$edit["title"] = 0;
// fall through:
case t("Submit"):
if (arg(4) == "bundle") {
aggregator_save_bundle($edit);
}
else {
aggregator_save_feed($edit);
}
// fall through:
default:
$output .= aggregator_view();
}
print theme("page", $output);
}
function aggregator_page_last() {
......
......@@ -613,59 +613,53 @@ function aggregator_tag() {
function aggregator_admin() {
$edit = $_POST["edit"];
if (user_access("administer news feeds")) {
switch ($_POST["op"] ? $_POST["op"] : arg(3)) {
case "add":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle();
}
else {
$output = aggregator_form_feed();
}
break;
case "edit":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle(aggregator_get_bundle(arg(5)));
}
else {
$output = aggregator_form_feed(aggregator_get_feed(arg(5)));
}
break;
case "remove":
aggregator_remove(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "update":
aggregator_refresh(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "tag":
$output = aggregator_tag();
break;
case t("Save attributes"):
aggregator_save_attributes($edit);
$output .= aggregator_tag();
break;
case t("Delete"):
$edit["title"] = 0;
// fall through:
case t("Submit"):
if (arg(4) == "bundle") {
aggregator_save_bundle($edit);
}
else {
aggregator_save_feed($edit);
}
// fall through:
default:
$output .= aggregator_view();
}
print theme("page", $output);
}
else {
print theme("page", message_access());
switch ($_POST["op"] ? $_POST["op"] : arg(3)) {
case "add":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle();
}
else {
$output = aggregator_form_feed();
}
break;
case "edit":
if (arg(4) == "bundle") {
$output = aggregator_form_bundle(aggregator_get_bundle(arg(5)));
}
else {
$output = aggregator_form_feed(aggregator_get_feed(arg(5)));
}
break;
case "remove":
aggregator_remove(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "update":
aggregator_refresh(aggregator_get_feed(arg(4)));
$output .= aggregator_view();
break;
case "tag":
$output = aggregator_tag();
break;
case t("Save attributes"):
aggregator_save_attributes($edit);
$output .= aggregator_tag();
break;
case t("Delete"):
$edit["title"] = 0;
// fall through:
case t("Submit"):
if (arg(4) == "bundle") {
aggregator_save_bundle($edit);
}
else {
aggregator_save_feed($edit);
}
// fall through:
default:
$output .= aggregator_view();
}
print theme("page", $output);
}
function aggregator_page_last() {
......
......@@ -205,51 +205,46 @@ function archive_page() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("access content")) {
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
$date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
$date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;
/*
** Prepare the values of the form fields:
*/
/*
** Prepare the values of the form fields:
*/
$years = drupal_map_assoc(range(2000, 2005));
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$days = drupal_map_assoc(range(0, 31));
$years = drupal_map_assoc(range(2000, 2005));
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$days = drupal_map_assoc(range(0, 31));
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
$output .= form($start);
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
$output .= form($start);
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d AND created < %d ORDER BY created", $date, $date_end, 0, 20);
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d AND created < %d ORDER BY created", $date, $date_end, 0, 20);
while ($nid = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
while ($nid = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
print theme("page", $output);
}
else {
print theme("page", message_access());
}
print theme("page", $output);
}
function archive_settings() {
......
......@@ -205,51 +205,46 @@ function archive_page() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("access content")) {
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
if ($op == t("Show")) {
$year = $edit["year"];
$month = $edit["month"];
$day = $edit["day"];
}
else {
$year = arg(1);
$month = arg(2);
$day = arg(3);
}
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
$date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;
$date = mktime(0, 0, 0, $month, $day, $year) - $user->timezone;
$date_end = mktime(0, 0, 0, $month, $day + 1, $year) - $user->timezone;
/*
** Prepare the values of the form fields:
*/
/*
** Prepare the values of the form fields:
*/
$years = drupal_map_assoc(range(2000, 2005));
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$days = drupal_map_assoc(range(0, 31));
$years = drupal_map_assoc(range(2000, 2005));
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
$days = drupal_map_assoc(range(0, 31));
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
$output .= form($start);
$start = "<div class=\"container-inline\">";
$start .= form_select("", "year", ($year ? $year : date("Y")), $years). form_select("", "month", ($month ? $month : date("m")), $months) . form_select("", "day", ($day ? $day : date("d")), $days) . form_submit(t("Show"));
$start .= "</div>";
$output .= form($start);
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d AND created < %d ORDER BY created", $date, $date_end, 0, 20);
if ($year && $month && $day) {
$result = db_query_range("SELECT nid FROM {node} WHERE status = '1' AND created > %d AND created < %d ORDER BY created", $date, $date_end, 0, 20);
while ($nid = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
while ($nid = db_fetch_object($result)) {
$output .= node_view(node_load(array("nid" => $nid->nid)), 1);
}
print theme("page", $output);
}
else {
print theme("page", message_access());
}
print theme("page", $output);
}
function archive_settings() {
......
......@@ -280,45 +280,39 @@ function block_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("administer blocks")) {
if (empty($op)) {
$op = arg(3);
}
switch ($op) {
case "preview":
$output = block_admin_preview();
break;
case "add":
$output = block_box_form();
break;
case "edit":
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
$output .= block_admin_display();
}
print theme("page", $output);
if (empty($op)) {
$op = arg(3);
}
else {
print theme("page", message_access());
switch ($op) {
case "preview":
$output = block_admin_preview();
break;
case "add":
$output = block_box_form();
break;
case "edit":
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
$output .= block_admin_display();
}
print theme("page", $output);
}
function block_user($type, $edit, &$user) {
......
......@@ -280,45 +280,39 @@ function block_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("administer blocks")) {
if (empty($op)) {
$op = arg(3);
}
switch ($op) {
case "preview":
$output = block_admin_preview();
break;
case "add":
$output = block_box_form();
break;
case "edit":
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
$output .= block_admin_display();
}
print theme("page", $output);
if (empty($op)) {
$op = arg(3);
}
else {
print theme("page", message_access());
switch ($op) {
case "preview":
$output = block_admin_preview();
break;
case "add":
$output = block_box_form();
break;
case "edit":
$output = block_box_form(block_box_get(arg(4)));
break;
case "delete":
drupal_set_message(block_box_delete(arg(4)));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save block"):
drupal_set_message(block_box_save($edit));
cache_clear_all();
$output .= block_admin_display();
break;
case t("Save blocks"):
drupal_set_message(block_admin_save($edit));
cache_clear_all();
// fall through
default:
$output .= block_admin_display();
}
print theme("page", $output);
}
function block_user($type, $edit, &$user) {
......
......@@ -177,29 +177,23 @@ function blog_form(&$node, &$error) {
function blog_page() {
if (user_access("access content")) {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
else {
print theme("page", message_access());
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
function blog_content($node, $main = 0) {
......
......@@ -177,29 +177,23 @@ function blog_form(&$node, &$error) {
function blog_page() {
if (user_access("access content")) {
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
else {
print theme("page", message_access());
switch (arg(1)) {
case "feed":
if (arg(2)) {
blog_feed_user(arg(2));
}
else {
blog_feed_last();
}
break;
default:
if (arg(1)) {
blog_page_user(arg(1));
}
else {
blog_page_last();
}
}
}
function blog_content($node, $main = 0) {
......
......@@ -841,33 +841,28 @@ function book_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("administer nodes")) {
if (empty($op)) {
$op = arg(3);
}
switch ($op) {
case t("Edit book outline"):
case t("Add to book outline"):
case t("Remove from book outline"):
case t("Update book outline"):
$output = book_node_link();
break;
case "orphan":
$output = book_admin_orphan();
break;
case t("Save book pages"):
drupal_set_message(book_admin_save(arg(3), $edit));
// fall through:
default:
$output .= book_admin_view(arg(3));
break;
}
print theme("page", $output);
if (empty($op)) {
$op = arg(3);
}
else {
print theme("page", message_access());
switch ($op) {
case t("Edit book outline"):
case t("Add to book outline"):
case t("Remove from book outline"):
case t("Update book outline"):
$output = book_node_link();
break;
case "orphan":
$output = book_admin_orphan();
break;
case t("Save book pages"):
drupal_set_message(book_admin_save(arg(3), $edit));
// fall through:
default:
$output .= book_admin_view(arg(3));
break;
}
print theme("page", $output);
}
function book_help($section = "admin/help#book") {
......
......@@ -841,33 +841,28 @@ function book_admin() {
$op = $_POST["op"];
$edit = $_POST["edit"];
if (user_access("administer nodes")) {
if (empty($op)) {
$op = arg(3);
}
switch ($op) {