OSDN Git Service

skinableADMIN.phpとADMIN.phpを統合
authorshizuki <shizuki@kinezumi.net>
Mon, 9 Apr 2012 10:51:04 +0000 (19:51 +0900)
committershizuki <shizuki@kinezumi.net>
Mon, 9 Apr 2012 10:51:04 +0000 (19:51 +0900)
スキンファイルのディレクトリは後で修正

nucleus/libs/ADMIN.php
nucleus/locales/adminskinTypes.php [new file with mode: 0644]

index f121248..52d0604 100644 (file)
-<?php
-/**
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
- * Copyright (C) 2002-2012 The Nucleus Group
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- * (see nucleus/documentation/index.html#license for more info)
- */
-/**
- * The code for the Nucleus admin area
- *
- * @license http://nucleuscms.org/license.txt GNU General Public License
- * @copyright Copyright (C) 2002-2012 The Nucleus Group
- * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
- *
- */
-
-if ( !function_exists('requestVar') ) exit;
-require_once dirname(__FILE__) . '/showlist.php';
-
-/**
- * Builds the admin area and executes admin actions
- */
-class Admin
-{
-       private $xml_version_info         = '1.0';
-       private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
-       private $system_identifier        = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
-       private $xhtml_namespace          = 'http://www.w3.org/1999/xhtml';
-       
-       /**
-        * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
-        */
-       public $action;
-
-       /**
-        * @var object $adminSkin
-        */
-       public $adminSkin;
-
-       /**
-        * @var string $extrahead
-        */
-       public $extrahead;
-
-       /**
-        * @var bool $passvar
-        */
-       public $passvar;
-
-       /**
-        * @var string $headMess
-        */
-       public $headMess;
-
-       public $aOptions;
-
-       /**
-        * Class constructor
-        */
-       /* function ADMIN() {
-       } */
-       function __construct()
-       {
-               global $member, $DIR_LIBS;
-                       $query = 'SELECT '
-                                  . '    COUNT(*) as result '
-                                  . 'FROM '
-                                  .      sql_table('adminskin_desc');
-               if ( !(quickQuery($query)) )
-               {
-                       $this->action_importAdmin();
-               }
-               if ( !isset($adminSkinid) || !($adminSkinid) )
-               {
-                       $adminSkinid = self::getAdminSkinID();
-               }
-               if ( skinableSKIN::existsID($adminSkinid) )
-               {
-                       $this->adminSkin = new skinableSKIN($adminSkinid);
-               }
-               else
-               {
-                       $this->adminSkin = 0;
-               }
-       }
-       
-       static private function getAdminSkinID()
-       {
-               global $CONF, $member, $manager;
-               if (isset($member) && $member->isLoggedIn()) {
-                       $memskin = $member->getAdminSkin();
-                       if ($memskin) {
-                               return $memskin;
-                       }
-               }
-               return $CONF['DefaultAdminSkin'];
-       }
-       
-       function getAdminskinEditActions()
-       {
-               return array(
-                               'adminskinoverview',
-                               'adminskinieoverview',
-                               'adminskinedittype',
-                               'adminskinremovetype',
-                               'adminskindelete',
-                               'adminskinedit',
-                               'adminskinieimport',
-                               'adminskiniedoimport',
-                               'admintemplateedit',
-                               'admintemplateoverview',
-                               'admintemplatedelete',
-               );
-       }
-       
-       function getSkinlessActions()
-       {
-               return array(
-                               'plugindeleteconfirm',
-                               'pluginoptionsupdate',
-                               'skinremovetypeconfirm',
-                               'skinclone',
-                               'skindeleteconfirm',
-                               'skinnew',
-                               'skineditgeneral',
-                               'skinieexport',
-                               'skinupdate',
-                               'templateupdate',
-                               'templatedeleteconfirm',
-                               'templatenew',
-                               'templateclone',
-                               'adminskinremovetypeconfirm',
-                               'adminskinclone',
-                               'adminskindeleteconfirm',
-                               'adminskinnew',
-                               'adminskineditgeneral',
-                               'adminskinieexport',
-                               'adminskinupdate',
-                               'admintemplateupdate',
-                               'admintemplatedeleteconfirm',
-                               'admintemplatenew',
-                               'admintemplateclone',
-                               'blogsettingsupdate',
-                               'settingsupdate',
-                               'addnewlog2',
-                               'additem',
-                               'itemdeleteconfirm',
-                               'itemupdate',
-                               'changemembersettings',
-                               'clearactionlog',
-                               'memberedit',
-               );
-       }
-       
-       /**
-        * Executes an action
-        *
-        * @param string $action action to be performed
-        */
-       function action($action)
-       {
-               global $CONF, $manager;
-               $f = false;
-               
-               // list of action aliases
-               $alias = array(
-                       'login' => 'overview',
-                       ''      => 'overview'
-               );
-
-               $customAction = postvar('customaction');
-               if ( !empty($customAction) )
-               {
-                       $alias = array(
-                               'login' => $customAction,
-                               ''      => $customAction
-                       );
-               }
-               if ( isset($alias[$action]) )
-               {
-                       $action = $alias[$action];
-               }
-               $methodName = 'action_' . $action;
-
-               $this->action = strtolower($action);
-
-               // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
-               // is an action that requires user interaction before something is actually done)
-               // all safe actions are in this array:
-               $aActionsNotToCheck = array(
-                       'showlogin',
-                       'login',
-                       'overview',
-                       'itemlist',
-                       'blogcommentlist',
-                       'bookmarklet',
-                       'blogsettings',
-                       'banlist',
-                       'deleteblog',
-                       'editmembersettings',
-                       'browseownitems',
-                       'browseowncomments',
-                       'createitem',
-                       'itemedit',
-                       'itemmove',
-                       'categoryedit',
-                       'categorydelete',
-                       'manage',
-                       'actionlog',
-                       'settingsedit',
-                       'backupoverview',
-                       'pluginlist',
-                       'createnewlog',
-                       'usermanagement',
-                       'skinoverview',
-                       'templateoverview',
-                       'skinieoverview',
-                       'itemcommentlist',
-                       'commentedit',
-                       'commentdelete',
-                       'banlistnewfromitem',
-                       'banlistdelete',
-                       'itemdelete',
-                       'manageteam',
-                       'teamdelete',
-                       'banlistnew',
-                       'memberedit',
-                       'memberdelete',
-                       'pluginhelp',
-                       'pluginoptions',
-                       'plugindelete',
-                       'skinedittype',
-                       'skinremovetype',
-                       'skindelete',
-                       'skinedit',
-                       'templateedit',
-                       'templatedelete',
-                       'activate',
-                       'systemoverview',
-            'activatesetpwd',
-               );
-        $synonimActions = array(
-            'banlistnewfromitem',
-            'memberedit',
-            'login',
-        );
-/*
-               // the rest of the actions needs to be checked
-               $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
-*/
-        $adminskinEditActions = $this->getAdminskinEditActions();
-        $skinLessActions      = $this->getSkinlessActions();
-        $allowActions         = array_merge($synonimActions, $this->getSkinlessActions());
-        $aActionsNotToCheck   = array_merge($aActionsNotToCheck, $adminskinEditActions, $allowActions);
-               if (!in_array($this->action, $aActionsNotToCheck) && !$this->existsSkinContents($action) )
-               {
-                       if (!$manager->checkTicket())
-                       {
-                               $this->error(_ERROR_BADTICKET);
-                       }
-               }
-               if ( !$this->adminSkin && $CONF['DefaultAdminSkin'] )
-               {
-                       $this->adminSkin = new Skin($CONF['DefaultAdminSkin']);
-               }
-       
-               if ( !method_exists($this, $methodName) && !in_array($this->action, $allowActions) && $this->existsSkinContents($action) )
-               {
-                       $this->action_parseSpecialskin;
-                       $f = true;
-               }
-               elseif ( method_exists($this, $methodName) )
-               {
-                       call_user_func(array(&$this, $methodName));
-                       $f = true;
-               }
-               if ($f) {
-                       exit;
-               }
-               $id              = self::getAdminSkinID();
-               $this->adminSkin = new skinableSKIN($id);
-               if ( $this->adminSkin && $this->existsSkinContents('adminerrorpage') )
-               {
-                       $this->error(_BADACTION . ENTITY::hsc($action));
-                       $f = true;
-               }
-               elseif ( $id != $CONF['DefaultAdminSkin'] )
-               {
-                       $this->adminSkin = new Skin($CONF['DefaultAdminSkin']);
-                       if ( $this->adminSkin && $this->existsSkinContents('adminerrorpage') )
-                       {
-                               $this->error(_BADACTION . ENTITY::hsc($action));
-                               $f = true;
-                       }
-               }
-               if ($f)
-               {
-                       exit;
-               }
-               $this->error(_BADACTION . ENTITY::hsc($action));
-       }
-
-       /**
-        * Check skin contents
-        *
-        * @param  string action type
-        * @return bool
-        */
-       function existsSkinContents($action)
-       {
-               $nsActions = $this->getSkinlessActions();
-                       $in_array  = in_array($action, $nsActions);
-               if ($in_array) {
-                       return $in_array;
-               } else {
-                       $query = 'SELECT '
-                                  . '    scontent as result '
-                                  . 'FROM '
-                                  .      sql_table('adminskin') . ' '
-                                  . 'WHERE '
-                                  . '    sdesc = %d '
-                                  . 'AND stype = "%s"';
-                       if ( is_object($this->adminSkin) )
-                       {
-                               return quickQuery(sprintf($query, $this->adminSkin->id, sql_real_escape_string($action)));
-                       }
-                       else
-                       {
-                               return quickQuery(sprintf($query, 1, sql_real_escape_string($action)));
-                       }
-               }
-       }
-       
-       /**
-        * Check exists specialskinparts
-        *
-        * @param string action type
-        * @return bool
-        */
-       function specialActionsAllow($action)
-       {
-               $query = 'SELECT '
-               . '    sdesc as result '
-               . 'FROM '
-               .      sql_table('adminskin') . ' '
-               . 'WHERE '
-               . '    sdesc = %d '
-               . 'AND stype = "%s"';
-               return quickQuery(sprintf($query, $this->adminSkin->id, sql_real_escape_string($action)));
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_showlogin()
-       {
-               global $error;
-               $this->action_login($error);
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_login($msg = '', $passvars = 1)
-       {
-               global $member;
-
-               // skip to overview when allowed
-               if ( $member->isLoggedIn() && $member->canLogin() )
-               {
-                       $this->action_overview();
-                       exit;
-               }
-
-               $this->passvar = $passvars;
-               if ( $msg )
-               {
-                       $this->headMess = $msg;
-               }
-
-               $this->pagehead();
-               $this->parse('showlogin');
-               $this->pagefoot();
-       }
-
-       /**
-        * provides a screen with the overview of the actions available
-        * @todo document parameter
-        */
-       function action_overview($msg = '')
-       {
-               if ( $msg )
-               {
-                       $this->headMess = $msg;
-               }
-
-               $this->pagehead();
-               $this->parse('overview');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_manage($msg = '')
-       {
-               global $member;
-
-               if ( $msg )
-               {
-                       $this->headMess = $msg;
-               }
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('manage');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_itemlist($blogid = '')
-       {
-               global $member, $manager, $CONF;
-
-               if ( $blogid == '' )
-               {
-                       $blogid = intRequestVar('blogid');
-               }
-
-               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('itemlist');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_batchitem()
-       {
-               global $member, $manager;
-
-               // check if logged in
-               $member->isLoggedIn() or $this->disallow();
-
-               // more precise check will be done for each performed operation
-
-               // get array of itemids from request
-               $selected = requestIntArray('batch');
-               $action   = requestVar('batchaction');
-
-               // Show error when no items were selected
-               if ( !is_array($selected) || sizeof($selected) == 0 )
-               {
-                       $this->error(_BATCH_NOSELECTION);
-               }
-
-               // On move: when no destination blog/category chosen, show choice now
-               $destCatid = intRequestVar('destcatid');
-               if ( ($action == 'move') && (!$manager->existsCategory($destCatid)) )
-               {
-                       $this->batchMoveSelectDestination('item', $selected);
-               }
-
-               // On delete: check if confirmation has been given
-               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
-               {
-                       $this->batchAskDeleteConfirmation('item',$selected);
-               }
-
-               $this->pagehead();
-               $this->parse('batchitem');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_batchcomment()
-       {
-               global $member;
-
-               // check if logged in
-               $member->isLoggedIn() or $this->disallow();
-
-               // more precise check will be done for each performed operation
-
-               // get array of itemids from request
-               $selected = requestIntArray('batch');
-               $action   = requestVar('batchaction');
-
-               // Show error when no items were selected
-               if ( !is_array($selected) || sizeof($selected) == 0 )
-               {
-                       $this->error(_BATCH_NOSELECTION);
-               }
-
-               // On delete: check if confirmation has been given
-               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
-               {
-                       $this->batchAskDeleteConfirmation('comment',$selected);
-               }
-
-               $this->pagehead();
-               $this->parse('batchcomment');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_batchmember()
-       {
-               global $member;
-
-               // check if logged in and admin
-               ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
-
-               // get array of itemids from request
-               $selected = requestIntArray('batch');
-               $action   = requestVar('batchaction');
-
-               // Show error when no members selected
-               if ( !is_array($selected) || sizeof($selected) == 0 )
-               {
-                       $this->error(_BATCH_NOSELECTION);
-               }
-
-               // On delete: check if confirmation has been given
-               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
-               {
-                       $this->batchAskDeleteConfirmation('member',$selected);
-               }
-
-               $this->pagehead();
-               $this->parse('batchmember');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_batchteam()
-       {
-               global $member;
-
-               $blogid = intRequestVar('blogid');
-
-               // check if logged in and admin
-               ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
-
-               // get array of itemids from request
-               $selected = requestIntArray('batch');
-               $action   = requestVar('batchaction');
-
-               // Show error when no members selected
-               if ( !is_array($selected) || sizeof($selected) == 0 )
-               {
-                       $this->error(_BATCH_NOSELECTION);
-               }
-
-               // On delete: check if confirmation has been given
-               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
-               {
-                       $this->batchAskDeleteConfirmation('team',$selected);
-               }
-
-               $this->pagehead();
-               $this->parse('batchmember');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_batchcategory()
-       {
-               global $member, $manager;
-
-               // check if logged in
-               $member->isLoggedIn() or $this->disallow();
-
-               // more precise check will be done for each performed operation
-
-               // get array of itemids from request
-               $selected = requestIntArray('batch');
-               $action   = requestVar('batchaction');
-
-               // Show error when no items were selected
-               if ( !is_array($selected) || sizeof($selected) == 0 )
-               {
-                       $this->error(_BATCH_NOSELECTION);
-               }
-
-               // On move: when no destination blog chosen, show choice now
-               $destBlogId = intRequestVar('destblogid');
-               if ( ($action == 'move') && (!$manager->existsBlogID($destBlogId)) )
-               {
-                       $this->batchMoveCategorySelectDestination('category', $selected);
-               }
-
-               // On delete: check if confirmation has been given
-               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )
-               {
-                       $this->batchAskDeleteConfirmation('category', $selected);
-               }
-
-               $this->pagehead();
-               $this->parse('batchcategory');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function batchMoveSelectDestination($type, $ids)
-       {
-               $this->pagehead();
-               $this->parse('batchmove');
-               $this->pagefoot();
-               exit;
-       }
-
-       /**
-        * @todo document this
-        */
-       function batchMoveCategorySelectDestination($type, $ids)
-       {
-               global $manager;
-               $this->pagehead();
-               $this->parse('batchmovecat');
-               $this->pagefoot();
-               exit;
-       }
-
-       /**
-        * @todo document this
-        */
-       function batchAskDeleteConfirmation($type, $ids)
-       {
-        $this->pagehead();
-        $this->parse('batchdelete');
-        $this->pagefoot();
-               exit;
-       }
-
-
-       /**
-        * Inserts a HTML select element with choices for all categories to which the current
-        * member has access
-        * @see function selectBlog
-        */
-       function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
-       {
-               Admin::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
-       }
-
-       /**
-        * Inserts a HTML select element with choices for all blogs to which the user has access
-        *      mode = 'blog' => shows blognames and values are blogids
-        *      mode = 'category' => show category names and values are catids
-        *
-        * @param $iForcedBlogInclude
-        *      ID of a blog that always needs to be included, without checking if the
-        *      member is on the blog team (-1 = none)
-        * @todo document parameters
-        */
-       function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
-       {
-               global $member, $CONF;
-
-               // 0. get IDs of blogs to which member can post items (+ forced blog)
-               $aBlogIds = array();
-               if ( $iForcedBlogInclude != -1 )
-               {
-                       $aBlogIds[] = intval($iForcedBlogInclude);
-               }
-
-               if ( ($member->isAdmin()) && ($CONF['ShowAllBlogs']) )
-               {
-                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
-               }
-               else
-               {
-                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
-               }
-               $rblogids = sql_query($queryBlogs);
-               while ($o = sql_fetch_object($rblogids))
-               {
-                       if ( $o->bnumber != $iForcedBlogInclude )
-                       {
-                               $aBlogIds[] = intval($o->bnumber);
-                       }
-               }
-
-               if ( count($aBlogIds) == 0 )
-               {
-                       return;
-               }
-
-               $_REQUEST['selectData'] = array(
-                       'name'       => $name,
-                       'tabindex'   => $tabindex,
-                       'mode'       => $mode,
-                       'selected'   => $selected,
-                       'showNewCat' => $showNewCat,
-                       'aBlogIds'   => $aBlogIds,
-               );
-               $this->parse('blogselectbox');
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_browseownitems() {
-               global $member, $manager, $CONF;
-
-               $this->pagehead();
-               $this->parse('browseownitems');
-               $this->pagefoot();
-       }
-
-       /**
-        * Show all the comments for a given item
-        * @param int $itemid
-        */
-       function action_itemcommentlist($itemid = '') {
-               global $member, $manager, $CONF;
-
-               if ( $itemid == '' )
-               {
-                       $itemid = intRequestVar('itemid');
-               }
-               $_REQUEST['itemid'] = $itemid;
-               $_REQUEST['blogid'] = getBlogIdFromItemId($itemid);
-               
-               // only allow if user is allowed to alter item
-               $member->canAlterItem($itemid) or $this->disallow();
-
-               $blogid = getBlogIdFromItemId($itemid);
-
-               $this->pagehead();
-               $this->parse('itemcommentlist');
-               $this->pagefoot();
-       }
-
-       /**
-        * Browse own comments
-        */
-       function action_browseowncomments() {
-               $this->pagehead();
-               $this->parse('browseowncomments');
-               $this->pagefoot();
-       }
-
-       /**
-        * Browse all comments for a weblog
-        * @param int $blogid
-        */
-       function action_blogcommentlist($blogid = '')
-       {
-               global $member, $manager, $CONF;
-
-               if ( $blogid == '' )
-               {
-                       $blogid = intRequestVar('blogid');
-               }
-               else
-               {
-                       $blogid = intval($blogid);
-               }
-
-               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
-               $_REQUEST['blogid'] = $blogid;
-
-               $this->pagehead();
-               $this->parse('blogcommentlist');
-               $this->pagefoot();
-       }
-
-       /**
-        * Provide a page to item a new item to the given blog
-        */
-       function action_createitem()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               // check if allowed
-               $member->teamRights($blogid) or $this->disallow();
-
-               $memberid = $member->getID();
-
-               $blog =& $manager->getBlog($blogid);
-
-               $this->pagehead();
-               $this->parse('createitem');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_itemedit()
-       {
-               global $member, $manager;
-
-               $itemid = intRequestVar('itemid');
-
-               // only allow if user is allowed to alter item
-               $member->canAlterItem($itemid) or $this->disallow();
-
-               $item =& $manager->getItem($itemid, 1, 1);
-               $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
-               $this->pagehead();
-               $this->parse('itemedit');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_itemupdate()
-       {
-               global $member, $manager, $CONF;
-
-               $itemid = intRequestVar('itemid');
-               $catid  = postVar('catid');
-
-               // only allow if user is allowed to alter item
-               $member->canUpdateItem($itemid, $catid) or $this->disallow();
-
-               $actiontype = postVar('actiontype');
-
-               // delete actions are handled by itemdelete (which has confirmation)
-               if ( $actiontype == 'delete' )
-               {
-                       $this->action_itemdelete();
-                       return;
-               }
-
-               $body    = postVar('body');
-               $title   = postVar('title');
-               $more    = postVar('more');
-               $closed  = intPostVar('closed');
-               $draftid = intPostVar('draftid');
-
-               // default action = add now
-               if ( !$actiontype )
-               {
-                       $actiontype='addnow';
-               }
-
-               // create new category if needed
-               if ( strstr($catid,'newcat') )
-               {
-                       // get blogid
-                       list($blogid) = sscanf($catid,"newcat-%d");
-
-                       // create
-                       $blog =& $manager->getBlog($blogid);
-                       $catid = $blog->createNewCategory();
-
-                       // show error when sth goes wrong
-                       if ( !$catid )
-                       {
-                               $this->doError(_ERROR_CATCREATEFAIL);
-                       }
-               }
-
-               /*
-                       set some variables based on actiontype
-
-                       actiontypes:
-                               draft items -> addnow, addfuture, adddraft, delete
-                               non-draft items -> edit, changedate, delete
-
-                       variables set:
-                               $timestamp: set to a nonzero value for future dates or date changes
-                               $wasdraft: set to 1 when the item used to be a draft item
-                               $publish: set to 1 when the edited item is not a draft
-        */
-               $blogid =  getBlogIDFromItemID($itemid);
-               $blog   =& $manager->getBlog($blogid);
-
-               $wasdrafts = array('adddraft', 'addfuture', 'addnow');
-               $wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;
-               $publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
-               if ( $actiontype == 'addfuture' || $actiontype == 'changedate' )
-               {
-                       $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
-               }
-               else
-               {
-                       $timestamp =0;
-               }
-
-               // edit the item for real
-               Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
-
-               $this->updateFuturePosted($blogid);
-
-               if ( $draftid > 0 )
-               {
-                       // delete permission is checked inside Item::delete()
-                       Item::delete($draftid);
-               }
-
-               // show category edit window when we created a new category
-               // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
-               if ( $catid != intPostVar('catid') )
-               {
-                       $this->action_categoryedit(
-                               $catid,
-                               $blog->getID(),
-                               $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
-                       );
-               }
-               else
-               {
-                       // TODO: set start item correctly for itemlist
-                       $item = Item::getItem($itemid, 0, 0);
-                       $cnt  = quickQuery('SELECT COUNT(*) FROM ' . sql_table('item') . ' WHERE unix_timestamp(itime) <= ' . $item['timestamp']);
-                       $_REQUEST['start'] = $cnt + 1;
-                       $this->action_itemlist(getBlogIDFromItemID($itemid));
-               }
-       }
-       
-       /**
-        * Admin::action_itemdelete()
-        * Delete item
-        * 
-        * @param       Void
-        * @return      Void
-        */
-       function action_itemdelete()
-       {
-               global $member, $manager;
-               
-               $itemid = intRequestVar('itemid');
-               
-               // only allow if user is allowed to alter item
-               $member->canAlterItem($itemid) or $this->disallow();
-               
-               if ( !$manager->existsItem($itemid,1,1) )
-               {
-                       $this->error(_ERROR_NOSUCHITEM);
-               }
-               
-               $this->pagehead();
-               $this->parse('itemdelete');
-               $this->pagefoot();
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_itemdeleteconfirm()
-       {
-               global $member;
-
-               $itemid = intRequestVar('itemid');
-
-               // only allow if user is allowed to alter item
-               $member->canAlterItem($itemid) or $this->disallow();
-
-               // get blogid first
-               $blogid = getBlogIdFromItemId($itemid);
-
-               // delete item (note: some checks will be performed twice)
-               $this->deleteOneItem($itemid);
-
-               $this->action_itemlist($blogid);
-       }
-
-       /**
-        * Deletes one item and returns error if something goes wrong
-        * @param int $itemid
-        */
-       function deleteOneItem($itemid)
-       {
-               global $member, $manager;
-
-               // only allow if user is allowed to alter item (also checks if itemid exists)
-               if ( !$member->canAlterItem($itemid) )
-               {
-                       return _ERROR_DISALLOWED;
-               }
-
-               // need to get blogid before the item is deleted
-               $blogid = getBlogIDFromItemId($itemid);
-
-               $manager->loadClass('ITEM');
-               Item::delete($itemid);
-
-               // update blog's futureposted
-               $this->updateFuturePosted($blogid);
-       }
-
-       /**
-        * Admin::updateFuturePosted()
-        * Update a blog's future posted flag
-        * 
-        * @param integer $blogid
-        * @return      void
-        * 
-        */
-       function updateFuturePosted($blogid)
-       {
-               global $manager;
-               
-               $blogid      =  intval($blogid);
-               $blog        =& $manager->getBlog($blogid);
-               $currenttime =  $blog->getCorrectTime(time());
-               
-               $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
-               $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));
-               $result = sql_query($query);
-               
-               if ( sql_num_rows($result) > 0 )
-               {
-                               $blog->setFuturePost();
-               }
-               else
-               {
-                               $blog->clearFuturePost();
-               }
-               return;
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_itemmove()
-       {
-               global $member, $manager;
-
-               $itemid = intRequestVar('itemid');
-
-               // only allow if user is allowed to alter item
-               $member->canAlterItem($itemid) or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('itemmove');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_itemmoveto()
-       {
-               global $member, $manager;
-
-               $itemid = intRequestVar('itemid');
-               $catid = requestVar('catid');
-
-               // create new category if needed
-               if ( strstr($catid,'newcat') )
-               {
-                       // get blogid
-                       list($blogid) = sscanf($catid,'newcat-%d');
-
-                       // create
-                       $blog =& $manager->getBlog($blogid);
-                       $catid = $blog->createNewCategory();
-
-                       // show error when sth goes wrong
-                       if ( !$catid )
-                       {
-                               $this->doError(_ERROR_CATCREATEFAIL);
-                       }
-               }
-
-               // only allow if user is allowed to alter item
-               $member->canUpdateItem($itemid, $catid) or $this->disallow();
-
-               $old_blogid = getBlogIDFromItemId($itemid);
-
-               Item::move($itemid, $catid);
-
-               // set the futurePosted flag on the blog
-               $this->updateFuturePosted(getBlogIDFromItemId($itemid));
-
-               // reset the futurePosted in case the item is moved from one blog to another
-               $this->updateFuturePosted($old_blogid);
-
-               if ( $catid != intRequestVar('catid') )
-               {
-                       $this->action_categoryedit($catid, $blog->getID());
-               }
-               else
-               {
-                       $this->action_itemlist(getBlogIDFromCatID($catid));
-               }
-       }
-
-       /**
-        * Moves one item to a given category (category existance should be checked by caller)
-        * errors are returned
-        * @param int $itemid
-        * @param int $destCatid category ID to which the item will be moved
-        */
-       function moveOneItem($itemid, $destCatid)
-       {
-               global $member;
-
-               // only allow if user is allowed to move item
-               if ( !$member->canUpdateItem($itemid, $destCatid) )
-               {
-                       return _ERROR_DISALLOWED;
-               }
-
-               Item::move($itemid, $destCatid);
-       }
-
-       /**
-        * Adds a item to the chosen blog
-        */
-       function action_additem()
-       {
-               global $manager, $CONF;
-
-               $manager->loadClass('ITEM');
-
-               $result = Item::createFromRequest();
-
-               if ( $result['status'] == 'error' )
-               {
-                       $this->error($result['message']);
-               }
-
-               $blogid     =  getBlogIDFromItemID($result['itemid']);
-               $blog       =& $manager->getBlog($blogid);
-               $btimestamp =  $blog->getCorrectTime();
-               $item       =  $manager->getItem(intval($result['itemid']), 1, 1);
-
-               if ( $result['status'] == 'newcategory' )
-               {
-                       $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
-                       $this->action_categoryedit($result['catid'], $blogid, $distURI);
-               }
-               else
-               {
-                       $methodName = 'action_itemList';
-                       call_user_func(array(&$this, $methodName), $blogid);
-               }
-       }
-
-       /**
-        * Allows to edit previously made comments
-        **/
-       function action_commentedit()
-       {
-
-               global $member, $manager;
-
-               $commentid = intRequestVar('commentid');
-
-               $member->canAlterComment($commentid) or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('commentedit');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_commentupdate()
-       {
-               global $member, $manager;
-
-               $commentid = intRequestVar('commentid');
-
-               $member->canAlterComment($commentid) or $this->disallow();
-
-               $url   = postVar('url');
-               $email = postVar('email');
-               $body  = postVar('body');
-
-               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
-               # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
-               # important note that '\' must be matched with '\\\\' in preg* expressions
-
-               // intercept words that are too long
-               if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
-               {
-                       $this->error(_ERROR_COMMENT_LONGWORD);
-               }
-
-               // check length
-               if ( i18n::strlen($body) < 3 )
-               {
-                       $this->error(_ERROR_COMMENT_NOCOMMENT);
-               }
-
-               if ( i18n::strlen($body) > 5000 )
-               {
-                       $this->error(_ERROR_COMMENT_TOOLONG);
-               }
-
-               // prepare body
-               $body = Comment::prepareBody($body);
-
-               // call plugins
-               $manager->notify(
-                       'PreUpdateComment',
-                       array(
-                                       'body' => &$body
-                       )
-               );
-
-               $query = 'UPDATE ' . sql_table('comment')
-                          . " SET "
-                          . "    cmail   = '" . sql_real_escape_string($url) . "',"
-                          . "    cemail  = '" . sql_real_escape_string($email) . "',"
-                          . "    cbody   = '" . sql_real_escape_string($body) . "'"
-                          . " WHERE "
-                          . "    cnumber = " . $commentid;
-               sql_query($query);
-
-               // get itemid
-               $res    = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
-               $o      = sql_fetch_object($res);
-               $itemid = $o->citem;
-
-               if ( $member->canAlterItem($itemid) )
-               {
-                       $this->action_itemcommentlist($itemid);
-               }
-               else
-               {
-                       $this->action_browseowncomments();
-               }
-       }
-       
-       /**
-        * Admin::action_commentdelete()
-        * Update comment
-        * 
-        * @param       Void
-        * @return      Void
-        */
-       function action_commentdelete()
-       {
-               global $member, $manager;
-               
-               $commentid = intRequestVar('commentid');
-               $member->canAlterComment($commentid) or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('commentdelete');
-               $this->pagefoot();
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_commentdeleteconfirm()
-       {
-               global $member;
-
-               $commentid = intRequestVar('commentid');
-
-               // get item id first
-               $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
-               $o = sql_fetch_object($res);
-               $itemid = $o->citem;
-
-               $error = $this->deleteOneComment($commentid);
-               if ( $error )
-               {
-                       $this->doError($error);
-               }
-
-               if ( $member->canAlterItem($itemid) )
-               {
-                       $this->action_itemcommentlist($itemid);
-               }
-               else
-               {
-                       $this->action_browseowncomments();
-               }
-       }
-
-       /**
-        * @todo document this
-        */
-       function deleteOneComment($commentid) {
-               global $member, $manager;
-
-               $commentid = intval($commentid);
-
-               if ( !$member->canAlterComment($commentid) )
-               {
-                       return _ERROR_DISALLOWED;
-               }
-
-               $manager->notify(
-                       'PreDeleteComment',
-                       array(
-                               'commentid' => $commentid
-                       )
-               );
-
-               // delete the comments associated with the item
-               $query = 'DELETE FROM ' . sql_table('comment') . ' WHERE cnumber=' . $commentid;
-               sql_query($query);
-
-               $manager->notify(
-                       'PostDeleteComment',
-                       array(
-                               'commentid' => $commentid
-                       )
-               );
-
-               return '';
-       }
-
-       /**
-        * Usermanagement main
-        */
-       function action_usermanagement()
-       {
-               global $member, $manager;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('usermanagement');
-               $this->pagefoot();
-       }
-
-       /**
-        * Edit member settings
-        */
-       function action_memberedit()
-       {
-               $this->action_editmembersettings(intRequestVar('memberid'));
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_editmembersettings($memberid = '') {
-               global $member, $manager, $CONF;
-               
-               if ( $memberid == '' )
-               {
-                       $memberid = $member->getID();
-               }
-               $_REQUEST['memberid'] = $memberid;
-
-               // check if allowed
-               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-               
-               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-               $this->pagehead($extrahead);
-               $this->parse('editmembersettings');
-               $this->pagefoot();
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_changemembersettings() {
-               global $member, $CONF, $manager;
-
-               $memberid = intRequestVar('memberid');
-
-               // check if allowed
-               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-               $name           = trim(strip_tags(postVar('name')));
-               $realname       = trim(strip_tags(postVar('realname')));
-               $password       = postVar('password');
-               $repeatpassword = postVar('repeatpassword');
-               $email          = strip_tags(postVar('email'));
-               $url            = strip_tags(postVar('url'));
-               $adminskin      = intPostVar('adminskin');
-               
-               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
-               # original eregi: !eregi("^https?://", $url)
-
-               // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
-               if ( !preg_match('#^https?://#', $url) )
-               {
-                       $url = 'http://' . $url;
-               }
-
-               $admin          = postVar('admin');
-               $canlogin       = postVar('canlogin');
-               $notes          = strip_tags(postVar('notes'));
-               $locale         = postVar('locale');
-
-               $mem = Member::createFromID($memberid);
-
-               if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
-
-                       if ( !isValidDisplayName($name) )
-                       {
-                               $this->error(_ERROR_BADNAME);
-                       }
-
-                       if ( ($name != $mem->getDisplayName()) && Member::exists($name) )
-                       {
-                               $this->error(_ERROR_NICKNAMEINUSE);
-                       }
-
-                       if ( $password != $repeatpassword )
-                       {
-                               $this->error(_ERROR_PASSWORDMISMATCH);
-                       }
-
-                       if ( $password && (i18n::strlen($password) < 6) )
-                       {
-                               $this->error(_ERROR_PASSWORDTOOSHORT);
-                       }
-                               
-                       if ( $password )
-                       {
-                               $pwdvalid = true;
-                               $pwderror = '';
-                               $manager->notify(
-                                       'PrePasswordSet',
-                                       array(
-                                               'password'     => $password,
-                                               'errormessage' => &$pwderror,
-                                               'valid'        => &$pwdvalid
-                                       )
-                               );
-                               if ( !$pwdvalid )
-                               {
-                                       $this->error($pwderror);
-                               }
-                       }
-               }
-               
-               if ( !NOTIFICATION::address_validation($email) )
-               {
-                       $this->error(_ERROR_BADMAILADDRESS);
-               }
-               if ( !$realname )
-               {
-                       $this->error(_ERROR_REALNAMEMISSING);
-               }
-               if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
-               {
-                       $this->error(_ERROR_NOSUCHTRANSLATION);
-               }
-
-               // check if there will remain at least one site member with both the logon and admin rights
-               // (check occurs when taking away one of these rights from such a member)
-               if (    (!$admin && $mem->isAdmin() && $mem->canLogin())
-                       ||      (!$canlogin && $mem->isAdmin() && $mem->canLogin())
-                       )
-               {
-                       $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
-                       if ( sql_num_rows($r) < 2 )
-                       {
-                               $this->error(_ERROR_ATLEASTONEADMIN);
-                       }
-               }
-
-               if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )
-               {
-                       $mem->setDisplayName($name);
-                       if ( $password )
-                       {
-                               $mem->setPassword($password);
-                       }
-               }
-
-               $oldEmail = $mem->getEmail();
-
-               $mem->setRealName($realname);
-               $mem->setEmail($email);
-               $mem->setURL($url);
-               $mem->setNotes($notes);
-               $mem->setLocale($locale);
-
-
-               // only allow super-admins to make changes to the admin status
-               if ( $member->isAdmin() )
-               {
-                       $mem->setAdmin($admin);
-                       $mem->setCanLogin($canlogin);
-               }
-
-               $autosave = postVar('autosave');
-               $mem->setAutosave($autosave);
-
-               $mem->write();
-
-               // store plugin options
-               $aOptions = requestArray('plugoption');
-               NucleusPlugin::apply_plugin_options($aOptions);
-               $manager->notify(
-                       'PostPluginOptionsUpdate',
-                       array(
-                               'context'  => 'member',
-                               'memberid' => $memberid,
-                               'member'   => &$mem
-                       )
-               );
-
-               // if email changed, generate new password
-               if ( $oldEmail != $mem->getEmail() )
-               {
-                       $mem->sendActivationLink('addresschange', $oldEmail);
-                       // logout member
-                       $mem->newCookieKey();
-
-                       // only log out if the member being edited is the current member.
-                       if ( $member->getID() == $memberid )
-                       {
-                               $member->logout();
-                       }
-                       $this->action_login(_MSG_ACTIVATION_SENT, 0);
-                       return;
-               }
-
-
-               if (    ( $mem->getID() == $member->getID() )
-                       &&      ( $mem->getDisplayName() != $member->getDisplayName() )
-                       )
-               {
-                       $mem->newCookieKey();
-                       $member->logout();
-                       $this->action_login(_MSG_LOGINAGAIN, 0);
-               }
-               else
-               {
-                       $this->action_overview(_MSG_SETTINGSCHANGED);
-               }
-       }
-
-       /**
-        * Admin::action_memberadd()
-        * 
-        * @param       void
-        * @return      void
-        * 
-       */
-       function action_memberadd()
-       {
-               global $member, $manager;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               if ( postVar('password') != postVar('repeatpassword') )
-               {
-                       $this->error(_ERROR_PASSWORDMISMATCH);
-               }
-               
-               if ( i18n::strlen(postVar('password')) < 6 )
-               {
-                       $this->error(_ERROR_PASSWORDTOOSHORT);
-               }
-               
-               $res = Member::create(
-                                       postVar('name'),
-                                       postVar('realname'),
-                                       postVar('password'),
-                                       postVar('email'),
-                                       postVar('url'),
-                                       postVar('admin'),
-                                       postVar('canlogin'),
-                                       postVar('notes')
-                               );
-               if ( $res != 1 )
-               {
-                       $this->error($res);
-               }
-               
-               // fire PostRegister event
-               $newmem = new Member();
-               $newmem->readFromName(postVar('name'));
-               $manager->notify(
-                       'PostRegister',
-                       array(
-                               'member' => &$newmem
-                       )
-               );
-               
-               $this->action_usermanagement();
-               return;
-       }
-
-       /**
-        * Account activation
-        *
-        * @author dekarma
-        */
-       function action_activate()
-       {
-
-               $key = getVar('key');
-               $this->_showActivationPage($key);
-       }
-
-       /**
-        * @todo document this
-        */
-       function _showActivationPage($key, $message = '')
-       {
-               global $manager;
-
-               // clean up old activation keys
-               Member::cleanupActivationTable();
-
-               // get activation info
-               $info = Member::getActivationInfo($key);
-
-               if ( !$info )
-               {
-                       $this->error(_ERROR_ACTIVATE);
-               }
-
-               $mem = Member::createFromId($info->vmember);
-
-               if ( !$mem )
-               {
-                       $this->error(_ERROR_ACTIVATE);
-               }
-               $_POST['ackey']                = $key;
-               $this->headMess                = $message;
-               $_POST['bNeedsPasswordChange'] = true;
-               $this->pagehead();
-               $this->parse('activate');
-               $this->pagefoot();
-
-       }
-
-       /**
-        * Account activation - set password part
-        *
-        * @author dekarma
-        */
-       function action_activatesetpwd()
-       {
-
-               $key = postVar('key');
-
-               // clean up old activation keys
-               Member::cleanupActivationTable();
-
-               // get activation info
-               $info = Member::getActivationInfo($key);
-
-               if ( !$info || ($info->type == 'addresschange') )
-               {
-                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);
-               }
-
-               $mem = Member::createFromId($info->vmember);
-
-               if ( !$mem )
-               {
-                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);
-               }
-
-               $password       = postVar('password');
-               $repeatpassword = postVar('repeatpassword');
-
-               if ( $password != $repeatpassword )
-               {
-                       return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
-               }
-
-               if ( $password && (i18n::strlen($password) < 6) )
-               {
-                       return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
-               }
-                       
-               if ( $password )
-               {
-                       $pwdvalid = true;
-                       $pwderror = '';
-                       global $manager;
-                       $manager->notify(
-                               'PrePasswordSet',
-                               array(
-                                       'password'     => $password,
-                                       'errormessage' => &$pwderror,
-                                       'valid'        => &$pwdvalid
-                               )
-                       );
-                       if ( !$pwdvalid )
-                       {
-                               return $this->_showActivationPage($key,$pwderror);
-                       }
-               }
-
-               $error = '';
-               
-               $manager->notify(
-                       'ValidateForm',
-                       array(
-                               'type'   => 'activation',
-                               'member' => $mem,
-                               'error'  => &$error
-                       )
-               );
-               if ( $error != '' )
-               {
-                       return $this->_showActivationPage($key, $error);
-               }
-
-
-               // set password
-               $mem->setPassword($password);
-               $mem->write();
-
-               // do the activation
-               Member::activate($key);
-
-               $this->pagehead();
-               $this->parse('activatesetpwd');
-               $this->pagefoot();
-       }
-
-       /**
-        * Manage team
-        */
-       function action_manageteam()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               // check if allowed
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('manageteam');
-               $this->pagefoot();
-       }
-
-       /**
-        * Add member to team
-        */
-       function action_teamaddmember()
-       {
-               global $member, $manager;
-
-               $memberid = intPostVar('memberid');
-               $blogid = intPostVar('blogid');
-               $admin = intPostVar('admin');
-
-               // check if allowed
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-               if ( !$blog->addTeamMember($memberid, $admin) )
-               {
-                       $this->error(_ERROR_ALREADYONTEAM);
-               }
-
-               $this->action_manageteam();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_teamdelete()
-       {
-               global $member, $manager;
-
-               $memberid = intRequestVar('memberid');
-               $blogid   = intRequestVar('blogid');
-
-               // check if allowed
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $teammem =  Member::createFromID($memberid);
-               $blog    =& $manager->getBlog($blogid);
-
-               $this->pagehead();
-               $this->parse('teamdelete');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_teamdeleteconfirm()
-       {
-               global $member;
-
-               $memberid = intRequestVar('memberid');
-               $blogid = intRequestVar('blogid');
-
-               $error = $this->deleteOneTeamMember($blogid, $memberid);
-               if ( $error )
-               {
-                       $this->error($error);
-               }
-               $this->action_manageteam();
-       }
-
-       /**
-        * @todo document this
-        */
-       function deleteOneTeamMember($blogid, $memberid)
-       {
-               global $member, $manager;
-
-               $blogid   = intval($blogid);
-               $memberid = intval($memberid);
-
-               // check if allowed
-               if ( !$member->blogAdminRights($blogid) )
-               {
-                       return _ERROR_DISALLOWED;
-               }
-
-               // check if: - there remains at least one blog admin
-               //           - (there remains at least one team member)
-               $tmem = Member::createFromID($memberid);
-
-               $manager->notify(
-                       'PreDeleteTeamMember',
-                       array(
-                               'member' => &$tmem,
-                               'blogid' => $blogid
-                       )
-               );
-
-               if ( $tmem->isBlogAdmin($blogid) )
-               {
-                       // check if there are more blog members left and at least one admin
-                       // (check for at least two admins before deletion)
-                       $query = 'SELECT * FROM ' . sql_table('team') . ' WHERE tblog=' . $blogid . ' and tadmin=1';
-                       $r     = sql_query($query);
-                       if ( sql_num_rows($r) < 2 )
-                       {
-                               return _ERROR_ATLEASTONEBLOGADMIN;
-                       }
-               }
-
-               $query = 'DELETE FROM ' . sql_table('team') . " WHERE tblog=$blogid and tmember=$memberid";
-               sql_query($query);
-
-               $manager->notify(
-                       'PostDeleteTeamMember',
-                       array(
-                               'member' => &$tmem,
-                               'blogid' => $blogid
-                       )
-               );
-
-               return '';
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_teamchangeadmin()
-       {
-               global $member;
-
-               $blogid   = intRequestVar('blogid');
-               $memberid = intRequestVar('memberid');
-
-               // check if allowed
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $mem = Member::createFromID($memberid);
-
-               // don't allow when there is only one admin at this moment
-               if ( $mem->isBlogAdmin($blogid) )
-               {
-                       $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
-                       if ( sql_num_rows($r) == 1 )
-                       {
-                               $this->error(_ERROR_ATLEASTONEBLOGADMIN);
-                       }
-               }
-
-               if ( $mem->isBlogAdmin($blogid) )
-               {
-                       $newval = 0;
-               }
-               else
-               {
-                       $newval = 1;
-               }
-
-               $query = 'UPDATE ' . sql_table('team') . " SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
-               sql_query($query);
-
-               // only show manageteam if member did not change its own admin privileges
-               if ( $member->isBlogAdmin($blogid) )
-               {
-                       $this->action_manageteam();
-               }
-               else
-               {
-                       $this->action_overview(_MSG_ADMINCHANGED);
-               }
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_blogsettings()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               // check if allowed
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-
-               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-               $this->pagehead($extrahead);
-               $this->parse('blogsettings');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_categorynew()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $cname = postVar('cname');
-               $cdesc = postVar('cdesc');
-
-               if ( !isValidCategoryName($cname) )
-               {
-                       $this->error(_ERROR_BADCATEGORYNAME);
-               }
-
-               $query = 'SELECT * FROM ' . sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname) . '\' and cblog=' . intval($blogid);
-               $res = sql_query($query);
-               if ( sql_num_rows($res) > 0 )
-               {
-                       $this->error(_ERROR_DUPCATEGORYNAME);
-               }
-
-               $blog       =& $manager->getBlog($blogid);
-               $newCatID   =  $blog->createNewCategory($cname, $cdesc);
-
-               $this->action_blogsettings();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_categoryedit($catid = '', $blogid = '', $desturl = '')
-       {
-               global $member, $manager;
-
-               if ( $blogid == '' )
-               {
-                       $blogid = intGetVar('blogid');
-               }
-               else
-               {
-                       $blogid = intval($blogid);
-               }
-               if ( $catid == '' )
-               {
-                       $catid = intGetVar('catid');
-               }
-               else
-               {
-                       $catid = intval($catid);
-               }
-               $_REQUEST['blogid']  = $blogid;
-               $_REQUEST['catid']   = $catid;
-               $_REQUEST['desturl'] = $desturl;
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
-               $this->pagehead($extrahead);
-               $this->parse('categoryedit');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_categoryupdate()
-       {
-               global $member, $manager;
-
-               $blogid  = intPostVar('blogid');
-               $catid   = intPostVar('catid');
-               $cname   = postVar('cname');
-               $cdesc   = postVar('cdesc');
-               $desturl = postVar('desturl');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               if ( !isValidCategoryName($cname) )
-               {
-                       $this->error(_ERROR_BADCATEGORYNAME);
-               }
-
-               $query = "SELECT *"
-                          . " FROM " . sql_table('category')
-                          . " WHERE cname='" . sql_real_escape_string($cname) . "'"
-                          . " and cblog=" . intval($blogid)
-                          . " and not(catid=" . intval($catid) . ")";
-               $res   = sql_query($query);
-               if ( sql_num_rows($res) > 0 )
-               {
-                       $this->error(_ERROR_DUPCATEGORYNAME);
-               }
-
-               $query =  'UPDATE '.sql_table('category').' SET'
-                               . " cname='" . sql_real_escape_string($cname) . "',"
-                               . " cdesc='" . sql_real_escape_string($cdesc) . "'"
-                               . " WHERE catid=" . intval($catid);
-
-               sql_query($query);
-
-               // store plugin options
-               $aOptions = requestArray('plugoption');
-               NucleusPlugin::apply_plugin_options($aOptions);
-               $manager->notify(
-                       'PostPluginOptionsUpdate',
-                       array(
-                               'context' => 'category',
-                               'catid'   => $catid
-                       )
-               );
-
-
-               if ( $desturl )
-               {
-                       redirect($desturl);
-                       exit;
-               }
-               else
-               {
-                       $this->action_blogsettings();
-               }
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_categorydelete()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-               $catid  = intRequestVar('catid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-
-               // check if the category is valid
-               if ( !$blog->isValidCategory($catid) )
-               {
-                       $this->error(_ERROR_NOSUCHCATEGORY);
-               }
-
-               // don't allow deletion of default category
-               if ( $blog->getDefaultCategory() == $catid )
-               {
-                       $this->error(_ERROR_DELETEDEFCATEGORY);
-               }
-
-               // check if catid is the only category left for blogid
-               $query = 'SELECT catid FROM ' . sql_table('category') . ' WHERE cblog=' . $blogid;
-               $res = sql_query($query);
-               if ( sql_num_rows($res) == 1 )
-               {
-                       $this->error(_ERROR_DELETELASTCATEGORY);
-               }
-
-
-               $this->pagehead();
-               $this->parse('categorydelete');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_categorydeleteconfirm()
-       {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-               $catid  = intRequestVar('catid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $error = $this->deleteOneCategory($catid);
-               if ( $error )
-               {
-                       $this->error($error);
-               }
-
-               $this->action_blogsettings();
-       }
-       
-       /**
-        * Admin::deleteOneCategory()
-        * Delete a category by its id
-        * 
-        * @param       String  $catid  category id for deleting
-        * @return      Void
-        */
-       function deleteOneCategory($catid)
-       {
-               global $manager, $member;
-               
-               $catid  = intval($catid);
-               $blogid = getBlogIDFromCatID($catid);
-
-               if ( !$member->blogAdminRights($blogid) )
-               {
-                       return ERROR_DISALLOWED;
-               }
-
-               // get blog
-               $blog =& $manager->getBlog($blogid);
-
-               // check if the category is valid
-               if ( !$blog || !$blog->isValidCategory($catid) )
-               {
-                       return _ERROR_NOSUCHCATEGORY;
-               }
-
-               $destcatid = $blog->getDefaultCategory();
-
-               // don't allow deletion of default category
-               if ( $blog->getDefaultCategory() == $catid )
-               {
-                       return _ERROR_DELETEDEFCATEGORY;
-               }
-
-               // check if catid is the only category left for blogid
-               $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
-               $res = sql_query($query);
-               if ( sql_num_rows($res) == 1 )
-               {
-                       return _ERROR_DELETELASTCATEGORY;
-               }
-
-               $manager->notify(
-                       'PreDeleteCategory',
-                       array(
-                               'catid' => $catid
-                       )
-               );
-
-               // change category for all items to the default category
-               $query = 'UPDATE ' . sql_table('item') . " SET icat=$destcatid WHERE icat=$catid";
-               sql_query($query);
-               
-               // delete all associated plugin options
-               NucleusPlugin::delete_option_values('category', $catid);
-               
-               // delete category
-               $query = 'DELETE FROM ' . sql_table('category') . ' WHERE catid=' . $catid;
-               sql_query($query);
-               
-               $manager->notify(
-                       'PostDeleteCategory',
-                       array(
-                               'catid' => $catid
-                       )
-               );
-               return;
-       }
-       
-       /**
-        * Admin::action_blogsettingsupdate
-        * Updating blog settings
-        * 
-        * @param       Void
-        * @return      Void
-        */
-       function action_blogsettingsupdate()
-       {
-               global $member, $manager;
-               
-               $blogid = intRequestVar('blogid');
-               
-               $member->blogAdminRights($blogid) or $this->disallow();
-               
-               $blog =& $manager->getBlog($blogid);
-               
-               $notify_address = trim(postVar('notify'));
-               $shortname              = trim(postVar('shortname'));
-               $updatefile     = trim(postVar('update'));
-               
-               $notifyComment  = intPostVar('notifyComment');
-               $notifyVote             = intPostVar('notifyVote');
-               $notifyNewItem  = intPostVar('notifyNewItem');
-               
-               if ( $notifyComment == 0 )
-               {
-                       $notifyComment = 1;
-               }
-               if ( $notifyVote == 0 )
-               {
-                       $notifyVote = 1;
-               }
-               if ( $notifyNewItem == 0 )
-               {
-                       $notifyNewItem = 1;
-               }
-               $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
-               
-               if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
-               {
-                       $this->error(_ERROR_BADNOTIFY);
-               }
-               
-               if ( !isValidShortName($shortname) )
-               {
-                       $this->error(_ERROR_BADSHORTBLOGNAME);
-               }
-               
-               if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
-               {
-                       $this->error(_ERROR_DUPSHORTBLOGNAME);
-               }
-               // check if update file is writable
-               if ( $updatefile && !is_writeable($updatefile) )
-               {
-                       $this->error(_ERROR_UPDATEFILE);
-               }
-               
-               $blog->setName(trim(postVar('name')));
-               $blog->setShortName($shortname);
-               $blog->setNotifyAddress($notify_address);
-               $blog->setNotifyType($notifyType);
-               $blog->setMaxComments(postVar('maxcomments'));
-               $blog->setCommentsEnabled(postVar('comments'));
-               $blog->setTimeOffset(postVar('timeoffset'));
-               $blog->setUpdateFile($updatefile);
-               $blog->setURL(trim(postVar('url')));
-               $blog->setDefaultSkin(intPostVar('defskin'));
-               $blog->setDescription(trim(postVar('desc')));
-               $blog->setPublic(postVar('public'));
-               $blog->setConvertBreaks(intPostVar('convertbreaks'));
-               $blog->setAllowPastPosting(intPostVar('allowpastposting'));
-               $blog->setDefaultCategory(intPostVar('defcat'));
-               $blog->setSearchable(intPostVar('searchable'));
-               $blog->setEmailRequired(intPostVar('reqemail'));
-               $blog->writeSettings();
-               
-               // store plugin options
-               $aOptions = requestArray('plugoption');
-               NucleusPlugin::apply_plugin_options($aOptions);
-               $manager->notify(
-                       'PostPluginOptionsUpdate',
-                       array(
-                               'context' => 'blog',
-                               'blogid'  => $blogid,
-                               'blog'    => &$blog
-                       )
-               );
-               
-               $this->action_overview(_MSG_SETTINGSCHANGED);
-               return;
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_deleteblog()
-       {
-               global $member, $CONF, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               // check if blog is default blog
-               if ( $CONF['DefaultBlog'] == $blogid )
-               {
-                       $this->error(_ERROR_DELDEFBLOG);
-               }
-
-               $blog =& $manager->getBlog($blogid);
-
-               $this->pagehead();
-               $this->parse('deleteblog');
-               $this->pagefoot();
-       }
-       
-       /**
-        * Admin::action_deleteblogconfirm()
-        * Delete Blog
-        * 
-        * @param       Void
-        * @return      Void
-        */
-       function action_deleteblogconfirm()
-       {
-               global $member, $CONF, $manager;
-               
-               $blogid = intRequestVar('blogid');
-               $manager->notify(
-                       'PreDeleteBlog',
-                       array(
-                               'blogid' => $blogid
-                       )
-               );
-               $member->blogAdminRights($blogid) or $this->disallow();
-               
-               // check if blog is default blog
-               if ( $CONF['DefaultBlog'] == $blogid )
-               {
-                       $this->error(_ERROR_DELDEFBLOG);
-               }
-               
-               // delete all comments
-               $query = 'DELETE FROM ' . sql_table('comment') . ' WHERE cblog='.$blogid;
-               sql_query($query);
-               
-               // delete all items
-               $query = 'DELETE FROM ' . sql_table('item') . ' WHERE iblog=' . $blogid;
-               sql_query($query);
-               
-               // delete all team members
-               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tblog=' . $blogid;
-               sql_query($query);
-               
-               // delete all bans
-               $query = 'DELETE FROM ' . sql_table('ban') . ' WHERE blogid=' . $blogid;
-               sql_query($query);
-               
-               // delete all categories
-               $query = 'DELETE FROM ' . sql_table('category') . ' WHERE cblog=' . $blogid;
-               sql_query($query);
-               
-               // delete all associated plugin options
-               NucleusPlugin::delete_option_values('blog', $blogid);
-               
-               // delete the blog itself
-               $query = 'DELETE FROM ' . sql_table('blog') . ' WHERE bnumber=' . $blogid;
-               sql_query($query);
-               
-               $manager->notify(
-                       'PostDeleteBlog',
-                       array(
-                               'blogid' => $blogid
-                       )
-               );
-               
-               $this->action_overview(_DELETED_BLOG);
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_memberdelete()
-       {
-               global $member, $manager;
-
-               $memberid = intRequestVar('memberid');
-
-               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-               $mem = Member::createFromID($memberid);
-
-               $this->pagehead();
-               $this->parse('memberdelete');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_memberdeleteconfirm()
-       {
-               global $member;
-
-               $memberid = intRequestVar('memberid');
-
-               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
-               $error = $this->deleteOneMember($memberid);
-               if ( $error )
-               {
-                       $this->error($error);
-               }
-
-               if ( $member->isAdmin() )
-               {
-                       $this->action_usermanagement();
-               }
-               else
-               {
-                       $this->action_overview(_DELETED_MEMBER);
-               }
-       }
-       
-       /**
-        * Admin::deleteOneMember()
-        * Delete a member by id
-        * 
-        * @static
-        * @params      Integer $memberid       member id
-        * @return      String  null string or error messages
-        */
-       function deleteOneMember($memberid)
-       {
-               global $manager;
-               
-               $memberid = intval($memberid);
-               $mem = Member::createFromID($memberid);
-               
-               if ( !$mem->canBeDeleted() )
-               {
-                       return _ERROR_DELETEMEMBER;
-               }
-               
-               $manager->notify(
-                       'PreDeleteMember',
-                       array(
-                               'member' => &$mem
-                       )
-               );
-               
-               /* unlink comments from memberid */
-               if ( $memberid )
-               {
-                       $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";
-                       $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);
-                       sql_query($query);
-               }
-               
-               $query = 'DELETE FROM ' . sql_table('member') . ' WHERE mnumber=' . $memberid;
-               sql_query($query);
-               
-               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tmember=' . $memberid;
-               sql_query($query);
-               
-               $query = 'DELETE FROM ' . sql_table('activation') . ' WHERE vmember=' . $memberid;
-               sql_query($query);
-               
-               // delete all associated plugin options
-               NucleusPlugin::delete_option_values('member', $memberid);
-               
-               $manager->notify(
-                       'PostDeleteMember',
-                       array(
-                               'member' => &$mem
-                       )
-               );
-               
-               return '';
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_createnewlog()
-       {
-               global $member, $CONF, $manager;
-
-               // Only Super-Admins can do this
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-               $this->parse('createnewlog');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_addnewlog()
-       {
-               global $member, $manager, $CONF;
-
-               // Only Super-Admins can do this
-               $member->isAdmin() or $this->disallow();
-
-               $bname          = trim(postVar('name'));
-               $bshortname     = trim(postVar('shortname'));
-               $btimeoffset    = postVar('timeoffset');
-               $bdesc          = trim(postVar('desc'));
-               $bdefskin       = postVar('defskin');
-
-               if ( !isValidShortName($bshortname) )
-               {
-                       $this->error(_ERROR_BADSHORTBLOGNAME);
-               }
-
-               if ( $manager->existsBlog($bshortname) )
-               {
-                       $this->error(_ERROR_DUPSHORTBLOGNAME);
-               }
-
-               $manager->notify(
-                       'PreAddBlog',
-                       array(
-                               'name'        => &$bname,
-                               'shortname'   => &$bshortname,
-                               'timeoffset'  => &$btimeoffset,
-                               'description' => &$bdesc,
-                               'defaultskin' => &$bdefskin
-                       )
-               );
-
-
-               // add slashes for sql queries
-               $bname       = sql_real_escape_string($bname);
-               $bshortname  = sql_real_escape_string($bshortname);
-               $btimeoffset = sql_real_escape_string($btimeoffset);
-               $bdesc       = sql_real_escape_string($bdesc);
-               $bdefskin    = sql_real_escape_string($bdefskin);
-
-               // create blog
-               $query = 'INSERT '
-                          . 'INTO '
-                          .      sql_table('blog')
-                          . '('
-                          . '    bname, '
-                          . '    bshortname, '
-                          . '    bdesc, '
-                          . '    btimeoffset, '
-                          . '    bdefskin'
-                          . ') VALUES ('
-                          . "'" . $bname . "'," 
-                          . "'" . $bshortname . "'," 
-                          . "'" . $bdesc . "'," 
-                          . "'" . $btimeoffset . "'," 
-                          . "'" . $bdefskin . "'" 
-                          . ")";
-               sql_query($query);
-               $blogid =  sql_insert_id();
-               $blog   =& $manager->getBlog($blogid);
-
-               // create new category
-               $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
-               $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
-               $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
-               sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
-               $catid = sql_insert_id();
-
-               // set as default category
-               $blog->setDefaultCategory($catid);
-               $blog->writeSettings();
-
-               // create team member
-               $memberid = $member->getID();
-               $query    = 'INSERT '
-                                 . 'INTO '
-                                 .      sql_table('team')
-                                 . '('
-                                 . '    tmember, '
-                                 . '    tblog, '
-                                 . '    tadmin'
-                                 . ') VALUES ('
-                                 . '%d, '
-                                 . '%d, '
-                                 . '    1'
-                                 . ')';
-               sql_query(sprintf($query), $memberid, $blogid);
-
-               $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
-               $itemdefbody  = (defined('_EBLOG_FIRSTITEM_BODY')  ? _EBLOG_FIRSTITEM_BODY  : 'This is the first item in your weblog. Feel free to delete it.');
-
-               $blog->additem(
-                       $blog->getDefaultCategory(),
-                       $itemdeftitle,$itemdefbody,
-                       '',
-                       $blogid,
-                       $memberid,
-                       $blog->getCorrectTime(),
-                       0,
-                       0,
-                       0
-               );
-               $manager->notify(
-                       'PostAddBlog',
-                       array(
-                               'blog' => &$blog
-                       )
-               );
-
-               $manager->notify(
-                       'PostAddCategory',
-                       array(
-                               'blog'        => &$blog,
-                               'name'        => _EBLOGDEFAULTCATEGORY_NAME,
-                               'description' => _EBLOGDEFAULTCATEGORY_DESC,
-                               'catid'       => $catid
-                       )
-               );
-
-               $_REQUEST['blogid'] = $blogid;
-               $_REQUEST['catid']  = $catid;
-               $this->pagehead();
-               $this->parse('addnewlog');
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_addnewlog2()
-       {
-               global $member, $manager;
-               $blogid = intRequestVar('blogid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $burl   = requestVar('url');
-
-               $blog =& $manager->getBlog($blogid);
-               $blog->setURL(trim($burl));
-               $blog->writeSettings();
-
-               $this->action_overview(_MSG_NEWBLOG);
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinieoverview()
-       {
-               global $member, $DIR_LIBS, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               // load skinie class
-               include_once($DIR_LIBS . 'skinie.php');
-
-               $this->pagehead();
-               $this->parse('skinieoverview');
-               $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinieimport() {
-               global $member, $DIR_LIBS, $DIR_SKINS, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               // load skinie class
-               include_once($DIR_LIBS . 'skinie.php');
-
-               $skinFileRaw= postVar('skinfile');
-               $mode       = postVar('mode');
-
-               $importer = new SkinImport();
-
-               // get full filename
-               if ($mode == 'file')
-               {
-                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
-
-                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
-                       if (!file_exists($skinFile))
-                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
-               } else {
-                       $skinFile = $skinFileRaw;
-               }
-
-               // read only metadata
-               $error = $importer->readFile($skinFile, 1);
-
-               // clashes
-               $skinNameClashes = $importer->checkSkinNameClashes();
-               $templateNameClashes = $importer->checkTemplateNameClashes();
-               $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
-
-               if ($error) $this->error($error);
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
-               ?>
-               <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
-
-               <ul>
-                       <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
-                       <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-                       <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
-                       <?php
-                               if ($hasNameClashes)
-                               {
-                       ?>
-                       <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
-                       <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
-                       <?php
-                               } // if (hasNameClashes)
-                       ?>
-               </ul>
-
-               <form method="post" action="index.php"><div>
-                       <input type="hidden" name="action" value="skiniedoimport" />
-                       <?php $manager->addTicketHidden() ?>
-                       <input type="hidden" name="skinfile" value="<?php echo Entity::hsc(postVar('skinfile'))?>" />
-                       <input type="hidden" name="mode" value="<?php echo Entity::hsc($mode)?>" />
-                       <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
-                       <?php
-                               if ($hasNameClashes)
-                               {
-                       ?>
-                       <br />
-                       <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
-                       <?php
-                               } // if (hasNameClashes)
-                       ?>
-               </div></form>
-
-
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skiniedoimport() {
-               global $member, $DIR_LIBS, $DIR_SKINS;
-
-               $member->isAdmin() or $this->disallow();
-
-               // load skinie class
-               include_once($DIR_LIBS . 'skinie.php');
-
-               $skinFileRaw= postVar('skinfile');
-               $mode       = postVar('mode');
-
-               $allowOverwrite = intPostVar('overwrite');
-
-               // get full filename
-               if ($mode == 'file')
-               {
-                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
-
-                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
-                       if (!file_exists($skinFile))
-                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
-
-               } else {
-                       $skinFile = $skinFileRaw;
-               }
-
-               $importer = new SkinImport();
-
-               $error = $importer->readFile($skinFile);
-
-               if ($error)
-                       $this->error($error);
-
-               $error = $importer->writeToDatabase($allowOverwrite);
-
-               if ($error)
-                       $this->error($error);
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-       ?>
-               <h2><?php echo _SKINIE_DONE?></h2>
-
-               <ul>
-                       <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
-                       <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
-                       <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
-               </ul>
-
-       <?php       $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinieexport() {
-               global $member, $DIR_LIBS;
-
-               $member->isAdmin() or $this->disallow();
-
-               // load skinie class
-               include_once($DIR_LIBS . 'skinie.php');
-
-               $aSkins = requestIntArray('skin');
-               $aTemplates = requestIntArray('template');
-
-               if (!is_array($aTemplates)) $aTemplates = array();
-               if (!is_array($aSkins)) $aSkins = array();
-
-               $skinList = array_keys($aSkins);
-               $templateList = array_keys($aTemplates);
-
-               $info = postVar('info');
-
-               $exporter = new SkinExport();
-               foreach ($skinList as $skinId) {
-                       $exporter->addSkin($skinId);
-               }
-               foreach ($templateList as $templateId) {
-                       $exporter->addTemplate($templateId);
-               }
-               $exporter->setInfo($info);
-
-               $exporter->export();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templateoverview() {
-               global $member, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-               echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
-               echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
-
-               $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
-               $template['content'] = 'templatelist';
-               $template['tabindex'] = 10;
-               showlist($query,'table',$template);
-
-               echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
-
-               ?>
-               <form method="post" action="index.php"><div>
-
-               <input name="action" value="templatenew" type="hidden" />
-               <?php $manager->addTicketHidden() ?>
-               <table><tr>
-                       <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
-                       <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_DESC?></td>
-                       <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_CREATE?></td>
-                       <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-               </tr></table>
-
-               </div></form>
-
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templateedit($msg = '') {
-               global $member, $manager;
-
-               $templateid = intRequestVar('templateid');
-
-               $member->isAdmin() or $this->disallow();
-
-               $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
-               $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
-
-               $this->pagehead($extrahead);
-
-               $templatename = Template::getNameFromId($templateid);
-               $templatedescription = Template::getDesc($templateid);
-               $template =& $manager->getTemplate($templatename);
-
-               ?>
-               <p>
-               <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
-               </p>
-
-               <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo  Entity::hsc($templatename); ?>'</h2>
-
-               <?php                   if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-               ?>
-
-               <p><?php echo _TEMPLATE_EDIT_MSG?></p>
-
-               <form method="post" action="index.php">
-               <div>
-
-               <input type="hidden" name="action" value="templateupdate" />
-               <?php $manager->addTicketHidden() ?>
-               <input type="hidden" name="templateid" value="<?php echo  $templateid; ?>" />
-
-               <table><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
-                       <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo  Entity::hsc($templatename) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_DESC?></td>
-                       <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo  Entity::hsc($templatedescription) ?>" /></td>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_UPDATE?></td>
-                       <td>
-                               <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-                               <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
-                       </td>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
-       $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
-       $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
-       $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
-       $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
-       $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
-       $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
-       $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
-       $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
-       $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
-       $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
-       $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
-<?php
-       $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
-       $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
-       $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
-       $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
-       $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
-       $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
-       $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
-       $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
-       $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
-       $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
-       $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
-       $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
-       $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
-<?php  $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
-       $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
-<?php
-               $tab = 600;
-               $pluginfields = array();
-               $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
-
-               foreach ($pluginfields as $pfkey=>$pfvalue) {
-                       echo "</tr><tr>\n";
-                       echo '<th colspan="2">' . Entity::hen($pfkey) . "</th>\n";
-                       foreach ($pfvalue as $pffield=>$pfdesc) {
-                               $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
-                       }
-               }
-?>
-               </tr><tr>
-                       <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
-               </tr><tr>
-                       <td><?php echo _TEMPLATE_UPDATE?></td>
-                       <td>
-                               <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
-                               <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
-                       </td>
-               </tr></table>
-
-               </div>
-               </form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
-               static $count = 1;
-               if (!isset($template[$name])) $template[$name] = '';
-       ?>
-               </tr><tr>
-                       <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
-                       <td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo  Entity::hsc($template[$name]); ?></textarea></td>
-       <?php       $count++;
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templateupdate() {
-               global $member,$manager;
-
-               $templateid = intRequestVar('templateid');
-
-               $member->isAdmin() or $this->disallow();
-
-               $name = postVar('tname');
-               $desc = postVar('tdesc');
-
-               if (!isValidTemplateName($name))
-                       $this->error(_ERROR_BADTEMPLATENAME);
-
-               if ((Template::getNameFromId($templateid) != $name) && Template::exists($name))
-                       $this->error(_ERROR_DUPTEMPLATENAME);
-
-
-               $name = sql_real_escape_string($name);
-               $desc = sql_real_escape_string($desc);
-
-               // 1. Remove all template parts
-               $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
-               sql_query($query);
-
-               // 2. Update description
-               $query =  'UPDATE '.sql_table('template_desc').' SET'
-                               . " tdname='" . $name . "',"
-                               . " tddesc='" . $desc . "'"
-                               . " WHERE tdnumber=" . $templateid;
-               sql_query($query);
-
-               // 3. Add non-empty template parts
-               $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
-               $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
-               $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
-               $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
-               $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
-               $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
-               $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
-               $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
-               $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
-               $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
-               $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
-               $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
-               $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
-               $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
-               $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
-               $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
-               $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
-               $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
-               $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
-               $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
-               $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
-               $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
-               $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
-               $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
-               $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
-               $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
-               $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
-               $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
-               $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
-               $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
-               $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
-               $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
-               $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
-               $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
-
-               $pluginfields = array();
-               $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
-               foreach ($pluginfields as $pfkey=>$pfvalue) {
-                       foreach ($pfvalue as $pffield=>$pfdesc) {
-                               $this->addToTemplate($templateid, $pffield, postVar($pffield));
-                       }
-               }
-
-               // jump back to template edit
-               $this->action_templateedit(_TEMPLATE_UPDATED);
-
-       }
-
-       /**
-        * Admin::addToTemplate()
-        * 
-        * @param       Integer $id     ID for template
-        * @param       String  $partname       parts name
-        * @param       String  $content        template contents
-        * @return      Integer record index
-        * 
-        */
-       function addToTemplate($id, $partname, $content)
-       {
-               // don't add empty parts:
-               if ( !trim($content) )
-               {
-                       return -1;
-               }
-               
-               $partname = sql_real_escape_string($partname);
-               $content = sql_real_escape_string($content);
-               
-               $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, '%s', '%s')";
-               $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
-               sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
-               return sql_insert_id();
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_templatedelete() {
-               global $member, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               $templateid = intRequestVar('templateid');
-               // TODO: check if template can be deleted
-
-               $this->pagehead();
-
-               $name = Template::getNameFromId($templateid);
-               $desc = Template::getDesc($templateid);
-
-               ?>
-                       <h2><?php echo _DELETE_CONFIRM?></h2>
-
-                       <p>
-                       <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo Entity::hsc($name)?></b> (<?php echo  Entity::hsc($desc) ?>)
-                       </p>
-
-                       <form method="post" action="index.php"><div>
-                               <input type="hidden" name="action" value="templatedeleteconfirm" />
-                               <?php $manager->addTicketHidden() ?>
-                               <input type="hidden" name="templateid" value="<?php echo  $templateid ?>" />
-                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-                       </div></form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templatedeleteconfirm() {
-               global $member, $manager;
-
-               $templateid = intRequestVar('templateid');
-
-               $member->isAdmin() or $this->disallow();
-
-               $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
-
-               // 1. delete description
-               sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
-
-               // 2. delete parts
-               sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
-
-               $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
-
-               $this->action_templateoverview();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templatenew() {
-               global $member;
-
-               $member->isAdmin() or $this->disallow();
-
-               $name = postVar('name');
-               $desc = postVar('desc');
-
-               if (!isValidTemplateName($name))
-                       $this->error(_ERROR_BADTEMPLATENAME);
-
-               if (Template::exists($name))
-                       $this->error(_ERROR_DUPTEMPLATENAME);
-
-               $newTemplateId = Template::createNew($name, $desc);
-
-               $this->action_templateoverview();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_templateclone() {
-               global $member;
-
-               $templateid = intRequestVar('templateid');
-
-               $member->isAdmin() or $this->disallow();
-
-               // 1. read old template
-               $name = Template::getNameFromId($templateid);
-               $desc = Template::getDesc($templateid);
-
-               // 2. create desc thing
-               $name = "cloned" . $name;
-
-               // if a template with that name already exists:
-               if (Template::exists($name)) {
-                       $i = 1;
-                       while (Template::exists($name . $i))
-                               $i++;
-                       $name .= $i;
-               }
-
-               $newid = Template::createNew($name, $desc);
-
-               // 3. create clone
-               // go through parts of old template and add them to the new one
-               $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
-               while ($o = sql_fetch_object($res)) {
-                       $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
-               }
-
-               $this->action_templateoverview();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinoverview() {
-               global $member, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-               echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
-
-               echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
-
-               $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
-               $template['content'] = 'skinlist';
-               $template['tabindex'] = 10;
-               $template['friendly_names'] = Skin::getFriendlyNames();
-               showlist($query,'table',$template);
-               
-               echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
-
-               ?>
-               <form method="post" action="index.php">
-               <div>
-
-               <input name="action" value="skinnew" type="hidden" />
-               <?php $manager->addTicketHidden() ?>
-               <table><tr>
-                       <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-                       <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_DESC?></td>
-                       <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_CREATE?></td>
-                       <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
-               </tr></table>
-
-               </div>
-               </form>
-
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinnew() {
-               global $member;
-
-               $member->isAdmin() or $this->disallow();
-
-               $name = trim(postVar('name'));
-               $desc = trim(postVar('desc'));
-
-               if (!isValidSkinName($name))
-                       $this->error(_ERROR_BADSKINNAME);
-
-               if (SKIN::exists($name))
-                       $this->error(_ERROR_DUPSKINNAME);
-
-               $newId = SKIN::createNew($name, $desc);
-
-               $this->action_skinoverview();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinedit() {
-               global $member, $manager;
-
-               $skinid = intRequestVar('skinid');
-
-               $member->isAdmin() or $this->disallow();
-
-               $skin = new SKIN($skinid);
-
-               $this->pagehead();
-               ?>
-               <p>
-                       <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
-               </p>
-               <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo  $skin->getName() ?>'</h2>
-
-               <h3><?php echo _SKIN_PARTS_TITLE?></h3>
-               <?php echo _SKIN_PARTS_MSG?>
-               <ul>
-                       <li><a tabindex="10" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
-                       <li><a tabindex="20" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
-                       <li><a tabindex="30" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
-                       <li><a tabindex="40" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
-                       <li><a tabindex="50" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
-                       <li><a tabindex="60" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
-                       <li><a tabindex="70" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
-                       <li><a tabindex="75" href="index.php?action=skinedittype&amp;skinid=<?php echo  $skinid ?>&amp;type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
-               </ul>
-
-               <?php
-
-               $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
-               $res = sql_query($query);
-
-               echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
-               echo '<form method="get" action="index.php">' . "\r\n";
-               echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
-               echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
-               echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
-               echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
-               echo '</form>' . "\r\n";
-
-               if ($res && sql_num_rows($res) > 0) {
-                       echo '<ul>';
-                       $tabstart = 75;
-
-                       while ($row = sql_fetch_assoc($res)) {
-                               echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&amp;skinid=' . $skinid . '&amp;type=' . Entity::hsc(strtolower($row['stype'])) . '">' . Entity::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&amp;skinid=' . $skinid . '&amp;type=' . Entity::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
-                       }
-
-                       echo '</ul>';
-               }
-
-               ?>
-
-               <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
-               <form method="post" action="index.php">
-               <div>
-
-               <input type="hidden" name="action" value="skineditgeneral" />
-               <?php $manager->addTicketHidden() ?>
-               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-               <table><tr>
-                       <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
-                       <td><input name="name" tabindex="90" value="<?php echo  Entity::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_DESC?></td>
-                       <td><input name="desc" tabindex="100" value="<?php echo  Entity::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_TYPE?></td>
-                       <td><input name="type" tabindex="110" value="<?php echo  Entity::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
-                       <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
-                       <td><input name="inc_prefix" tabindex="130" value="<?php echo  Entity::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
-               </tr><tr>
-                       <td><?php echo _SKIN_CHANGE?></td>
-                       <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
-               </tr></table>
-
-               </div>
-               </form>
-
-
-               <?php       $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skineditgeneral() {
-               global $member;
-
-               $skinid = intRequestVar('skinid');
-
-               $member->isAdmin() or $this->disallow();
-
-               $name = postVar('name');
-               $desc = postVar('desc');
-               $type = postVar('type');
-               $inc_mode = postVar('inc_mode');
-               $inc_prefix = postVar('inc_prefix');
-
-               $skin = new SKIN($skinid);
-
-               // 1. Some checks
-               if (!isValidSkinName($name))
-                       $this->error(_ERROR_BADSKINNAME);
-
-               if (($skin->getName() != $name) && SKIN::exists($name))
-                       $this->error(_ERROR_DUPSKINNAME);
-
-               if (!$type) $type = 'text/html';
-               if (!$inc_mode) $inc_mode = 'normal';
-
-               // 2. Update description
-               $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
-
-               $this->action_skinedit();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinedittype($msg = '') {
-               global $member, $manager;
-
-               $skinid = intRequestVar('skinid');
-               $type = requestVar('type');
-
-               $member->isAdmin() or $this->disallow();
-
-               $type = trim($type);
-               $type = strtolower($type);
-
-               if (!isValidShortName($type)) {
-                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
-               }
-
-               $skin = new SKIN($skinid);
-
-               $friendlyNames = SKIN::getFriendlyNames();
-
-               $this->pagehead();
-               ?>
-               <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
-
-               <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo Entity::hsc($skin->getName()) ?>': <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
-
-               <?php           if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
-               ?>
-
-
-               <form method="post" action="index.php">
-               <div>
-
-               <input type="hidden" name="action" value="skinupdate" />
-               <?php $manager->addTicketHidden() ?>
-               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-               <input type="hidden" name="type" value="<?php echo  $type ?>" />
-
-               <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-               <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-               (skin type: <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-               <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-                       help('skinpart' . $type);
-               } else {
-                       help('skinpartspecial');
-               }?>
-               <br />
-
-               <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo  Entity::hsc($skin->getContent($type)) ?></textarea>
-
-               <br />
-               <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
-               <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
-               (skin type: <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
-
-               <br /><br />
-               <?php echo _SKIN_ALLOWEDVARS?>
-               <?php           $actions = SKIN::getAllowedActionsForType($type);
-
-                       sort($actions);
-
-                       while ($current = array_shift($actions)) {
-                               // skip deprecated vars
-                               if ($current == 'ifcat') continue;
-                               if ($current == 'imagetext') continue;
-                               if ($current == 'vars') continue;
-
-                               echo helplink('skinvar-' . $current) . "$current</a>";
-                               if (count($actions) != 0) echo ", ";
-                       }
-               echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
-               $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
-               showlist($query,'table',array('content'=>'shortblognames'));
-               echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
-               $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
-               showlist($query,'table',array('content'=>'shortnames'));
-               echo '</div></form>';
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinupdate() {
-               global $member;
-
-               $skinid = intRequestVar('skinid');
-               $content = trim(postVar('content'));
-               $type = postVar('type');
-
-               $member->isAdmin() or $this->disallow();
-
-               $skin = new SKIN($skinid);
-               $skin->update($type, $content);
-
-               $this->action_skinedittype(_SKIN_UPDATED);
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skindelete() {
-               global $member, $manager, $CONF;
-
-               $skinid = intRequestVar('skinid');
-
-               $member->isAdmin() or $this->disallow();
-
-               // don't allow default skin to be deleted
-               if ($skinid == $CONF['BaseSkin'])
-                       $this->error(_ERROR_DEFAULTSKIN);
-
-               // don't allow deletion of default skins for blogs
-               $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-               $r = sql_query($query);
-               if ($o = sql_fetch_object($r))
-                       $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($o->bname));
-
-               $this->pagehead();
-
-               $skin = new SKIN($skinid);
-               $name = $skin->getName();
-               $desc = $skin->getDescription();
-
-               ?>
-                       <h2><?php echo _DELETE_CONFIRM?></h2>
-
-                       <p>
-                               <?php echo _CONFIRMTXT_SKIN?><b><?php echo Entity::hsc($name) ?></b> (<?php echo  Entity::hsc($desc)?>)
-                       </p>
-
-                       <form method="post" action="index.php"><div>
-                               <input type="hidden" name="action" value="skindeleteconfirm" />
-                               <?php $manager->addTicketHidden() ?>
-                               <input type="hidden" name="skinid" value="<?php echo  $skinid ?>" />
-                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-                       </div></form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skindeleteconfirm() {
-               global $member, $CONF, $manager;
-
-               $skinid = intRequestVar('skinid');
-
-               $member->isAdmin() or $this->disallow();
-
-               // don't allow default skin to be deleted
-               if ($skinid == $CONF['BaseSkin'])
-                       $this->error(_ERROR_DEFAULTSKIN);
-
-               // don't allow deletion of default skins for blogs
-               $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
-               $r = sql_query($query);
-               if ($o = sql_fetch_object($r))
-                       $this->error(_ERROR_SKINDEFDELETE .$o->bname);
-
-               $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
-
-               // 1. delete description
-               sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
-
-               // 2. delete parts
-               sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
-
-               $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
-
-               $this->action_skinoverview();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinremovetype() {
-               global $member, $manager, $CONF;
-
-               $skinid = intRequestVar('skinid');
-               $skintype = requestVar('type');
-
-               if (!isValidShortName($skintype)) {
-                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-               }
-
-               $member->isAdmin() or $this->disallow();
-
-               // don't allow default skinparts to be deleted
-               if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-               }
-
-               $this->pagehead();
-
-               $skin = new SKIN($skinid);
-               $name = $skin->getName();
-               $desc = $skin->getDescription();
-
-               ?>
-                       <h2><?php echo _DELETE_CONFIRM?></h2>
-
-                       <p>
-                               <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo Entity::hsc($skintype); ?> (<?php echo Entity::hsc($name); ?>)</b> (<?php echo  Entity::hsc($desc)?>)
-                       </p>
-
-                       <form method="post" action="index.php"><div>
-                               <input type="hidden" name="action" value="skinremovetypeconfirm" />
-                               <?php $manager->addTicketHidden() ?>
-                               <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
-                               <input type="hidden" name="type" value="<?php echo Entity::hsc($skintype); ?>" />
-                               <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-                       </div></form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinremovetypeconfirm() {
-               global $member, $CONF, $manager;
-
-               $skinid = intRequestVar('skinid');
-               $skintype = requestVar('type');
-
-               if (!isValidShortName($skintype)) {
-                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-               }
-
-               $member->isAdmin() or $this->disallow();
-
-               // don't allow default skinparts to be deleted
-               if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
-                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
-               }
-
-               $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-               // delete part
-               sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
-
-               $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
-
-               $this->action_skinedit();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_skinclone() {
-               global $member;
-
-               $skinid = intRequestVar('skinid');
-
-               $member->isAdmin() or $this->disallow();
-
-               // 1. read skin to clone
-               $skin = new SKIN($skinid);
-
-               $name = "clone_" . $skin->getName();
-
-               // if a skin with that name already exists:
-               if (SKIN::exists($name)) {
-                       $i = 1;
-                       while (SKIN::exists($name . $i))
-                               $i++;
-                       $name .= $i;
-               }
-
-               // 2. create skin desc
-               $newid = SKIN::createNew(
-                       $name,
-                       $skin->getDescription(),
-                       $skin->getContentType(),
-                       $skin->getIncludeMode(),
-                       $skin->getIncludePrefix()
-               );
-
-
-               // 3. clone
-               /*
-               $this->skinclonetype($skin, $newid, 'index');
-               $this->skinclonetype($skin, $newid, 'item');
-               $this->skinclonetype($skin, $newid, 'archivelist');
-               $this->skinclonetype($skin, $newid, 'archive');
-               $this->skinclonetype($skin, $newid, 'search');
-               $this->skinclonetype($skin, $newid, 'error');
-               $this->skinclonetype($skin, $newid, 'member');
-               $this->skinclonetype($skin, $newid, 'imagepopup');
-        */
-
-               $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
-               $res = sql_query($query);
-               while ($row = sql_fetch_assoc($res)) {
-                       $this->skinclonetype($skin, $newid, $row['stype']);
-               }
-
-               $this->action_skinoverview();
-
-       }
-
-       /**
-        * Admin::skinclonetype()
-        * 
-        * @param       String  $skin   Skin object
-        * @param       Integer $newid  ID for this clone
-        * @param       String  $type   type of skin
-        * @return      Void
-        */
-       function skinclonetype($skin, $newid, $type)
-       {
-               $newid = intval($newid);
-               $content = $skin->getContent($type);
-               
-               if ( $content )
-               {
-                       $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
-                       $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
-                       sql_query($query);
-               }
-               return;
-       }
-       
-       /**
-        * Admin::action_settingsedit()
-        * 
-        * @param       Void
-        * @return      Void
-        */
-       function action_settingsedit() {
-               global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
-
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-               ?>
-
-               <h2><?php echo _SETTINGS_TITLE?></h2>
-
-               <form action="index.php" method="post">
-               <div>
-
-               <input type="hidden" name="action" value="settingsupdate" />
-               <?php $manager->addTicketHidden() ?>
-
-               <table><tr>
-                       <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
-                       <td>
-                               <?php
-                                       $query =  'SELECT bname as text, bnumber as value'
-                                                       . ' FROM '.sql_table('blog');
-                                       $template['name'] = 'DefaultBlog';
-                                       $template['selected'] = $CONF['DefaultBlog'];
-                                       $template['tabindex'] = 10;
-                                       showlist($query,'select',$template);
-                               ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
-                       <td>
-                               <?php
-                                       $query =  'SELECT sdname as text, sdnumber as value'
-                                                       . ' FROM '.sql_table('skin_desc');
-                                       $template['name'] = 'BaseSkin';
-                                       $template['selected'] = $CONF['BaseSkin'];
-                                       $template['tabindex'] = 1;
-                                       showlist($query,'select',$template);
-                               ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ADMINMAIL?></td>
-                       <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo  Entity::hsc($CONF['AdminEmail']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_SITENAME?></td>
-                       <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo  Entity::hsc($CONF['SiteName']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_SITEURL?></td>
-                       <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo  Entity::hsc($CONF['IndexURL']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ADMINURL?></td>
-                       <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo  Entity::hsc($CONF['AdminURL']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
-                       <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo  Entity::hsc($CONF['PluginURL']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
-                       <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo  Entity::hsc($CONF['SkinsURL']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
-                       <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo  Entity::hsc($CONF['ActionURL']) ?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_LOCALE?> <?php help('locale'); ?>
-                       </td>
-                       <td>
-                               <select name="Locale" tabindex="10050">
-                       <?php
-                               $locales = i18n::get_available_locale_list();
-                               if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
-                               {
-                                       echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
-                               }
-                               else
-                               {
-                                       echo "<option value=\"\">en_Latn_US</option>\n";
-                               }
-                               
-                               foreach ( $locales as $locale )
-                               {
-                                       if ( $locale == 'en_Latn_US' )
-                                       {
-                                               continue;
-                                       }
-                                       if ( $locale == i18n::get_current_locale() )
-                                       {
-                                               echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
-                                       }
-                                       else
-                                       {
-                                               echo "<option value=\"{$locale}\">{$locale}</option>\n";
-                                       }
-                               }
-                       ?>
-                       </select>
-
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
-                       </td>
-                       <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
-                                       <br />
-                               <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo  Entity::hsc($CONF['DisableSiteURL'])?>" />
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DIRS?></td>
-                       <td><?php echo  Entity::hsc($DIR_NUCLEUS) ?>
-                               <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DBLOGIN?></td>
-                       <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
-               </tr><tr>
-                       <td>
-                       <?php
-                               echo _SETTINGS_JSTOOLBAR
-                               /* =_SETTINGS_DISABLEJS
-
-                                       I temporary changed the meaning of DisableJsTools, until I can find a good
-                                       way to select the javascript version to use
-
-                                       now, its:
-                                               0 : IE
-                                               1 : all javascript disabled
-                                               2 : 'simpler' javascript (for mozilla/opera/mac)
-                        */
-                               ?>
-                       </td>
-                       <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
-                               <select name="DisableJsTools" tabindex="10075">
-                       <?php                              $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
-                                       echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
-                                       $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
-                                       echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
-                                       $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
-                                       echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
-                       ?>
-                               </select>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
-                                               <td><?php
-
-                                               $this->input_yesno('URLMode',$CONF['URLMode'],10077,
-                                                               'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
-
-                                               echo ' ', _SETTINGS_URLMODE_HELP;
-
-                                                               ?>
-
-                                               </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
-                                               <td><?php
-
-                                               $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
-
-                                                               ?>
-
-                                               </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
-                       <td>
-                       <?php
-                               if (!array_key_exists('DefaultListSize',$CONF)) {
-                                       sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
-                                       $CONF['DefaultListSize'] = 10;
-                               }
-                       ?>
-                               <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo  Entity::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ADMINCSS?> 
-                       </td>
-                       <td>
-
-                               <select name="AdminCSS" tabindex="10080">
-                               <?php                      // show a dropdown list of all available admin css files
-                               global $DIR_NUCLEUS;
-                               
-                               $dirhandle = opendir($DIR_NUCLEUS."styles/");
-
-                               while ($filename = readdir($dirhandle) )
-                               {
-
-                                       # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
-                                       # original ereg: ereg("^(.*)\.php$",$filename,$matches)
-
-                                       if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
-                                       {
-
-                                               $name = $matches[1];
-                                               echo "<option value=\"$name\"";
-
-                                               if ($name == $CONF['AdminCSS'])
-                                               {
-                                                       echo " selected=\"selected\"";
-                                               }
-
-                                               echo ">$name</option>";
-
-                                       }
-
-                               }
-
-                               closedir($dirhandle);
-
-                               ?>
-                               </select>
-
-                       </td>
-               </tr><tr>
-                       <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_MEDIADIR?></td>
-                       <td><?php echo  Entity::hsc($DIR_MEDIA) ?>
-                               <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
-                               <?php                              if (!is_dir($DIR_MEDIA))
-                                               echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
-                                       if (!is_readable($DIR_MEDIA))
-                                               echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
-                                       if (!is_writeable($DIR_MEDIA))
-                                               echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
-                               ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_MEDIAURL?></td>
-                       <td>
-                               <input name="MediaURL" tabindex="10090" size="40" value="<?php echo  Entity::hsc($CONF['MediaURL']) ?>" />
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
-                       <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
-                       <td>
-                               <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo  Entity::hsc($CONF['AllowedTypes']) ?>" />
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
-                       <td>
-                               <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo  Entity::hsc($CONF['MaxUploadSize']) ?>" />
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
-                       <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
-
-               </tr><tr>
-                       <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_CHANGELOGIN?></td>
-                       <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_ALLOWCREATE?>
-                               <?php help('allowaccountcreation'); ?>
-                       </td>
-                       <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
-                               <br /><?php echo _SETTINGS_NEWLOGIN2?>
-                       </td>
-                       <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_MEMBERMSGS?>
-                               <?php help('messageservice'); ?>
-                       </td>
-                       <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_NONMEMBERMSGS?>
-                               <?php help('messageservice'); ?>
-                       </td>
-                       <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
-                               <?php help('protectmemnames'); ?>
-                       </td>
-                       <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
-                       </td>
-
-
-
-               </tr><tr>
-                       <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
-                       <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo  Entity::hsc($CONF['CookiePrefix'])?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
-                       <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo  Entity::hsc($CONF['CookieDomain'])?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_COOKIEPATH?></td>
-                       <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo  Entity::hsc($CONF['CookiePath'])?>" /></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_COOKIESECURE?></td>
-                       <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_COOKIELIFE?></td>
-                       <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
-                                                               1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
-                       </td>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_LASTVISIT?></td>
-                       <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
-
-
-
-               </tr><tr>
-                       <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
-               </tr><tr>
-                       <td><?php echo _SETTINGS_UPDATE?></td>
-                       <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
-               </tr></table>
-
-               </div>
-               </form>
-
-               <?php
-                       echo '<h2>',_PLUGINS_EXTRA,'</h2>';
-
-                       $manager->notify(
-                               'GeneralSettingsFormExtras',
-                               array()
-                       );
-
-               $this->pagefoot();
-       }
-       
-       /**
-        * Admin::action_settingsupdate()
-        * Update $CONFIG and redirect
-        * 
-        * @param       void
-        * @return      void
-        */
-       function action_settingsupdate() {
-               global $member, $CONF;
-               
-               $member->isAdmin() or $this->disallow();
-               
-               // check if email address for admin is valid
-               if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
-               {
-                       $this->error(_ERROR_BADMAILADDRESS);
-               }
-               
-               // save settings
-               $this->updateConfig('DefaultBlog',        postVar('DefaultBlog'));
-               $this->updateConfig('BaseSkin',          postVar('BaseSkin'));
-               $this->updateConfig('IndexURL',          postVar('IndexURL'));
-               $this->updateConfig('AdminURL',          postVar('AdminURL'));
-               $this->updateConfig('PluginURL',                postVar('PluginURL'));
-               $this->updateConfig('SkinsURL',          postVar('SkinsURL'));
-               $this->updateConfig('ActionURL',                postVar('ActionURL'));
-               $this->updateConfig('Locale',              postVar('Locale'));
-               $this->updateConfig('AdminEmail',          postVar('AdminEmail'));
-               $this->updateConfig('SessionCookie',    postVar('SessionCookie'));
-               $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
-               $this->updateConfig('AllowMemberMail',  postVar('AllowMemberMail'));
-               $this->updateConfig('NonmemberMail',    postVar('NonmemberMail'));
-               $this->updateConfig('ProtectMemNames',  postVar('ProtectMemNames'));
-               $this->updateConfig('SiteName',          postVar('SiteName'));
-               $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
-               $this->updateConfig('DisableSite',        postVar('DisableSite'));
-               $this->updateConfig('DisableSiteURL',   postVar('DisableSiteURL'));
-               $this->updateConfig('LastVisit',                postVar('LastVisit'));
-               $this->updateConfig('MediaURL',          postVar('MediaURL'));
-               $this->updateConfig('AllowedTypes',      postVar('AllowedTypes'));
-               $this->updateConfig('AllowUpload',        postVar('AllowUpload'));
-               $this->updateConfig('MaxUploadSize',    postVar('MaxUploadSize'));
-               $this->updateConfig('MediaPrefix',        postVar('MediaPrefix'));
-               $this->updateConfig('AllowLoginEdit',   postVar('AllowLoginEdit'));
-               $this->updateConfig('DisableJsTools',   postVar('DisableJsTools'));
-               $this->updateConfig('CookieDomain',      postVar('CookieDomain'));
-               $this->updateConfig('CookiePath',          postVar('CookiePath'));
-               $this->updateConfig('CookieSecure',      postVar('CookieSecure'));
-               $this->updateConfig('URLMode',            postVar('URLMode'));
-               $this->updateConfig('CookiePrefix',      postVar('CookiePrefix'));
-               $this->updateConfig('DebugVars',                        postVar('DebugVars'));
-               $this->updateConfig('DefaultListSize',            postVar('DefaultListSize'));
-               $this->updateConfig('AdminCSS',           postVar('AdminCSS'));
-               
-               // load new config and redirect (this way, the new locale will be used is necessary)
-               // note that when changing cookie settings, this redirect might cause the user
-               // to have to log in again.
-               getConfig();
-               redirect($CONF['AdminURL'] . '?action=manage');
-               exit;
-       }
-
-       /**
-        * Admin::action_systemoverview()
-        * Output system overview
-        * 
-        * @param       void
-        * @return      void
-        */
-       function action_systemoverview()
-       {
-               global $member, $nucleus, $CONF;
-               
-               $this->pagehead();
-               
-               echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
-               
-               if ( $member->isLoggedIn() && $member->isAdmin() )
-               {
-                       // Information about the used PHP and MySQL installation
-                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
-                       
-                       // Version of PHP MySQL
-                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
-                       echo '<td>' . phpversion() . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
-                       echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
-                       echo "</tr>\n";
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-                       
-                       // Important PHP settings
-                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       echo "<tr>\n";
-                       echo '<td>magic_quotes_gpc' . "</td>\n";
-                       $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
-                       echo '<td>' . $mqg . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>magic_quotes_runtime' . "</td>\n";
-                       $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
-                       echo '<td>' . $mqr . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>register_globals' . "</td>\n";
-                       $rg = ini_get('register_globals') ? 'On' : 'Off';
-                       echo '<td>' . $rg . "</td>\n";
-                       echo "</tr>\n";
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-                       
-                       // Information about GD library
-                       $gdinfo = gd_info();
-                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       foreach ( $gdinfo as $key=>$value )
-                       {
-                               if ( is_bool($value) )
-                               {
-                                       $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
-                               }
-                               else
-                               {
-                                       $value = Entity::hsc($value);
-                               }
-                               echo "<tr>\n";
-                               echo '<td>' . $key . "</td>\n";
-                               echo '<td>' . $value . "</td>\n";
-                               echo "</tr>\n";
-                       }
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-
-                       // Check if special modules are loaded
-                       ob_start();
-                       phpinfo(INFO_MODULES);
-                       $im = ob_get_contents();
-                       ob_clean();
-                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>";
-                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
-                       echo "</tr>\n";
-                       echo "<tbody>\n";
-                       echo "<tr>\n";
-                       echo '<td>mod_rewrite' . "</td>\n";
-                       $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
-                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :
-                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;
-                       echo '<td>' . $modrewrite . "</td>\n";
-                       echo "</tr>\n";
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-
-                       // Information about the used Nucleus CMS
-                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
-                       global $nucleus;
-                       $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
-                       $np = getNucleusPatchLevel();
-                       echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       echo '<th colspan="2">Nucleus CMS' . "</th>\n";
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
-                       echo '<td>' . $nv . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
-                       echo '<td>' . $np . "</td>\n";
-                       echo "</tr>\n";
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-
-                       // Important settings of the installation
-                       echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
-                       echo "<thead>\n";
-                       echo "<tr>\n";
-                       echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
-                       echo "</tr>\n";
-                       echo "</thead>\n";
-                       echo "<tbody>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . '$CONF[' . "'Self']</td>\n";
-                       echo '<td>' . $CONF['Self'] . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
-                       echo '<td>' . $CONF['ItemURL'] . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
-                       $ohs = $CONF['alertOnHeadersSent'] ?
-                                               _ADMIN_SYSTEMOVERVIEW_ENABLE :
-                                               _ADMIN_SYSTEMOVERVIEW_DISABLE;
-                       echo '<td>' . $ohs . "</td>\n";
-                       echo "</tr>\n";
-                       echo "<tr>\n";
-                       echo "<td>i18n::get_current_charset()</td>\n";
-                       echo '<td>' . i18n::get_current_charset() . "</td>\n";
-                       echo "</tr>\n";
-                       echo "</tbody>\n";
-                       echo "</table>\n\n";
-
-                       // Link to the online version test at the Nucleus CMS website
-                       echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
-                       if ( $nucleus['codename'] != '')
-                       {
-                               $codenamestring = ' &quot;' . $nucleus['codename'] . '&quot;';
-                       }
-                       else
-                       {
-                               $codenamestring = '';
-                       }
-                       echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
-                       $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-                       echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
-                       echo 'Nucleus CMS ' . $nv . $codenamestring;
-                       echo '</a>';
-               }
-               else
-               {
-                       echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
-               }
-               $this->pagefoot();
-       }
-
-       /**
-        * Admin::updateConfig()
-        * 
-        * @param       string  $name   
-        * @param       string  $val    
-        * @return      integer return the ID in which the latest query posted
-        */
-       function updateConfig($name, $val)
-       {
-               $name = sql_real_escape_string($name);
-               $val = trim(sql_real_escape_string($val));
-               
-               $query = "UPDATE %s SET value='%s' WHERE name='%s'";
-               $query = sprintf($query, sql_table('config'), $val, $name);
-               sql_query($query) or die("Query error: " . sql_error());
-               return sql_insert_id();
-       }
-       
-       /**
-        * Error message
-        * @param string $msg message that will be shown
-        */
-       function error($msg)
-       {
-               $this->pagehead();
-               
-               echo "<h2>Error!</h2>\n";
-               echo $msg;
-               echo "<br />\n";
-               echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
-               $this->pagefoot();
-               exit;
-       }
-       
-       /**
-        * Admin::disallow()
-        * add error log and show error page 
-        * 
-        * @param       void
-        * @return      void
-        */
-       function disallow()
-       {
-               ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
-               $this->error(_ERROR_DISALLOWED);
-       }
-       
-       /**
-        * Admin::pagehead()
-        * Output admin page head
-        * 
-        * @param       void
-        * @return      void
-        */
-       function pagehead($extrahead = '')
-       {
-               global $member, $nucleus, $CONF, $manager;
-               
-               $manager->notify(
-                       'AdminPrePageHead',
-                       array(
-                               'extrahead' => &$extrahead,
-                               'action' => $this->action));
-               
-               $baseUrl = Entity::hsc($CONF['AdminURL']);
-               if ( !array_key_exists('AdminCSS',$CONF) )
-               {
-                       sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
-                       $CONF['AdminCSS'] = 'original';
-               }
-               
-               /* HTTP 1.1 application for no caching */
-               header("Cache-Control: no-cache, must-revalidate");
-               header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
-               
-               $root_element = 'html';
-               $charset = i18n::get_current_charset();
-               $locale = preg_replace('#_#', '-', i18n::get_current_locale());
-               
-               echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
-               echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
-               echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
-               echo "<head>\n";
-               echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
-               echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
-               echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
-               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
-               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
-               echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
-               echo "{$extrahead}\n";
-               echo "</head>\n\n";
-               echo "<body>\n";
-               echo "<div id=\"adminwrapper\">\n";
-               echo "<div class=\"header\">\n";
-               echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
-               echo "</div>\n";
-               echo "<div id=\"container\">\n";
-               echo "<div id=\"content\">\n";
-               echo "<div class=\"loginname\">\n";
-               if ( $member->isLoggedIn() )
-               {
-                       echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
-                       echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
-               }
-               else
-               {
-                       echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
-               }
-               echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
-               echo '(';
-               
-               if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
-               {
-                       $codenamestring = ' &quot;' . $nucleus['codename'].'&quot;';
-               }
-               else
-               {
-                       $codenamestring = '';
-               }
-               
-               if ( $member->isLoggedIn() && $member->isAdmin() )
-               {
-                       $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
-                       echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
-                       
-                       $newestVersion = getLatestVersion();
-                       $newestCompare = str_replace('/','.',$newestVersion);
-                       $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
-                       if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
-                       {
-                               echo "<br />\n";
-                               echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
-                               echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
-                               echo "</a>";
-                       }
-               }
-               else
-               {
-                       echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
-               }
-               echo ')';
-               echo '</div>';
-               return;
-       }
-       
-       /**
-        * Admin::pagefoot()
-        * Output admin page foot include quickmenu
-        * 
-        * @param       void
-        * @return      void
-        */
-       function pagefoot()
-       {
-               global $action, $member, $manager;
-               
-               $manager->notify(
-                       'AdminPrePageFoot',
-                       array('action' => $this->action)
-               );
-               
-               if ( $member->isLoggedIn() && ($action != 'showlogin') )
-               {
-                       echo '<h2>' . _LOGOUT . "</h2>\n";
-                       echo "<ul>\n";
-                       echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
-                       echo '<li><a href="index.php?action=logout">' .  _LOGOUT . "</a></li>\n";
-                       echo "</ul>\n";
-               }
-               
-               echo "<div class=\"foot\">\n";
-               echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> &copy; 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
-               echo '-';
-               echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
-               echo "</div>\n";
-               
-               echo "<!-- content -->\n";
-               echo "<div id=\"quickmenu\">\n";
-               
-               if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
-               {
-                       echo "<ul>\n";
-                       echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
-                       echo "</ul>\n";
-                       
-                       echo '<h2>' . _QMENU_ADD . "</h2>\n";
-                       echo "<form method=\"get\" action=\"index.php\">\n";
-                       echo "<p>\n";
-                       echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
-                       
-                       $showAll = requestVar('showall');
-                       
-                       if ( ($member->isAdmin()) && ($showAll == 'yes') )
-                       {
-                               // Super-Admins have access to all blogs! (no add item support though)
-                               $query =  'SELECT bnumber as value, bname as text'
-                                               . ' FROM ' . sql_table('blog')
-                                               . ' ORDER BY bname';
-                       }
-                       else
-                       {
-                               $query =  'SELECT bnumber as value, bname as text'
-                                               . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
-                                               . ' WHERE tblog=bnumber and tmember=' . $member->getID()
-                                               . ' ORDER BY bname';
-                       }
-                       $template['name'] = 'blogid';
-                       $template['tabindex'] = 15000;
-                       $template['extra'] = _QMENU_ADD_SELECT;
-                       $template['selected'] = -1;
-                       $template['shorten'] = 10;
-                       $template['shortenel'] = '';
-                       $template['javascript'] = 'onchange="return form.submit()"';
-                       showlist($query,'select',$template);
-                       
-                       echo "</p>\n";
-                       echo "</form>\n";
-                       
-                       echo "<h2>{$member->getDisplayName()}</h2>\n";
-                       echo "<ul>\n";
-                       echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
-                       echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
-                       echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
-                       echo "</ul>\n";
-                       
-                       // ---- general settings ----
-                       if ( $member->isAdmin() )
-                       {
-                               echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
-                               echo "<ul>\n";
-                               echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
-                               echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
-                               echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
-                               echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
-                               echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
-                               echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
-                               echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
-                               echo "</ul>\n";
-                               
-                               echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
-                               echo "<ul>\n";
-                               echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
-                               echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
-                               echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
-                               echo "</ul>\n";
-                       }
-                       
-                       $aPluginExtras = array();
-                       $manager->notify(
-                               'QuickMenu',
-                               array(
-                                       'options' => &$aPluginExtras));
-                       
-                       if ( count($aPluginExtras) > 0 )
-                       {
-                               echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
-                               echo "<ul>\n";
-                               foreach ( $aPluginExtras as $aInfo )
-                               {
-                                       echo '<li><a href="' . Entity::hsc($aInfo['url']) . '" title="' . Entity::hsc($aInfo['tooltip']) . '">' . Entity::hsc($aInfo['title']) . "</a></li>\n";
-                               }
-                               echo "</ul>\n";
-                       }
-               }
-               else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
-               {
-               
-                       echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
-               }
-               else
-               {
-                       // introduction text on login screen
-                       echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
-               }
-               
-               echo "<!-- quickmenu -->\n";
-               echo "</div>\n";
-               
-               echo "<!-- content -->\n";
-               echo "</div>\n";
-               
-               echo "<!-- container -->\n";
-               echo "</div>\n";
-               
-               echo "<!-- adminwrapper -->\n";
-               echo "</div>\n";
-               
-               echo "</body>\n";
-               echo "</html>\n";
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_regfile() {
-               global $member, $CONF;
-
-               $blogid = intRequestVar('blogid');
-
-               $member->teamRights($blogid) or $this->disallow();
-
-               // header-code stolen from phpMyAdmin
-               // REGEDIT and bookmarklet code stolen from GreyMatter
-
-               $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
-
-
-               header('Content-Type: application/octetstream');
-               header('Content-Disposition: filename="nucleus.reg"');
-               header('Pragma: no-cache');
-               header('Expires: 0');
-
-               echo "REGEDIT4\n";
-               echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
-               echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
-               echo '"contexts"=hex:31';
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_bookmarklet() {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               $member->teamRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-               $bm = getBookmarklet($blogid);
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-
-               ?>
-
-               <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
-
-               <p>
-               <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
-               </p>
-
-               <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
-               <p>
-                       <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
-                       <br />
-                       <br />
-                       <?php echo '<a href="' . Entity::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, Entity::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
-               </p>
-
-               <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
-               <p>
-                       <?php
-                               $url = 'index.php?action=regfile&blogid=' . intval($blogid);
-                               $url = $manager->addTicketToUrl($url);
-                       ?>
-                       <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . Entity::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
-               </p>
-
-               <p>
-                       <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
-               </p>
-
-               <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
-               <p>
-                       <?php echo _BOOKMARKLET_DELETEBAR ?>
-               </p>
-
-               <p>
-                       <?php echo _BOOKMARKLET_DELETERIGHTT ?>
-               </p>
-
-               <ol>
-                       <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
-                       <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
-                       <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
-                       <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
-                       <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
-               </ol>
-
-               <?php
-               $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_actionlog() {
-               global $member, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-
-               $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
-
-               ?>
-                       <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
-                       <p><a href="<?php echo Entity::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
-               <?php
-               echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
-
-               $query =  'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
-               $template['content'] = 'actionlist';
-               $amount = showlist($query,'table',$template);
-
-               $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlist() {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
-
-               echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
-
-               $query =  'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
-               $template['content'] = 'banlist';
-               $amount = showlist($query,'table',$template);
-
-               if ($amount == 0)
-                       echo _BAN_NONE;
-
-               echo '<h2>'._BAN_NEW_TITLE.'</h2>';
-               echo "<p><a href='index.php?action=banlistnew&amp;blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
-
-
-               $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlistdelete() {
-               global $member, $manager;
-
-               $blogid = intRequestVar('blogid');
-               $iprange = requestVar('iprange');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-               $banBlogName =  Entity::hsc($blog->getName());
-
-               $this->pagehead();
-               ?>
-                       <h2><?php echo _BAN_REMOVE_TITLE?></h2>
-
-                       <form method="post" action="index.php">
-
-                       <h3><?php echo _BAN_IPRANGE?></h3>
-
-                       <p>
-                               <?php echo _CONFIRMTXT_BAN?> <?php echo Entity::hsc($iprange) ?>
-                               <input name="iprange" type="hidden" value="<?php echo Entity::hsc($iprange)?>" />
-                       </p>
-
-                       <h3><?php echo _BAN_BLOGS?></h3>
-
-                       <div>
-                               <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-                               <input name="allblogs" type="radio" value="0" id="allblogs_one" />
-                               <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
-                               <br />
-                               <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
-                       </div>
-
-                       <h3><?php echo _BAN_DELETE_TITLE?></h3>
-
-                       <div>
-                               <?php $manager->addTicketHidden() ?>
-                               <input type="hidden" name="action" value="banlistdeleteconfirm" />
-                               <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-                       </div>
-
-                       </form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlistdeleteconfirm() {
-               global $member, $manager;
-
-               $blogid = intPostVar('blogid');
-               $allblogs = postVar('allblogs');
-               $iprange = postVar('iprange');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $deleted = array();
-
-               if (!$allblogs) {
-                       if (Ban::removeBan($blogid, $iprange))
-                               array_push($deleted, $blogid);
-               } else {
-                       // get blogs fot which member has admin rights
-                       $adminblogs = $member->getAdminBlogs();
-                       foreach ($adminblogs as $blogje) {
-                               if (Ban::removeBan($blogje, $iprange))
-                                       array_push($deleted, $blogje);
-                       }
-               }
-
-               if (sizeof($deleted) == 0)
-                       $this->error(_ERROR_DELETEBAN);
-
-               $this->pagehead();
-
-               echo '<a href="index.php?action=banlist&amp;blogid=',$blogid,'">(',_BACK,')</a>';
-               echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
-               echo "<p>"._BAN_REMOVED_TEXT."</p>";
-
-               echo "<ul>";
-               foreach ($deleted as $delblog) {
-                       $b =& $manager->getBlog($delblog);
-                       echo "<li>" . Entity::hsc($b->getName()). "</li>";
-               }
-               echo "</ul>";
-
-               $this->pagefoot();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlistnewfromitem() {
-               $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlistnew($blogid = '') {
-               global $member, $manager;
-
-               if ($blogid == '')
-                       $blogid = intRequestVar('blogid');
-
-               $ip = requestVar('ip');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               $blog =& $manager->getBlog($blogid);
-
-               $this->pagehead();
-               ?>
-               <h2><?php echo _BAN_ADD_TITLE?></h2>
-
-
-               <form method="post" action="index.php">
-
-               <h3><?php echo _BAN_IPRANGE?></h3>
-
-               <p><?php echo _BAN_IPRANGE_TEXT?></p>
-
-               <div class="note">
-                       <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
-                       <?php echo _BAN_EXAMPLE_TEXT ?>
-               </div>
-
-               <div>
-               <?php
-               if ($ip) {
-                       $iprangeVal = Entity::hsc($ip);
-               ?>
-                       <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
-                       <label for="ip_fixed"><?php echo $iprangeVal ?></label>
-                       <br />
-                       <input name="iprange" type="radio" value="custom" id="ip_custom" />
-                       <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
-                       <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
-               <?php
-               } else {
-                       echo "<input name='iprange' value='custom' type='hidden' />";
-                       echo "<input name='customiprange' value='' maxlength='15' size='15' />";
-               }
-               ?>
-               </div>
-
-               <h3><?php echo _BAN_BLOGS?></h3>
-
-               <p><?php echo _BAN_BLOGS_TEXT?></p>
-
-               <div>
-                       <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
-                       <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo Entity::hsc($blog->getName())?>'</label>
-                       <br />
-                       <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
-               </div>
-
-               <h3><?php echo _BAN_REASON_TITLE?></h3>
-
-               <p><?php echo _BAN_REASON_TEXT?></p>
-
-               <div><textarea name="reason" cols="40" rows="5"></textarea></div>
-
-               <h3><?php echo _BAN_ADD_TITLE?></h3>
-
-               <div>
-                       <input name="action" type="hidden" value="banlistadd" />
-                       <?php $manager->addTicketHidden() ?>
-                       <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
-               </div>
-
-               </form>
-
-               <?php       $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_banlistadd() {
-               global $member;
-
-               $blogid =       intPostVar('blogid');
-               $allblogs =     postVar('allblogs');
-               $iprange =      postVar('iprange');
-               if ($iprange == "custom")
-                       $iprange = postVar('customiprange');
-               $reason =       postVar('reason');
-
-               $member->blogAdminRights($blogid) or $this->disallow();
-
-               // TODO: check IP range validity
-
-               if (!$allblogs) {
-                       if (!Ban::addBan($blogid, $iprange, $reason))
-                               $this->error(_ERROR_ADDBAN);
-               } else {
-                       // get blogs fot which member has admin rights
-                       $adminblogs = $member->getAdminBlogs();
-                       $failed = 0;
-                       foreach ($adminblogs as $blogje) {
-                               if (!Ban::addBan($blogje, $iprange, $reason))
-                                       $failed = 1;
-                       }
-                       if ($failed)
-                               $this->error(_ERROR_ADDBAN);
-               }
-
-               $this->action_banlist();
-
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_clearactionlog() {
-               global $member;
-
-               $member->isAdmin() or $this->disallow();
-
-               ActionLog::clear();
-
-               $this->action_manage(_MSG_ACTIONLOGCLEARED);
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_backupoverview() {
-               global $member, $manager;
-
-               $member->isAdmin() or $this->disallow();
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-               ?>
-               <h2><?php echo _BACKUPS_TITLE?></h2>
-
-               <h3><?php echo _BACKUP_TITLE?></h3>
-
-               <p><?php echo _BACKUP_INTRO?></p>
-
-               <form method="post" action="index.php"><p>
-               <input type="hidden" name="action" value="backupcreate" />
-               <?php $manager->addTicketHidden() ?>
-
-               <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
-               <br />
-               <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
-               <br /><br />
-               <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
-
-               </p></form>
-
-               <div class="note"><?php echo _BACKUP_NOTE?></div>
-
-
-               <h3><?php echo _RESTORE_TITLE?></h3>
-
-               <div class="note"><?php echo _RESTORE_NOTE?></div>
-
-               <p><?php echo _RESTORE_INTRO?></p>
-
-               <form method="post" action="index.php" enctype="multipart/form-data"><p>
-                       <input type="hidden" name="action" value="backuprestore" />
-                       <?php $manager->addTicketHidden() ?>
-                       <input name="backup_file" type="file" tabindex="30" />
-                       <br /><br />
-                       <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
-                       <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
-                       <br /><?php echo _RESTORE_WARNING?>
-               </p></form>
-
-               <?php       $this->pagefoot();
-       }
-
-       /**
-        * Admin::action_backupcreate()
-        * create file for backup
-        * 
-        * @param               void
-        * @return      void
-        * 
-        */
-       function action_backupcreate()
-       {
-               global $member, $DIR_LIBS;
-               
-               $member->isAdmin() or $this->disallow();
-               
-               // use compression ?
-               $useGzip = (integer) postVar('gzip');
-               
-               include($DIR_LIBS . 'backup.php');
-               
-               // try to extend time limit
-               // (creating/restoring dumps might take a while)
-               @set_time_limit(1200);
-               
-               Backup::do_backup($useGzip);
-               exit;
-       }
-       
-       /**
-        * Admin::action_backuprestore()
-        * restoring from uploaded file
-        * 
-        * @param               void
-        * @return      void
-        */
-       function action_backuprestore()
-       {
-               global $member, $DIR_LIBS;
-               
-               $member->isAdmin() or $this->disallow();
-               
-               if ( intPostVar('letsgo') != 1 )
-               {
-                       $this->error(_ERROR_BACKUP_NOTSURE);
-               }
-               
-               include($DIR_LIBS . 'backup.php');
-               
-               // try to extend time limit
-               // (creating/restoring dumps might take a while)
-               @set_time_limit(1200);
-               
-               $message = Backup::do_restore();
-               if ( $message != '' )
-               {
-                       $this->error($message);
-               }
-               $this->pagehead();
-               echo '<h2>' . _RESTORE_COMPLETE . "</h2>\n";
-               $this->pagefoot();
-               return;
-       }
-       
-       /**
-        * Admin::action_pluginlist()
-        * output the list of installed plugins
-        * 
-        * @param       void
-        * @return      void
-        * 
-        */
-       function action_pluginlist()
-       {
-               global $DIR_PLUGINS, $member, $manager;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               $this->pagehead();
-               
-               echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
-               
-               echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
-               
-               echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' &nbsp;&nbsp;<span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
-               
-               $query =  'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
-               
-               $template['content'] = 'pluginlist';
-               $template['tabindex'] = 10;
-               showlist($query, 'table', $template);
-               
-               echo '<h3>' . _PLUGS_TITLE_UPDATE . "</h3>\n";
-               echo '<p>' . _PLUGS_TEXT_UPDATE . "</p>\n";
-               echo '<form method="post" action="index.php">' . "\n";
-               echo "<div>\n";
-               echo '<input type="hidden" name="action" value="pluginupdate" />' . "\n";
-               $manager->addTicketHidden();
-               echo '<input type="submit" value="' . _PLUGS_BTN_UPDATE . '" tabindex="20" />' . "\n";
-               echo "</div>\n";
-               echo "</form>\n";
-               
-               echo '<h3>' . _PLUGS_TITLE_NEW . "</h3>\n";
-               
-               // find a list of possibly non-installed plugins
-               $candidates = array();
-               $dirhandle = opendir($DIR_PLUGINS);
-               
-               while ( $filename = readdir($dirhandle) )
-               {
-                       if ( preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
-                       {
-                               $name = $matches[1];
-                               
-                               // only show in list when not yet installed
-                               $query = 'SELECT * FROM %s WHERE pfile = "NP_%s"';
-                               $query = sprintf($query, sql_table('plugin'), sql_real_escape_string($name));
-                               $res = sql_query($query);
-                               
-                               if ( sql_num_rows($res) == 0 )
-                               {
-                                       array_push($candidates, $name);
-                               }
-                       }
-               }
-               
-               closedir($dirhandle);
-               
-               if ( sizeof($candidates) > 0 )
-               {
-                       echo '<p>' . _PLUGS_ADD_TEXT . "</p>\n";
-                       
-                       echo '<form method="post" action="index.php">' . "\n";
-                       echo "<div>\n";
-                       echo '<input type="hidden" name="action" value="pluginadd" />' . "\n";
-                       $manager->addTicketHidden();
-                       echo '<select name="filename" tabindex="30">' . "\n";
-                       
-                       foreach ( $candidates as $name )
-                       {
-                               echo '<option value="NP_',$name,'">',Entity::hsc($name),'</option>';
-                       }
-                       
-                       echo "</select>\n";
-                       echo '<input type="submit" tabindex="40" value="' . _PLUGS_BTN_INSTALL ."\" />\n";
-                       echo "</div>\n";
-                       echo "</form>\n";
-               }
-               else
-               {
-                       echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
-               }
-               
-               $this->pagefoot();
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_pluginhelp() {
-               global $member, $manager, $DIR_PLUGINS, $CONF;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $plugid = intGetVar('plugid');
-
-               if (!$manager->pidInstalled($plugid))
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-
-               $plugName = getPluginNameFromPid($plugid);
-
-               $this->pagehead();
-
-               echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
-
-               echo '<h2>',_PLUGS_HELP_TITLE,': ',Entity::hsc($plugName),'</h2>';
-
-               $plug =& $manager->getPlugin($plugName);
-               $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
-
-               if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
-                       @readfile($helpFile);
-               } else {
-                       echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
-                       echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
-               }
-
-
-               $this->pagefoot();
-       }
-
-       /**
-        * Admin::action_pluginadd()
-        * 
-        * @param       Void
-        * @return      Void
-        * 
-        */
-       function action_pluginadd()
-       {
-               global $member, $manager, $DIR_PLUGINS;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               $name = postVar('filename');
-               
-               if ( $manager->pluginInstalled($name) )
-               {
-                       $this->error(_ERROR_DUPPLUGIN);
-               }
-               
-               if ( !checkPlugin($name) )
-               {
-                       $this->error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');
-               }
-               
-               // get number of currently installed plugins
-               $res = sql_query('SELECT * FROM '.sql_table('plugin'));
-               $numCurrent = sql_num_rows($res);
-               
-               // plugin will be added as last one in the list
-               $newOrder = $numCurrent + 1;
-               
-               $manager->notify(
-                       'PreAddPlugin',
-                       array(
-                               'file' => &$name
-                       )
-               );
-               
-               // do this before calling getPlugin (in case the plugin id is used there)
-               $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
-               sql_query($query);
-               $iPid = sql_insert_id();
-               
-               $manager->clearCachedInfo('installedPlugins');
-               
-               // Load the plugin for condition checking and instalation
-               $plugin =& $manager->getPlugin($name);
-               
-               // check if it got loaded (could have failed)
-               if ( !$plugin )
-               {
-                       sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
-                       $manager->clearCachedInfo('installedPlugins');
-                       $this->error(_ERROR_PLUGIN_LOAD);
-               }
-               
-               // check if plugin needs a newer Nucleus version
-               if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
-               {
-                       // uninstall plugin again...
-                       $this->deleteOnePlugin($plugin->getID());
-                       
-                       // ...and show error
-                       $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));
-               }
-               
-               // check if plugin needs a newer Nucleus version
-               if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
-               {
-                       // uninstall plugin again...
-                       $this->deleteOnePlugin($plugin->getID());
-                       
-                       // ...and show error
-                       $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
-               }
-               
-               $pluginList = $plugin->getPluginDep();
-               foreach ( $pluginList as $pluginName )
-               {
-                       $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
-                       if (sql_num_rows($res) == 0)
-                       {
-                               // uninstall plugin again...
-                               $this->deleteOnePlugin($plugin->getID());
-                               $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
-                       }
-               }
-               
-               // call the install method of the plugin
-               $plugin->install();
-               
-               $manager->notify(
-                       'PostAddPlugin',
-                       array(
-                               'plugin' => &$plugin
-                       )
-               );
-               
-               // update all events
-               $this->action_pluginupdate();
-               return;
-       }
-       
-       /**
-        * ADMIN:action_pluginupdate():
-        * 
-        * @param       Void
-        * @return      Void
-        * 
-        */
-       function action_pluginupdate()
-       {
-               global $member, $manager, $CONF;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               // delete everything from plugin_events
-               sql_query('DELETE FROM '.sql_table('plugin_event'));
-               
-               // loop over all installed plugins
-               $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
-               while ( $o = sql_fetch_object($res) )
-               {
-                       $pid = $o->pid;
-                       $plug =& $manager->getPlugin($o->pfile);
-                       if ( $plug )
-                       {
-                               $eventList = $plug->getEventList();
-                               foreach ( $eventList as $eventName )
-                               {
-                                       $query = "INSERT INTO %s (pid, event) VALUES (%d, '%s')";
-                                       $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, sql_real_escape_string($eventName));
-                                       sql_query($query);
-                               }
-                       }
-               }
-               redirect($CONF['AdminURL'] . '?action=pluginlist');
-               return;
-       }
-       
-       /**
-        * @todo document this
-        */
-       function action_plugindelete() {
-               global $member, $manager;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $pid = intGetVar('plugid');
-
-               if (!$manager->pidInstalled($pid))
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-
-               $this->pagehead();
-               ?>
-                       <h2><?php echo _DELETE_CONFIRM?></h2>
-
-                       <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
-
-                       <form method="post" action="index.php"><div>
-                       <?php $manager->addTicketHidden() ?>
-                       <input type="hidden" name="action" value="plugindeleteconfirm" />
-                       <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
-                       <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
-                       </div></form>
-               <?php
-               $this->pagefoot();
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_plugindeleteconfirm() {
-               global $member, $manager, $CONF;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $pid = intPostVar('plugid');
-
-               $error = $this->deleteOnePlugin($pid, 1);
-               if ($error) {
-                       $this->error($error);
-               }
-
-               redirect($CONF['AdminURL'] . '?action=pluginlist');
-//             $this->action_pluginlist();
-       }
-
-       /**
-        * @todo document this
-        */
-       function deleteOnePlugin($pid, $callUninstall = 0) {
-               global $manager;
-
-               $pid = intval($pid);
-
-               if (!$manager->pidInstalled($pid))
-                       return _ERROR_NOSUCHPLUGIN;
-
-               $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
-
-/*             // call the unInstall method of the plugin
-               if ($callUninstall) {
-                       $plugin =& $manager->getPlugin($name);
-                       if ($plugin) $plugin->unInstall();
-               }*/
-
-               // check dependency before delete
-               $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
-               while($o = sql_fetch_object($res)) {
-                       $plug =& $manager->getPlugin($o->pfile);
-                       if ($plug)
-                       {
-                               $depList = $plug->getPluginDep();
-                               foreach ($depList as $depName)
-                               {
-                                       if ($name == $depName)
-                                       {
-                                               return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
-                                       }
-                               }
-                       }
-               }
-
-               $manager->notify('PreDeletePlugin', array('plugid' => $pid));
-
-               // call the unInstall method of the plugin
-               if ($callUninstall) {
-                       $plugin =& $manager->getPlugin($name);
-                       if ($plugin) $plugin->unInstall();
-               }
-
-               // delete all subscriptions
-               sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
-
-               // delete all options
-               // get OIDs from plugin_option_desc
-               $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
-               $aOIDs = array();
-               while ($o = sql_fetch_object($res)) {
-                       array_push($aOIDs, $o->oid);
-               }
-
-               // delete from plugin_option and plugin_option_desc
-               sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
-               if (count($aOIDs) > 0)
-                       sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
-
-               // update order numbers
-               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
-               $o = sql_fetch_object($res);
-               sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
-
-               // delete row
-               sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
-
-               $manager->clearCachedInfo('installedPlugins');
-               $manager->notify('PostDeletePlugin', array('plugid' => $pid));
-
-               return '';
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_pluginup() {
-               global $member, $manager, $CONF;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $plugid = intGetVar('plugid');
-
-               if (!$manager->pidInstalled($plugid))
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-
-               // 1. get old order number
-               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-               $o = sql_fetch_object($res);
-               $oldOrder = $o->porder;
-
-               // 2. calculate new order number
-               $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
-
-               // 3. update plug numbers
-               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-               //$this->action_pluginlist();
-               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
-               redirect($CONF['AdminURL'] . '?action=pluginlist');
-       }
-
-       /**
-        * @todo document this
-        */
-       function action_plugindown() {
-               global $member, $manager, $CONF;
-
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-
-               $plugid = intGetVar('plugid');
-               if (!$manager->pidInstalled($plugid))
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-
-               // 1. get old order number
-               $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
-               $o = sql_fetch_object($res);
-               $oldOrder = $o->porder;
-
-               $res = sql_query('SELECT * FROM '.sql_table('plugin'));
-               $maxOrder = sql_num_rows($res);
-
-               // 2. calculate new order number
-               $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
-
-               // 3. update plug numbers
-               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
-               sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
-
-               //$this->action_pluginlist();
-               // To avoid showing ticket in the URL, redirect to pluginlist, instead.
-               redirect($CONF['AdminURL'] . '?action=pluginlist');
-       }
-       
-       /**
-        * Admin::action_pluginoptions()
-        * 
-        * Output Plugin option page
-        * 
-        * @access      public
-        * @param       string $message message when fallbacked
-        * @return      void
-        * 
-        */
-       public function action_pluginoptions($message = '')
-       {
-               global $member, $manager;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               $pid = (integer) requestVar('plugid');
-               if ( !$manager->pidInstalled($pid) )
-               {
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-               }
-               
-               $pname = getPluginNameFromPid($pid);
-               
-               /* just for including translation */
-               $manager->getPlugin($pname);
-               
-               $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
-               $this->pagehead($extrahead);
-               echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
-               echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($pname)) . "</h2>\n";
-               
-               if ( isset($message) )
-               {
-                       echo $message;
-               }
-               
-               echo "<form action=\"index.php\" method=\"post\">\n";
-               echo "<div>\n";
-               echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
-               echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
-               $manager->addTicketHidden();
-               
-               $aOptions = array();
-               $aOIDs = array();
-               $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
-               $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
-               $result = sql_query($query);
-               while ( $object = sql_fetch_object($result) )
-               {
-                       array_push($aOIDs, $object->oid);
-                       $aOptions[$object->oid] = array(
-                                               'oid' => $object->oid,
-                                               'value' => $object->odef,
-                                               'name' => $object->oname,
-                                               'description' => $object->odesc,
-                                               'type' => $object->otype,
-                                               'typeinfo' => $object->oextra,
-                                               'contextid' => 0
-                       );
-               }
-               // fill out actual values
-               if ( count($aOIDs) > 0 )
-               {
-                       $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
-                       $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
-                       $result = sql_query($query);
-                       while ( $object = sql_fetch_object($result) )
-                       {
-                               $aOptions[$object->oid]['value'] = $object->ovalue;
-                       }
-               }
-               
-               // call plugins
-               $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
-               $manager->notify('PrePluginOptionsEdit',$data);
-               
-               $template['content'] = 'plugoptionlist';
-               $amount = showlist($aOptions,'table',$template);
-               if ( $amount == 0 )
-               {
-                       echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
-               }
-               echo "</div>\n";
-               echo "</form>\n";
-               $this->pagefoot();
-               
-               return;
-       }
-       
-       /**
-        * Admin::action_pluginoptionsupdate()
-        * 
-        * Update plugin options and fallback to plugin option page
-        * 
-        * @access      public
-        * @param       void
-        * @return      void
-        */
-       public function action_pluginoptionsupdate()
-       {
-               global $member, $manager;
-               
-               // check if allowed
-               $member->isAdmin() or $this->disallow();
-               
-               $pid = (integer) requestVar('plugid');
-               if ( !$manager->pidInstalled($pid) )
-               {
-                       $this->error(_ERROR_NOSUCHPLUGIN);
-               }
-               
-               $aOptions = requestArray('plugoption');
-               NucleusPlugin::apply_plugin_options($aOptions);
-               
-               $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
-               
-               $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
-               return;
-       }
-       
-       /**
-        * Admin::_insertPluginOptions()
-        * 
-        * Output plugin option field
-        * 
-        * @access      public
-        * @param string        $context        plugin option context
-        * @param integer       $contextid      plugin option context id
-        * @return      void
-        */
-       public function _insertPluginOptions($context, $contextid = 0)
-       {
-               // get all current values for this contextid
-               // (note: this might contain doubles for overlapping contextids)
-               $aIdToValue = array();
-               $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
-               while ( $object = sql_fetch_object($res) )
-               {
-                       $aIdToValue[$object->oid] = $object->ovalue;
-               }
-               
-               // get list of oids per pid
-               $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
-                               . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
-               $res = sql_query($query);
-               $aOptions = array();
-               while ( $object = sql_fetch_object($res) )
-               {
-                       if (in_array($object->oid, array_keys($aIdToValue)))
-                       {
-                               $value = $aIdToValue[$object->oid];
-                       }
-                       else
-                       {
-                               $value = $object->odef;
-                       }
-                       
-                       array_push($aOptions, array(
-                               'pid' => $object->pid,
-                               'pfile' => $object->pfile,
-                               'oid' => $object->oid,
-                               'value' => $value,
-                               'name' => $object->oname,
-                               'description' => $object->odesc,
-                               'type' => $object->otype,
-                               'typeinfo' => $object->oextra,
-                               'contextid' => $contextid,
-                               'extra' => ''));
-               }
-               
-               global $manager;
-               $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
-               
-               $iPrevPid = -1;
-               foreach ($aOptions as $aOption)
-               {
-                       // new plugin?
-                       if ( $iPrevPid != $aOption['pid'] )
-                       {
-                               $iPrevPid = $aOption['pid'];
-                               if ( !defined('_PLUGIN_OPTIONS_TITLE') )
-                               {
-                                       define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
-                               }
-                               echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($aOption['pfile'])).'</th></tr>';
-                       }
-                       
-                       $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
-                       if ( @$meta['access'] != 'hidden' )
-                       {
-                               echo '<tr>';
-                               listplug_plugOptionRow($aOption);
-                               echo '</tr>';
-                       }
-               }
-               return;
-       }
-       
-       /**
-        * Admin::input_yesno()
-        * Output input elements with radio attribute for yes/no options
-        * 
-        * @param       string  $name   name attribute
-        * @param       string  $value_current  current value attribute
-        * @param       integer $tabindex       tab index
-        * @param       string  $value_yes      value attribute for yes option
-        * @param       string  $value_no       value attribute for no option
-        * @param       string  $text_yes       child text element for yes option
-        * @param       string  $text_no        child text element for no option
-        * @param       boolean $isAdmin        have admin right or not
-        * @return      void
-        */
-       function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
-       {
-               $id = preg_replace('#\[|\]#', '-', $name);
-               $id_yes = $id . $value_yes;
-               $id_no  = $id . $value_no;
-               
-               /* yes option */
-               echo '<input type="radio" id="' . Entity::hsc($id_yes) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_yes) . '"';
-               if ( $name=="admin" )
-               {
-                       echo ' onclick="selectCanLogin(true);"';
-               }
-               if ( $value_current == $value_yes )
-               {
-                       echo " tabindex='$tabindex' checked='checked'";
-               }
-               echo " />\n";
-               echo '<label for="' . Entity::hsc($id_yes) . '">' . Entity::hsc($text_yes) . "</label>\n";
-               
-               /* no option */
-               echo '<input type="radio" id="' . Entity::hsc($id_no) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_no) . '"';
-               if ( $name=="admin" )
-               {
-                       echo ' onclick="selectCanLogin(false);"';
-               }
-               if ( $value_current != $value_yes )
-               {
-                       echo " tabindex='$tabindex' checked='checked'";
-               }
-               if ($isAdmin && $name=="canlogin")
-               {
-                       echo ' disabled="disabled"';
-               }
-               echo " />\n";
-               echo '<label for="' . Entity::hsc($id_no) . '">' . Entity::hsc($text_no) . "</label>\n";
-               
-               return;
-       }
-
-       /**
-        * Returns a link to a weblog
-        * @param object BLOG
-        */
-       function bloglink(&$blog) {
-               return '<a href="'.Entity::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. Entity::hsc( $blog->getName() ) .'</a>';
-       }
-}
+<?php\r
+/**\r
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
+ * Copyright (C) 2002-2012 The Nucleus Group\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ * (see nucleus/documentation/index.html#license for more info)\r
+ */\r
+/**\r
+ * The code for the Nucleus admin area\r
+ *\r
+ * @license http://nucleuscms.org/license.txt GNU General Public License\r
+ * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
+ * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $\r
+ *\r
+ */\r
+\r
+if ( !function_exists('requestVar') ) exit;\r
+require_once dirname(__FILE__) . '/showlist.php';\r
+\r
+/**\r
+ * Builds the admin area and executes admin actions\r
+ */\r
+class Admin\r
+{\r
+       private $xml_version_info         = '1.0';\r
+       private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';\r
+       private $system_identifier        = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';\r
+       private $xhtml_namespace          = 'http://www.w3.org/1999/xhtml';\r
+       \r
+       /**\r
+        * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)\r
+        */\r
+       public $action;\r
+\r
+       /**\r
+        * @var object $adminSkin\r
+        */\r
+       public $adminSkin;\r
+\r
+       /**\r
+        * @var string $extrahead\r
+        */\r
+       public $extrahead;\r
+\r
+       /**\r
+        * @var bool $passvar\r
+        */\r
+       public $passvar;\r
+\r
+       /**\r
+        * @var string $headMess\r
+        */\r
+       public $headMess;\r
+\r
+       public $aOptions;\r
+\r
+       /**\r
+        * Class constructor\r
+        */\r
+       /* function ADMIN() {\r
+       } */\r
+       function __construct()\r
+       {\r
+               global $member, $DIR_LIBS;\r
+                       $query = 'SELECT '\r
+                                  . '    COUNT(*) as result '\r
+                                  . 'FROM '\r
+                                  .      sql_table('adminskin_desc');\r
+               if ( !(quickQuery($query)) )\r
+               {\r
+                       $this->action_importAdmin();\r
+               }\r
+               if ( !isset($adminSkinid) || !($adminSkinid) )\r
+               {\r
+                       $adminSkinid = self::getAdminSkinID();\r
+               }\r
+               if ( skinableSKIN::existsID($adminSkinid) )\r
+               {\r
+                       $this->adminSkin = new skinableSKIN($adminSkinid);\r
+               }\r
+               else\r
+               {\r
+                       $this->adminSkin = 0;\r
+               }\r
+       }\r
+       \r
+       static private function getAdminSkinID()\r
+       {\r
+               global $CONF, $member, $manager;\r
+               if (isset($member) && $member->isLoggedIn()) {\r
+                       $memskin = $member->getAdminSkin();\r
+                       if ($memskin) {\r
+                               return $memskin;\r
+                       }\r
+               }\r
+               return $CONF['DefaultAdminSkin'];\r
+       }\r
+       \r
+       function getAdminskinEditActions()\r
+       {\r
+               return array(\r
+                               'adminskinoverview',\r
+                               'adminskinieoverview',\r
+                               'adminskinedittype',\r
+                               'adminskinremovetype',\r
+                               'adminskindelete',\r
+                               'adminskinedit',\r
+                               'adminskinieimport',\r
+                               'adminskiniedoimport',\r
+                               'admintemplateedit',\r
+                               'admintemplateoverview',\r
+                               'admintemplatedelete',\r
+               );\r
+       }\r
+       \r
+       function getSkinlessActions()\r
+       {\r
+               return array(\r
+                               'plugindeleteconfirm',\r
+                               'pluginoptionsupdate',\r
+                               'skinremovetypeconfirm',\r
+                               'skinclone',\r
+                               'skindeleteconfirm',\r
+                               'skinnew',\r
+                               'skineditgeneral',\r
+                               'skinieexport',\r
+                               'skinupdate',\r
+                               'templateupdate',\r
+                               'templatedeleteconfirm',\r
+                               'templatenew',\r
+                               'templateclone',\r
+                               'adminskinremovetypeconfirm',\r
+                               'adminskinclone',\r
+                               'adminskindeleteconfirm',\r
+                               'adminskinnew',\r
+                               'adminskineditgeneral',\r
+                               'adminskinieexport',\r
+                               'adminskinupdate',\r
+                               'admintemplateupdate',\r
+                               'admintemplatedeleteconfirm',\r
+                               'admintemplatenew',\r
+                               'admintemplateclone',\r
+                               'blogsettingsupdate',\r
+                               'settingsupdate',\r
+                               'addnewlog2',\r
+                               'additem',\r
+                               'itemdeleteconfirm',\r
+                               'itemupdate',\r
+                               'changemembersettings',\r
+                               'clearactionlog',\r
+                               'memberedit',\r
+               );\r
+       }\r
+       \r
+       /**\r
+        * Executes an action\r
+        *\r
+        * @param string $action action to be performed\r
+        */\r
+       function action($action)\r
+       {\r
+               global $CONF, $manager;\r
+               $f = false;\r
+               \r
+               // list of action aliases\r
+               $alias = array(\r
+                       'login' => 'overview',\r
+                       ''      => 'overview'\r
+               );\r
+\r
+               $customAction = postvar('customaction');\r
+               if ( !empty($customAction) )\r
+               {\r
+                       $alias = array(\r
+                               'login' => $customAction,\r
+                               ''      => $customAction\r
+                       );\r
+               }\r
+               if ( isset($alias[$action]) )\r
+               {\r
+                       $action = $alias[$action];\r
+               }\r
+               $methodName = 'action_' . $action;\r
+\r
+               $this->action = strtolower($action);\r
+\r
+               // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action\r
+               // is an action that requires user interaction before something is actually done)\r
+               // all safe actions are in this array:\r
+               $aActionsNotToCheck = array(\r
+                       'showlogin',\r
+                       'login',\r
+                       'overview',\r
+                       'itemlist',\r
+                       'blogcommentlist',\r
+                       'bookmarklet',\r
+                       'blogsettings',\r
+                       'banlist',\r
+                       'deleteblog',\r
+                       'editmembersettings',\r
+                       'browseownitems',\r
+                       'browseowncomments',\r
+                       'createitem',\r
+                       'itemedit',\r
+                       'itemmove',\r
+                       'categoryedit',\r
+                       'categorydelete',\r
+                       'manage',\r
+                       'actionlog',\r
+                       'settingsedit',\r
+                       'backupoverview',\r
+                       'pluginlist',\r
+                       'createnewlog',\r
+                       'usermanagement',\r
+                       'skinoverview',\r
+                       'templateoverview',\r
+                       'skinieoverview',\r
+                       'itemcommentlist',\r
+                       'commentedit',\r
+                       'commentdelete',\r
+                       'banlistnewfromitem',\r
+                       'banlistdelete',\r
+                       'itemdelete',\r
+                       'manageteam',\r
+                       'teamdelete',\r
+                       'banlistnew',\r
+                       'memberedit',\r
+                       'memberdelete',\r
+                       'pluginhelp',\r
+                       'pluginoptions',\r
+                       'plugindelete',\r
+                       'skinedittype',\r
+                       'skinremovetype',\r
+                       'skindelete',\r
+                       'skinedit',\r
+                       'templateedit',\r
+                       'templatedelete',\r
+                       'activate',\r
+                       'systemoverview',\r
+            'activatesetpwd',\r
+               );\r
+        $synonimActions = array(\r
+            'banlistnewfromitem',\r
+            'memberedit',\r
+            'login',\r
+        );\r
+/*\r
+               // the rest of the actions needs to be checked\r
+               $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');\r
+*/\r
+        $adminskinEditActions = $this->getAdminskinEditActions();\r
+        $skinLessActions      = $this->getSkinlessActions();\r
+        $allowActions         = array_merge($synonimActions, $this->getSkinlessActions());\r
+        $aActionsNotToCheck   = array_merge($aActionsNotToCheck, $adminskinEditActions, $allowActions);\r
+               if (!in_array($this->action, $aActionsNotToCheck) && !$this->existsSkinContents($action) )\r
+               {\r
+                       if (!$manager->checkTicket())\r
+                       {\r
+                               $this->error(_ERROR_BADTICKET);\r
+                       }\r
+               }\r
+               if ( !$this->adminSkin && $CONF['DefaultAdminSkin'] )\r
+               {\r
+                       $this->adminSkin = new Skin($CONF['DefaultAdminSkin']);\r
+               }\r
+       \r
+               if ( !method_exists($this, $methodName) && !in_array($this->action, $allowActions) && $this->existsSkinContents($action) )\r
+               {\r
+                       $this->action_parseSpecialskin;\r
+                       $f = true;\r
+               }\r
+               elseif ( method_exists($this, $methodName) )\r
+               {\r
+                       call_user_func(array(&$this, $methodName));\r
+                       $f = true;\r
+               }\r
+               if ($f) {\r
+                       exit;\r
+               }\r
+               $id              = self::getAdminSkinID();\r
+               $this->adminSkin = new skinableSKIN($id);\r
+               if ( $this->adminSkin && $this->existsSkinContents('adminerrorpage') )\r
+               {\r
+                       $this->error(_BADACTION . ENTITY::hsc($action));\r
+                       $f = true;\r
+               }\r
+               elseif ( $id != $CONF['DefaultAdminSkin'] )\r
+               {\r
+                       $this->adminSkin = new Skin($CONF['DefaultAdminSkin']);\r
+                       if ( $this->adminSkin && $this->existsSkinContents('adminerrorpage') )\r
+                       {\r
+                               $this->error(_BADACTION . ENTITY::hsc($action));\r
+                               $f = true;\r
+                       }\r
+               }\r
+               if ($f)\r
+               {\r
+                       exit;\r
+               }\r
+               $this->error(_BADACTION . ENTITY::hsc($action));\r
+       }\r
+\r
+       /**\r
+        * Check skin contents\r
+        *\r
+        * @param  string action type\r
+        * @return bool\r
+        */\r
+       function existsSkinContents($action)\r
+       {\r
+               $nsActions = $this->getSkinlessActions();\r
+                       $in_array  = in_array($action, $nsActions);\r
+               if ($in_array) {\r
+                       return $in_array;\r
+               } else {\r
+                       $query = 'SELECT '\r
+                                  . '    scontent as result '\r
+                                  . 'FROM '\r
+                                  .      sql_table('adminskin') . ' '\r
+                                  . 'WHERE '\r
+                                  . '    sdesc = %d '\r
+                                  . 'AND stype = "%s"';\r
+                       if ( is_object($this->adminSkin) )\r
+                       {\r
+                               return quickQuery(sprintf($query, $this->adminSkin->id, sql_real_escape_string($action)));\r
+                       }\r
+                       else\r
+                       {\r
+                               return quickQuery(sprintf($query, 1, sql_real_escape_string($action)));\r
+                       }\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Check exists specialskinparts\r
+        *\r
+        * @param string action type\r
+        * @return bool\r
+        */\r
+       function specialActionsAllow($action)\r
+       {\r
+               $query = 'SELECT '\r
+               . '    sdesc as result '\r
+               . 'FROM '\r
+               .      sql_table('adminskin') . ' '\r
+               . 'WHERE '\r
+               . '    sdesc = %d '\r
+               . 'AND stype = "%s"';\r
+               return quickQuery(sprintf($query, $this->adminSkin->id, sql_real_escape_string($action)));\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_showlogin()\r
+       {\r
+               global $error;\r
+               $this->action_login($error);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_login($msg = '', $passvars = 1)\r
+       {\r
+               global $member;\r
+\r
+               // skip to overview when allowed\r
+               if ( $member->isLoggedIn() && $member->canLogin() )\r
+               {\r
+                       $this->action_overview();\r
+                       exit;\r
+               }\r
+\r
+               $this->passvar = $passvars;\r
+               if ( $msg )\r
+               {\r
+                       $this->headMess = $msg;\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('showlogin');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * provides a screen with the overview of the actions available\r
+        * @todo document parameter\r
+        */\r
+       function action_overview($msg = '')\r
+       {\r
+               if ( $msg )\r
+               {\r
+                       $this->headMess = $msg;\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('overview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_manage($msg = '')\r
+       {\r
+               global $member;\r
+\r
+               if ( $msg )\r
+               {\r
+                       $this->headMess = $msg;\r
+               }\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('manage');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemlist($blogid = '')\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ( $blogid == '' )\r
+               {\r
+                       $blogid = intRequestVar('blogid');\r
+               }\r
+\r
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('itemlist');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchitem()\r
+       {\r
+               global $member, $manager;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action   = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if ( !is_array($selected) || sizeof($selected) == 0 )\r
+               {\r
+                       $this->error(_BATCH_NOSELECTION);\r
+               }\r
+\r
+               // On move: when no destination blog/category chosen, show choice now\r
+               $destCatid = intRequestVar('destcatid');\r
+               if ( ($action == 'move') && (!$manager->existsCategory($destCatid)) )\r
+               {\r
+                       $this->batchMoveSelectDestination('item', $selected);\r
+               }\r
+\r
+               // On delete: check if confirmation has been given\r
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )\r
+               {\r
+                       $this->batchAskDeleteConfirmation('item',$selected);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('batchitem');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchcomment()\r
+       {\r
+               global $member;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action   = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if ( !is_array($selected) || sizeof($selected) == 0 )\r
+               {\r
+                       $this->error(_BATCH_NOSELECTION);\r
+               }\r
+\r
+               // On delete: check if confirmation has been given\r
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )\r
+               {\r
+                       $this->batchAskDeleteConfirmation('comment',$selected);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('batchcomment');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchmember()\r
+       {\r
+               global $member;\r
+\r
+               // check if logged in and admin\r
+               ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action   = requestVar('batchaction');\r
+\r
+               // Show error when no members selected\r
+               if ( !is_array($selected) || sizeof($selected) == 0 )\r
+               {\r
+                       $this->error(_BATCH_NOSELECTION);\r
+               }\r
+\r
+               // On delete: check if confirmation has been given\r
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )\r
+               {\r
+                       $this->batchAskDeleteConfirmation('member',$selected);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('batchmember');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchteam()\r
+       {\r
+               global $member;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if logged in and admin\r
+               ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action   = requestVar('batchaction');\r
+\r
+               // Show error when no members selected\r
+               if ( !is_array($selected) || sizeof($selected) == 0 )\r
+               {\r
+                       $this->error(_BATCH_NOSELECTION);\r
+               }\r
+\r
+               // On delete: check if confirmation has been given\r
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )\r
+               {\r
+                       $this->batchAskDeleteConfirmation('team',$selected);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('batchmember');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_batchcategory()\r
+       {\r
+               global $member, $manager;\r
+\r
+               // check if logged in\r
+               $member->isLoggedIn() or $this->disallow();\r
+\r
+               // more precise check will be done for each performed operation\r
+\r
+               // get array of itemids from request\r
+               $selected = requestIntArray('batch');\r
+               $action   = requestVar('batchaction');\r
+\r
+               // Show error when no items were selected\r
+               if ( !is_array($selected) || sizeof($selected) == 0 )\r
+               {\r
+                       $this->error(_BATCH_NOSELECTION);\r
+               }\r
+\r
+               // On move: when no destination blog chosen, show choice now\r
+               $destBlogId = intRequestVar('destblogid');\r
+               if ( ($action == 'move') && (!$manager->existsBlogID($destBlogId)) )\r
+               {\r
+                       $this->batchMoveCategorySelectDestination('category', $selected);\r
+               }\r
+\r
+               // On delete: check if confirmation has been given\r
+               if ( ($action == 'delete') && (requestVar('confirmation') != 'yes') )\r
+               {\r
+                       $this->batchAskDeleteConfirmation('category', $selected);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('batchcategory');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchMoveSelectDestination($type, $ids)\r
+       {\r
+               $this->pagehead();\r
+               $this->parse('batchmove');\r
+               $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchMoveCategorySelectDestination($type, $ids)\r
+       {\r
+               global $manager;\r
+               $this->pagehead();\r
+               $this->parse('batchmovecat');\r
+               $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function batchAskDeleteConfirmation($type, $ids)\r
+       {\r
+        $this->pagehead();\r
+        $this->parse('batchdelete');\r
+        $this->pagefoot();\r
+               exit;\r
+       }\r
+\r
+\r
+       /**\r
+        * Inserts a HTML select element with choices for all categories to which the current\r
+        * member has access\r
+        * @see function selectBlog\r
+        */\r
+       function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)\r
+       {\r
+               Admin::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);\r
+       }\r
+\r
+       /**\r
+        * Inserts a HTML select element with choices for all blogs to which the user has access\r
+        *      mode = 'blog' => shows blognames and values are blogids\r
+        *      mode = 'category' => show category names and values are catids\r
+        *\r
+        * @param $iForcedBlogInclude\r
+        *      ID of a blog that always needs to be included, without checking if the\r
+        *      member is on the blog team (-1 = none)\r
+        * @todo document parameters\r
+        */\r
+       function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)\r
+       {\r
+               global $member, $CONF;\r
+\r
+               // 0. get IDs of blogs to which member can post items (+ forced blog)\r
+               $aBlogIds = array();\r
+               if ( $iForcedBlogInclude != -1 )\r
+               {\r
+                       $aBlogIds[] = intval($iForcedBlogInclude);\r
+               }\r
+\r
+               if ( ($member->isAdmin()) && ($CONF['ShowAllBlogs']) )\r
+               {\r
+                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';\r
+               }\r
+               else\r
+               {\r
+                       $queryBlogs =  'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();\r
+               }\r
+               $rblogids = sql_query($queryBlogs);\r
+               while ($o = sql_fetch_object($rblogids))\r
+               {\r
+                       if ( $o->bnumber != $iForcedBlogInclude )\r
+                       {\r
+                               $aBlogIds[] = intval($o->bnumber);\r
+                       }\r
+               }\r
+\r
+               if ( count($aBlogIds) == 0 )\r
+               {\r
+                       return;\r
+               }\r
+\r
+               $_REQUEST['selectData'] = array(\r
+                       'name'       => $name,\r
+                       'tabindex'   => $tabindex,\r
+                       'mode'       => $mode,\r
+                       'selected'   => $selected,\r
+                       'showNewCat' => $showNewCat,\r
+                       'aBlogIds'   => $aBlogIds,\r
+               );\r
+               $this->parse('blogselectbox');\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_browseownitems() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $this->pagehead();\r
+               $this->parse('browseownitems');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Show all the comments for a given item\r
+        * @param int $itemid\r
+        */\r
+       function action_itemcommentlist($itemid = '') {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ( $itemid == '' )\r
+               {\r
+                       $itemid = intRequestVar('itemid');\r
+               }\r
+               $_REQUEST['itemid'] = $itemid;\r
+               $_REQUEST['blogid'] = getBlogIdFromItemId($itemid);\r
+               \r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $blogid = getBlogIdFromItemId($itemid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('itemcommentlist');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Browse own comments\r
+        */\r
+       function action_browseowncomments() {\r
+               $this->pagehead();\r
+               $this->parse('browseowncomments');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Browse all comments for a weblog\r
+        * @param int $blogid\r
+        */\r
+       function action_blogcommentlist($blogid = '')\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               if ( $blogid == '' )\r
+               {\r
+                       $blogid = intRequestVar('blogid');\r
+               }\r
+               else\r
+               {\r
+                       $blogid = intval($blogid);\r
+               }\r
+\r
+               $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $_REQUEST['blogid'] = $blogid;\r
+\r
+               $this->pagehead();\r
+               $this->parse('blogcommentlist');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Provide a page to item a new item to the given blog\r
+        */\r
+       function action_createitem()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               $memberid = $member->getID();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('createitem');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemedit()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $item =& $manager->getItem($itemid, 1, 1);\r
+               $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));\r
+               $this->pagehead();\r
+               $this->parse('itemedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemupdate()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+               $catid  = postVar('catid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canUpdateItem($itemid, $catid) or $this->disallow();\r
+\r
+               $actiontype = postVar('actiontype');\r
+\r
+               // delete actions are handled by itemdelete (which has confirmation)\r
+               if ( $actiontype == 'delete' )\r
+               {\r
+                       $this->action_itemdelete();\r
+                       return;\r
+               }\r
+\r
+               $body    = postVar('body');\r
+               $title   = postVar('title');\r
+               $more    = postVar('more');\r
+               $closed  = intPostVar('closed');\r
+               $draftid = intPostVar('draftid');\r
+\r
+               // default action = add now\r
+               if ( !$actiontype )\r
+               {\r
+                       $actiontype='addnow';\r
+               }\r
+\r
+               // create new category if needed\r
+               if ( strstr($catid,'newcat') )\r
+               {\r
+                       // get blogid\r
+                       list($blogid) = sscanf($catid,"newcat-%d");\r
+\r
+                       // create\r
+                       $blog =& $manager->getBlog($blogid);\r
+                       $catid = $blog->createNewCategory();\r
+\r
+                       // show error when sth goes wrong\r
+                       if ( !$catid )\r
+                       {\r
+                               $this->doError(_ERROR_CATCREATEFAIL);\r
+                       }\r
+               }\r
+\r
+               /*\r
+                       set some variables based on actiontype\r
+\r
+                       actiontypes:\r
+                               draft items -> addnow, addfuture, adddraft, delete\r
+                               non-draft items -> edit, changedate, delete\r
+\r
+                       variables set:\r
+                               $timestamp: set to a nonzero value for future dates or date changes\r
+                               $wasdraft: set to 1 when the item used to be a draft item\r
+                               $publish: set to 1 when the edited item is not a draft\r
+        */\r
+               $blogid =  getBlogIDFromItemID($itemid);\r
+               $blog   =& $manager->getBlog($blogid);\r
+\r
+               $wasdrafts = array('adddraft', 'addfuture', 'addnow');\r
+               $wasdraft  = in_array($actiontype, $wasdrafts) ? 1 : 0;\r
+               $publish   = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;\r
+               if ( $actiontype == 'addfuture' || $actiontype == 'changedate' )\r
+               {\r
+                       $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));\r
+               }\r
+               else\r
+               {\r
+                       $timestamp =0;\r
+               }\r
+\r
+               // edit the item for real\r
+               Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);\r
+\r
+               $this->updateFuturePosted($blogid);\r
+\r
+               if ( $draftid > 0 )\r
+               {\r
+                       // delete permission is checked inside Item::delete()\r
+                       Item::delete($draftid);\r
+               }\r
+\r
+               // show category edit window when we created a new category\r
+               // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')\r
+               if ( $catid != intPostVar('catid') )\r
+               {\r
+                       $this->action_categoryedit(\r
+                               $catid,\r
+                               $blog->getID(),\r
+                               $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)\r
+                       );\r
+               }\r
+               else\r
+               {\r
+                       // TODO: set start item correctly for itemlist\r
+                       $item = Item::getItem($itemid, 0, 0);\r
+                       $cnt  = quickQuery('SELECT COUNT(*) FROM ' . sql_table('item') . ' WHERE unix_timestamp(itime) <= ' . $item['timestamp']);\r
+                       $_REQUEST['start'] = $cnt + 1;\r
+                       $this->action_itemlist(getBlogIDFromItemID($itemid));\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_itemdelete()\r
+        * Delete item\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        */\r
+       function action_itemdelete()\r
+       {\r
+               global $member, $manager;\r
+               \r
+               $itemid = intRequestVar('itemid');\r
+               \r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+               \r
+               if ( !$manager->existsItem($itemid,1,1) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHITEM);\r
+               }\r
+               \r
+               $this->pagehead();\r
+               $this->parse('itemdelete');\r
+               $this->pagefoot();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemdeleteconfirm()\r
+       {\r
+               global $member;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               // get blogid first\r
+               $blogid = getBlogIdFromItemId($itemid);\r
+\r
+               // delete item (note: some checks will be performed twice)\r
+               $this->deleteOneItem($itemid);\r
+\r
+               $this->action_itemlist($blogid);\r
+       }\r
+\r
+       /**\r
+        * Deletes one item and returns error if something goes wrong\r
+        * @param int $itemid\r
+        */\r
+       function deleteOneItem($itemid)\r
+       {\r
+               global $member, $manager;\r
+\r
+               // only allow if user is allowed to alter item (also checks if itemid exists)\r
+               if ( !$member->canAlterItem($itemid) )\r
+               {\r
+                       return _ERROR_DISALLOWED;\r
+               }\r
+\r
+               // need to get blogid before the item is deleted\r
+               $blogid = getBlogIDFromItemId($itemid);\r
+\r
+               $manager->loadClass('ITEM');\r
+               Item::delete($itemid);\r
+\r
+               // update blog's futureposted\r
+               $this->updateFuturePosted($blogid);\r
+       }\r
+\r
+       /**\r
+        * Admin::updateFuturePosted()\r
+        * Update a blog's future posted flag\r
+        * \r
+        * @param integer $blogid\r
+        * @return      void\r
+        * \r
+        */\r
+       function updateFuturePosted($blogid)\r
+       {\r
+               global $manager;\r
+               \r
+               $blogid      =  intval($blogid);\r
+               $blog        =& $manager->getBlog($blogid);\r
+               $currenttime =  $blog->getCorrectTime(time());\r
+               \r
+               $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";\r
+               $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));\r
+               $result = sql_query($query);\r
+               \r
+               if ( sql_num_rows($result) > 0 )\r
+               {\r
+                               $blog->setFuturePost();\r
+               }\r
+               else\r
+               {\r
+                               $blog->clearFuturePost();\r
+               }\r
+               return;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemmove()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canAlterItem($itemid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('itemmove');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_itemmoveto()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $itemid = intRequestVar('itemid');\r
+               $catid = requestVar('catid');\r
+\r
+               // create new category if needed\r
+               if ( strstr($catid,'newcat') )\r
+               {\r
+                       // get blogid\r
+                       list($blogid) = sscanf($catid,'newcat-%d');\r
+\r
+                       // create\r
+                       $blog =& $manager->getBlog($blogid);\r
+                       $catid = $blog->createNewCategory();\r
+\r
+                       // show error when sth goes wrong\r
+                       if ( !$catid )\r
+                       {\r
+                               $this->doError(_ERROR_CATCREATEFAIL);\r
+                       }\r
+               }\r
+\r
+               // only allow if user is allowed to alter item\r
+               $member->canUpdateItem($itemid, $catid) or $this->disallow();\r
+\r
+               $old_blogid = getBlogIDFromItemId($itemid);\r
+\r
+               Item::move($itemid, $catid);\r
+\r
+               // set the futurePosted flag on the blog\r
+               $this->updateFuturePosted(getBlogIDFromItemId($itemid));\r
+\r
+               // reset the futurePosted in case the item is moved from one blog to another\r
+               $this->updateFuturePosted($old_blogid);\r
+\r
+               if ( $catid != intRequestVar('catid') )\r
+               {\r
+                       $this->action_categoryedit($catid, $blog->getID());\r
+               }\r
+               else\r
+               {\r
+                       $this->action_itemlist(getBlogIDFromCatID($catid));\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Moves one item to a given category (category existance should be checked by caller)\r
+        * errors are returned\r
+        * @param int $itemid\r
+        * @param int $destCatid category ID to which the item will be moved\r
+        */\r
+       function moveOneItem($itemid, $destCatid)\r
+       {\r
+               global $member;\r
+\r
+               // only allow if user is allowed to move item\r
+               if ( !$member->canUpdateItem($itemid, $destCatid) )\r
+               {\r
+                       return _ERROR_DISALLOWED;\r
+               }\r
+\r
+               Item::move($itemid, $destCatid);\r
+       }\r
+\r
+       /**\r
+        * Adds a item to the chosen blog\r
+        */\r
+       function action_additem()\r
+       {\r
+               global $manager, $CONF;\r
+\r
+               $manager->loadClass('ITEM');\r
+\r
+               $result = Item::createFromRequest();\r
+\r
+               if ( $result['status'] == 'error' )\r
+               {\r
+                       $this->error($result['message']);\r
+               }\r
+\r
+               $blogid     =  getBlogIDFromItemID($result['itemid']);\r
+               $blog       =& $manager->getBlog($blogid);\r
+               $btimestamp =  $blog->getCorrectTime();\r
+               $item       =  $manager->getItem(intval($result['itemid']), 1, 1);\r
+\r
+               if ( $result['status'] == 'newcategory' )\r
+               {\r
+                       $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));\r
+                       $this->action_categoryedit($result['catid'], $blogid, $distURI);\r
+               }\r
+               else\r
+               {\r
+                       $methodName = 'action_itemList';\r
+                       call_user_func(array(&$this, $methodName), $blogid);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Allows to edit previously made comments\r
+        **/\r
+       function action_commentedit()\r
+       {\r
+\r
+               global $member, $manager;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('commentedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_commentupdate()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $url   = postVar('url');\r
+               $email = postVar('email');\r
+               $body  = postVar('body');\r
+\r
+               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+               # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE\r
+               # important note that '\' must be matched with '\\\\' in preg* expressions\r
+\r
+               // intercept words that are too long\r
+               if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)\r
+               {\r
+                       $this->error(_ERROR_COMMENT_LONGWORD);\r
+               }\r
+\r
+               // check length\r
+               if ( i18n::strlen($body) < 3 )\r
+               {\r
+                       $this->error(_ERROR_COMMENT_NOCOMMENT);\r
+               }\r
+\r
+               if ( i18n::strlen($body) > 5000 )\r
+               {\r
+                       $this->error(_ERROR_COMMENT_TOOLONG);\r
+               }\r
+\r
+               // prepare body\r
+               $body = Comment::prepareBody($body);\r
+\r
+               // call plugins\r
+               $manager->notify(\r
+                       'PreUpdateComment',\r
+                       array(\r
+                                       'body' => &$body\r
+                       )\r
+               );\r
+\r
+               $query = 'UPDATE ' . sql_table('comment')\r
+                          . " SET "\r
+                          . "    cmail   = '" . sql_real_escape_string($url) . "',"\r
+                          . "    cemail  = '" . sql_real_escape_string($email) . "',"\r
+                          . "    cbody   = '" . sql_real_escape_string($body) . "'"\r
+                          . " WHERE "\r
+                          . "    cnumber = " . $commentid;\r
+               sql_query($query);\r
+\r
+               // get itemid\r
+               $res    = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);\r
+               $o      = sql_fetch_object($res);\r
+               $itemid = $o->citem;\r
+\r
+               if ( $member->canAlterItem($itemid) )\r
+               {\r
+                       $this->action_itemcommentlist($itemid);\r
+               }\r
+               else\r
+               {\r
+                       $this->action_browseowncomments();\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_commentdelete()\r
+        * Update comment\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        */\r
+       function action_commentdelete()\r
+       {\r
+               global $member, $manager;\r
+               \r
+               $commentid = intRequestVar('commentid');\r
+               $member->canAlterComment($commentid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('commentdelete');\r
+               $this->pagefoot();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_commentdeleteconfirm()\r
+       {\r
+               global $member;\r
+\r
+               $commentid = intRequestVar('commentid');\r
+\r
+               // get item id first\r
+               $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);\r
+               $o = sql_fetch_object($res);\r
+               $itemid = $o->citem;\r
+\r
+               $error = $this->deleteOneComment($commentid);\r
+               if ( $error )\r
+               {\r
+                       $this->doError($error);\r
+               }\r
+\r
+               if ( $member->canAlterItem($itemid) )\r
+               {\r
+                       $this->action_itemcommentlist($itemid);\r
+               }\r
+               else\r
+               {\r
+                       $this->action_browseowncomments();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOneComment($commentid) {\r
+               global $member, $manager;\r
+\r
+               $commentid = intval($commentid);\r
+\r
+               if ( !$member->canAlterComment($commentid) )\r
+               {\r
+                       return _ERROR_DISALLOWED;\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreDeleteComment',\r
+                       array(\r
+                               'commentid' => $commentid\r
+                       )\r
+               );\r
+\r
+               // delete the comments associated with the item\r
+               $query = 'DELETE FROM ' . sql_table('comment') . ' WHERE cnumber=' . $commentid;\r
+               sql_query($query);\r
+\r
+               $manager->notify(\r
+                       'PostDeleteComment',\r
+                       array(\r
+                               'commentid' => $commentid\r
+                       )\r
+               );\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * Usermanagement main\r
+        */\r
+       function action_usermanagement()\r
+       {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('usermanagement');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Edit member settings\r
+        */\r
+       function action_memberedit()\r
+       {\r
+               $this->action_editmembersettings(intRequestVar('memberid'));\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_editmembersettings($memberid = '') {\r
+               global $member, $manager, $CONF;\r
+               \r
+               if ( $memberid == '' )\r
+               {\r
+                       $memberid = $member->getID();\r
+               }\r
+               $_REQUEST['memberid'] = $memberid;\r
+\r
+               // check if allowed\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+               \r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+               $this->parse('editmembersettings');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_changemembersettings() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               // check if allowed\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $name           = trim(strip_tags(postVar('name')));\r
+               $realname       = trim(strip_tags(postVar('realname')));\r
+               $password       = postVar('password');\r
+               $repeatpassword = postVar('repeatpassword');\r
+               $email          = strip_tags(postVar('email'));\r
+               $url            = strip_tags(postVar('url'));\r
+               $adminskin      = intPostVar('adminskin');\r
+               \r
+               # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0\r
+               # original eregi: !eregi("^https?://", $url)\r
+\r
+               // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.\r
+               if ( !preg_match('#^https?://#', $url) )\r
+               {\r
+                       $url = 'http://' . $url;\r
+               }\r
+\r
+               $admin          = postVar('admin');\r
+               $canlogin       = postVar('canlogin');\r
+               $notes          = strip_tags(postVar('notes'));\r
+               $locale         = postVar('locale');\r
+\r
+               $mem = Member::createFromID($memberid);\r
+\r
+               if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {\r
+\r
+                       if ( !isValidDisplayName($name) )\r
+                       {\r
+                               $this->error(_ERROR_BADNAME);\r
+                       }\r
+\r
+                       if ( ($name != $mem->getDisplayName()) && Member::exists($name) )\r
+                       {\r
+                               $this->error(_ERROR_NICKNAMEINUSE);\r
+                       }\r
+\r
+                       if ( $password != $repeatpassword )\r
+                       {\r
+                               $this->error(_ERROR_PASSWORDMISMATCH);\r
+                       }\r
+\r
+                       if ( $password && (i18n::strlen($password) < 6) )\r
+                       {\r
+                               $this->error(_ERROR_PASSWORDTOOSHORT);\r
+                       }\r
+                               \r
+                       if ( $password )\r
+                       {\r
+                               $pwdvalid = true;\r
+                               $pwderror = '';\r
+                               $manager->notify(\r
+                                       'PrePasswordSet',\r
+                                       array(\r
+                                               'password'     => $password,\r
+                                               'errormessage' => &$pwderror,\r
+                                               'valid'        => &$pwdvalid\r
+                                       )\r
+                               );\r
+                               if ( !$pwdvalid )\r
+                               {\r
+                                       $this->error($pwderror);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               if ( !NOTIFICATION::address_validation($email) )\r
+               {\r
+                       $this->error(_ERROR_BADMAILADDRESS);\r
+               }\r
+               if ( !$realname )\r
+               {\r
+                       $this->error(_ERROR_REALNAMEMISSING);\r
+               }\r
+               if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHTRANSLATION);\r
+               }\r
+\r
+               // check if there will remain at least one site member with both the logon and admin rights\r
+               // (check occurs when taking away one of these rights from such a member)\r
+               if (    (!$admin && $mem->isAdmin() && $mem->canLogin())\r
+                       ||      (!$canlogin && $mem->isAdmin() && $mem->canLogin())\r
+                       )\r
+               {\r
+                       $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');\r
+                       if ( sql_num_rows($r) < 2 )\r
+                       {\r
+                               $this->error(_ERROR_ATLEASTONEADMIN);\r
+                       }\r
+               }\r
+\r
+               if ( $CONF['AllowLoginEdit'] || $member->isAdmin() )\r
+               {\r
+                       $mem->setDisplayName($name);\r
+                       if ( $password )\r
+                       {\r
+                               $mem->setPassword($password);\r
+                       }\r
+               }\r
+\r
+               $oldEmail = $mem->getEmail();\r
+\r
+               $mem->setRealName($realname);\r
+               $mem->setEmail($email);\r
+               $mem->setURL($url);\r
+               $mem->setNotes($notes);\r
+               $mem->setLocale($locale);\r
+\r
+\r
+               // only allow super-admins to make changes to the admin status\r
+               if ( $member->isAdmin() )\r
+               {\r
+                       $mem->setAdmin($admin);\r
+                       $mem->setCanLogin($canlogin);\r
+               }\r
+\r
+               $autosave = postVar('autosave');\r
+               $mem->setAutosave($autosave);\r
+\r
+               $mem->write();\r
+\r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::apply_plugin_options($aOptions);\r
+               $manager->notify(\r
+                       'PostPluginOptionsUpdate',\r
+                       array(\r
+                               'context'  => 'member',\r
+                               'memberid' => $memberid,\r
+                               'member'   => &$mem\r
+                       )\r
+               );\r
+\r
+               // if email changed, generate new password\r
+               if ( $oldEmail != $mem->getEmail() )\r
+               {\r
+                       $mem->sendActivationLink('addresschange', $oldEmail);\r
+                       // logout member\r
+                       $mem->newCookieKey();\r
+\r
+                       // only log out if the member being edited is the current member.\r
+                       if ( $member->getID() == $memberid )\r
+                       {\r
+                               $member->logout();\r
+                       }\r
+                       $this->action_login(_MSG_ACTIVATION_SENT, 0);\r
+                       return;\r
+               }\r
+\r
+\r
+               if (    ( $mem->getID() == $member->getID() )\r
+                       &&      ( $mem->getDisplayName() != $member->getDisplayName() )\r
+                       )\r
+               {\r
+                       $mem->newCookieKey();\r
+                       $member->logout();\r
+                       $this->action_login(_MSG_LOGINAGAIN, 0);\r
+               }\r
+               else\r
+               {\r
+                       $this->action_overview(_MSG_SETTINGSCHANGED);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * Admin::action_memberadd()\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        * \r
+       */\r
+       function action_memberadd()\r
+       {\r
+               global $member, $manager;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               if ( postVar('password') != postVar('repeatpassword') )\r
+               {\r
+                       $this->error(_ERROR_PASSWORDMISMATCH);\r
+               }\r
+               \r
+               if ( i18n::strlen(postVar('password')) < 6 )\r
+               {\r
+                       $this->error(_ERROR_PASSWORDTOOSHORT);\r
+               }\r
+               \r
+               $res = Member::create(\r
+                                       postVar('name'),\r
+                                       postVar('realname'),\r
+                                       postVar('password'),\r
+                                       postVar('email'),\r
+                                       postVar('url'),\r
+                                       postVar('admin'),\r
+                                       postVar('canlogin'),\r
+                                       postVar('notes')\r
+                               );\r
+               if ( $res != 1 )\r
+               {\r
+                       $this->error($res);\r
+               }\r
+               \r
+               // fire PostRegister event\r
+               $newmem = new Member();\r
+               $newmem->readFromName(postVar('name'));\r
+               $manager->notify(\r
+                       'PostRegister',\r
+                       array(\r
+                               'member' => &$newmem\r
+                       )\r
+               );\r
+               \r
+               $this->action_usermanagement();\r
+               return;\r
+       }\r
+\r
+       /**\r
+        * Account activation\r
+        *\r
+        * @author dekarma\r
+        */\r
+       function action_activate()\r
+       {\r
+\r
+               $key = getVar('key');\r
+               $this->_showActivationPage($key);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function _showActivationPage($key, $message = '')\r
+       {\r
+               global $manager;\r
+\r
+               // clean up old activation keys\r
+               Member::cleanupActivationTable();\r
+\r
+               // get activation info\r
+               $info = Member::getActivationInfo($key);\r
+\r
+               if ( !$info )\r
+               {\r
+                       $this->error(_ERROR_ACTIVATE);\r
+               }\r
+\r
+               $mem = Member::createFromId($info->vmember);\r
+\r
+               if ( !$mem )\r
+               {\r
+                       $this->error(_ERROR_ACTIVATE);\r
+               }\r
+               $_POST['ackey']                = $key;\r
+               $this->headMess                = $message;\r
+               $_POST['bNeedsPasswordChange'] = true;\r
+               $this->pagehead();\r
+               $this->parse('activate');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * Account activation - set password part\r
+        *\r
+        * @author dekarma\r
+        */\r
+       function action_activatesetpwd()\r
+       {\r
+\r
+               $key = postVar('key');\r
+\r
+               // clean up old activation keys\r
+               Member::cleanupActivationTable();\r
+\r
+               // get activation info\r
+               $info = Member::getActivationInfo($key);\r
+\r
+               if ( !$info || ($info->type == 'addresschange') )\r
+               {\r
+                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);\r
+               }\r
+\r
+               $mem = Member::createFromId($info->vmember);\r
+\r
+               if ( !$mem )\r
+               {\r
+                       return $this->_showActivationPage($key, _ERROR_ACTIVATE);\r
+               }\r
+\r
+               $password       = postVar('password');\r
+               $repeatpassword = postVar('repeatpassword');\r
+\r
+               if ( $password != $repeatpassword )\r
+               {\r
+                       return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);\r
+               }\r
+\r
+               if ( $password && (i18n::strlen($password) < 6) )\r
+               {\r
+                       return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);\r
+               }\r
+                       \r
+               if ( $password )\r
+               {\r
+                       $pwdvalid = true;\r
+                       $pwderror = '';\r
+                       global $manager;\r
+                       $manager->notify(\r
+                               'PrePasswordSet',\r
+                               array(\r
+                                       'password'     => $password,\r
+                                       'errormessage' => &$pwderror,\r
+                                       'valid'        => &$pwdvalid\r
+                               )\r
+                       );\r
+                       if ( !$pwdvalid )\r
+                       {\r
+                               return $this->_showActivationPage($key,$pwderror);\r
+                       }\r
+               }\r
+\r
+               $error = '';\r
+               \r
+               $manager->notify(\r
+                       'ValidateForm',\r
+                       array(\r
+                               'type'   => 'activation',\r
+                               'member' => $mem,\r
+                               'error'  => &$error\r
+                       )\r
+               );\r
+               if ( $error != '' )\r
+               {\r
+                       return $this->_showActivationPage($key, $error);\r
+               }\r
+\r
+\r
+               // set password\r
+               $mem->setPassword($password);\r
+               $mem->write();\r
+\r
+               // do the activation\r
+               Member::activate($key);\r
+\r
+               $this->pagehead();\r
+               $this->parse('activatesetpwd');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Manage team\r
+        */\r
+       function action_manageteam()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('manageteam');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Add member to team\r
+        */\r
+       function action_teamaddmember()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $memberid = intPostVar('memberid');\r
+               $blogid = intPostVar('blogid');\r
+               $admin = intPostVar('admin');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               if ( !$blog->addTeamMember($memberid, $admin) )\r
+               {\r
+                       $this->error(_ERROR_ALREADYONTEAM);\r
+               }\r
+\r
+               $this->action_manageteam();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamdelete()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+               $blogid   = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $teammem =  Member::createFromID($memberid);\r
+               $blog    =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('teamdelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamdeleteconfirm()\r
+       {\r
+               global $member;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $error = $this->deleteOneTeamMember($blogid, $memberid);\r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+               $this->action_manageteam();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOneTeamMember($blogid, $memberid)\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid   = intval($blogid);\r
+               $memberid = intval($memberid);\r
+\r
+               // check if allowed\r
+               if ( !$member->blogAdminRights($blogid) )\r
+               {\r
+                       return _ERROR_DISALLOWED;\r
+               }\r
+\r
+               // check if: - there remains at least one blog admin\r
+               //           - (there remains at least one team member)\r
+               $tmem = Member::createFromID($memberid);\r
+\r
+               $manager->notify(\r
+                       'PreDeleteTeamMember',\r
+                       array(\r
+                               'member' => &$tmem,\r
+                               'blogid' => $blogid\r
+                       )\r
+               );\r
+\r
+               if ( $tmem->isBlogAdmin($blogid) )\r
+               {\r
+                       // check if there are more blog members left and at least one admin\r
+                       // (check for at least two admins before deletion)\r
+                       $query = 'SELECT * FROM ' . sql_table('team') . ' WHERE tblog=' . $blogid . ' and tadmin=1';\r
+                       $r     = sql_query($query);\r
+                       if ( sql_num_rows($r) < 2 )\r
+                       {\r
+                               return _ERROR_ATLEASTONEBLOGADMIN;\r
+                       }\r
+               }\r
+\r
+               $query = 'DELETE FROM ' . sql_table('team') . " WHERE tblog=$blogid and tmember=$memberid";\r
+               sql_query($query);\r
+\r
+               $manager->notify(\r
+                       'PostDeleteTeamMember',\r
+                       array(\r
+                               'member' => &$tmem,\r
+                               'blogid' => $blogid\r
+                       )\r
+               );\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_teamchangeadmin()\r
+       {\r
+               global $member;\r
+\r
+               $blogid   = intRequestVar('blogid');\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $mem = Member::createFromID($memberid);\r
+\r
+               // don't allow when there is only one admin at this moment\r
+               if ( $mem->isBlogAdmin($blogid) )\r
+               {\r
+                       $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");\r
+                       if ( sql_num_rows($r) == 1 )\r
+                       {\r
+                               $this->error(_ERROR_ATLEASTONEBLOGADMIN);\r
+                       }\r
+               }\r
+\r
+               if ( $mem->isBlogAdmin($blogid) )\r
+               {\r
+                       $newval = 0;\r
+               }\r
+               else\r
+               {\r
+                       $newval = 1;\r
+               }\r
+\r
+               $query = 'UPDATE ' . sql_table('team') . " SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";\r
+               sql_query($query);\r
+\r
+               // only show manageteam if member did not change its own admin privileges\r
+               if ( $member->isBlogAdmin($blogid) )\r
+               {\r
+                       $this->action_manageteam();\r
+               }\r
+               else\r
+               {\r
+                       $this->action_overview(_MSG_ADMINCHANGED);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_blogsettings()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               // check if allowed\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+               $this->parse('blogsettings');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorynew()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $cname = postVar('cname');\r
+               $cdesc = postVar('cdesc');\r
+\r
+               if ( !isValidCategoryName($cname) )\r
+               {\r
+                       $this->error(_ERROR_BADCATEGORYNAME);\r
+               }\r
+\r
+               $query = 'SELECT * FROM ' . sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname) . '\' and cblog=' . intval($blogid);\r
+               $res = sql_query($query);\r
+               if ( sql_num_rows($res) > 0 )\r
+               {\r
+                       $this->error(_ERROR_DUPCATEGORYNAME);\r
+               }\r
+\r
+               $blog       =& $manager->getBlog($blogid);\r
+               $newCatID   =  $blog->createNewCategory($cname, $cdesc);\r
+\r
+               $this->action_blogsettings();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categoryedit($catid = '', $blogid = '', $desturl = '')\r
+       {\r
+               global $member, $manager;\r
+\r
+               if ( $blogid == '' )\r
+               {\r
+                       $blogid = intGetVar('blogid');\r
+               }\r
+               else\r
+               {\r
+                       $blogid = intval($blogid);\r
+               }\r
+               if ( $catid == '' )\r
+               {\r
+                       $catid = intGetVar('catid');\r
+               }\r
+               else\r
+               {\r
+                       $catid = intval($catid);\r
+               }\r
+               $_REQUEST['blogid']  = $blogid;\r
+               $_REQUEST['catid']   = $catid;\r
+               $_REQUEST['desturl'] = $desturl;\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';\r
+               $this->pagehead($extrahead);\r
+               $this->parse('categoryedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categoryupdate()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid  = intPostVar('blogid');\r
+               $catid   = intPostVar('catid');\r
+               $cname   = postVar('cname');\r
+               $cdesc   = postVar('cdesc');\r
+               $desturl = postVar('desturl');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               if ( !isValidCategoryName($cname) )\r
+               {\r
+                       $this->error(_ERROR_BADCATEGORYNAME);\r
+               }\r
+\r
+               $query = "SELECT *"\r
+                          . " FROM " . sql_table('category')\r
+                          . " WHERE cname='" . sql_real_escape_string($cname) . "'"\r
+                          . " and cblog=" . intval($blogid)\r
+                          . " and not(catid=" . intval($catid) . ")";\r
+               $res   = sql_query($query);\r
+               if ( sql_num_rows($res) > 0 )\r
+               {\r
+                       $this->error(_ERROR_DUPCATEGORYNAME);\r
+               }\r
+\r
+               $query =  'UPDATE '.sql_table('category').' SET'\r
+                               . " cname='" . sql_real_escape_string($cname) . "',"\r
+                               . " cdesc='" . sql_real_escape_string($cdesc) . "'"\r
+                               . " WHERE catid=" . intval($catid);\r
+\r
+               sql_query($query);\r
+\r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::apply_plugin_options($aOptions);\r
+               $manager->notify(\r
+                       'PostPluginOptionsUpdate',\r
+                       array(\r
+                               'context' => 'category',\r
+                               'catid'   => $catid\r
+                       )\r
+               );\r
+\r
+\r
+               if ( $desturl )\r
+               {\r
+                       redirect($desturl);\r
+                       exit;\r
+               }\r
+               else\r
+               {\r
+                       $this->action_blogsettings();\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorydelete()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $catid  = intRequestVar('catid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               // check if the category is valid\r
+               if ( !$blog->isValidCategory($catid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHCATEGORY);\r
+               }\r
+\r
+               // don't allow deletion of default category\r
+               if ( $blog->getDefaultCategory() == $catid )\r
+               {\r
+                       $this->error(_ERROR_DELETEDEFCATEGORY);\r
+               }\r
+\r
+               // check if catid is the only category left for blogid\r
+               $query = 'SELECT catid FROM ' . sql_table('category') . ' WHERE cblog=' . $blogid;\r
+               $res = sql_query($query);\r
+               if ( sql_num_rows($res) == 1 )\r
+               {\r
+                       $this->error(_ERROR_DELETELASTCATEGORY);\r
+               }\r
+\r
+\r
+               $this->pagehead();\r
+               $this->parse('categorydelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_categorydeleteconfirm()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $catid  = intRequestVar('catid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $error = $this->deleteOneCategory($catid);\r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $this->action_blogsettings();\r
+       }\r
+       \r
+       /**\r
+        * Admin::deleteOneCategory()\r
+        * Delete a category by its id\r
+        * \r
+        * @param       String  $catid  category id for deleting\r
+        * @return      Void\r
+        */\r
+       function deleteOneCategory($catid)\r
+       {\r
+               global $manager, $member;\r
+               \r
+               $catid  = intval($catid);\r
+               $blogid = getBlogIDFromCatID($catid);\r
+\r
+               if ( !$member->blogAdminRights($blogid) )\r
+               {\r
+                       return ERROR_DISALLOWED;\r
+               }\r
+\r
+               // get blog\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               // check if the category is valid\r
+               if ( !$blog || !$blog->isValidCategory($catid) )\r
+               {\r
+                       return _ERROR_NOSUCHCATEGORY;\r
+               }\r
+\r
+               $destcatid = $blog->getDefaultCategory();\r
+\r
+               // don't allow deletion of default category\r
+               if ( $blog->getDefaultCategory() == $catid )\r
+               {\r
+                       return _ERROR_DELETEDEFCATEGORY;\r
+               }\r
+\r
+               // check if catid is the only category left for blogid\r
+               $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;\r
+               $res = sql_query($query);\r
+               if ( sql_num_rows($res) == 1 )\r
+               {\r
+                       return _ERROR_DELETELASTCATEGORY;\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreDeleteCategory',\r
+                       array(\r
+                               'catid' => $catid\r
+                       )\r
+               );\r
+\r
+               // change category for all items to the default category\r
+               $query = 'UPDATE ' . sql_table('item') . " SET icat=$destcatid WHERE icat=$catid";\r
+               sql_query($query);\r
+               \r
+               // delete all associated plugin options\r
+               NucleusPlugin::delete_option_values('category', $catid);\r
+               \r
+               // delete category\r
+               $query = 'DELETE FROM ' . sql_table('category') . ' WHERE catid=' . $catid;\r
+               sql_query($query);\r
+               \r
+               $manager->notify(\r
+                       'PostDeleteCategory',\r
+                       array(\r
+                               'catid' => $catid\r
+                       )\r
+               );\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_blogsettingsupdate\r
+        * Updating blog settings\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        */\r
+       function action_blogsettingsupdate()\r
+       {\r
+               global $member, $manager;\r
+               \r
+               $blogid = intRequestVar('blogid');\r
+               \r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+               \r
+               $blog =& $manager->getBlog($blogid);\r
+               \r
+               $notify_address = trim(postVar('notify'));\r
+               $shortname              = trim(postVar('shortname'));\r
+               $updatefile     = trim(postVar('update'));\r
+               \r
+               $notifyComment  = intPostVar('notifyComment');\r
+               $notifyVote             = intPostVar('notifyVote');\r
+               $notifyNewItem  = intPostVar('notifyNewItem');\r
+               \r
+               if ( $notifyComment == 0 )\r
+               {\r
+                       $notifyComment = 1;\r
+               }\r
+               if ( $notifyVote == 0 )\r
+               {\r
+                       $notifyVote = 1;\r
+               }\r
+               if ( $notifyNewItem == 0 )\r
+               {\r
+                       $notifyNewItem = 1;\r
+               }\r
+               $notifyType = $notifyComment * $notifyVote * $notifyNewItem;\r
+               \r
+               if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )\r
+               {\r
+                       $this->error(_ERROR_BADNOTIFY);\r
+               }\r
+               \r
+               if ( !isValidShortName($shortname) )\r
+               {\r
+                       $this->error(_ERROR_BADSHORTBLOGNAME);\r
+               }\r
+               \r
+               if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )\r
+               {\r
+                       $this->error(_ERROR_DUPSHORTBLOGNAME);\r
+               }\r
+               // check if update file is writable\r
+               if ( $updatefile && !is_writeable($updatefile) )\r
+               {\r
+                       $this->error(_ERROR_UPDATEFILE);\r
+               }\r
+               \r
+               $blog->setName(trim(postVar('name')));\r
+               $blog->setShortName($shortname);\r
+               $blog->setNotifyAddress($notify_address);\r
+               $blog->setNotifyType($notifyType);\r
+               $blog->setMaxComments(postVar('maxcomments'));\r
+               $blog->setCommentsEnabled(postVar('comments'));\r
+               $blog->setTimeOffset(postVar('timeoffset'));\r
+               $blog->setUpdateFile($updatefile);\r
+               $blog->setURL(trim(postVar('url')));\r
+               $blog->setDefaultSkin(intPostVar('defskin'));\r
+               $blog->setDescription(trim(postVar('desc')));\r
+               $blog->setPublic(postVar('public'));\r
+               $blog->setConvertBreaks(intPostVar('convertbreaks'));\r
+               $blog->setAllowPastPosting(intPostVar('allowpastposting'));\r
+               $blog->setDefaultCategory(intPostVar('defcat'));\r
+               $blog->setSearchable(intPostVar('searchable'));\r
+               $blog->setEmailRequired(intPostVar('reqemail'));\r
+               $blog->writeSettings();\r
+               \r
+               // store plugin options\r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::apply_plugin_options($aOptions);\r
+               $manager->notify(\r
+                       'PostPluginOptionsUpdate',\r
+                       array(\r
+                               'context' => 'blog',\r
+                               'blogid'  => $blogid,\r
+                               'blog'    => &$blog\r
+                       )\r
+               );\r
+               \r
+               $this->action_overview(_MSG_SETTINGSCHANGED);\r
+               return;\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_deleteblog()\r
+       {\r
+               global $member, $CONF, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               // check if blog is default blog\r
+               if ( $CONF['DefaultBlog'] == $blogid )\r
+               {\r
+                       $this->error(_ERROR_DELDEFBLOG);\r
+               }\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('deleteblog');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_deleteblogconfirm()\r
+        * Delete Blog\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        */\r
+       function action_deleteblogconfirm()\r
+       {\r
+               global $member, $CONF, $manager;\r
+               \r
+               $blogid = intRequestVar('blogid');\r
+               $manager->notify(\r
+                       'PreDeleteBlog',\r
+                       array(\r
+                               'blogid' => $blogid\r
+                       )\r
+               );\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+               \r
+               // check if blog is default blog\r
+               if ( $CONF['DefaultBlog'] == $blogid )\r
+               {\r
+                       $this->error(_ERROR_DELDEFBLOG);\r
+               }\r
+               \r
+               // delete all comments\r
+               $query = 'DELETE FROM ' . sql_table('comment') . ' WHERE cblog='.$blogid;\r
+               sql_query($query);\r
+               \r
+               // delete all items\r
+               $query = 'DELETE FROM ' . sql_table('item') . ' WHERE iblog=' . $blogid;\r
+               sql_query($query);\r
+               \r
+               // delete all team members\r
+               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tblog=' . $blogid;\r
+               sql_query($query);\r
+               \r
+               // delete all bans\r
+               $query = 'DELETE FROM ' . sql_table('ban') . ' WHERE blogid=' . $blogid;\r
+               sql_query($query);\r
+               \r
+               // delete all categories\r
+               $query = 'DELETE FROM ' . sql_table('category') . ' WHERE cblog=' . $blogid;\r
+               sql_query($query);\r
+               \r
+               // delete all associated plugin options\r
+               NucleusPlugin::delete_option_values('blog', $blogid);\r
+               \r
+               // delete the blog itself\r
+               $query = 'DELETE FROM ' . sql_table('blog') . ' WHERE bnumber=' . $blogid;\r
+               sql_query($query);\r
+               \r
+               $manager->notify(\r
+                       'PostDeleteBlog',\r
+                       array(\r
+                               'blogid' => $blogid\r
+                       )\r
+               );\r
+               \r
+               $this->action_overview(_DELETED_BLOG);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_memberdelete()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $mem = Member::createFromID($memberid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('memberdelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_memberdeleteconfirm()\r
+       {\r
+               global $member;\r
+\r
+               $memberid = intRequestVar('memberid');\r
+\r
+               ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();\r
+\r
+               $error = $this->deleteOneMember($memberid);\r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+\r
+               if ( $member->isAdmin() )\r
+               {\r
+                       $this->action_usermanagement();\r
+               }\r
+               else\r
+               {\r
+                       $this->action_overview(_DELETED_MEMBER);\r
+               }\r
+       }\r
+       \r
+       /**\r
+        * Admin::deleteOneMember()\r
+        * Delete a member by id\r
+        * \r
+        * @static\r
+        * @params      Integer $memberid       member id\r
+        * @return      String  null string or error messages\r
+        */\r
+       function deleteOneMember($memberid)\r
+       {\r
+               global $manager;\r
+               \r
+               $memberid = intval($memberid);\r
+               $mem = Member::createFromID($memberid);\r
+               \r
+               if ( !$mem->canBeDeleted() )\r
+               {\r
+                       return _ERROR_DELETEMEMBER;\r
+               }\r
+               \r
+               $manager->notify(\r
+                       'PreDeleteMember',\r
+                       array(\r
+                               'member' => &$mem\r
+                       )\r
+               );\r
+               \r
+               /* unlink comments from memberid */\r
+               if ( $memberid )\r
+               {\r
+                       $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";\r
+                       $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);\r
+                       sql_query($query);\r
+               }\r
+               \r
+               $query = 'DELETE FROM ' . sql_table('member') . ' WHERE mnumber=' . $memberid;\r
+               sql_query($query);\r
+               \r
+               $query = 'DELETE FROM ' . sql_table('team') . ' WHERE tmember=' . $memberid;\r
+               sql_query($query);\r
+               \r
+               $query = 'DELETE FROM ' . sql_table('activation') . ' WHERE vmember=' . $memberid;\r
+               sql_query($query);\r
+               \r
+               // delete all associated plugin options\r
+               NucleusPlugin::delete_option_values('member', $memberid);\r
+               \r
+               $manager->notify(\r
+                       'PostDeleteMember',\r
+                       array(\r
+                               'member' => &$mem\r
+                       )\r
+               );\r
+               \r
+               return '';\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_createnewlog()\r
+       {\r
+               global $member, $CONF, $manager;\r
+\r
+               // Only Super-Admins can do this\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('createnewlog');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_addnewlog()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               // Only Super-Admins can do this\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $bname          = trim(postVar('name'));\r
+               $bshortname     = trim(postVar('shortname'));\r
+               $btimeoffset    = postVar('timeoffset');\r
+               $bdesc          = trim(postVar('desc'));\r
+               $bdefskin       = postVar('defskin');\r
+\r
+               if ( !isValidShortName($bshortname) )\r
+               {\r
+                       $this->error(_ERROR_BADSHORTBLOGNAME);\r
+               }\r
+\r
+               if ( $manager->existsBlog($bshortname) )\r
+               {\r
+                       $this->error(_ERROR_DUPSHORTBLOGNAME);\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreAddBlog',\r
+                       array(\r
+                               'name'        => &$bname,\r
+                               'shortname'   => &$bshortname,\r
+                               'timeoffset'  => &$btimeoffset,\r
+                               'description' => &$bdesc,\r
+                               'defaultskin' => &$bdefskin\r
+                       )\r
+               );\r
+\r
+\r
+               // add slashes for sql queries\r
+               $bname       = sql_real_escape_string($bname);\r
+               $bshortname  = sql_real_escape_string($bshortname);\r
+               $btimeoffset = sql_real_escape_string($btimeoffset);\r
+               $bdesc       = sql_real_escape_string($bdesc);\r
+               $bdefskin    = sql_real_escape_string($bdefskin);\r
+\r
+               // create blog\r
+               $query = 'INSERT '\r
+                          . 'INTO '\r
+                          .      sql_table('blog')\r
+                          . '('\r
+                          . '    bname, '\r
+                          . '    bshortname, '\r
+                          . '    bdesc, '\r
+                          . '    btimeoffset, '\r
+                          . '    bdefskin'\r
+                          . ') VALUES ('\r
+                          . "'" . $bname . "'," \r
+                          . "'" . $bshortname . "'," \r
+                          . "'" . $bdesc . "'," \r
+                          . "'" . $btimeoffset . "'," \r
+                          . "'" . $bdefskin . "'" \r
+                          . ")";\r
+               sql_query($query);\r
+               $blogid =  sql_insert_id();\r
+               $blog   =& $manager->getBlog($blogid);\r
+\r
+               // create new category\r
+               $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');\r
+               $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');\r
+               $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';\r
+               sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));\r
+               $catid = sql_insert_id();\r
+\r
+               // set as default category\r
+               $blog->setDefaultCategory($catid);\r
+               $blog->writeSettings();\r
+\r
+               // create team member\r
+               $memberid = $member->getID();\r
+               $query    = 'INSERT '\r
+                                 . 'INTO '\r
+                                 .      sql_table('team')\r
+                                 . '('\r
+                                 . '    tmember, '\r
+                                 . '    tblog, '\r
+                                 . '    tadmin'\r
+                                 . ') VALUES ('\r
+                                 . '%d, '\r
+                                 . '%d, '\r
+                                 . '    1'\r
+                                 . ')';\r
+               sql_query(sprintf($query), $memberid, $blogid);\r
+\r
+               $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');\r
+               $itemdefbody  = (defined('_EBLOG_FIRSTITEM_BODY')  ? _EBLOG_FIRSTITEM_BODY  : 'This is the first item in your weblog. Feel free to delete it.');\r
+\r
+               $blog->additem(\r
+                       $blog->getDefaultCategory(),\r
+                       $itemdeftitle,$itemdefbody,\r
+                       '',\r
+                       $blogid,\r
+                       $memberid,\r
+                       $blog->getCorrectTime(),\r
+                       0,\r
+                       0,\r
+                       0\r
+               );\r
+               $manager->notify(\r
+                       'PostAddBlog',\r
+                       array(\r
+                               'blog' => &$blog\r
+                       )\r
+               );\r
+\r
+               $manager->notify(\r
+                       'PostAddCategory',\r
+                       array(\r
+                               'blog'        => &$blog,\r
+                               'name'        => _EBLOGDEFAULTCATEGORY_NAME,\r
+                               'description' => _EBLOGDEFAULTCATEGORY_DESC,\r
+                               'catid'       => $catid\r
+                       )\r
+               );\r
+\r
+               $_REQUEST['blogid'] = $blogid;\r
+               $_REQUEST['catid']  = $catid;\r
+               $this->pagehead();\r
+               $this->parse('addnewlog');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_addnewlog2()\r
+       {\r
+               global $member, $manager;\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $burl   = requestVar('url');\r
+\r
+               $blog =& $manager->getBlog($blogid);\r
+               $blog->setURL(trim($burl));\r
+               $blog->writeSettings();\r
+\r
+               $this->action_overview(_MSG_NEWBLOG);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieoverview()\r
+       {\r
+               global $member, $DIR_LIBS, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinieoverview');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieimport() {\r
+               global $member, $DIR_LIBS, $DIR_SKINS, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $skinFileRaw = postVar('skinfile');\r
+               $mode        = postVar('mode');\r
+\r
+               $importer = new SkinImport();\r
+\r
+               // get full filename\r
+               if ($mode == 'file')\r
+               {\r
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';\r
+\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if ( !file_exists($skinFile) )\r
+                       {\r
+                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';\r
+                       }\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+\r
+               // read only metadata\r
+               $error = $importer->readFile($skinFile, 1);\r
+\r
+               $_REQUEST['skininfo']  = $importer->getInfo();\r
+               $_REQUEST['skinnames'] = $importer->getSkinNames();\r
+               $_REQUEST['tpltnames'] = $importer->getTemplateNames();\r
+\r
+               // clashes\r
+               $skinNameClashes     = $importer->checkSkinNameClashes();\r
+               $templateNameClashes = $importer->checkTemplateNameClashes();\r
+               $hasNameClashes      = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);\r
+\r
+               $_REQUEST['skinclashes'] = $skinNameClashes;\r
+               $_REQUEST['tpltclashes'] = $templateNameClashes;\r
+               $_REQUEST['nameclashes'] = $hasNameClashes ? 1 : 0;\r
+               \r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinieimport');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skiniedoimport()\r
+       {\r
+               global $member, $DIR_LIBS, $DIR_SKINS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $skinFileRaw= postVar('skinfile');\r
+               $mode       = postVar('mode');\r
+\r
+               $allowOverwrite = intPostVar('overwrite');\r
+\r
+               // get full filename\r
+               if ( $mode == 'file' )\r
+               {\r
+                       $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';\r
+\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if ( !file_exists($skinFile) )\r
+                       {\r
+                               $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';\r
+                       }\r
+\r
+               }\r
+               else\r
+               {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+\r
+               $importer = new SkinImport();\r
+\r
+               $error    = $importer->readFile($skinFile);\r
+\r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $error = $importer->writeToDatabase($allowOverwrite);\r
+\r
+               if ( $error )\r
+               {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $_REQUEST['skininfo']  = $importer->getInfo();\r
+               $_REQUEST['skinnames'] = $importer->getSkinNames();\r
+               $_REQUEST['tpltnames'] = $importer->getTemplateNames();\r
+\r
+               $this->pagehead();\r
+               $this->parse('skiniedoimport');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinieexport()\r
+       {\r
+               global $member, $DIR_LIBS;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinie.php');\r
+\r
+               $aSkins     = requestIntArray('skin');\r
+               $aTemplates = requestIntArray('template');\r
+\r
+               if ( !is_array($aTemplates) )\r
+               {\r
+                       $aTemplates = array();\r
+               }\r
+               if ( !is_array($aSkins) )\r
+               {\r
+                       $aSkins = array();\r
+               }\r
+\r
+               $skinList     = array_keys($aSkins);\r
+               $templateList = array_keys($aTemplates);\r
+\r
+               $info = postVar('info');\r
+\r
+               $exporter = new SkinExport();\r
+               foreach ($skinList as $skinId)\r
+               {\r
+                       $exporter->addSkin($skinId);\r
+               }\r
+               foreach ($templateList as $templateId)\r
+               {\r
+                       $exporter->addTemplate($templateId);\r
+               }\r
+               $exporter->setInfo($info);\r
+\r
+               $exporter->export();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateoverview()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('templateoverview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateedit($msg = '')\r
+       {\r
+               global $member, $manager;\r
+               if ( $msg )\r
+               {\r
+                       $this->headMess = $msg;\r
+               }\r
+               \r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';\r
+               $extrahead .= '<script type="text/javascript">setTemplateEditText("' . sql_real_escape_string(_EDITTEMPLATE_EMPTY) . '");</script>';\r
+\r
+               $this->pagehead($extrahead);\r
+               $this->parse('templateedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        *\r
+       function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {\r
+               static $count = 1;\r
+               if (!isset($template[$name])) $template[$name] = '';\r
+       ?>\r
+               </tr><tr>\r
+                       <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>\r
+                       <td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo  Entity::hsc($template[$name]); ?></textarea></td>\r
+       <?php       $count++;\r
+       }\r
+       */\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateupdate()\r
+       {\r
+               global $member,$manager;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('tname');\r
+               $desc = postVar('tdesc');\r
+\r
+               if ( !isValidTemplateName($name) )\r
+               {\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+               }\r
+\r
+               if ( (Template::getNameFromId($templateid) != $name) && Template::exists($name) )\r
+               {\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+               }\r
+\r
+               $name = sql_real_escape_string($name);\r
+               $desc = sql_real_escape_string($desc);\r
+\r
+               // 1. Remove all template parts\r
+               $query = 'DELETE FROM ' . sql_table('template') . ' WHERE tdesc=' . $templateid;\r
+               sql_query($query);\r
+\r
+               // 2. Update description\r
+               $query = 'UPDATE '\r
+                          .      sql_table('template_desc')\r
+                          . ' SET'\r
+                          . "    tdname='" . $name . "',"\r
+                          . "    tddesc='" . $desc . "'"\r
+                          . " WHERE"\r
+                          . "    tdnumber=" . $templateid;\r
+               sql_query($query);\r
+\r
+               // 3. Add non-empty template parts\r
+               $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));\r
+               $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));\r
+               $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));\r
+               $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));\r
+               $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));\r
+               $this->addToTemplate($templateid, 'NEW', postVar('NEW'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));\r
+               $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));\r
+               $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));\r
+               $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));\r
+               $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));\r
+               $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));\r
+               $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));\r
+               $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));\r
+               $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));\r
+               $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));\r
+               $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));\r
+               $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));\r
+               $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));\r
+               $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));\r
+\r
+               $pluginfields = array();\r
+               $manager->notify(\r
+                       'TemplateExtraFields',\r
+                       array(\r
+                               'fields'=>&$pluginfields\r
+                       )\r
+               );\r
+               foreach ($pluginfields as $pfkey=>$pfvalue)\r
+               {\r
+                       foreach ($pfvalue as $pffield=>$pfdesc)\r
+                       {\r
+                               $this->addToTemplate($templateid, $pffield, postVar($pffield));\r
+                       }\r
+               }\r
+\r
+               // jump back to template edit\r
+               $this->action_templateedit(_TEMPLATE_UPDATED);\r
+\r
+       }\r
+\r
+       /**\r
+        * Admin::addToTemplate()\r
+        * \r
+        * @param       Integer $id     ID for template\r
+        * @param       String  $partname       parts name\r
+        * @param       String  $content        template contents\r
+        * @return      Integer record index\r
+        * \r
+        */\r
+       function addToTemplate($id, $partname, $content)\r
+       {\r
+               // don't add empty parts:\r
+               if ( !trim($content) )\r
+               {\r
+                       return -1;\r
+               }\r
+               \r
+               $partname = sql_real_escape_string($partname);\r
+               $content  = sql_real_escape_string($content);\r
+               \r
+               $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, '%s', '%s')";\r
+               $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);\r
+               sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());\r
+               return sql_insert_id();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatedelete() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $templateid = intRequestVar('templateid');\r
+               // TODO: check if template can be deleted\r
+\r
+               $this->pagehead();\r
+               $this->parse('templatedelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatedeleteconfirm() {\r
+               global $member, $manager;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $manager->notify(\r
+                       'PreDeleteTemplate',\r
+                       array(\r
+                               'templateid' => $templateid\r
+                       )\r
+               );\r
+\r
+               // 1. delete description\r
+               sql_query('DELETE FROM ' . sql_table('template_desc') . ' WHERE tdnumber=' . $templateid);\r
+\r
+               // 2. delete parts\r
+               sql_query('DELETE FROM ' . sql_table('template') . ' WHERE tdesc=' . $templateid);\r
+\r
+               $manager->notify(\r
+                       'PostDeleteTemplate',\r
+                       array(\r
+                               'templateid' => $templateid\r
+                       )\r
+               );\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templatenew()\r
+       {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('name');\r
+               $desc = postVar('desc');\r
+\r
+               if ( !isValidTemplateName($name) )\r
+               {\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+               }\r
+\r
+               if ( Template::exists($name) )\r
+               {\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+               }\r
+\r
+               $newTemplateId = Template::createNew($name, $desc);\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_templateclone()\r
+       {\r
+               global $member;\r
+\r
+               $templateid = intRequestVar('templateid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // 1. read old template\r
+               $name = Template::getNameFromId($templateid);\r
+               $desc = Template::getDesc($templateid);\r
+\r
+               // 2. create desc thing\r
+               $name = "cloned" . $name;\r
+\r
+               // if a template with that name already exists:\r
+               if (Template::exists($name)) {\r
+                       $i = 1;\r
+                       while (Template::exists($name . $i))\r
+                       {\r
+                               $i++;\r
+                       }\r
+                       $name .= $i;\r
+               }\r
+\r
+               $newid = Template::createNew($name, $desc);\r
+\r
+               // 3. create clone\r
+               // go through parts of old template and add them to the new one\r
+               $que = 'SELECT '\r
+                        . '    tpartname,'\r
+                        . '    tcontent '\r
+                        . 'FROM '\r
+                        .      sql_table('template')\r
+                        . ' WHERE'\r
+                        . '    tdesc=' . intval($templateid);\r
+               $res = sql_query($que);\r
+               while ($o = sql_fetch_object($res)) {\r
+                       $this->addToTemplate($newid, $o->tpartname, $o->tcontent);\r
+               }\r
+\r
+               $this->action_templateoverview();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplateoverview()\r
+       {\r
+               global $member, $manager;\r
+               $member->isAdmin() or $this->disallow();\r
+               $this->pagehead();\r
+               $this->parse('admintemplateoverview');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplateedit($msg = '')\r
+       {\r
+               global $member, $manager;\r
+               if ($msg) {\r
+                       $this->headMess = $msg;\r
+               }\r
+               $member->isAdmin() or $this->disallow();\r
+               $extrahead  = '<script type="text/javascript" src="javascript/templateEdit.js"></script>' . "\n";\r
+               $extrahead .= '<script type="text/javascript">setTemplateEditText("' . sql_real_escape_string(_EDITTEMPLATE_EMPTY) . '");</script>';\r
+               $this->pagehead($extrahead);\r
+               $this->parse('admintemplateedit');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplateupdate()\r
+       {\r
+               global $member, $manager;\r
+               $templateid = intRequestVar('templateid');\r
+               $member->isAdmin() or $this->disallow();\r
+               $name = postVar('tname');\r
+               $desc = postVar('tdesc');\r
+       \r
+               if (!isValidTemplateName($name)) {\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+               }\r
+               //        if (!class_exists('skinableTEMPLATE')) {\r
+               //            NP_SkinableAdmin::loadSkinableClass('skinableTEMPLATE');\r
+               //        }\r
+               if ((skinableTEMPLATE::getNameFromId($templateid) != $name) && skinableTEMPLATE::exists($name)) {\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+               }\r
+               $name = sql_real_escape_string($name);\r
+               $desc = sql_real_escape_string($desc);\r
+       \r
+               // 1. Remove all template parts\r
+               $query = 'DELETE '\r
+               . 'FROM '\r
+               .      sql_table('admintemplate') . ' '\r
+               . 'WHERE '\r
+               . '    tdesc = %d';\r
+               sql_query(sprintf($query, $templateid));\r
+       \r
+               // 2. Update description\r
+               $query = 'UPDATE '\r
+               .      sql_table('admintemplate_desc') . ' '\r
+               . 'SET '\r
+               . '    tdname = "' . sql_real_escape_string($name) . '", '\r
+               . '    tddesc = "' . sql_real_escape_string($desc) . '" '\r
+               . 'WHERE '\r
+               . '    tdnumber = %d';\r
+               sql_query(sprintf($query, $templateid));\r
+       \r
+               // 3. Add non-empty template parts\r
+               $this->addToAdminTemplate($templateid, 'ADMINSKINTYPELIST_HEAD',                 postVar('ADMINSKINTYPELIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'ADMINSKINTYPELIST_BODY',                 postVar('ADMINSKINTYPELIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'ADMINSKINTYPELIST_FOOT',                 postVar('ADMINSKINTYPELIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_CUSTOMHELPLINK_ICON',              postVar('ADMIN_CUSTOMHELPLINK_ICON'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_CUSTOMHELPLINK_ANCHOR',            postVar('ADMIN_CUSTOMHELPLINK_ANCHOR'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_BLOGLINK',                         postVar('ADMIN_BLOGLINK'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_BATCHLIST',                        postVar('ADMIN_BATCHLIST'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_FORGOT_TITLE',                  postVar('ACTIVATE_FORGOT_TITLE'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_FORGOT_TEXT',                   postVar('ACTIVATE_FORGOT_TEXT'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_REGISTER_TITLE',                postVar('ACTIVATE_REGISTER_TITLE'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_REGISTER_TEXT',                 postVar('ACTIVATE_REGISTER_TEXT'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_CHANGE_TITLE',                  postVar('ACTIVATE_CHANGE_TITLE'));\r
+               $this->addToAdminTemplate($templateid, 'ACTIVATE_CHANGE_TEXT',                   postVar('ACTIVATE_CHANGE_TEXT'));\r
+               $this->addToAdminTemplate($templateid, 'TEMPLATE_EDIT_EXPLUGNAME',               postVar('TEMPLATE_EDIT_EXPLUGNAME'));\r
+               $this->addToAdminTemplate($templateid, 'TEMPLATE_EDIT_ROW_HEAD',                 postVar('TEMPLATE_EDIT_ROW_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'TEMPLATE_EDIT_ROW_TAIL',                 postVar('TEMPLATE_EDIT_ROW_TAIL'));\r
+               $this->addToAdminTemplate($templateid, 'SPECIALSKINLIST_HEAD',                   postVar('SPECIALSKINLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SPECIALSKINLIST_BODY',                   postVar('SPECIALSKINLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SPECIALSKINLIST_FOOT',                   postVar('SPECIALSKINLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SYSTEMINFO_GDSETTINGS',                  postVar('SYSTEMINFO_GDSETTINGS'));\r
+               $this->addToAdminTemplate($templateid, 'BANLIST_DELETED_LIST',                   postVar('BANLIST_DELETED_LIST'));\r
+               $this->addToAdminTemplate($templateid, 'INSERT_PLUGOPTION_TITLE',                postVar('INSERT_PLUGOPTION_TITLE'));\r
+               $this->addToAdminTemplate($templateid, 'INSERT_PLUGOPTION_BODY',                 postVar('INSERT_PLUGOPTION_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'INPUTYESNO_TEMPLATE_ADMIN',              postVar('INPUTYESNO_TEMPLATE_ADMIN'));\r
+               $this->addToAdminTemplate($templateid, 'INPUTYESNO_TEMPLATE_NORMAL',             postVar('INPUTYESNO_TEMPLATE_NORMAL'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_SPECIALSKINLIST_HEAD',             postVar('ADMIN_SPECIALSKINLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_SPECIALSKINLIST_BODY',             postVar('ADMIN_SPECIALSKINLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'ADMIN_SPECIALSKINLIST_FOOT',             postVar('ADMIN_SPECIALSKINLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SKINIE_EXPORT_LIST',                     postVar('SKINIE_EXPORT_LIST'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_HEAD',          postVar('SHOWLIST_LISTPLUG_SELECT_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_BODY',          postVar('SHOWLIST_LISTPLUG_SELECT_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_SELECT_FOOT',          postVar('SHOWLIST_LISTPLUG_SELECT_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_HEAD',           postVar('SHOWLIST_LISTPLUG_TABLE_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BODY',           postVar('SHOWLIST_LISTPLUG_TABLE_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_FOOT',           postVar('SHOWLIST_LISTPLUG_TABLE_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_GURL'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGEVENTLIST'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGNEDUPDATE'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPEND'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGIN_DEPREQ'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLISTFALSE'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ACTN'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_ADMN'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HELP'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGOPTSETURL'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT',  postVar('SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN',  postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM',  postVar('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_TADM'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM',  postVar('SHOWLIST_LISTPLUG_TABLE_BLIST_BD_SADM'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD',  postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY',  postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT',  postVar('SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT'));\r
+               $this->addToAdminTemplate($templateid, 'PLUGIN_QUICKMENU_TITLE',                 postVar('PLUGIN_QUICKMENU_TITLE'));\r
+               $this->addToAdminTemplate($templateid, 'PLUGIN_QUICKMENU_HEAD',                  postVar('PLUGIN_QUICKMENU_HEAD'));\r
+               $this->addToAdminTemplate($templateid, 'PLUGIN_QUICKMENU_BODY',                  postVar('PLUGIN_QUICKMENU_BODY'));\r
+               $this->addToAdminTemplate($templateid, 'PLUGIN_QUICKMENU_FOOT',                  postVar('PLUGIN_QUICKMENU_FOOT'));\r
+       \r
+               $pluginfields = array();\r
+               $manager->notify(\r
+                               'TemplateExtraFields',\r
+                               array(\r
+                                               'fields' => &$pluginfields\r
+                               )\r
+               );\r
+               foreach ($pluginfields as $pfkey => $pfvalue) {\r
+                       foreach ($pfvalue as $pffield => $pfdesc) {\r
+                               $this->addToAdminTemplate($templateid, $pffield, postVar($pffield));\r
+                       }\r
+               }\r
+       \r
+               // jump back to template edit\r
+               $this->action_admintemplateedit(_TEMPLATE_UPDATED);\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function addToAdminTemplate($id, $partname, $content)\r
+       {\r
+               $partname = sql_real_escape_string($partname);\r
+               $content  = sql_real_escape_string($content);\r
+       \r
+       \r
+               $id = intval($id);\r
+       \r
+               // don't add empty parts:\r
+               if (!trim($content)) {\r
+                       return -1;\r
+               }\r
+               $query = 'INSERT '\r
+               . 'INTO '\r
+               .      sql_table('admintemplate') . ' '\r
+               . '('\r
+               . '    tdesc, '\r
+               . '    tpartname, '\r
+               . '    tcontent '\r
+               . ') VALUES ('\r
+               . '    %d, '\r
+               . '    "%s", '\r
+               . '    "%s"'\r
+               . ')';\r
+               sql_query(sprintf($query, $id, $partname, $content)) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());\r
+               return sql_insert_id();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplatedelete()\r
+       {\r
+               global $member, $manager;\r
+               $member->isAdmin() or $this->disallow();\r
+               // TODO: check if template can be deleted\r
+               $this->pagehead();\r
+               $this->parse('admintemplatedelete');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplatedeleteconfirm()\r
+       {\r
+               global $member, $manager;\r
+               $templateid = intRequestVar('templateid');\r
+               $member->isAdmin() or $this->disallow();\r
+               $manager->notify(\r
+                               'PreDeleteAdminTemplate',\r
+                               array(\r
+                                               'templateid' => $templateid\r
+                               )\r
+               );\r
+       \r
+               $query = 'DELETE '\r
+               . 'FROM '\r
+               . '    %s '\r
+               . 'WHERE '\r
+               . '    %s = ' .intval($templateid);\r
+               // 1. delete description\r
+               sql_query(sprintf($query, sql_table('admintemplate_desc'), 'tdnumber'));\r
+               // 2. delete parts\r
+               sql_query(sprintf($query, sql_table('admintemplate'), 'tdesc'));\r
+       \r
+               $manager->notify(\r
+                               'PostDeleteAdminTemplate',\r
+                               array(\r
+                                               'templateid' => $templateid\r
+                               )\r
+               );\r
+               $this->action_admintemplateoverview();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplatenew()\r
+       {\r
+               global $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               $name = postVar('name');\r
+               $desc = postVar('desc');\r
+       \r
+               if (!isValidTemplateName($name)) {\r
+                       $this->error(_ERROR_BADTEMPLATENAME);\r
+               }\r
+               //        if (!class_exists('skinableTEMPLATE')) {\r
+               //            NP_SkinableAdmin::loadSkinableClass('skinableTEMPLATE');\r
+               //        }\r
+               if (skinableTEMPLATE::exists($name)) {\r
+                       $this->error(_ERROR_DUPTEMPLATENAME);\r
+               }\r
+       \r
+               $newTemplateId = skinableTEMPLATE::createNew($name, $desc);\r
+               $this->action_admintemplateoverview();\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_admintemplateclone()\r
+       {\r
+               global $member;\r
+               $templateid = intRequestVar('templateid');\r
+               $member->isAdmin() or $this->disallow();\r
+       \r
+               //        if (!class_exists('skinableTEMPLATE')) {\r
+               //            NP_SkinableAdmin::loadSkinableClass('skinableTEMPLATE');\r
+               //        }\r
+       \r
+               // 1. read old template\r
+               $name = skinableTEMPLATE::getNameFromId($templateid);\r
+               $desc = skinableTEMPLATE::getDesc($templateid);\r
+               // 2. create desc thing\r
+               $name = "cloned" . $name;\r
+       \r
+               // if a template with that name already exists:\r
+               if (skinableTEMPLATE::exists($name)) {\r
+                       $i = 1;\r
+                       while (skinableTEMPLATE::exists($name . $i)) {\r
+                               $i++;\r
+                       }\r
+                       $name .= $i;\r
+               }\r
+       \r
+               $newid = skinableTEMPLATE::admincreateNew($name, $desc);\r
+       \r
+               // 3. create clone\r
+               // go through parts of old template and add them to the new one\r
+               $que = 'SELECT '\r
+               . '    tpartname, '\r
+               . '    tcontent '\r
+               . 'FROM '\r
+               .      sql_table('admintemplate') . ' '\r
+               . 'WHERE '\r
+               . '    tdesc = ' . intval($templateid);\r
+               $res = sql_query($que);\r
+               while ($o = sql_fetch_object($res)) {\r
+                       $this->addToAdminTemplate($newid, $o->tpartname, $o->tcontent);\r
+               }\r
+               $this->action_admintemplateoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinoverview()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinoverview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinnew()\r
+       {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = trim(postVar('name'));\r
+               $desc = trim(postVar('desc'));\r
+\r
+               if ( !isValidSkinName($name) )\r
+               {\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+               }\r
+\r
+               if ( SKIN::exists($name) )\r
+               {\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+               }\r
+\r
+               $newId = SKIN::createNew($name, $desc);\r
+\r
+               $this->action_skinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinedit()\r
+       {\r
+               global $member, $manager;\r
+\r
+//             $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+//             $skin = new SKIN($skinid);\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skineditgeneral()\r
+       {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name = postVar('name');\r
+               $desc = postVar('desc');\r
+               $type = postVar('type');\r
+               $inc_mode = postVar('inc_mode');\r
+               $inc_prefix = postVar('inc_prefix');\r
+\r
+               $skin = new Skin($skinid);\r
+\r
+               // 1. Some checks\r
+               if ( !isValidSkinName($name) )\r
+               {\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+               }\r
+\r
+               if ( ($skin->getName() != $name) && SKIN::exists($name) )\r
+               {\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+               }\r
+\r
+               if ( !$type )\r
+               {\r
+                       $type = 'text/html';\r
+               }\r
+               if ( !$inc_mode )\r
+               {\r
+                       $inc_mode = 'normal';\r
+               }\r
+\r
+               // 2. Update description\r
+               $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);\r
+\r
+               $this->action_skinedit();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinedittype($msg = '')\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               if ($msg) {\r
+                       $this->headMess = $msg;\r
+               }\r
+               $skinid = intRequestVar('skinid');\r
+               $type   = requestVar('type');\r
+               $type   = trim($type);\r
+               $type   = strtolower($type);\r
+\r
+               if ( !isValidShortName($type) )\r
+               {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinedittype');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinupdate()\r
+       {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $content = trim(postVar('content'));\r
+               $type = postVar('type');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skin = new SKIN($skinid);\r
+               $skin->update($type, $content);\r
+\r
+               $this->action_skinedittype(_SKIN_UPDATED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skindelete()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skin to be deleted\r
+               if ( $skinid == $CONF['BaseSkin'] )\r
+               {\r
+                       $this->error(_ERROR_DEFAULTSKIN);\r
+               }\r
+\r
+               // don't allow deletion of default skins for blogs\r
+               $query = 'SELECT bname FROM ' . sql_table('blog') . ' WHERE bdefskin=' . $skinid;\r
+               $r = sql_query($query);\r
+               if ( $o = sql_fetch_object($r) )\r
+               {\r
+                       $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($o->bname));\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('skindelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skindeleteconfirm()\r
+       {\r
+               global $member, $CONF, $manager;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               // don't allow default skin to be deleted\r
+               if ( $skinid == $CONF['BaseSkin'] )\r
+               {\r
+                       $this->error(_ERROR_DEFAULTSKIN);\r
+               }\r
+\r
+               // don't allow deletion of default skins for blogs\r
+               $query = 'SELECT'\r
+                          . '    bname '\r
+                          . 'FROM '\r
+                          .      sql_table('blog') . ' '\r
+                          . 'WHERE'\r
+                          . '    bdefskin=' . $skinid;\r
+               $r = sql_query($query);\r
+               if ( $o = sql_fetch_object($r) )\r
+               {\r
+                       $this->error(_ERROR_SKINDEFDELETE .$o->bname);\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreDeleteSkin',\r
+                       array(\r
+                               'skinid' => $skinid\r
+                       )\r
+               );\r
+\r
+               // 1. delete description\r
+               sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);\r
+\r
+               // 2. delete parts\r
+               sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);\r
+\r
+               $manager->notify(\r
+                       'PostDeleteSkin',\r
+                       array(\r
+                               'skinid' => $skinid\r
+                       )\r
+               );\r
+\r
+               $this->action_skinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinremovetype() {\r
+               global $member, $manager, $CONF;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+\r
+               if ( !isValidShortName($skintype) )\r
+               {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+\r
+               // don't allow default skinparts to be deleted\r
+               if ( in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )\r
+               {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('skinremovetype');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinremovetypeconfirm() {\r
+               global $member, $CONF, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skinid = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+\r
+               if ( !isValidShortName($skintype) )\r
+               {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               // don't allow default skinparts to be deleted\r
+               if ( in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup')) )\r
+               {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreDeleteSkinPart',\r
+                       array(\r
+                               'skinid'   => $skinid,\r
+                               'skintype' => $skintype\r
+                       )\r
+               );\r
+\r
+               // delete part\r
+               sql_query("DELETE FROM " . sql_table('skin') . " WHERE sdesc=" . $skinid . " AND stype='" . $skintype . "'");\r
+\r
+               $manager->notify(\r
+                       'PostDeleteSkinPart',\r
+                       array(\r
+                               'skinid'   => $skinid,\r
+                               'skintype' => $skintype\r
+                       )\r
+               );\r
+\r
+               $this->action_skinedit();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_skinclone()\r
+       {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               // 1. read skin to clone\r
+               $skin = new SKIN($skinid);\r
+\r
+               $name = "clone_" . $skin->getName();\r
+\r
+               // if a skin with that name already exists:\r
+               if (Skin::exists($name)) {\r
+                       $i = 1;\r
+                       while (Skin::exists($name . $i))\r
+                               $i++;\r
+                       $name .= $i;\r
+               }\r
+\r
+               // 2. create skin desc\r
+               $newid = Skin::createNew(\r
+                       $name,\r
+                       $skin->getDescription(),\r
+                       $skin->getContentType(),\r
+                       $skin->getIncludeMode(),\r
+                       $skin->getIncludePrefix()\r
+               );\r
+\r
+\r
+               // 3. clone\r
+               $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;\r
+               $res = sql_query($query);\r
+               while ($row = sql_fetch_assoc($res)) {\r
+                       $this->skinclonetype($skin, $newid, $row['stype']);\r
+               }\r
+\r
+               $this->action_skinoverview();\r
+\r
+       }\r
+\r
+       /**\r
+        * Admin::skinclonetype()\r
+        * \r
+        * @param       String  $skin   Skin object\r
+        * @param       Integer $newid  ID for this clone\r
+        * @param       String  $type   type of skin\r
+        * @return      Void\r
+        */\r
+       function skinclonetype($skin, $newid, $type)\r
+       {\r
+               $newid = intval($newid);\r
+               $content = $skin->getContent($type);\r
+               \r
+               if ( $content )\r
+               {\r
+                       $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";\r
+                       $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);\r
+                       sql_query($query);\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinoverview() {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('adminskinoverview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinnew()\r
+       {\r
+               global $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               $name = trim(postVar('name'));\r
+               $desc = trim(postVar('desc'));\r
+\r
+               if (!isValidSkinName($name)) {\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+               }\r
+               if (skinableSKIN::exists($name)) {\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+               }\r
+               $newId = skinableSKIN::createNew($name, $desc);\r
+               $this->action_adminskinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinedit()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+               $this->pagehead();\r
+               $this->parse('adminskinedit');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskineditgeneral()\r
+       {\r
+               global $member;\r
+\r
+               $skinid = intRequestVar('skinid');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $name       = postVar('name');\r
+               $desc       = postVar('desc');\r
+               $type       = postVar('type');\r
+               $inc_mode   = postVar('inc_mode');\r
+               $inc_prefix = postVar('inc_prefix');\r
+\r
+               $skin = new skinableSKIN($skinid);\r
+\r
+               // 1. Some checks\r
+               if (!isValidSkinName($name)) {\r
+                       $this->error(_ERROR_BADSKINNAME);\r
+               }\r
+               if (($skin->getName() != $name) && skinableSKIN::exists($name)) {\r
+                       $this->error(_ERROR_DUPSKINNAME);\r
+               }\r
+               if (!$type) {\r
+                       $type = 'text/html';\r
+               }\r
+               if (!$inc_mode) {\r
+                       $inc_mode = 'normal';\r
+               }\r
+               // 2. Update description\r
+               $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);\r
+               $this->action_adminskinedit();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinedittype($msg = '')\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+               if ($msg) {\r
+                       $this->headMess = $msg;\r
+               }\r
+               $type = requestVar('type');\r
+               $type = trim($type);\r
+               $type = strtolower($type);\r
+               if (!isValidShortName($type)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);\r
+               }\r
+               $this->pagehead();\r
+               $this->parse('adminskinedittype');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinupdate()\r
+       {\r
+               global $member;\r
+               $skinid  = intRequestVar('skinid');\r
+               $content = trim(postVar('content'));\r
+               $type    = postVar('type');\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $skin = new skinableSKIN($skinid);\r
+               $skin->update($type, $content);\r
+               $this->action_adminskinedittype(_SKIN_UPDATED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskindelete()\r
+       {\r
+               global $member, $manager, $CONF;\r
+               $member->isAdmin() or $this->disallow();\r
+               $skinid = intRequestVar('skinid');\r
+               $this->pagehead();\r
+               $this->parse('adminskindelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskindeleteconfirm()\r
+       {\r
+               global $member, $CONF, $manager;\r
+               $member->isAdmin() or $this->disallow();\r
+               $skinid = intRequestVar('skinid');\r
+               // don't allow default skin to be deleted\r
+               if ($skinid == $CONF['DefaultAdminSkin']) {\r
+                       $this->error(_ERROR_DEFAULTSKIN);\r
+               }\r
+               // don't allow deletion of default skins for members\r
+//        $skinableAdmin  = $manager->getPlugin('NP_SkinableAdmin');\r
+//        $memberDefaults = $skinableAdmin->getAllMemberOptions('sknadmn_memid');\r
+               $memberDefaults =  $member->getAdminSkin();\r
+               foreach ($memberDefaults as $memID => $adminskin) {\r
+                       if ($skinid == $adminskin) {\r
+                               $mem = MEMBER::createFromID($memID);\r
+                               $this->error(_ERROR_SKINDEFDELETE . $mem->displayname);\r
+                       }\r
+               }\r
+               $manager->notify(\r
+                       'PreDeleteAdminSkin',\r
+                       array(\r
+                               'skinid' => intval($skinid)\r
+                       )\r
+               );\r
+               $query = 'DELETE FROM %s WHERE %s = ' . intval($skinid);\r
+               // 1. delete description\r
+               sql_query(sprintf($query, sql_table('adminskin_desc'), 'sdnumber'));\r
+               // 2. delete parts\r
+               sql_query(sprintf($query, sql_table('adminskin'), 'sdesc'));\r
+               $manager->notify(\r
+                       'PostDeleteAdminSkin',\r
+                       array(\r
+                               'skinid' => intval($skinid)\r
+                       )\r
+               );\r
+               $this->action_adminskinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinremovetype()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+               $skinid   = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+               if (!isValidShortName($skintype)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+               $this->pagehead();\r
+               $this->parse('adminskinremovetype');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinremovetypeconfirm()\r
+       {\r
+               global $member, $CONF, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+               $skinid   = intRequestVar('skinid');\r
+               $skintype = requestVar('type');\r
+               if (!isValidShortName($skintype)) {\r
+                       $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);\r
+               }\r
+               $manager->notify(\r
+                       'PreDeleteAdminSkinPart',\r
+                       array(\r
+                               'skinid'   => $skinid,\r
+                               'skintype' => $skintype\r
+                       )\r
+               );\r
+               // delete part\r
+               $query = 'DELETE FROM %s WHERE sdesc = %d AND stype ="%s"';\r
+               sql_query(sprintf($query, sql_table('adminskin'), intval($skinid), $skintype ));\r
+               $manager->notify(\r
+                       'PostDeleteAdminSkinPart',\r
+                       array(\r
+                               'skinid'   => $skinid,\r
+                               'skintype' => $skintype\r
+                       )\r
+               );\r
+               $this->action_adminskinedit();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinclone()\r
+       {\r
+               global $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               $skinid = intRequestVar('skinid');\r
+               // 1. read skin to clone\r
+               $skin = new skinableSKIN($skinid);\r
+               $name = "clone_" . $skin->getName();\r
+               // if a skin with that name already exists:\r
+               if (skinableSKIN::exists($name)) {\r
+                       $i = 1;\r
+                       while (skinableSKIN::exists($name . $i)) {\r
+                               $i++;\r
+                       }\r
+                       $name .= $i;\r
+               }\r
+               // 2. create skin desc\r
+               $newid = skinableSKIN::createNew(\r
+                       $name,\r
+                       $skin->getDescription(),\r
+                       $skin->getContentType(),\r
+                       $skin->getIncludeMode(),\r
+                       $skin->getIncludePrefix()\r
+               );\r
+               $query = 'SELECT '\r
+                               . '    stype '\r
+                               . 'FROM '\r
+                               .      sql_table('adminskin') . ' '\r
+                               . 'WHERE '\r
+                               . '    sdesc = ' . $skinid;\r
+               $res   = sql_query($query);\r
+               while ($row = sql_fetch_assoc($res)) {\r
+                       $this->adminskinclonetype($skin, $newid, $row['stype']);\r
+               }\r
+               $this->action_adminskinoverview();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function adminskinclonetype($skin, $newid, $type)\r
+       {\r
+               $newid   = intval($newid);\r
+               $content = $skin->getContent($type);\r
+               if ($content) {\r
+                       $query = 'INSERT '\r
+                                       . 'INTO '\r
+                                       .      sql_table('adminskin') . ' '\r
+                                       . '('\r
+                                       . '    sdesc, '\r
+                                       . '    scontent, '\r
+                                       . '    stype'\r
+                                       . ') VALUES ('\r
+                                       .      intval($newid) . ', '\r
+                                       . '"' . sql_real_escape_string($content) . '", '\r
+                                       . '"' . sql_real_escape_string($type) . '" '\r
+                                       . ')';\r
+                       sql_query($query);\r
+               }\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinieoverview()\r
+       {\r
+               global $member, $DIR_LIBS, $manager;\r
+               $member->isAdmin() or $this->disallow();\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinableadmin/skinableSkinie.php');\r
+               $this->pagehead();\r
+               $this->parse('adminskinieoverview');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinieimport()\r
+       {\r
+               global $DIR_LIBS, $DIR_ADMINSKINS, $manager, $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinableadmin/skinableSkinie.php');\r
+               $skinFileRaw= postVar('skinfile');\r
+               $mode       = postVar('mode');\r
+               $importer   = new skinableSKINIMPORT();\r
+               // get full filename\r
+               if ($mode == 'file') {\r
+                       $skinFile = $DIR_ADMINSKINS . $skinFileRaw . '/skinbackup.xml';\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if (!file_exists($skinFile)) {\r
+                               $skinFile = $DIR_ADMINSKINS . $skinFileRaw . '/skindata.xml';\r
+                       }\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+               // read only metadata\r
+               $error = $importer->readFile($skinFile, 1);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $_REQUEST['skininfo']  = $importer->getInfo();\r
+               $_REQUEST['skinnames'] = $importer->getSkinNames();\r
+               $_REQUEST['tpltnames'] = $importer->getTemplateNames();\r
+\r
+               // clashes\r
+               $skinNameClashes         = $importer->checkSkinNameClashes();\r
+               $templateNameClashes     = $importer->checkTemplateNameClashes();\r
+               $hasNameClashes          = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);\r
+               $_REQUEST['skinclashes'] = $skinNameClashes;\r
+               $_REQUEST['tpltclashes'] = $templateNameClashes;\r
+               $_REQUEST['nameclashes'] = $hasNameClashes ? 1 : 0;\r
+\r
+               $this->pagehead();\r
+               $this->parse('adminskinieimport');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskiniedoimport()\r
+       {\r
+               global $DIR_LIBS, $DIR_ADMINSKINS, $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'skinableadmin/skinableSkinie.php');\r
+               $skinFileRaw    = postVar('skinfile');\r
+               $mode           = postVar('mode');\r
+               $allowOverwrite = intPostVar('overwrite');\r
+               // get full filename\r
+               if ($mode == 'file') {\r
+                       $skinFile = $DIR_ADMINSKINS . $skinFileRaw . '/skinbackup.xml';\r
+                       // backwards compatibilty (in v2.0, exports were saved as skindata.xml)\r
+                       if (!file_exists($skinFile)) {\r
+                               $skinFile = $DIR_ADMINSKINS . $skinFileRaw . '/skindata.xml';\r
+                       }\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+               $importer = new skinableSKINIMPORT();\r
+               $error    = $importer->readFile($skinFile);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+               $error = $importer->writeToDatabase($allowOverwrite);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+\r
+               $_REQUEST['skininfo']  = $importer->getInfo();\r
+               $_REQUEST['skinnames'] = $importer->getSkinNames();\r
+               $_REQUEST['tpltnames'] = $importer->getTemplateNames();\r
+\r
+               $this->pagehead();\r
+               $this->parse('adminskiniedoimport');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_adminskinieexport()\r
+       {\r
+               global $member, $DIR_PLUGINS;\r
+               $member->isAdmin() or $this->disallow();\r
+               // load skinie class\r
+//        include_once($DIR_PLUGINS . 'skinableadmin/core/skinableSkinie.php');\r
+               $aSkins     = requestIntArray('skin');\r
+               $aTemplates = requestIntArray('template');\r
+               if (!is_array($aTemplates)) {\r
+                       $aTemplates = array();\r
+               }\r
+               if (!is_array($aSkins)) {\r
+                       $aSkins = array();\r
+               }\r
+               $skinList     = array_keys($aSkins);\r
+               $templateList = array_keys($aTemplates);\r
+\r
+               $info = postVar('info');\r
+\r
+               $exporter = new skinableSKINEXPORT();\r
+               foreach ($skinList as $skinId) {\r
+                       $exporter->addSkin($skinId);\r
+               }\r
+               foreach ($templateList as $templateId) {\r
+                       $exporter->addTemplate($templateId);\r
+               }\r
+               $exporter->setInfo($info);\r
+               $exporter->export();\r
+               \r
+       }\r
+\r
+       /**\r
+        * Admin::action_settingsedit()\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        */\r
+       function action_settingsedit() {\r
+               global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('settingsedit');\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_settingsupdate()\r
+        * Update $CONFIG and redirect\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       function action_settingsupdate() {\r
+               global $member, $CONF;\r
+               \r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               // check if email address for admin is valid\r
+               if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )\r
+               {\r
+                       $this->error(_ERROR_BADMAILADDRESS);\r
+               }\r
+               \r
+               // save settings\r
+               $this->updateConfig('DefaultBlog',        postVar('DefaultBlog'));\r
+               $this->updateConfig('BaseSkin',          postVar('BaseSkin'));\r
+               $this->updateConfig('IndexURL',          postVar('IndexURL'));\r
+               $this->updateConfig('AdminURL',          postVar('AdminURL'));\r
+               $this->updateConfig('PluginURL',                postVar('PluginURL'));\r
+               $this->updateConfig('SkinsURL',          postVar('SkinsURL'));\r
+               $this->updateConfig('ActionURL',                postVar('ActionURL'));\r
+               $this->updateConfig('Locale',              postVar('Locale'));\r
+               $this->updateConfig('AdminEmail',          postVar('AdminEmail'));\r
+               $this->updateConfig('SessionCookie',    postVar('SessionCookie'));\r
+               $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));\r
+               $this->updateConfig('AllowMemberMail',  postVar('AllowMemberMail'));\r
+               $this->updateConfig('NonmemberMail',    postVar('NonmemberMail'));\r
+               $this->updateConfig('ProtectMemNames',  postVar('ProtectMemNames'));\r
+               $this->updateConfig('SiteName',          postVar('SiteName'));\r
+               $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));\r
+               $this->updateConfig('DisableSite',        postVar('DisableSite'));\r
+               $this->updateConfig('DisableSiteURL',   postVar('DisableSiteURL'));\r
+               $this->updateConfig('LastVisit',                postVar('LastVisit'));\r
+               $this->updateConfig('MediaURL',          postVar('MediaURL'));\r
+               $this->updateConfig('AllowedTypes',      postVar('AllowedTypes'));\r
+               $this->updateConfig('AllowUpload',        postVar('AllowUpload'));\r
+               $this->updateConfig('MaxUploadSize',    postVar('MaxUploadSize'));\r
+               $this->updateConfig('MediaPrefix',        postVar('MediaPrefix'));\r
+               $this->updateConfig('AllowLoginEdit',   postVar('AllowLoginEdit'));\r
+               $this->updateConfig('DisableJsTools',   postVar('DisableJsTools'));\r
+               $this->updateConfig('CookieDomain',      postVar('CookieDomain'));\r
+               $this->updateConfig('CookiePath',          postVar('CookiePath'));\r
+               $this->updateConfig('CookieSecure',      postVar('CookieSecure'));\r
+               $this->updateConfig('URLMode',            postVar('URLMode'));\r
+               $this->updateConfig('CookiePrefix',      postVar('CookiePrefix'));\r
+               $this->updateConfig('DebugVars',                        postVar('DebugVars'));\r
+               $this->updateConfig('DefaultListSize',            postVar('DefaultListSize'));\r
+               $this->updateConfig('AdminCSS',           postVar('AdminCSS'));\r
+               \r
+               // load new config and redirect (this way, the new locale will be used is necessary)\r
+               // note that when changing cookie settings, this redirect might cause the user\r
+               // to have to log in again.\r
+               getConfig();\r
+               redirect($CONF['AdminURL'] . '?action=manage');\r
+               exit;\r
+       }\r
+\r
+       /**\r
+        * Admin::action_systemoverview()\r
+        * Output system overview\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       function action_systemoverview()\r
+       {\r
+               $this->pagehead();\r
+               $this->parse('systemoverview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Admin::updateConfig()\r
+        * \r
+        * @param       string  $name   \r
+        * @param       string  $val    \r
+        * @return      integer return the ID in which the latest query posted\r
+        */\r
+       function updateConfig($name, $val)\r
+       {\r
+               $name = sql_real_escape_string($name);\r
+               $val = trim(sql_real_escape_string($val));\r
+               \r
+               $query = "UPDATE %s SET value='%s' WHERE name='%s'";\r
+               $query = sprintf($query, sql_table('config'), $val, $name);\r
+//             sql_query($query) or die("Query error: " . sql_error());\r
+        sql_query($query) or die(_ADMIN_SQLDIE_QUERYERROR . sql_error());\r
+               return sql_insert_id();\r
+       }\r
+       \r
+       /**\r
+        * Error message\r
+        * @param string $msg message that will be shown\r
+        */\r
+       function error($msg)\r
+       {\r
+               $this->pagehead();\r
+               $this->parse('adminerrorpage');\r
+               $this->pagefoot();\r
+               exit;\r
+       }\r
+       \r
+       /**\r
+        * Admin::disallow()\r
+        * add error log and show error page \r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       function disallow()\r
+       {\r
+               ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));\r
+               $this->error(_ERROR_DISALLOWED);\r
+       }\r
+       \r
+       /**\r
+        * Admin::pagehead()\r
+        * Output admin page head\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       function pagehead($extrahead = '')\r
+       {\r
+               if ( $this->existsSkinContents('pagehead') )\r
+               {\r
+                       if ( isset($extrahead) && !empty($extrahead) )\r
+                       {\r
+                       $this->extrahead = $extrahead;\r
+                       }\r
+                       $this->parse('pagehead');\r
+               }\r
+               else\r
+               {\r
+                       global $member, $nucleus, $CONF, $manager;\r
+                       \r
+                       $manager->notify(\r
+                               'AdminPrePageHead',\r
+                               array(\r
+                                       'extrahead' => &$extrahead,\r
+                                       'action'    => $this->action\r
+                               )\r
+                       );\r
+                       \r
+                       $baseUrl = Entity::hsc($CONF['AdminURL']);\r
+                       if ( !array_key_exists('AdminCSS',$CONF) )\r
+                       {\r
+                               sql_query("INSERT INTO " . sql_table('config') . " VALUES ('AdminCSS', 'original')");\r
+                               $CONF['AdminCSS'] = 'original';\r
+                       }\r
+                       \r
+                       /* HTTP 1.1 application for no caching */\r
+                       header("Cache-Control: no-cache, must-revalidate");\r
+                       header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");\r
+                       \r
+                       $root_element = 'html';\r
+                       $charset = i18n::get_current_charset();\r
+                       $locale = preg_replace('#_#', '-', i18n::get_current_locale());\r
+       \r
+                       echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";\r
+                       echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";\r
+                       echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";\r
+                       echo "<head>\n";\r
+                       echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";\r
+                       echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";\r
+                       echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";\r
+                       echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";\r
+                       echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";\r
+                       echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";\r
+                       echo "{$extrahead}\n";\r
+                       echo "</head>\n\n";\r
+                       echo "<body>\n";\r
+                       echo "<div id=\"adminwrapper\">\n";\r
+                       echo "<div class=\"header\">\n";\r
+                       echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";\r
+                       echo "</div>\n";\r
+                       echo "<div id=\"container\">\n";\r
+                       echo "<div id=\"content\">\n";\r
+                       echo "<div class=\"loginname\">\n";\r
+                       if ( $member->isLoggedIn() )\r
+                       {\r
+                               echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";\r
+                               echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";\r
+                       }\r
+                       else\r
+                       {\r
+                               echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";\r
+                       }\r
+                       echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";\r
+                       echo '(';\r
+                       \r
+                       if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )\r
+                       {\r
+                               $codenamestring = ' &quot;' . $nucleus['codename'].'&quot;';\r
+                       }\r
+                       else\r
+                       {\r
+                               $codenamestring = '';\r
+                       }\r
+                       \r
+                       if ( $member->isLoggedIn() && $member->isAdmin() )\r
+                       {\r
+                               $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());\r
+                               echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';\r
+                               \r
+                               $newestVersion = getLatestVersion();\r
+                               $newestCompare = str_replace('/','.',$newestVersion);\r
+                               $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);\r
+                               if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )\r
+                               {\r
+                                       echo "<br />\n";\r
+                                       echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';\r
+                                       echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;\r
+                                       echo "</a>";\r
+                               }\r
+                       }\r
+                       else\r
+                       {\r
+                               echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;\r
+                       }\r
+                       echo ')';\r
+                       echo '</div>';\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Admin::pagefoot()\r
+        * Output admin page foot include quickmenu\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       function pagefoot()\r
+       {\r
+               if ($this->existsSkinContents('pagefoot')) {\r
+                       $this->parse('pagefoot');\r
+                       exit;\r
+               }\r
+               else\r
+               {\r
+                       global $action, $member, $manager;\r
+                       \r
+                       $manager->notify(\r
+                               'AdminPrePageFoot',\r
+                               array(\r
+                                       'action' => $this->action\r
+                               )\r
+                       );\r
+                       \r
+                       if ( $member->isLoggedIn() && ($action != 'showlogin') )\r
+                       {\r
+                               echo '<h2>' . _LOGOUT . "</h2>\n";\r
+                               echo "<ul>\n";\r
+                               echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";\r
+                               echo '<li><a href="index.php?action=logout">' .  _LOGOUT . "</a></li>\n";\r
+                               echo "</ul>\n";\r
+                       }\r
+                       \r
+                       echo "<div class=\"foot\">\n";\r
+                       echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> &copy; 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;\r
+                       echo '-';\r
+                       echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";\r
+                       echo "</div>\n";\r
+                       \r
+                       echo "<!-- content -->\n";\r
+                       echo "<div id=\"quickmenu\">\n";\r
+                       \r
+                       if ( ($action != 'showlogin') && ($member->isLoggedIn()) )\r
+                       {\r
+                               echo "<ul>\n";\r
+                               echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";\r
+                               echo "</ul>\n";\r
+                               \r
+                               echo '<h2>' . _QMENU_ADD . "</h2>\n";\r
+                               echo "<form method=\"get\" action=\"index.php\">\n";\r
+                               echo "<p>\n";\r
+                               echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";\r
+                               \r
+                               $showAll = requestVar('showall');\r
+                               \r
+                               if ( ($member->isAdmin()) && ($showAll == 'yes') )\r
+                               {\r
+                                       // Super-Admins have access to all blogs! (no add item support though)\r
+                                       $query =  'SELECT bnumber as value, bname as text'\r
+                                                       . ' FROM ' . sql_table('blog')\r
+                                                       . ' ORDER BY bname';\r
+                               }\r
+                               else\r
+                               {\r
+                                       $query =  'SELECT bnumber as value, bname as text'\r
+                                                       . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')\r
+                                                       . ' WHERE tblog=bnumber and tmember=' . $member->getID()\r
+                                                       . ' ORDER BY bname';\r
+                               }\r
+                               $template['name'] = 'blogid';\r
+                               $template['tabindex'] = 15000;\r
+                               $template['extra'] = _QMENU_ADD_SELECT;\r
+                               $template['selected'] = -1;\r
+                               $template['shorten'] = 10;\r
+                               $template['shortenel'] = '';\r
+                               $template['javascript'] = 'onchange="return form.submit()"';\r
+                               showlist($query,'select',$template);\r
+                               \r
+                               echo "</p>\n";\r
+                               echo "</form>\n";\r
+                               \r
+                               echo "<h2>{$member->getDisplayName()}</h2>\n";\r
+                               echo "<ul>\n";\r
+                               echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";\r
+                               echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";\r
+                               echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";\r
+                               echo "</ul>\n";\r
+                               \r
+                               // ---- general settings ----\r
+                               if ( $member->isAdmin() )\r
+                               {\r
+                                       echo '<h2>' . _QMENU_MANAGE . "</h2>\n";\r
+                                       echo "<ul>\n";\r
+                                       echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";\r
+                                       echo "</ul>\n";\r
+                                       \r
+                                       echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";\r
+                                       echo "<ul>\n";\r
+                                       echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";\r
+                                       echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";\r
+                                       echo "</ul>\n";\r
+                               }\r
+                               \r
+                               $aPluginExtras = array();\r
+                               $manager->notify(\r
+                                       'QuickMenu',\r
+                                       array(\r
+                                               'options' => &$aPluginExtras));\r
+                               \r
+                               if ( count($aPluginExtras) > 0 )\r
+                               {\r
+                                       echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";\r
+                                       echo "<ul>\n";\r
+                                       foreach ( $aPluginExtras as $aInfo )\r
+                                       {\r
+                                               echo '<li><a href="' . Entity::hsc($aInfo['url']) . '" title="' . Entity::hsc($aInfo['tooltip']) . '">' . Entity::hsc($aInfo['title']) . "</a></li>\n";\r
+                                       }\r
+                                       echo "</ul>\n";\r
+                               }\r
+                       }\r
+                       else if ( ($action == 'activate') || ($action == 'activatesetpwd') )\r
+                       {\r
+                       \r
+                               echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;\r
+                       }\r
+                       else\r
+                       {\r
+                               // introduction text on login screen\r
+                               echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;\r
+                       }\r
+                       \r
+                       echo "<!-- quickmenu -->\n";\r
+                       echo "</div>\n";\r
+                       \r
+                       echo "<!-- content -->\n";\r
+                       echo "</div>\n";\r
+                       \r
+                       echo "<!-- container -->\n";\r
+                       echo "</div>\n";\r
+                       \r
+                       echo "<!-- adminwrapper -->\n";\r
+                       echo "</div>\n";\r
+                       \r
+                       echo "</body>\n";\r
+                       echo "</html>\n";\r
+               }\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_regfile()\r
+       {\r
+               global $member, $CONF;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               // header-code stolen from phpMyAdmin\r
+               // REGEDIT and bookmarklet code stolen from GreyMatter\r
+\r
+               $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));\r
+\r
+\r
+               header('Content-Type: application/octetstream');\r
+               header('Content-Disposition: filename="nucleus.reg"');\r
+               header('Pragma: no-cache');\r
+               header('Expires: 0');\r
+\r
+               echo "REGEDIT4\n";\r
+               echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";\r
+               echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";\r
+               echo '"contexts"=hex:31';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_bookmarklet()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->teamRights($blogid) or $this->disallow();\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $this->pagehead();\r
+               $this->parse('bookmarklet');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_actionlog()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('actionlog');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlist() {\r
+               global $member, $manager;\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blogid = intRequestVar('blogid');\r
+\r
+               $this->pagehead();\r
+               $this->parse('banlist');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistdelete() {\r
+               global $member, $manager;\r
+\r
+               $blogid = intRequestVar('blogid');\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('banlistdelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistdeleteconfirm()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $blogid = intPostVar('blogid');\r
+               $allblogs = postVar('allblogs');\r
+               $iprange = postVar('iprange');\r
+\r
+               $deleted = array();\r
+\r
+               if ( !$allblogs )\r
+               {\r
+                       if ( Ban::removeBan($blogid, $iprange) )\r
+                       {\r
+                               array_push($deleted, $blogid);\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       // get blogs fot which member has admin rights\r
+                       $adminblogs = $member->getAdminBlogs();\r
+                       foreach ($adminblogs as $blogje)\r
+                       {\r
+                               if ( Ban::removeBan($blogje, $iprange) )\r
+                               {\r
+                                       array_push($deleted, $blogje);\r
+                               }\r
+                       }\r
+               }\r
+\r
+               if ( sizeof($deleted) == 0 )\r
+               {\r
+                       $this->error(_ERROR_DELETEBAN);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('banlistdeleteconfirm');\r
+               $this->pagefoot();\r
+\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistnewfromitem()\r
+       {\r
+               $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistnew($blogid = '')\r
+       {\r
+               global $member, $manager;\r
+\r
+               if ( $blogid == '' )\r
+               {\r
+                       $blogid = intRequestVar('blogid');\r
+               }\r
+\r
+               $ip = requestVar('ip');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               $_REQUEST['blogid'] = $blogid;          \r
+\r
+               $this->pagehead();\r
+               $this->parse('banlistnew');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_banlistadd() {\r
+               global $member;\r
+\r
+               $blogid   = intPostVar('blogid');\r
+               $allblogs = postVar('allblogs');\r
+               $iprange  = postVar('iprange');\r
+               if ( $iprange == "custom" )\r
+               {\r
+                       $iprange = postVar('customiprange');\r
+               }\r
+               $reason   = postVar('reason');\r
+\r
+               $member->blogAdminRights($blogid) or $this->disallow();\r
+\r
+               // TODO: check IP range validity\r
+\r
+               if ( !$allblogs )\r
+               {\r
+                       if ( !Ban::addBan($blogid, $iprange, $reason) )\r
+                       {\r
+                               $this->error(_ERROR_ADDBAN);\r
+                       }\r
+               }\r
+               else\r
+               {\r
+                       // get blogs fot which member has admin rights\r
+                       $adminblogs = $member->getAdminBlogs();\r
+                       $failed = 0;\r
+                       foreach ($adminblogs as $blogje)\r
+                       {\r
+                               if ( !Ban::addBan($blogje, $iprange, $reason) )\r
+                               {\r
+                                       $failed = 1;\r
+                               }\r
+                       }\r
+                       if ( $failed )\r
+                       {\r
+                               $this->error(_ERROR_ADDBAN);\r
+                       }\r
+               }\r
+               $this->action_banlist();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_clearactionlog()\r
+       {\r
+               global $member;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               ActionLog::clear();\r
+\r
+               $this->action_manage(_MSG_ACTIONLOGCLEARED);\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_backupoverview()\r
+       {\r
+               global $member, $manager;\r
+\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $this->pagehead();\r
+               $this->parse('backupoverview');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Admin::action_backupcreate()\r
+        * create file for backup\r
+        * \r
+        * @param               void\r
+        * @return      void\r
+        * \r
+        */\r
+       function action_backupcreate()\r
+       {\r
+               global $member, $DIR_LIBS;\r
+               \r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               // use compression ?\r
+               $useGzip = (integer) postVar('gzip');\r
+               \r
+               include($DIR_LIBS . 'backup.php');\r
+               \r
+               // try to extend time limit\r
+               // (creating/restoring dumps might take a while)\r
+               @set_time_limit(1200);\r
+               \r
+               Backup::do_backup($useGzip);\r
+               exit;\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_backuprestore()\r
+        * restoring from uploaded file\r
+        * \r
+        * @param               void\r
+        * @return      void\r
+        */\r
+       function action_backuprestore()\r
+       {\r
+               global $member, $DIR_LIBS;\r
+               \r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               if ( intPostVar('letsgo') != 1 )\r
+               {\r
+                       $this->error(_ERROR_BACKUP_NOTSURE);\r
+               }\r
+               \r
+               include($DIR_LIBS . 'backup.php');\r
+               \r
+               // try to extend time limit\r
+               // (creating/restoring dumps might take a while)\r
+               @set_time_limit(1200);\r
+               \r
+               $message = Backup::do_restore();\r
+               if ( $message != '' )\r
+               {\r
+                       $this->error($message);\r
+               }\r
+               $this->pagehead();\r
+               $this->parse('backuprestore');\r
+               $this->pagefoot();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_pluginlist()\r
+        * output the list of installed plugins\r
+        * \r
+        * @param       void\r
+        * @return      void\r
+        * \r
+        */\r
+       function action_pluginlist()\r
+       {\r
+               global $DIR_PLUGINS, $member, $manager;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               $this->pagehead();\r
+               $this->parse('pluginlist');\r
+               $this->pagefoot();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginhelp()\r
+       {\r
+               global $member, $manager, $DIR_PLUGINS, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+\r
+               if ( !$manager->pidInstalled($plugid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('pluginhelp');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * Admin::action_pluginadd()\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        * \r
+        */\r
+       function action_pluginadd()\r
+       {\r
+               global $member, $manager, $DIR_PLUGINS;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               $name = postVar('filename');\r
+               \r
+               if ( $manager->pluginInstalled($name) )\r
+               {\r
+                       $this->error(_ERROR_DUPPLUGIN);\r
+               }\r
+               \r
+               if ( !checkPlugin($name) )\r
+               {\r
+                       $this->error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');\r
+               }\r
+               \r
+               // get number of currently installed plugins\r
+               $res = sql_query('SELECT * FROM ' . sql_table('plugin'));\r
+               $numCurrent = sql_num_rows($res);\r
+               \r
+               // plugin will be added as last one in the list\r
+               $newOrder = $numCurrent + 1;\r
+               \r
+               $manager->notify(\r
+                       'PreAddPlugin',\r
+                       array(\r
+                               'file' => &$name\r
+                       )\r
+               );\r
+               \r
+               // do this before calling getPlugin (in case the plugin id is used there)\r
+               $query = 'INSERT INTO '\r
+                          .      sql_table('plugin')\r
+                          . ' ('\r
+                          . '    porder,'\r
+                          . '    pfile'\r
+                          . ') VALUES ('\r
+                          .      $newOrder . ','\r
+                          . '"' . sql_real_escape_string($name) . '"'\r
+                          . ')';\r
+               sql_query($query);\r
+               $iPid = sql_insert_id();\r
+               \r
+               $manager->clearCachedInfo('installedPlugins');\r
+               \r
+               // Load the plugin for condition checking and instalation\r
+               $plugin =& $manager->getPlugin($name);\r
+               \r
+               // check if it got loaded (could have failed)\r
+               if ( !$plugin )\r
+               {\r
+                       sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));\r
+                       $manager->clearCachedInfo('installedPlugins');\r
+                       $this->error(_ERROR_PLUGIN_LOAD);\r
+               }\r
+               \r
+               // check if plugin needs a newer Nucleus version\r
+               if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )\r
+               {\r
+                       // uninstall plugin again...\r
+                       $this->deleteOnePlugin($plugin->getID());\r
+                       \r
+                       // ...and show error\r
+                       $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));\r
+               }\r
+               \r
+               // check if plugin needs a newer Nucleus version\r
+               if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )\r
+               {\r
+                       // uninstall plugin again...\r
+                       $this->deleteOnePlugin($plugin->getID());\r
+                       \r
+                       // ...and show error\r
+                       $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );\r
+               }\r
+               \r
+               $pluginList = $plugin->getPluginDep();\r
+               foreach ( $pluginList as $pluginName )\r
+               {\r
+                       $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');\r
+                       if (sql_num_rows($res) == 0)\r
+                       {\r
+                               // uninstall plugin again...\r
+                               $this->deleteOnePlugin($plugin->getID());\r
+                               $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));\r
+                       }\r
+               }\r
+               \r
+               // call the install method of the plugin\r
+               $plugin->install();\r
+               \r
+               $manager->notify(\r
+                       'PostAddPlugin',\r
+                       array(\r
+                               'plugin' => &$plugin\r
+                       )\r
+               );\r
+               \r
+               // update all events\r
+               $this->action_pluginupdate();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * ADMIN:action_pluginupdate():\r
+        * \r
+        * @param       Void\r
+        * @return      Void\r
+        * \r
+        */\r
+       function action_pluginupdate()\r
+       {\r
+               global $member, $manager, $CONF;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               // delete everything from plugin_events\r
+               sql_query('DELETE FROM '.sql_table('plugin_event'));\r
+               \r
+               // loop over all installed plugins\r
+               $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));\r
+               while ( $o = sql_fetch_object($res) )\r
+               {\r
+                       $pid  =  $o->pid;\r
+                       $plug =& $manager->getPlugin($o->pfile);\r
+                       if ( $plug )\r
+                       {\r
+                               $eventList = $plug->getEventList();\r
+                               foreach ( $eventList as $eventName )\r
+                               {\r
+                                       $query = "INSERT INTO %s (pid, event) VALUES (%d, '%s')";\r
+                                       $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, sql_real_escape_string($eventName));\r
+                                       sql_query($query);\r
+                               }\r
+                       }\r
+               }\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindelete()\r
+       {\r
+               global $member, $manager;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intGetVar('plugid');\r
+\r
+               if ( !$manager->pidInstalled($pid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+\r
+               $this->pagehead();\r
+               $this->parse('plugindelete');\r
+               $this->pagefoot();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindeleteconfirm()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $pid = intPostVar('plugid');\r
+\r
+               $error = $this->deleteOnePlugin($pid, 1);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+//             $this->action_pluginlist();\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function deleteOnePlugin($pid, $callUninstall = 0)\r
+       {\r
+               global $manager;\r
+\r
+               $pid = intval($pid);\r
+\r
+               if ( !$manager->pidInstalled($pid) )\r
+               {\r
+                       return _ERROR_NOSUCHPLUGIN;\r
+               }\r
+\r
+               $name = quickQuery('SELECT pfile as result FROM ' . sql_table('plugin') . ' WHERE pid=' . $pid);\r
+\r
+/*             // call the unInstall method of the plugin\r
+               if ($callUninstall) {\r
+                       $plugin =& $manager->getPlugin($name);\r
+                       if ($plugin) $plugin->unInstall();\r
+               }*/\r
+\r
+               // check dependency before delete\r
+               $res = sql_query('SELECT pfile FROM ' . sql_table('plugin'));\r
+               while ($o = sql_fetch_object($res))\r
+               {\r
+                       $plug =& $manager->getPlugin($o->pfile);\r
+                       if ($plug)\r
+                       {\r
+                               $depList = $plug->getPluginDep();\r
+                               foreach ($depList as $depName)\r
+                               {\r
+                                       if ($name == $depName)\r
+                                       {\r
+                                               return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);\r
+                                       }\r
+                               }\r
+                       }\r
+               }\r
+\r
+               $manager->notify(\r
+                       'PreDeletePlugin',\r
+                       array(\r
+                               'plugid' => $pid\r
+                       )\r
+               );\r
+\r
+               // call the unInstall method of the plugin\r
+               if ( $callUninstall )\r
+               {\r
+                       $plugin =& $manager->getPlugin($name);\r
+                       if ( $plugin )\r
+                       {\r
+                               $plugin->unInstall();\r
+                       }\r
+               }\r
+\r
+               // delete all subscriptions\r
+               sql_query('DELETE FROM ' . sql_table('plugin_event') . ' WHERE pid=' . $pid);\r
+\r
+               // delete all options\r
+               // get OIDs from plugin_option_desc\r
+               $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);\r
+               $aOIDs = array();\r
+               while ($o = sql_fetch_object($res))\r
+               {\r
+                       array_push($aOIDs, $o->oid);\r
+               }\r
+\r
+               // delete from plugin_option and plugin_option_desc\r
+               sql_query('DELETE FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);\r
+               if (count($aOIDs) > 0)\r
+               {\r
+                       sql_query('DELETE FROM ' . sql_table('plugin_option') . ' WHERE oid in (' . implode(',',$aOIDs) . ')');\r
+               }\r
+\r
+               // update order numbers\r
+               $res = sql_query('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $pid);\r
+               $o = sql_fetch_object($res);\r
+               sql_query('UPDATE ' . sql_table('plugin') . ' SET porder=(porder - 1) WHERE porder>' . $o->porder);\r
+\r
+               // delete row\r
+               sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid=' . $pid);\r
+\r
+               $manager->clearCachedInfo('installedPlugins');\r
+               $manager->notify(\r
+                       'PostDeletePlugin',\r
+                       array(\r
+                               'plugid' => $pid\r
+                       )\r
+               );\r
+\r
+               return '';\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_pluginup()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+\r
+               if ( !$manager->pidInstalled($plugid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+\r
+               // 1. get old order number\r
+               $res = sql_query('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $plugid);\r
+               $o = sql_fetch_object($res);\r
+               $oldOrder = $o->porder;\r
+\r
+               // 2. calculate new order number\r
+               $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;\r
+\r
+               // 3. update plug numbers\r
+               sql_query('UPDATE ' . sql_table('plugin') . ' SET porder=' . $oldOrder . ' WHERE porder=' . $newOrder);\r
+               sql_query('UPDATE ' . sql_table('plugin') . ' SET porder=' . $newOrder . ' WHERE pid=' . $plugid);\r
+\r
+               //$this->action_pluginlist();\r
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+       }\r
+\r
+       /**\r
+        * @todo document this\r
+        */\r
+       function action_plugindown()\r
+       {\r
+               global $member, $manager, $CONF;\r
+\r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+\r
+               $plugid = intGetVar('plugid');\r
+               if ( !$manager->pidInstalled($plugid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+\r
+               // 1. get old order number\r
+               $res = sql_query('SELECT porder FROM ' . sql_table('plugin') . ' WHERE pid=' . $plugid);\r
+               $o   = sql_fetch_object($res);\r
+               $oldOrder = $o->porder;\r
+\r
+               $res = sql_query('SELECT * FROM ' . sql_table('plugin'));\r
+               $maxOrder = sql_num_rows($res);\r
+\r
+               // 2. calculate new order number\r
+               $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;\r
+\r
+               // 3. update plug numbers\r
+               sql_query('UPDATE ' . sql_table('plugin') . ' SET porder=' . $oldOrder . ' WHERE porder=' . $newOrder);\r
+               sql_query('UPDATE ' . sql_table('plugin') . ' SET porder=' . $newOrder . ' WHERE pid=' . $plugid);\r
+\r
+               //$this->action_pluginlist();\r
+               // To avoid showing ticket in the URL, redirect to pluginlist, instead.\r
+               redirect($CONF['AdminURL'] . '?action=pluginlist');\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_pluginoptions()\r
+        * \r
+        * Output Plugin option page\r
+        * \r
+        * @access      public\r
+        * @param       string $message message when fallbacked\r
+        * @return      void\r
+        * \r
+        */\r
+       public function action_pluginoptions($message = '')\r
+       {\r
+               global $member, $manager;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+//             $pid = (integer) requestVar('plugid');\r
+               $pid = intRequestVar('plugid');\r
+               if ( !$manager->pidInstalled($pid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+\r
+               if ( isset($message) )\r
+               {\r
+                       $this->headMess = $message;\r
+               }\r
+               $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";\r
+               $this->pagehead($extrahead);\r
+               $this->parse('pluginoptions');\r
+               $this->pagefoot();\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Admin::action_pluginoptionsupdate()\r
+        * \r
+        * Update plugin options and fallback to plugin option page\r
+        * \r
+        * @access      public\r
+        * @param       void\r
+        * @return      void\r
+        */\r
+       public function action_pluginoptionsupdate()\r
+       {\r
+               global $member, $manager;\r
+               \r
+               // check if allowed\r
+               $member->isAdmin() or $this->disallow();\r
+               \r
+               $pid = intRequestVar('plugid');\r
+//             $pid = (integer) requestVar('plugid');\r
+               if ( !$manager->pidInstalled($pid) )\r
+               {\r
+                       $this->error(_ERROR_NOSUCHPLUGIN);\r
+               }\r
+               \r
+               $aOptions = requestArray('plugoption');\r
+               NucleusPlugin::apply_plugin_options($aOptions);\r
+\r
+               $manager->notify(\r
+                       'PostPluginOptionsUpdate',\r
+                       array(\r
+                               'context' => 'global',\r
+                               'plugid' => $pid\r
+                       )\r
+               );\r
+               \r
+               $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * Admin::_insertPluginOptions()\r
+        * \r
+        * Output plugin option field\r
+        * \r
+        * @access      public\r
+        * @param string        $context        plugin option context\r
+        * @param integer       $contextid      plugin option context id\r
+        * @return      void\r
+        */\r
+       public function _insertPluginOptions($context, $contextid = 0)\r
+       {\r
+               // get all current values for this contextid\r
+               // (note: this might contain doubles for overlapping contextids)\r
+               $aIdToValue = array();\r
+               $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));\r
+               while ( $object = sql_fetch_object($res) )\r
+               {\r
+                       $aIdToValue[$object->oid] = $object->ovalue;\r
+               }\r
+               \r
+               // get list of oids per pid\r
+               $query = 'SELECT '\r
+                          . '    * '\r
+                          . 'FROM '\r
+                          .      sql_table('plugin_option_desc') . ', '\r
+                          .      sql_table('plugin') . ' '\r
+                          . 'WHERE '\r
+                          . '    opid     = pid '\r
+                          . 'and ocontext = "' . sql_real_escape_string($context) . '" '\r
+                          . 'ORDER BY '\r
+                          . '    porder, oid ASC';\r
+               $res   = sql_query($query);\r
+               $aOptions = array();\r
+               while ( $object = sql_fetch_object($res) )\r
+               {\r
+                       if (in_array($object->oid, array_keys($aIdToValue)))\r
+                       {\r
+                               $value = $aIdToValue[$object->oid];\r
+                       }\r
+                       else\r
+                       {\r
+                               $value = $object->odef;\r
+                       }\r
+                       \r
+                       array_push(\r
+                               $aOptions,\r
+                               array(\r
+                                       'pid'         => $object->pid,\r
+                                       'pfile'       => $object->pfile,\r
+                                       'oid'         => $object->oid,\r
+                                       'value'       => $value,\r
+                                       'name'        => $object->oname,\r
+                                       'description' => $object->odesc,\r
+                                       'type'        => $object->otype,\r
+                                       'typeinfo'    => $object->oextra,\r
+                                       'contextid'   => $contextid,\r
+                                       'extra'       => ''\r
+                               )\r
+                       );\r
+               }\r
+               \r
+               global $manager;\r
+               $manager->notify(\r
+                       'PrePluginOptionsEdit',\r
+                       array(\r
+                               'context'   =>  $context,\r
+                               'contextid' =>  $contextid,\r
+                               'options'   =>& $aOptions\r
+                       )\r
+               );\r
+               \r
+               $this->aOptions = $aOptions;\r
+               $this->parse('insertpluginoptions');\r
+               return;\r
+       }\r
+       \r
+       /**\r
+        * TODO: this document\r
+        */\r
+       function action_parseSpecialskin()\r
+       {\r
+               $this->pagehead();\r
+               $this->parse($this->action);\r
+               $this->pagefoot();\r
+       }\r
+       \r
+       function parse($type)\r
+       {\r
+               global $manager, $CONF;\r
+               if ( $type == 'pagehead' )\r
+               {\r
+                       $manager->notify(\r
+                                       'InitAdminSkinParse',\r
+                                       array(\r
+                                                       'skin' => &$this->adminSkin,\r
+                                                       'type' => $type\r
+                                       )\r
+                       );\r
+                       // set output type\r
+                       sendContentType($this->adminSkin->getContentType(), 'skin', i18n::get_current_charset());\r
+               }\r
+               // set skin name as global var (so plugins can access it)\r
+               global $currentSkinName;\r
+               $currentSkinName = $this->adminSkin->getName();\r
+       \r
+               $contents = $this->adminSkin->getContent($type);\r
+       \r
+               if ( !$contents )\r
+               {\r
+                       // use base skin if this skin does not have contents\r
+                       $defskin  = new skinableSKIN($CONF['DefaultAdminSkin']);\r
+                       $contents = $defskin->getContent($type);\r
+                       if ( !$contents )\r
+                       {\r
+                               echo _ERROR_SKIN;\r
+                               return;\r
+                       }\r
+               }\r
+       \r
+               $actions = $this->adminSkin->getAllowedActionsForType($type);\r
+       \r
+               if ( $type == 'pagehead' )\r
+               {\r
+                       $manager->notify(\r
+                                       'PreAdminSkinParse',\r
+                                       array(\r
+                                                       'skin'     => &$this->adminSkin,\r
+                                                       'type'     => $type,\r
+                                                       'contents' => &$contents\r
+                                       )\r
+                       );\r
+               }\r
+       \r
+               // set IncludeMode properties of parser\r
+               PARSER::setProperty('IncludeMode', $this->adminSkin->getIncludeMode());\r
+               PARSER::setProperty('IncludePrefix', $this->adminSkin->getIncludePrefix());\r
+       \r
+               if ( $type == 'createitem' || $type == 'itemedit' )\r
+               {\r
+                       $handler = new Factory(intRequestVar('blogid'), $type, $this->adminSkin, $this);\r
+                       $actions = array_merge($actions, $handler->actions);\r
+               } else {\r
+                       $handler = new AdminActions($type, $this->adminSkin, $this);\r
+                       $actions = array_merge($actions, skinableACTIONS::getDefinedActions());\r
+               }\r
+               $parser = new Parser($actions, $handler);\r
+               $handler->setParser($parser);\r
+               $handler->setSkin($this->adminSkin);\r
+               $parser->parse($contents);\r
+       \r
+               if ( $type == 'pagefoot' )\r
+               {\r
+                       $manager->notify(\r
+                               'PostAdminSkinParse',\r
+                               array(\r
+                                       'skin' => &$this->adminSkin,\r
+                                       'type' => $type,\r
+                               )\r
+                       );\r
+               }\r
+       }\r
+       \r
+       function getAdminskinIDFromName($skinname)\r
+       {\r
+               $query     = 'SELECT `sdnumber` as result FROM `%s` WHERE `sdname` = "%s"';\r
+               $admnSknID = quickQuery(sprintf($query, sql_table('nucleus_adminskin_desc'), mysql_real_escape_string($skinname)));\r
+               return intval($adminSkinID);\r
+       }\r
+       \r
+       function getAdminskinNameFromID($skinid)\r
+       {\r
+               $query     = 'SELECT `sdname` as result FROM `%s` WHERE `sdnumber` = "%d"';\r
+               $admnSknID = quickQuery(sprintf($query, sql_table('nucleus_adminskin_desc'), intval($skinid)));\r
+               return intval($adminSkinID);\r
+       }\r
+       \r
+       function action_importAdmin()\r
+       {\r
+               global $DIR_ADMINSKINS, $action;\r
+               if ( $action == 'adminskinieimport' )\r
+               {\r
+                       $this->_doAdminskinimport();\r
+               }\r
+               $skn = array();\r
+               if ( $action == 'showlogin' )\r
+               {\r
+                       $skinName = 'showlogin';\r
+                       $actnName = 'showlogin';\r
+               }\r
+               else\r
+               {\r
+                       $skinName = 'defaultimporter';\r
+                       $actnName = 'importAdmin';\r
+               }\r
+               $contents             = file_get_contents($DIR_ADMINSKINS . $skinName . '.skn');\r
+               $skn['id']            = 0;\r
+               $skn['description']   = $skinName;\r
+               $skn['contentType']   = 'importAdmin';\r
+               $skn['includeMode']   = 'normal';\r
+               $skn['includePrefix'] = '';\r
+               $skn['name']          = 'defaultinporter';\r
+               $this->adminSkin      = (object)$skn;\r
+               $handler              = new AdminActions($actnName, $this->adminSkin, $this);\r
+               $actions              = Skin::getAllowedActionsForType($actnName);\r
+               $parser = new PARSER($actions, $handler);\r
+               $handler->setParser($parser);\r
+               $handler->setSkin($this->adminSkin);\r
+               $parser->parse($contents);\r
+       }\r
+       \r
+       /**\r
+        * @todo document this\r
+        */\r
+       private function _doAdminskinimport()\r
+       {\r
+               global $DIR_LIBS, $DIR_ADMINSKINS, $CONF, $member;\r
+               $member->isAdmin() or $this->disallow();\r
+               // load skinie class\r
+               include_once($DIR_LIBS . 'Skinie.php');\r
+               $skinFileRaw    = postVar('skinfile');\r
+               $mode           = postVar('mode');\r
+               $allowOverwrite = intPostVar('overwrite');\r
+               // get full filename\r
+               if ($mode == 'file') {\r
+                       $skinFile = $DIR_ADMINSKINS . $skinFileRaw . '/skinbackup.xml';\r
+               } else {\r
+                       $skinFile = $skinFileRaw;\r
+               }\r
+               $importer = new skinableSKINIMPORT();\r
+               $error    = $importer->readFile($skinFile);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+               $error = $importer->writeToDatabase($allowOverwrite);\r
+               if ($error) {\r
+                       $this->error($error);\r
+               }\r
+       \r
+               $_REQUEST['skininfo']  = $importer->getInfo();\r
+               $_REQUEST['skinnames'] = $importer->getSkinNames();\r
+               $_REQUEST['tpltnames'] = $importer->getTemplateNames();\r
+       \r
+               header('Location: ' . $CONF['AdminURL']);\r
+               exit;\r
+       \r
+       }\r
+\r
+       /**\r
+        * Returns a link to a weblog\r
+        * @param object BLOG\r
+        */\r
+       function bloglink(&$blog) {\r
+               return '<a href="'.Entity::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. Entity::hsc( $blog->getName() ) .'</a>';\r
+       }\r
+}\r
diff --git a/nucleus/locales/adminskinTypes.php b/nucleus/locales/adminskinTypes.php
new file mode 100644 (file)
index 0000000..0a75979
--- /dev/null
@@ -0,0 +1,177 @@
+<?php\r
+\r
+// ADMIN-skin skin types\r
+define('_ADM_SKPRT_ACTIONLOG',                              '[' . _ACTIONLOG_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ACTIVATE',                               '[' . _QMENU_ACTIVATE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ACTIVATESETPWD',                         '[' . _MEMBERS_SETPWD . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADDNEWLOG',                              '[' . _BLOGCREATED_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINERRORPAGE',                         _OVERVIEW_MANAGE . ':[' . _ERROR . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINOVERVIEW',                      _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _QMENU_LAYOUT_SKINS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINEDIT',                          _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKIN_EDITONE_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BACKUPOVERVIEW',                         '[' . _QMENU_MANAGE_BACKUPS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BACKUPRESTORE',                          '[' . _RESTORE_COMPLETE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BANLIST',                                '[' . _BAN_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BANLISTDELETE',                          '[' . _BAN_REMOVE_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BANLISTDELETECONFIRM',                   '[' . _BAN_REMOVED_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BANLISTNEW',                             '[' . _BAN_NEW_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHCATEGORY',                          '[' . _BATCH_CATEGORIES . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHCOMMENT',                           '[' . _BATCH_COMMENTS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHDELETE',                            '[' . _BATCH_DELETE_CONFIRM . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHITEM',                              '[' . _BATCH_ITEMS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHMEMBER',                            '[' . _BATCH_MEMBERS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHMOVE',                              '[' . _SKINABLEADMIN_BATCH_MOVE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BATCHTEAM',                              '[' . _BATCH_TEAM . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BLOGCOMMENTLIST',                        '[' . _COMMENTS_BLOG . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BLOGSETTINGS',                           '[' . _EBLOG_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BOOKMARKLET',                            '[' . _BOOKMARKLET_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BROWSEOWNCOMMENTS',                      '[' . _COMMENTS_YOUR . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_BROWSEOWNITEMS',                         '[' . _ITEMLIST_YOUR . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_CATEGORYDELETE',                         '[' . _CONFIRMTXT_CATEGORY . '(' . _SKINABLEADMIN_BATCH . ')' .']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_CATEGORYEDIT',                           '[' . _EBLOG_CAT_UPDATE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_COMMENTDELETE',                          '[' . _CONFIRMTXT_COMMENT . '(' . _SKINABLEADMIN_BATCH . ')' . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_COMMENTEDIT',                            '[' . _EDITC_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_CREATENEWLOG',                           '[' . _EBLOG_CREATE_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_DELETEBLOG',                             '[' . _WARNINGTXT_BLOGDEL . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_EDITMEMBERSETTINGS',                     '[' . _MEMBERS_EDIT . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_INSERTPLUGINO',                          '[' . _ADD_PLUGIN_EXTRAS . ']');\r
+define('_ADM_SKPRT_ITEMCOMMENTLIST',                        '[' . _COMMENTS . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ITEMDELETE',                             '[' . _CONFIRMTXT_ITEM . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ITEMLIST',                               '[' . _ITEMLIST_BLOG . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ITEMMOVE',                               '[' . _MOVE_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_MANAGE',                                 '[' . _OVERVIEW_MANAGE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_MANAGETEAM',                             '[' . _TEAM_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_MEMBERDELETE',                           '[' . _CONFIRMTXT_MEMBER . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_OVERVIEW',                               '[' . _QMENU_HOME . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_PAGEFOOT',                               '[' . _SKINABLEADMIN_PAGEFOOT . ']');\r
+define('_ADM_SKPRT_PAGEHEAD',                               '[' . _SKINABLEADMIN_PAGEHEAD . ']');\r
+define('_ADM_SKPRT_PLUGINDELETE',                           '[' . _CONFIRMTXT_PLUGIN . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_PLUGINHELP',                             '[' . _PLUGS_HELP_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_PLUGINLIST',                             '[' . _PLUGS_TITLE_MANAGE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_PLUGINOPTIONS',                          '[' . sprintf(_PLUGIN_OPTIONS_TITLE, _QMENU_PLUGINS) . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SETTINGSEDIT',                           '[' . _SETTINGS_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SHOWLOGIN',                              '[' . _LOGIN . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINDELETE',                             '[' . _CONFIRMTXT_SKIN . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINEDIT',                               '[' . _SKIN_EDITONE_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINEDITTYPE',                           '[' . _SKIN_EDITPART_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINIEDOIMPORT',                         '[' . _SKINIE_DONE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINIEIMPORT',                           '[' . _SKINIE_CONFIRM_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINIEOVERVIEW',                         '[' . _SKINIE_TITLE_IMPORT . '/' . _SKINIE_TITLE_EXPORT . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINOVERVIEW',                           '[' . _SKIN_EDIT_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SKINREMOVETYPE',                         '[' . _CONFIRMTXT_SKIN_PARTS_SPECIAL . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_SYSTEMOVERVIEW',                         '[' . _ADMIN_SYSTEMOVERVIEW_HEADING . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_TEAMDELETE',                             '[' . _CONFIRMTXT_TEAM1 . _CONFIRMTXT_TEAM2 . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_TEMPLATEDELETE',                         '[' . _CONFIRMTXT_TEMPLATE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_TEMPLATEEDIT',                           '[' . _TEMPLATE_EDIT_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_TEMPLATEOVERVIEW',                       '[' . _SKINABLEADMIN_TEMPLATEOVERVIEW . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_USERMANAGEMENT',                         '[' . _MEMBERS_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_CREATEITEM',                             '[' . _ADD_ADDTO . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ITEMEDIT',                               '[' . _EDIT_ITEM . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINDELETE',                        _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _CONFIRMTXT_SKIN . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINIEDOIMPORT',                    _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKINIE_DONE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINIEOVERVIEW',                    _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKINIE_TITLE_IMPORT . '/' . _SKINIE_TITLE_EXPORT . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINEDITTYPE',                      _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKIN_EDITPART_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINIEIMPORT',                      _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKINIE_CONFIRM_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINTEMPLATEOVERVIEW',                  _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _SKINABLEADMIN_TEMPLATEOVERVIEW . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINSKINREMOVETYPE',                    _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _CONFIRMTXT_SKIN_PARTS_SPECIAL . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINTEMPLATEEDIT',                      _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _TEMPLATE_EDIT_TITLE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+define('_ADM_SKPRT_ADMINTEMPLATEDELETE',                    _SKINABLEADMIN_QMENU_LAYOUT . ':[' . _CONFIRMTXT_TEMPLATE . ']' . _SKINABLEADMIN_PAGE_STR);\r
+\r
+\r
+// ADMIN-template template types\r
+\r
+define('_ADM_TPLPT_ADMINSKINTYPELIST_HEAD',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [defaultadminskintypes]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_ADMINSKINTYPELIST_BODY',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [defaultadminskintypes]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_ADMINSKINTYPELIST_FOOT',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [defaultadminskintypes]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_ADMIN_CUSTOMHELPLINK_ICON',              _SKINABLEADMIN_ADMINSKINVAR_STR . ' [customhelplink] ' . _SKINABLEADMIN_HELPICONURL_STR);\r
+define('_ADM_TPLPT_ADMIN_CUSTOMHELPLINK_ANCHOR',            _SKINABLEADMIN_ADMINSKINVAR_STR . ' [customhelplink] ' . _SKINABLEADMIN_HELPFILEURL_STR);\r
+define('_ADM_TPLPT_ADMIN_BLOGLINK',                         _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminbloglink]');\r
+define('_ADM_TPLPT_ADMIN_BATCHLIST',                        _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminbatchlist]');\r
+define('_ADM_TPLPT_ACTIVATE_FORGOT_TITLE',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(forgot)]' . _SKINABLEADMIN_TITLE_STR);\r
+define('_ADM_TPLPT_ACTIVATE_FORGOT_TEXT',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(forgot)]' . _SKINABLEADMIN_TEXT_STR);\r
+define('_ADM_TPLPT_ACTIVATE_REGISTER_TITLE',                _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(register)]' . _SKINABLEADMIN_TITLE_STR);\r
+define('_ADM_TPLPT_ACTIVATE_REGISTER_TEXT',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(register)]' . _SKINABLEADMIN_TEXT_STR);\r
+define('_ADM_TPLPT_ACTIVATE_CHANGE_TITLE',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(addresschange)]' . _SKINABLEADMIN_TITLE_STR);\r
+define('_ADM_TPLPT_ACTIVATE_CHANGE_TEXT',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [activationtitle(addresschange)]' . _SKINABLEADMIN_TEXT_STR);\r
+define('_ADM_TPLPT_TEMPLATE_EDIT_EXPLUGNAME',               _SKINABLEADMIN_ADMINSKINVAR_STR . ' [edittemplateinfo/editadmintemplateinfo(extratemplate)]');\r
+define('_ADM_TPLPT_TEMPLATE_EDIT_ROW_HEAD',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [edittemplateinfo/editadmintemplateinfo(extratemplate_default)]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_TEMPLATE_EDIT_ROW_TAIL',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [edittemplateinfo/editadmintemplateinfo(extratemplate_default)]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SPECIALSKINLIST_HEAD',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [specialskinlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SPECIALSKINLIST_BODY',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [specialskinlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SPECIALSKINLIST_FOOT',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [specialskinlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SYSTEMINFO_GDSETTINGS',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [systemsettings(gdinfo)]');\r
+define('_ADM_TPLPT_BANLIST_DELETED_LIST',                   _SKINABLEADMIN_ADMINSKINVAR_STR . ' [banlistdeletedlist]');\r
+define('_ADM_TPLPT_INSERT_PLUGOPTION_TITLE',                _SKINABLEADMIN_ADMINSKINVAR_STR . ' [insertpluginoptions]' . _SKINABLEADMIN_TITLE_STR);\r
+define('_ADM_TPLPT_INSERT_PLUGOPTION_BODY',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [insertpluginoptions]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_INPUTYESNO_TEMPLATE_ADMIN',              _SKINABLEADMIN_ADMINSKINVAR_STR . ' [inputyesno] ' . _SKINABLEADMIN_ADMINSETTING_STR);\r
+define('_ADM_TPLPT_INPUTYESNO_TEMPLATE_NORMAL',             _SKINABLEADMIN_ADMINSKINVAR_STR . ' [inputyesno] ' . _SKINABLEADMIN_NORMALSETTING_STR);\r
+define('_ADM_TPLPT_ADMIN_SPECIALSKINLIST_HEAD',             _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminspecialskinlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_ADMIN_SPECIALSKINLIST_BODY',             _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminspecialskinlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_ADMIN_SPECIALSKINLIST_FOOT',             _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminspecialskinlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SKINIE_EXPORT_LIST',                     _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skinielist/adminskinielist]');\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_SELECT_HEAD',          _SKINABLEADMIN_ADMINSKINVAR_STR . ' [qmanuaddselect/newmemberselect/defskinselect/defcatselect/defblogselect]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_SELECT_BODY',          _SKINABLEADMIN_ADMINSKINVAR_STR . ' [qmanuaddselect/newmemberselect/defskinselect/defcatselect/defblogselect]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_SELECT_FOOT',          _SKINABLEADMIN_ADMINSKINVAR_STR . ' [qmanuaddselect/newmemberselect/defskinselect/defcatselect/defblogselect]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_HEAD',           _SKINABLEADMIN_SHOWLIST_LISTPLUG_TABLE . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BODY',           _SKINABLEADMIN_SHOWLIST_LISTPLUG_TABLE . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_FOOT',           _SKINABLEADMIN_SHOWLIST_LISTPLUG_TABLE . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_MEMBLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editmemberlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_MEMBLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editmemberlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_MEMBLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editmemberlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TEAMLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogteamlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TEAMLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogteamlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TEAMLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogteamlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLUGLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [pluginlistlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLUGLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [pluginlistlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLUGLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [pluginlistlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_POPTLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_POPTLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . _SKINABLEADMIN_BODY_STR . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OYESNO',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[yesno]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OPWORD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[password]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEP',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[&lt;select&gt;]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEO',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[&lt;option /&gt;]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OSELEC',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[&lt;/select&gt;]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OTAREA',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[textarea]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_OITEXT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[text]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_MNUMER',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTTYPE, '[datatype=numerical]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLGOPT_MRONRY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . sprintf(_SKINABLEADMIN_PLUGIN_PLGOPT_OPTMETA, '[access=readonly]'));\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_PLUGOPTN_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . _SKINABLEADMIN_BODY_STR . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_POPTLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [editplugoptionslist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ITEMLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [itemnavlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ITEMLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [itemnavlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ITEMLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [itemnavlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CMNTLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [commentnavlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CMNTLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [commentnavlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CMNTLIST_ABAN',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [commentnavlist]' . _SKINABLEADMIN_BODY_STR . '(BAN)');\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CMNTLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [commentnavlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(blog)]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(blog)]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_BLOGSNAM_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(blog)]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SHORTNAM_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(template)]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SHORTNAM_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(template)]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SHORTNAM_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skineditallowedlist/adminskineditallowedlist(template)]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CATELIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogcatlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CATELIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogcatlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_CATELIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [blogcatlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TPLTLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [templateoverview/admintemplateoverview]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TPLTLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [templateoverview/admintemplateoverview]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_TPLTLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [templateoverview/admintemplateoverview]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SKINLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skinoverview/adminskinoverview]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SKINLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skinoverview/adminskinoverview]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_SKINLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [skinoverview/adminskinoverview]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_DRFTLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist(draft)]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_DRFTLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist(draft)]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_DRFTLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [yrbloglist(draft)]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ACTNLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [actionloglist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ACTNLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [actionloglist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_ACTNLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [actionloglist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_IBANLIST_HEAD',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminbanlist]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_IBANLIST_BODY',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminbanlist]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_SHOWLIST_LISTPLUG_TABLE_IBANLIST_FOOT',  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [adminbanlist]' . _SKINABLEADMIN_FOOT_STR);\r
+define('_ADM_TPLPT_PLUGIN_QUICKMENU_TITLE',                 _SKINABLEADMIN_ADMINSKINVAR_STR . ' [quickmenu]' . _SKINABLEADMIN_TITLE_STR);\r
+define('_ADM_TPLPT_PLUGIN_QUICKMENU_HEAD',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [quickmenu]' . _SKINABLEADMIN_HEAD_STR);\r
+define('_ADM_TPLPT_PLUGIN_QUICKMENU_BODY',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [quickmenu]' . _SKINABLEADMIN_BODY_STR);\r
+define('_ADM_TPLPT_PLUGIN_QUICKMENU_FOOT',                  _SKINABLEADMIN_ADMINSKINVAR_STR . ' [quickmenu]' . _SKINABLEADMIN_FOOT_STR);\r
+\r