summaryrefslogtreecommitdiffstats
path: root/code
diff options
context:
space:
mode:
authorneoraider <devnull@localhost>2006-01-13 00:49:05 +0100
committerneoraider <devnull@localhost>2006-01-13 00:49:05 +0100
commit8b89c8c8a9001c5f5b38465ceb58306fc6f0659e (patch)
treea5b57b8809365c8e3184ae81bd193986367e31b8 /code
parentecb8233cd7e9fbacd7614028115161565e841d87 (diff)
downloadneon-8b89c8c8a9001c5f5b38465ceb58306fc6f0659e.tar
neon-8b89c8c8a9001c5f5b38465ceb58306fc6f0659e.zip
Navigationsleiste verbessert (ungenutzte Eintr?ge werden ausgeblendet); einige kleinere ?nderungen + Bugs gefixt
Diffstat (limited to 'code')
-rw-r--r--code/content.inc.php35
-rw-r--r--code/links.inc.php4
-rw-r--r--code/nav.inc.php15
-rw-r--r--code/pages.inc.php53
4 files changed, 69 insertions, 38 deletions
diff --git a/code/content.inc.php b/code/content.inc.php
deleted file mode 100644
index 8a20507..0000000
--- a/code/content.inc.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?PHP
- if(!defined('CONTENT_INC')) {
- define('CONTENT_INC', 1);
-
- include('code/db.inc.php');
- include('code/user.inc.php');
- include('code/handlers.inc.php');
-
- function GetPage($name) {
- $user = $GLOBALS['user'];
-
- $res = DBQuery('SELECT access, handler, data FROM pages WHERE name = ?', $name);
-
- if(!$res->RecordCount()) {
- $message = $GLOBALS['handlers']['default']->HandleErrorMessage('PageNotFound', array('page' => $name));
-
- if(!$message['title']) $message['title'] = $name;
-
- return $message;
- }
-
- if((($user->GetUid() == 0) || ($user->GetGid() != 0)) && ($res->fields[0] & (1 << $user->GetGid())) == 0) {
- $message = $GLOBALS['handlers'][$res->fields[1]]->HandleErrorMessage('Forbidden', array('page' => $name));
-
- if(!$message['title']) $message['title'] = $name;
-
- return $message;
- }
- parse_str($res->fields[2], $data);
- $data['_page'] = $name;
-
- return $GLOBALS['handlers'][$res->fields[1]]->HandleContentData($data);
- }
- }
-?>
diff --git a/code/links.inc.php b/code/links.inc.php
index ab3b786..39a1ae2 100644
--- a/code/links.inc.php
+++ b/code/links.inc.php
@@ -4,7 +4,9 @@
class Links {
function GetNeonLink($page) {
- return 'index.php?page=' . $page;
+ if($GLOBALS['pages']->HasAccess($page))
+ return 'index.php?page=' . $page;
+ return '';
}
function GetExternalLink($link) {
diff --git a/code/nav.inc.php b/code/nav.inc.php
index f6f0782..245e208 100644
--- a/code/nav.inc.php
+++ b/code/nav.inc.php
@@ -65,6 +65,7 @@
}
function Parse() {
+ $ccount = 0;
$ret = '<li>';
$link = $GLOBALS['links']->ParseNavLink($this->link);
@@ -77,12 +78,22 @@
if(count($this->children) > 0) {
$ret .= '<ul>';
- foreach($this->children as $child)
- $ret .= $child->Parse();
+ foreach($this->children as $child) {
+ $cret = $child->Parse();
+
+ if($cret) {
+ $ret .= $cret;
+
+ $ccount++;
+ }
+ }
$ret .= '</ul>';
}
+ if(!$ccount && !$link)
+ return '';
+
return $ret . '</li>';
}
}
diff --git a/code/pages.inc.php b/code/pages.inc.php
new file mode 100644
index 0000000..d529602
--- /dev/null
+++ b/code/pages.inc.php
@@ -0,0 +1,53 @@
+<?PHP
+ if(!defined('PAGES_INC')) {
+ define('PAGES_INC', 1);
+
+ include('code/db.inc.php');
+ include('code/user.inc.php');
+ include('code/handlers.inc.php');
+
+ class Pages {
+ function Get($name) {
+ if(!$this->Exists($name)) {
+ $message = $GLOBALS['handlers']['default']->HandleErrorMessage('PageNotFound', array('page' => $name));
+
+ if(!$message['title']) $message['title'] = $name;
+
+ return $message;
+ }
+
+ $res = DBQuery('SELECT handler, data FROM pages WHERE name = ?', $name);
+
+ if(!$this->HasAccess($name)) {
+ $message = $GLOBALS['handlers'][$res->fields[0]]->HandleErrorMessage('Forbidden', array('page' => $name));
+
+ if(!$message['title']) $message['title'] = $name;
+
+ return $message;
+ }
+
+ parse_str($res->fields[1], $data);
+ $data['_page'] = $name;
+
+ return $GLOBALS['handlers'][$res->fields[0]]->HandleContentData($data);
+ }
+
+ function Exists($name) {
+ $res = DBQuery('SELECT id FROM pages WHERE name = ?', $name);
+
+ return ($res->RecordCount() > 0);
+ }
+
+ function HasAccess($name) {
+ $user = $GLOBALS['user'];
+
+ $res = DBQuery('SELECT access FROM pages WHERE name = ?', $name);
+
+ return ((($user->GetUid() != 0) && ($user->GetGid() == 0))
+ || ($res->fields[0] & (1 << $user->GetGid())) != 0);
+ }
+ }
+
+ $pages = new Pages;
+ }
+?>