summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordeva <deva>2010-02-27 13:47:07 +0000
committerdeva <deva>2010-02-27 13:47:07 +0000
commit35562f519abaece77746381b73dea0fa0d13ed3e (patch)
treeb1ebf287cb92b09267a91e550c9938b7ae87a7e9
parent5a3fb978c99fb0d9b6d559e9486f93d35ab306ed (diff)
Lots of work done on the admin system. New layout. Remove all use of graphics. Add access control on module basis.
-rw-r--r--htdocs/admin.css216
-rw-r--r--utils/admin.php158
-rw-r--r--utils/forms.php8
-rw-r--r--utils/user.php53
4 files changed, 342 insertions, 93 deletions
diff --git a/htdocs/admin.css b/htdocs/admin.css
index f86d851..40be6e5 100644
--- a/htdocs/admin.css
+++ b/htdocs/admin.css
@@ -1,68 +1,130 @@
/*** Admin ***/
.admin {
- text-align: center;
- position: absolute;
- top: 10%;
- left: 10%;
- right: 10%;
- width: 80%;
- min-height: 500px;
- border: solid #0000ff 3px;
- background: #fff;
- filter:alpha(opacity=85);
- -moz-opacity:0.85;
- -khtml-opacity: 0.85;
- opacity: 0.85;
- color: #000;
+ position: absolute;
+ top: 0%;
+ left: 0%;
+
+ border-color: #eee;
+ border-width: 2px;
+ border-style: outset;
+ background-color: #ddd;
+
+ width: 728px;
+
+ filter:alpha(opacity=95);
+ -moz-opacity:0.95;
+ -khtml-opacity: 0.95;
+ opacity: 0.95;
+
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.admin .header {
+ display: inline-block;
+ text-align: center;
+ background-image: none;
+ border: 0px;
+ font-size: 1.5em;
+ font-weight: bold;
+ color: #000;
+ padding: 0px;
+ padding-left: 10px;
+ padding-top: 3px;
}
.admin .logout {
- text-align: right;
+ float: right;
}
.admin .close {
- text-align: right;
+ float: right;
+ display: box;
+}
+
+.admin .menu,
+.admin .submenu,
+.admin .form {
+ background-color: #fff;
+
+ margin: 10px 10px 0px 10px;
+ border-color: inherit;
+ border-width: inherit;
+ border-style: inset;
+ clear: both;
+ background-image: none;
+ padding: 0px;
+ height: auto;
+ float: left;
+
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.admin .menu,
+.admin .submenu {
+ width: 704px;
+}
+
+.admin .form {
+ width: 684px;
+ padding: 10px;
}
.admin .menu {
- background-image: none;
- border-bottom: solid blue 1px;
- width: 100%;
- height: 30px;
- padding-top: 0px;
- padding-left: 0px;
+ margin-top: 0px;
+ min-height: 12px;
}
-.admin .menu .entry {
- border: solid green 1px;
- margin: 2px;
+.admin .menu .entry,
+.admin .submenu .entry {
+ color: #000;
+ background-color: #eee;
+
+ text-align: center;
+ border-color: inherit;
+ border-width: inherit;
+ border-style: outset;
+ font-size: 10px;
+ width: 80px;
+ float: left;
+ padding: 0px;
+ margin: 2px;
+ text-decoration: none;
+
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
}
.admin .submenu {
- border-bottom: solid green 1px;
+ min-height: 12px;
}
-.admin .submenu .entry{
- border: solid red 1px;
- margin: 2px;
+.admin .menu .active,
+.admin .submenu .active {
+ border-style: inset;
+ background-color: #ffc;
}
-.admin .header {
- background-image: none;
- text-align: center;
- font-size: 16px;
- font-weight: bold;
- border: 0px;
- border-bottom: solid #0000ff 3px;
+.admin .form {
+ min-height: 350px;
+ margin-bottom: 10px;
}
.admin .form .header {
- background-image: none;
- text-align: center;
- font-size: 14px;
- font-weight: bold;
- border: 0px;
+ display: inline-box;
+ background-image: none;
+ text-align: center;
+ font-size: 14px;
+ font-weight: bold;
+ border: 0px;
}
.admin .preview {
@@ -75,17 +137,79 @@
/*
* Forms
*/
-.admin .textedit {
- width: 700px;
+.admin .form .textedit {
+ width: 678px;
}
.admin .form .label {
- width: 200px;
- display: inline;
- valign: top;
+ text-align: right;
+ padding-right: 0.5em;
+ margin-top: 0.45em;
+ width: 10em;
+ display: inline-box;
+ float: left;
+ clear: none;
}
.admin .form .widget {
width: 200px;
display: inline;
}
+
+.button {
+ color: #000;
+ background-color: #eee;
+
+ width: 15px;
+ height: 15px;
+
+ border-color: inherit;
+ border-width: 2px;
+ border-style: outset;
+ margin: 3px;
+
+ padding: 0px;
+ display: box;
+ overflow: hidden;
+
+ font-size: 12px;
+ vertical-align: top;
+ text-align: center;
+ position: relative;
+ top: -2px;
+
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.button a {
+ color: #000;
+ text-decoration: none;
+}
+
+.admin .form input {
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;
+}
+
+.admin .form button {
+ background-color: #eee;
+
+ text-align: center;
+ border-color: #eee;
+ border-width: 2px;
+ border-style: outset;
+ font-size: 10px;
+
+ min-width: 80px;
+ padding: 0px;
+ margin: 2px;
+
+ -moz-border-radius: 6px;
+ -khtml-border-radius: 6px;
+ -webkit-border-radius: 6px;
+ border-radius: 6px;} \ No newline at end of file
diff --git a/utils/admin.php b/utils/admin.php
index d0303c9..ab22a9a 100644
--- a/utils/admin.php
+++ b/utils/admin.php
@@ -1,5 +1,7 @@
-<div class="admin">
- <div class="header">Admin</div>
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ ?>
+<div class="admin" id="admin">
+ <span class="header">Admin</span>
+ <div class="button close"><a href="?page=">X</a></div>
<?php
global $loggedin;
@@ -12,8 +14,7 @@ global $DATA_DIR;
else $UID = $HTTP_COOKIE_VARS["UserID"];
$user = $users->findUser($UID);
?>
-<div class="close"><a href="?page=">[X]</a></div>
-<div class="logout"><a href="?page=admin&amp;action=logout">Logout <em><?php echo $UID;?></em></a></div>
+<a class="logout" href="?page=admin&amp;action=logout">Logout <span class="user"><?php echo $UID;?></span></a>
<div class="menu">
<?php
include_once($UTIL_DIR . "/modules.php");
@@ -21,20 +22,32 @@ include_once($UTIL_DIR . "/modules.php");
loadAllModules();
foreach($modules as $modulename => $module) {
- if($m == $modulename) $admin_module = $module;
- echo "<a class=\"entry\" href=\"?page=admin&amp;m=$modulename\">$module->admin_title</a>\n";
+ if($user->checkModule($modulename) == false) continue;
+ $active = "";
+ if($m == $modulename) {
+ $admin_module = $module;
+ $admin_modulename = $modulename;
+ $active = " active";
+ }
+ echo "<a class=\"entry$active\" href=\"?page=admin&amp;m=$modulename\">";
+ echo $module->admin_title;
+ echo "</a>\n";
}
?>
</div>
<div class="submenu">
<?php
-if($admin_module) {
+if($admin_module && $user->checkModule($admin_modulename)) {
foreach($admin_module->admin_submodules as $submodulename => $submodule) {
+ $active = "";
if($s == $submodule) {
$admin_submodule = $s;
$admin_submodule_name = $submodulename;
+ $active = " active";
}
- echo "<a class=\"entry\" href=\"?page=admin&amp;m=$m&amp;s=$submodule\">$submodulename</a>\n";
+ echo "<a class=\"entry$active\" href=\"?page=admin&amp;m=$m&amp;s=$submodule\">";
+ echo $submodulename;
+ echo "</a>\n";
}
}
?>
@@ -62,3 +75,132 @@ if($admin_submodule) {
}
?>
</div>
+<script language="JavaScript" type="text/javascript">
+<!--
+
+function ExtractNumber(value)
+{
+ var n = parseInt(value);
+
+ return n == null || isNaN(n) ? 0 : n;
+}
+
+ function createCookie(name,value,days) {
+ if (days) {
+ var date = new Date();
+ date.setTime(date.getTime()+(days*24*60*60*1000));
+ var expires = "; expires="+date.toGMTString();
+ }
+ else var expires = "";
+ document.cookie = name+"="+value+expires+"; path=/";
+}
+
+function readCookie(name) {
+ var nameEQ = name + "=";
+ var ca = document.cookie.split(';');
+ for(var i=0;i < ca.length;i++) {
+ var c = ca[i];
+ while (c.charAt(0)==' ') c = c.substring(1,c.length);
+ if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
+ }
+ return null;
+}
+
+// this is simply a shortcut for the eyes and fingers
+function $(id)
+{
+ return document.getElementById(id);
+}
+
+InitDragDrop();
+
+function InitDragDrop()
+{
+ document.onmousedown = OnMouseDown;
+ document.onmouseup = OnMouseUp;
+
+ var x = readCookie('admin_x');
+ var y = readCookie('admin_y');
+
+ var _dragElement = document.getElementById('admin');
+
+ _dragElement.style.left = x + 'px';
+ _dragElement.style.top = y + 'px';
+}
+
+function OnMouseDown(e)
+{
+ // IE is retarded and doesn't pass the event object
+ if (e == null)
+ e = window.event;
+
+ // IE uses srcElement, others use target
+ var target = e.target != null ? e.target : e.srcElement;
+
+ // for IE, left click == 1
+ // for Firefox, left click == 0
+ if ((e.button == 1 && window.event != null || e.button == 0) && target.className == 'admin') {
+ // grab the mouse position
+ _startX = e.clientX;
+ _startY = e.clientY;
+
+ // grab the clicked element's position
+ _offsetX = ExtractNumber(target.style.left);
+ _offsetY = ExtractNumber(target.style.top);
+
+ // bring the clicked element to the front while it is being dragged
+ _oldZIndex = target.style.zIndex;
+ target.style.zIndex = 10000;
+
+ // we need to access the element in OnMouseMove
+ _dragElement = target;
+
+ // tell our code to start moving the element with the mouse
+ document.onmousemove = OnMouseMove;
+
+ // cancel out any text selections
+ document.body.focus();
+
+ // prevent text selection in IE
+ document.onselectstart = function () { return false; };
+ // prevent IE from trying to drag an image
+ target.ondragstart = function() { return false; };
+
+ // prevent text selection (except IE)
+ return false;
+ }
+}
+
+function OnMouseMove(e)
+{
+ if (e == null)
+ var e = window.event;
+
+ // this is the actual "drag code"
+ _dragElement.style.left = (_offsetX + e.clientX - _startX) + 'px';
+ _dragElement.style.top = (_offsetY + e.clientY - _startY) + 'px';
+}
+
+function OnMouseUp(e)
+{
+ if (_dragElement != null) {
+ _dragElement.style.zIndex = _oldZIndex;
+
+ // we're done with these events until the next OnMouseDown
+ document.onmousemove = null;
+ document.onselectstart = null;
+ _dragElement.ondragstart = null;
+
+ // this is how we know we're not dragging
+ _dragElement = null;
+
+ if (e == null)
+ var e = window.event;
+
+ // Store new coordinate
+ createCookie('admin_x', _offsetX + e.clientX - _startX);
+ createCookie('admin_y', _offsetY + e.clientY - _startY);
+ }
+}
+//-->
+</script>
diff --git a/utils/forms.php b/utils/forms.php
index 5694c03..45939e7 100644
--- a/utils/forms.php
+++ b/utils/forms.php
@@ -338,12 +338,12 @@ class ListEditor {
}
}
$str .= $indent . "</select><br/>\n";
- $str .= $indent . "<img src=\"gfx/up.png\" button onclick=\"moveUp()\"/><br/>\n";
- $str .= $indent . "<img src=\"gfx/down.png\" onclick=\"moveDown()\"/><br/>\n";
+ $str .= $indent . "<div class=\"button\" button onclick=\"moveUp()\">/\</div><br/>\n";
+ $str .= $indent . "<div class=\"button\" onclick=\"moveDown()\">\/</div><br/>\n";
$str .= $this->namewidget->render($indent);
$str .= $this->valuewidget->render($indent);
- $str .= "<img src=\"gfx/add.png\" onclick=\"addItem()\"/><br/>\n";
- $str .= $indent . "<img src=\"gfx/del.png\" onclick=\"deleteItem()\"/><br/>\n";
+ $str .= "<div class=\"button\" onclick=\"addItem()\">+</div><br/>\n";
+ $str .= $indent . "<div class=\"button\" onclick=\"deleteItem()\">-</div><br/>\n";
return $str;
}
diff --git a/utils/user.php b/utils/user.php
index 508f83d..f189987 100644
--- a/utils/user.php
+++ b/utils/user.php
@@ -1,18 +1,11 @@
-<?php
+<?php /* -*- Mode: php; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
include_once("convert.php");
class User {
public $userid;
public $password;
- public $users;
- public $news;
- public $events;
- public $guestbook;
- public $gallery;
- public $user;
- public $newsletter;
- public $pressrelease;
+ public $modules;
public function checkPassword($password) {
return $this->password == sha1(md5($password));
@@ -35,18 +28,22 @@ class User {
return 0;
}
- public function User($userid, $password, $users, $news, $events, $guestbook, $gallery, $user, $newsletter, $pressrelease)
+ public function checkModule($module)
+ {
+ if($this->modules == "*") return true;
+ if($this->modules == "") return false;
+
+ $modulelist = explode(" ", $this->modules);
+ return in_array($module, $modulelist);
+
+ return true;
+ }
+
+ public function User($userid, $password, $modules)
{
$this->userid = $userid;
$this->password = $password;
- $this->users = $users;
- $this->news = $news;
- $this->events = $events;
- $this->guestbook = $guestbook;
- $this->gallery = $gallery;
- $this->user = $user;
- $this->newsletter = $newsletter;
- $this->pressrelease = $pressrelease;
+ $this->modules = $modules;
}
}
@@ -70,14 +67,7 @@ class Users {
fwrite($fp, " <user userid=\"" .
htmlspecialchars($user->userid, ENT_QUOTES, "UTF-8") . "\"\n");
fwrite($fp, " password=\"" . $user->password . "\"\n");
- fwrite($fp, " users=\"" . $user->users . "\"\n");
- fwrite($fp, " news=\"" . $user->news . "\"\n");
- fwrite($fp, " events=\"" . $user->events . "\"\n");
- fwrite($fp, " guestbook=\"" . $user->guestbook . "\"\n");
- fwrite($fp, " gallery=\"" . $user->gallery . "\"\n");
- fwrite($fp, " user=\"" . $user->user . "\"\n");
- fwrite($fp, " newsletter=\"" . $user->newsletter . "\"\n");
- fwrite($fp, " pressrelease=\"" . $user->pressrelease . "\">\n");
+ fwrite($fp, " modules=\"" . $user->modules . "\">\n");
fwrite($fp, " </user>\n");
}
fwrite($fp, "</users>\n");
@@ -127,15 +117,8 @@ class Users {
foreach ($params as $param) {
$user = new User($param->getAttribute('userid'),
- $param->getAttribute('password'),
- $param->getAttribute('users'),
- $param->getAttribute('news'),
- $param->getAttribute('events'),
- $param->getAttribute('guestbook'),
- $param->getAttribute('gallery'),
- $param->getAttribute('user'),
- $param->getAttribute('newsletter'),
- $param->getAttribute('pressrelease'));
+ $param->getAttribute('password'),
+ $param->getAttribute('modules'));
$this->add($user);
}