From 5c0558b50366fe42634963b9676d9f4f697d07c4 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Mon, 18 Nov 2002 22:19:17 +0000 Subject: [PATCH] - Applied Natrak's "create PHP content" patch. --- modules/book.module | 14 ++++++++++++-- modules/book/book.module | 14 ++++++++++++-- modules/system.module | 2 +- modules/system/system.module | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/modules/book.module b/modules/book.module index d333da71cfa..504845d8d21 100644 --- a/modules/book.module +++ b/modules/book.module @@ -173,6 +173,14 @@ function book_delete(&$node) { db_query("DELETE FROM book WHERE nid = '%d'", $node->nid); } +function book_validate($node, &$error) { + + // Make sure user has permissions to create php content: + $node->format = $node->format && user_access("create php content"); + + return $node; +} + function book_form(&$node, &$help, &$error) { global $user, $op; @@ -198,7 +206,9 @@ function book_form(&$node, &$help, &$error) { if (user_access("administer nodes")) { $output .= form_select(t("Weight"), "weight", $node->weight, array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier pages will sink and the lighter pages will be positioned nearer the top.")); - $output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + if (user_access("create php content")) { + $output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + } } else { @@ -327,7 +337,7 @@ function book_body($node) { */ if ($op == t("Preview")) { - if (user_access("administer nodes")) { + if (user_access("create php content")) { $node->body = stripslashes($node->body); // see also book_form() } else { diff --git a/modules/book/book.module b/modules/book/book.module index d333da71cfa..504845d8d21 100644 --- a/modules/book/book.module +++ b/modules/book/book.module @@ -173,6 +173,14 @@ function book_delete(&$node) { db_query("DELETE FROM book WHERE nid = '%d'", $node->nid); } +function book_validate($node, &$error) { + + // Make sure user has permissions to create php content: + $node->format = $node->format && user_access("create php content"); + + return $node; +} + function book_form(&$node, &$help, &$error) { global $user, $op; @@ -198,7 +206,9 @@ function book_form(&$node, &$help, &$error) { if (user_access("administer nodes")) { $output .= form_select(t("Weight"), "weight", $node->weight, array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30), t("The heavier pages will sink and the lighter pages will be positioned nearer the top.")); - $output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + if (user_access("create php content")) { + $output .= form_select("Type", "format", $node->format, array(0 => "HTML / text", 1 => "PHP")); + } } else { @@ -327,7 +337,7 @@ function book_body($node) { */ if ($op == t("Preview")) { - if (user_access("administer nodes")) { + if (user_access("create php content")) { $node->body = stripslashes($node->body); // see also book_form() } else { diff --git a/modules/system.module b/modules/system.module index 4ca23b860ce..c20d1c8488d 100644 --- a/modules/system.module +++ b/modules/system.module @@ -29,7 +29,7 @@ function system_help_cron() { } function system_perm() { - return array("administer site configuration", "access administration pages"); + return array("administer site configuration", "access administration pages", "create php content"); } function system_link($type) { diff --git a/modules/system/system.module b/modules/system/system.module index 4ca23b860ce..c20d1c8488d 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -29,7 +29,7 @@ function system_help_cron() { } function system_perm() { - return array("administer site configuration", "access administration pages"); + return array("administer site configuration", "access administration pages", "create php content"); } function system_link($type) {