X-Git-Url: http://git.sourceforge.jp/view?p=nucleus-jp%2Fnucleus-jp-ancient.git;a=blobdiff_plain;f=utf8%2Fnucleus%2Flibs%2FADMIN.php;h=6b6e5361e69ecbe97e396b2060a191ac3216d490;hp=8efc710c3fa4586b1fe7f2238305dfb180126fbf;hb=7a9ab741d74fc3e819af9b1e23a2bb6a28e00297;hpb=e83687f5752b07f397c66d684966e1f0fad6cd66
diff --git a/utf8/nucleus/libs/ADMIN.php b/utf8/nucleus/libs/ADMIN.php
index 8efc710..6b6e536 100755
--- a/utf8/nucleus/libs/ADMIN.php
+++ b/utf8/nucleus/libs/ADMIN.php
@@ -1,6211 +1,6524 @@
- action_xxxx method)
- */
- var $action;
-
- /**
- * Class constructor
- */
- function ADMIN() {
-
- }
-
- /**
- * Executes an action
- *
- * @param string $action action to be performed
- */
- function action($action) {
- global $CONF, $manager;
-
- // list of action aliases
- $alias = array(
- 'login' => 'overview',
- '' => 'overview'
- );
-
- 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');
-/*
- // 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', 'sendping', 'rawping', 'activatesetpwd');
-*/
- if (!in_array($this->action, $aActionsNotToCheck))
- {
- if (!$manager->checkTicket())
- $this->error(_ERROR_BADTICKET);
- }
-
- if (method_exists($this, $methodName))
- call_user_func(array(&$this, $methodName));
- else
- $this->error(_BADACTION . " ($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->pagehead();
-
- echo '
', _LOGIN ,' ';
- if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
- ?>
-
-
- pagefoot();
- }
-
-
- /**
- * provides a screen with the overview of the actions available
- * @todo document parameter
- */
- function action_overview($msg = '') {
- global $member;
-
- $this->pagehead();
-
- if ($msg)
- echo _MESSAGE , ': ', $msg;
-
- /* ---- add items ---- */
- echo '' . _OVERVIEW_YRBLOGS . ' ';
-
- $showAll = requestVar('showall');
-
- if (($member->isAdmin()) && ($showAll == 'yes')) {
- // Super-Admins have access to all blogs! (no add item support though)
- $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
- . ' FROM ' . sql_table('blog')
- . ' ORDER BY bname';
- } else {
- $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
- . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
- . ' WHERE tblog=bnumber and tmember=' . $member->getID()
- . ' ORDER BY bname';
- }
- $template['content'] = 'bloglist';
- $template['superadmin'] = $member->isAdmin();
- $amount = showlist($query,'table',$template);
-
- if (($showAll != 'yes') && ($member->isAdmin())) {
- $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
- if ($total > $amount)
- echo 'Show all blogs
';
- }
-
- if ($amount == 0)
- echo _OVERVIEW_NOBLOGS;
-
- if ($amount != 0) {
- echo '' . _OVERVIEW_YRDRAFTS . ' ';
- $query = 'SELECT ititle, inumber, bshortname'
- . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
- . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
- $template['content'] = 'draftlist';
- $amountdrafts = showlist($query, 'table', $template);
- if ($amountdrafts == 0)
- echo _OVERVIEW_NODRAFTS;
- }
-
- /* ---- user settings ---- */
- echo '' . _OVERVIEW_YRSETTINGS . ' ';
- echo '';
-
- /* ---- general settings ---- */
- if ($member->isAdmin()) {
- echo '' . _OVERVIEW_MANAGEMENT. ' ';
- echo '';
- }
-
-
- $this->pagefoot();
- }
-
- /**
- * Returns a link to a weblog
- * @param object BLOG
- */
- function bloglink(&$blog) {
- return ''.$blog->getName() .' ';
- }
-
- /**
- * @todo document this
- */
- function action_manage($msg = '') {
- global $member;
-
- $member->isAdmin() or $this->disallow();
-
- $this->pagehead();
-
- echo '(',_BACKHOME,')
';
-
- if ($msg)
- echo '' , _MESSAGE , ': ', $msg , '
';
-
-
- echo '' . _MANAGE_GENERAL. ' ';
-
- echo '';
-
- echo '' . _MANAGE_SKINS . ' ';
- echo '';
-
- echo '' . _MANAGE_EXTRA . ' ';
- echo '';
-
- $this->pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_itemlist($blogid = '') {
- global $member, $manager;
-
- if ($blogid == '')
- $blogid = intRequestVar('blogid');
-
- $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
- $this->pagehead();
- $blog =& $manager->getBlog($blogid);
-
- echo '(',_BACKHOME,')
';
- echo '' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . ' ';
-
- // start index
- if (postVar('start'))
- $start = intPostVar('start');
- else
- $start = 0;
-
- if ($start == 0)
- echo '',_ITEMLIST_ADDNEW,'
';
-
- // amount of items to show
- if (postVar('amount'))
- $amount = intPostVar('amount');
- else
- $amount = 10;
-
- $search = postVar('search'); // search through items
-
- $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
- . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
- . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
-
- if ($search)
- $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
-
- // non-blog-admins can only edit/delete their own items
- if (!$member->blogAdminRights($blogid))
- $query .= ' and iauthor=' . $member->getID();
-
-
- $query .= ' ORDER BY itime DESC'
- . " LIMIT $start,$amount";
-
- $template['content'] = 'itemlist';
- $template['now'] = $blog->getCorrectTime(time());
-
- $manager->loadClass("ENCAPSULATE");
- $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
- $navList->showBatchList('item',$query,'table',$template);
-
-
- $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();
-
- echo '(',_BACKHOME,') ';
- echo '',_BATCH_ITEMS,' ';
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
- echo '';
-
-
- // walk over all itemids and perform action
- foreach ($selected as $itemid) {
- $itemid = intval($itemid);
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONITEM,' ', $itemid, ' ...';
-
- // perform action, display errors if needed
- switch($action) {
- case 'delete':
- $error = $this->deleteOneItem($itemid);
- break;
- case 'move':
- $error = $this->moveOneItem($itemid, $destCatid);
- break;
- default:
- $error = _BATCH_UNKNOWN . $action;
- }
-
- echo '',($error ? $error : _BATCH_SUCCESS),' ';
- echo ' ';
- }
-
- echo ' ';
- echo '',_BATCH_DONE,' ';
-
- $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();
-
- echo '(',_BACKHOME,') ';
- echo '',_BATCH_COMMENTS,' ';
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
- echo '';
-
- // walk over all itemids and perform action
- foreach ($selected as $commentid) {
- $commentid = intval($commentid);
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONCOMMENT,' ', $commentid, ' ...';
-
- // perform action, display errors if needed
- switch($action) {
- case 'delete':
- $error = $this->deleteOneComment($commentid);
- break;
- default:
- $error = _BATCH_UNKNOWN . $action;
- }
-
- echo '',($error ? $error : _BATCH_SUCCESS),' ';
- echo ' ';
- }
-
- echo ' ';
- echo '',_BATCH_DONE,' ';
-
- $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();
-
- echo '(',_MEMBERS_BACKTOOVERVIEW,') ';
- echo '',_BATCH_MEMBERS,' ';
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
- echo '';
-
- // walk over all itemids and perform action
- foreach ($selected as $memberid) {
- $memberid = intval($memberid);
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONMEMBER,' ', $memberid, ' ...';
-
- // perform action, display errors if needed
- switch($action) {
- case 'delete':
- $error = $this->deleteOneMember($memberid);
- break;
- case 'setadmin':
- // always succeeds
- sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
- $error = '';
- break;
- case 'unsetadmin':
- // there should always remain at least one super-admin
- $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
- if (mysql_num_rows($r) < 2)
- $error = _ERROR_ATLEASTONEADMIN;
- else
- sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
- break;
- default:
- $error = _BATCH_UNKNOWN . $action;
- }
-
- echo '',($error ? $error : _BATCH_SUCCESS),' ';
- echo ' ';
- }
-
- echo ' ';
- echo '',_BATCH_DONE,' ';
-
- $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();
-
- echo '(',_BACK,')
';
-
- echo '',_BATCH_TEAM,' ';
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
- echo '';
-
- // walk over all itemids and perform action
- foreach ($selected as $memberid) {
- $memberid = intval($memberid);
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONTEAM,' ', $memberid, ' ...';
-
- // perform action, display errors if needed
- switch($action) {
- case 'delete':
- $error = $this->deleteOneTeamMember($blogid, $memberid);
- break;
- case 'setadmin':
- // always succeeds
- sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
- $error = '';
- break;
- case 'unsetadmin':
- // there should always remain at least one admin
- $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
- if (mysql_num_rows($r) < 2)
- $error = _ERROR_ATLEASTONEBLOGADMIN;
- else
- sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
- break;
- default:
- $error = _BATCH_UNKNOWN . $action;
- }
-
- echo '',($error ? $error : _BATCH_SUCCESS),' ';
- echo ' ';
- }
-
- echo ' ';
- echo '',_BATCH_DONE,' ';
-
- $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();
-
- echo '(',_BACKHOME,') ';
- echo '',BATCH_CATEGORIES,' ';
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
- echo '';
-
- // walk over all itemids and perform action
- foreach ($selected as $catid) {
- $catid = intval($catid);
- echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONCATEGORY,' ', $catid, ' ...';
-
- // perform action, display errors if needed
- switch($action) {
- case 'delete':
- $error = $this->deleteOneCategory($catid);
- break;
- case 'move':
- $error = $this->moveOneCategory($catid, $destBlogId);
- break;
- default:
- $error = _BATCH_UNKNOWN . $action;
- }
-
- echo '',($error ? 'Error: '.$error : _BATCH_SUCCESS),' ';
- echo ' ';
- }
-
- echo ' ';
- echo '',_BATCH_DONE,' ';
-
- $this->pagefoot();
-
- }
-
- /**
- * @todo document this
- */
- function batchMoveSelectDestination($type, $ids) {
- global $manager;
- $this->pagehead();
- ?>
-
-
- pagefoot();
- exit;
- }
-
- /**
- * @todo document this
- */
- function batchMoveCategorySelectDestination($type, $ids) {
- global $manager;
- $this->pagehead();
- ?>
-
-
- pagefoot();
- exit;
- }
-
- /**
- * @todo document this
- */
- function batchAskDeleteConfirmation($type, $ids) {
- global $manager;
-
- $this->pagehead();
- ?>
-
-
- 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 = mysql_fetch_object($rblogids))
- if ($o->bnumber != $iForcedBlogInclude)
- $aBlogIds[] = intval($o->bnumber);
-
- if (count($aBlogIds) == 0)
- return;
-
- echo '';
-
- // 1. select blogs (we'll create optiongroups)
- // (only select those blogs that have the user on the team)
- $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
- $blogs = sql_query($queryBlogs);
- if ($mode == 'category') {
- if (mysql_num_rows($blogs) > 1)
- $multipleBlogs = 1;
-
- while ($oBlog = mysql_fetch_object($blogs)) {
- if ($multipleBlogs)
- echo '';
-
- // show selection to create new category when allowed/wanted
- if ($showNewCat) {
- // check if allowed to do so
- if ($member->blogAdminRights($oBlog->bnumber))
- echo '',_ADD_NEWCAT,' ';
- }
-
- // 2. for each category in that blog
- $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
- while ($oCat = mysql_fetch_object($categories)) {
- if ($oCat->catid == $selected)
- $selectText = ' selected="selected" ';
- else
- $selectText = '';
- echo '',htmlspecialchars($oCat->cname),' ';
- }
-
- if ($multipleBlogs)
- echo ' ';
- }
- } else {
- // blog mode
- while ($oBlog = mysql_fetch_object($blogs)) {
- echo 'bnumber == $selected)
- echo ' selected="selected"';
- echo'>',htmlspecialchars($oBlog->bname),' ';
- }
- }
- echo ' ';
-
- }
-
- /**
- * @todo document this
- */
- function action_browseownitems() {
- global $member, $manager;
-
- $this->pagehead();
-
- echo '(',_BACKHOME,')
';
- echo '' . _ITEMLIST_YOUR. ' ';
-
- // start index
- if (postVar('start'))
- $start = postVar('start');
- else
- $start = 0;
-
- // amount of items to show
- if (postVar('amount'))
- $amount = postVar('amount');
- else
- $amount = 10;
-
- $search = postVar('search'); // search through items
-
- $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
- . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
- . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
-
- if ($search)
- $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
-
- $query .= ' ORDER BY itime DESC'
- . " LIMIT $start,$amount";
-
- $template['content'] = 'itemlist';
- $template['now'] = time();
-
- $manager->loadClass("ENCAPSULATE");
- $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
- $navList->showBatchList('item',$query,'table',$template);
-
- $this->pagefoot();
-
- }
-
- /**
- * Show all the comments for a given item
- * @param int $itemid
- */
- function action_itemcommentlist($itemid = '') {
- global $member, $manager;
-
- if ($itemid == '')
- $itemid = intRequestVar('itemid');
-
- // only allow if user is allowed to alter item
- $member->canAlterItem($itemid) or $this->disallow();
-
- $blogid = getBlogIdFromItemId($itemid);
-
- $this->pagehead();
-
- // start index
- if (postVar('start'))
- $start = postVar('start');
- else
- $start = 0;
-
- // amount of items to show
- if (postVar('amount'))
- $amount = postVar('amount');
- else
- $amount = 10;
-
- $search = postVar('search');
-
- echo '(',_BACKTOOVERVIEW,' )
';
- echo '',_COMMENTS,' ';
-
- $query = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE citem=' . $itemid;
-
- if ($search)
- $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
- $query .= ' ORDER BY ctime ASC'
- . " LIMIT $start,$amount";
-
- $template['content'] = 'commentlist';
- $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
-
- $manager->loadClass("ENCAPSULATE");
- $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
- $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
-
- $this->pagefoot();
- }
-
- /**
- * Browse own comments
- */
- function action_browseowncomments() {
- global $member, $manager;
-
- // start index
- if (postVar('start'))
- $start = postVar('start');
- else
- $start = 0;
-
- // amount of items to show
- if (postVar('amount'))
- $amount = postVar('amount');
- else
- $amount = 10;
-
- $search = postVar('search');
-
-
- $query = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
-
- if ($search)
- $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
- $query .= ' ORDER BY ctime DESC'
- . " LIMIT $start,$amount";
-
- $this->pagehead();
-
- echo '(',_BACKHOME,')
';
- echo '', _COMMENTS_YOUR ,' ';
-
- $template['content'] = 'commentlist';
- $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
-
- $manager->loadClass("ENCAPSULATE");
- $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
- $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
-
- $this->pagefoot();
- }
-
- /**
- * Browse all comments for a weblog
- * @param int $blogid
- */
- function action_blogcommentlist($blogid = '')
- {
- global $member, $manager;
-
- if ($blogid == '')
- $blogid = intRequestVar('blogid');
- else
- $blogid = intval($blogid);
-
- $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
-
- // start index
- if (postVar('start'))
- $start = postVar('start');
- else
- $start = 0;
-
- // amount of items to show
- if (postVar('amount'))
- $amount = postVar('amount');
- else
- $amount = 10;
-
- $search = postVar('search'); // search through comments
-
-
- $query = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
-
- if ($search != '')
- $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
-
-
- $query .= ' ORDER BY ctime DESC'
- . " LIMIT $start,$amount";
-
-
- $blog =& $manager->getBlog($blogid);
-
- $this->pagehead();
-
- echo '(',_BACKHOME,')
';
- echo '', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), ' ';
-
- $template['content'] = 'commentlist';
- $template['canAddBan'] = $member->blogAdminRights($blogid);
-
- $manager->loadClass("ENCAPSULATE");
- $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
- $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
-
- $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();
-
- // generate the add-item form
- $formfactory =& new PAGEFACTORY($blogid);
- $formfactory->createAddForm('admin');
-
- $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));
-
- $manager->notify('PrepareItemForEdit', array('item' => &$item));
-
- if ($blog->convertBreaks()) {
- $item['body'] = removeBreaks($item['body']);
- $item['more'] = removeBreaks($item['more']);
- }
-
- // form to edit blog items
- $this->pagehead();
- $formfactory =& new PAGEFACTORY($blog->getID());
- $formfactory->createEditForm('admin',$item);
- $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
- */
- switch ($actiontype) {
- case 'adddraft':
- $publish = 0;
- $wasdraft = 1;
- $timestamp = 0;
- break;
- case 'addfuture':
- $wasdraft = 1;
- $publish = 1;
- $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
- break;
- case 'addnow':
- $wasdraft = 1;
- $publish = 1;
- $timestamp = 0;
- break;
- case 'changedate':
- $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
- $publish = 1;
- $wasdraft = 0;
- break;
- case 'edit':
- default:
- $publish = 1;
- $wasdraft = 0;
- $timestamp = 0;
- }
-
- // edit the item for real
- ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
-
- if ($draftid > 0) {
- ITEM::delete($draftid);
- }
-
- $blogid = getBlogIDFromItemID($itemid);
- $blog =& $manager->getBlog($blogid);
- if (!$closed && $publish && $wasdraft && $blog->pingUserland()) {
- $this->action_sendping($blogid);
- return;
- }
-
- // 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
- $this->action_itemlist(getBlogIDFromItemID($itemid));
- }
- }
-
- /**
- * @todo document this
- */
- 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);
-
- $item =& $manager->getItem($itemid,1,1);
- $title = htmlspecialchars(strip_tags($item['title']));
- $body = strip_tags($item['body']);
- $body = htmlspecialchars(shorten($body,300,'...'));
-
- $this->pagehead();
- ?>
-
-
-
-
-
- ""
-
-
-
-
-
- pagefoot();
- }
-
- /**
- * @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;
-
- $manager->loadClass('ITEM');
- ITEM::delete($itemid);
- }
-
- /**
- * @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();
-
- $item =& $manager->getItem($itemid,1,1);
-
- $this->pagehead();
- ?>
-
-
- 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();
-
- ITEM::move($itemid, $catid);
-
- 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 $member, $manager, $CONF;
-
- $manager->loadClass('ITEM');
-
- $result = ITEM::createFromRequest();
-
- if ($result['status'] == 'error')
- $this->error($result['message']);
-
- $blogid = getBlogIDFromItemID($result['itemid']);
- $blog =& $manager->getBlog($blogid);
-
- $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
-
- if ($result['status'] == 'newcategory')
- $this->action_categoryedit(
- $result['catid'],
- $blogid,
- $blog->pingUserland() ? $pingUrl : ''
- );
- elseif ((postVar('actiontype') == 'addnow') && $blog->pingUserland())
- $this->action_sendping($blogid);
- else
- $this->action_itemlist($blogid);
- }
-
- /**
- * Shows a window that says we're about to ping weblogs.com.
- * immediately refresh to the real pinging page, which will
- * show an error, or redirect to the blog.
- *
- * @param int $blogid ID of blog for which ping needs to be sent out
- */
- function action_sendping($blogid = -1) {
- global $member, $manager;
-
- if ($blogid == -1)
- $blogid = intRequestVar('blogid');
-
- $member->isLoggedIn() or $this->disallow();
-
- $rawPingUrl = $manager->addTicketToUrl('index.php?action=rawping&blogid=' . intval($blogid));
-
- $this->pagehead(' ');
- ?>
- Site Updated, Now pinging weblogs.com
-
-
- Pinging weblogs.com! This can a while...
-
- When the ping is complete (and successfull), your weblog will show up in the weblogs.com updates list.
-
-
-
- If you aren't automatically passed through, try again
-
- pagefoot();
- }
-
- /**
- * Ping to Weblogs.com
- * Sends the real ping (can take up to 10 seconds!)
- */
- function action_rawping() {
- global $manager;
- // TODO: checks?
-
- $blogid = intRequestVar('blogid');
- $blog =& $manager->getBlog($blogid);
-
- $result = $blog->sendUserlandPing();
-
- $this->pagehead();
-
- ?>
-
- Ping Results
-
- The following message was returned by weblogs.com:
-
-
-
-
-
- pagefoot();
- }
-
- /**
- * Allows to edit previously made comments
- */
- function action_commentedit() {
- global $member, $manager;
-
- $commentid = intRequestVar('commentid');
-
- $member->canAlterComment($commentid) or $this->disallow();
-
- $comment = COMMENT::getComment($commentid);
-
- $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
-
- // change to \n
- $comment['body'] = str_replace(' ','',$comment['body']);
-
- $comment['body'] = eregi_replace("[^<]* ","\\1",$comment['body']);
-
- $this->pagehead();
-
- ?>
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_commentupdate() {
- global $member, $manager;
-
- $commentid = intRequestVar('commentid');
-
- $member->canAlterComment($commentid) or $this->disallow();
-
- $body = postVar('body');
-
- // intercept words that are too long
- if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
- $this->error(_ERROR_COMMENT_LONGWORD);
-
- // check length
- if (strlen($body)<3)
- $this->error(_ERROR_COMMENT_NOCOMMENT);
- if (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 cbody='" .addslashes($body). "'"
- . " WHERE cnumber=" . $commentid;
- sql_query($query);
-
- // get itemid
- $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
- $o = mysql_fetch_object($res);
- $itemid = $o->citem;
-
- if ($member->canAlterItem($itemid))
- $this->action_itemcommentlist($itemid);
- else
- $this->action_browseowncomments();
-
- }
-
- /**
- * @todo document this
- */
- function action_commentdelete() {
- global $member, $manager;
-
- $commentid = intRequestVar('commentid');
-
- $member->canAlterComment($commentid) or $this->disallow();
-
- $comment = COMMENT::getComment($commentid);
-
- $body = strip_tags($comment['body']);
- $body = htmlspecialchars(shorten($body, 300, '...'));
-
- if ($comment['member'])
- $author = $comment['member'];
- else
- $author = $comment['user'];
-
- $this->pagehead();
- ?>
-
-
-
-
-
-
- :
-
- :
-
-
-
-
- addTicketHidden() ?>
-
-
-
- pagefoot();
- }
-
- /**
- * @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 = mysql_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();
-
- echo '(',_BACKTOMANAGE,')
';
-
- echo '' . _MEMBERS_TITLE .' ';
-
- echo '' . _MEMBERS_CURRENT .' ';
-
- // show list of members with actions
- $query = 'SELECT *'
- . ' FROM '.sql_table('member');
- $template['content'] = 'memberlist';
- $template['tabindex'] = 10;
-
- $manager->loadClass("ENCAPSULATE");
- $batch =& new BATCH('member');
- $batch->showlist($query,'table',$template);
-
- echo '' . _MEMBERS_NEW .' ';
- ?>
-
-
-
- addTicketHidden() ?>
-
-
-
-
- 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();
-
- // check if allowed
- ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
-
- $extrahead = '';
- $this->pagehead($extrahead);
-
- // show message to go back to member overview (only for admins)
- if ($member->isAdmin())
- echo '(' ._MEMBERS_BACKTOOVERVIEW. ') ';
- else
- echo '(' ._BACKHOME. ') ';
-
- echo '' . _MEMBERS_EDIT . ' ';
-
- $mem = MEMBER::createFromID($memberid);
-
- ?>
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
- isAdmin()) { ?>
-
- getDisplayName());
- }
- ?>
-
-
-
-
-
- isAdmin()) { ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- isAdmin()) {
- ?>
-
-
- input_yesno('admin',$mem->isAdmin(),60); ?>
-
-
- input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?>
-
-
-
-
-
-
-
-
-
-
-
- getLanguage())
- echo " selected='selected'";
- echo ">$name";
- }
- }
- closedir($dirhandle);
-
- ?>
-
-
-
-
- _insertPluginOptions('member',$memberid);
- ?>
-
-
-
-
-
-
-
-
-
- ',_PLUGINS_EXTRA,'';
-
- $manager->notify(
- 'MemberSettingsFormExtras',
- array(
- 'member' => &$mem
- )
- );
-
- $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'));
-
- // Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
- if (!eregi("^https?://", $url))
- $url = "http://".$url;
-
- $admin = postVar('admin');
- $canlogin = postVar('canlogin');
- $notes = strip_tags(postVar('notes'));
- $deflang = postVar('deflang');
-
- $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 && (strlen($password) < 6))
- $this->error(_ERROR_PASSWORDTOOSHORT);
- }
-
- if (!isValidMailAddress($email))
- $this->error(_ERROR_BADMAILADDRESS);
-
-
- if (!$realname)
- $this->error(_ERROR_REALNAMEMISSING);
-
- if (($deflang != '') && (!checkLanguage($deflang)))
- $this->error(_ERROR_NOSUCHLANGUAGE);
-
- // 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 (mysql_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->setLanguage($deflang);
-
-
- // only allow super-admins to make changes to the admin status
- if ($member->isAdmin()) {
- $mem->setAdmin($admin);
- $mem->setCanLogin($canlogin);
- }
-
-
- $mem->write();
-
- // store plugin options
- $aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($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);
- }
- }
-
- /**
- * @todo document this
- */
- function action_memberadd() {
- global $member, $manager;
-
- // check if allowed
- $member->isAdmin() or $this->disallow();
-
- if (postVar('password') != postVar('repeatpassword'))
- $this->error(_ERROR_PASSWORDMISMATCH);
- if (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();
- }
-
- /**
- * 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);
-
- $text = '';
- $title = '';
- $bNeedsPasswordChange = true;
-
- switch ($info->vtype)
- {
- case 'forgot':
- $title = _ACTIVATE_FORGOT_TITLE;
- $text = _ACTIVATE_FORGOT_TEXT;
- break;
- case 'register':
- $title = _ACTIVATE_REGISTER_TITLE;
- $text = _ACTIVATE_REGISTER_TEXT;
- break;
- case 'addresschange':
- $title = _ACTIVATE_CHANGE_TITLE;
- $text = _ACTIVATE_CHANGE_TEXT;
- $bNeedsPasswordChange = false;
- MEMBER::activate($key);
- break;
- }
-
- $aVars = array(
- 'memberName' => htmlspecialchars($mem->getDisplayName())
- );
- $title = TEMPLATE::fill($title, $aVars);
- $text = TEMPLATE::fill($text, $aVars);
-
- $this->pagehead();
-
- echo '' , $title, ' ';
- echo '' , $text, '
';
-
- if ($message != '')
- {
- echo '',$message,'
';
- }
-
- if ($bNeedsPasswordChange)
- {
- ?>
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
- 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 && (strlen($password) < 6))
- return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
-
- $error = '';
- global $manager;
- $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();
- echo '',_ACTIVATE_SUCCESS_TITLE,' ';
- echo '',_ACTIVATE_SUCCESS_TEXT,'
';
- $this->pagefoot();
- }
-
- /**
- * Manage team
- */
- function action_manageteam() {
- global $member, $manager;
-
- $blogid = intRequestVar('blogid');
-
- // check if allowed
- $member->blogAdminRights($blogid) or $this->disallow();
-
- $this->pagehead();
-
- echo "(",_BACK_TO_BLOGSETTINGS,")
";
-
- echo '' . _TEAM_TITLE . getBlogNameFromID($blogid) . ' ';
-
- echo '' . _TEAM_CURRENT . ' ';
-
-
-
- $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
- . ' FROM '.sql_table('member').', '.sql_table('team')
- . ' WHERE tmember=mnumber and tblog=' . $blogid;
-
- $template['content'] = 'teamlist';
- $template['tabindex'] = 10;
-
- $manager->loadClass("ENCAPSULATE");
- $batch =& new BATCH('team');
- $batch->showlist($query, 'table', $template);
-
- ?>
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
- 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();
- ?>
-
-
- getDisplayName() ?> getName())) ?>
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
- 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' => &$mem, '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 (mysql_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' => &$mem, '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 (mysql_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 = '';
- $this->pagehead($extrahead);
-
- echo '(',_BACKHOME,')
';
- ?>
- : 'bloglink($blog)?>'
-
-
-
- Members currently on your team:
- mname) . ' (' . htmlspecialchars($o->mrealname). ')');
- echo implode(',', $aMemberNames);
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- getDefaultSkin();
- $template['tabindex'] = 50;
- showlist($query,'select',$template);
- ?>
-
-
-
-
-
- input_yesno('convertbreaks',$blog->convertBreaks(),55); ?>
-
-
-
- input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?>
-
-
-
- input_yesno('comments',$blog->commentsEnabled(),60); ?>
-
-
-
- input_yesno('public',$blog->isPublic(),70); ?>
-
-
-
- input_yesno('reqemail',$blog->emailRequired(),72); ?>
-
-
-
-
-
-
- notifyOnComment()) echo "checked='checked'" ?>
- />
-
- notifyOnVote()) echo "checked='checked'" ?>
- />
-
- notifyOnNewItem()) echo "checked='checked'" ?>
- />
-
-
-
- input_yesno('pinguserland',$blog->pingUserland(),85); ?>
-
-
-
-
-
-
-
-
-
- getID();
- $template['name'] = 'defcat';
- $template['selected'] = $blog->getDefaultCategory();
- $template['tabindex'] = 110;
- showlist($query,'select',$template);
- ?>
-
-
-
-
- getCorrectTime()); ?>
-
-
-
-
- input_yesno('searchable',$blog->getSearchable(),122); ?>
-
- _insertPluginOptions('blog',$blogid);
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
- getID().' ORDER BY cname';
- $template['content'] = 'categorylist';
- $template['tabindex'] = 200;
-
- $manager->loadClass("ENCAPSULATE");
- $batch =& new BATCH('category');
- $batch->showlist($query,'table',$template);
-
- ?>
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
- ',_PLUGINS_EXTRA,'';
-
- $manager->notify(
- 'BlogSettingsFormExtras',
- array(
- 'blog' => &$blog
- )
- );
-
- $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=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
- $res = sql_query($query);
- if (mysql_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);
-
- $member->blogAdminRights($blogid) or $this->disallow();
-
- $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
- $obj = mysql_fetch_object($res);
-
- $cname = $obj->cname;
- $cdesc = $obj->cdesc;
-
- $extrahead = '';
- $this->pagehead($extrahead);
-
- echo "(",_BACK_TO_BLOGSETTINGS,")
";
-
- ?>
- ''
-
-
-
-
-
- addTicketHidden(); ?>
-
-
-
-
- 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=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
- $res = sql_query($query);
- if (mysql_num_rows($res) > 0)
- $this->error(_ERROR_DUPCATEGORYNAME);
-
- $query = 'UPDATE '.sql_table('category').' SET'
- . " cname='" . addslashes($cname) . "',"
- . " cdesc='" . addslashes($cdesc) . "'"
- . " WHERE catid=" . $catid;
-
- sql_query($query);
-
- // store plugin options
- $aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($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 (mysql_num_rows($res) == 1)
- $this->error(_ERROR_DELETELASTCATEGORY);
-
-
- $this->pagehead();
- ?>
-
-
-
- getCategoryName($catid)?>
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
- 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();
- }
-
- /**
- * @todo document this
- */
- function deleteOneCategory($catid) {
- global $manager, $member;
-
- $catid = intval($catid);
-
- $manager->notify('PreDeleteCategory', array('catid' => $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 (mysql_num_rows($res) == 1)
- return _ERROR_DELETELASTCATEGORY;
-
- // 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::_deleteOptionValues('category', $catid);
-
- // delete category
- $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
- sql_query($query);
-
- $manager->notify('PostDeleteCategory', array('catid' => $catid));
-
- }
-
- /**
- * @todo document this
- */
- function moveOneCategory($catid, $destblogid) {
- global $manager, $member;
-
- $catid = intval($catid);
- $destblogid = intval($destblogid);
-
- $blogid = getBlogIDFromCatID($catid);
-
- // mover should have admin rights on both blogs
- if (!$member->blogAdminRights($blogid))
- return _ERROR_DISALLOWED;
- if (!$member->blogAdminRights($destblogid))
- return _ERROR_DISALLOWED;
-
- // cannot move to self
- if ($blogid == $destblogid)
- return _ERROR_MOVETOSELF;
-
- // get blogs
- $blog =& $manager->getBlog($blogid);
- $destblog =& $manager->getBlog($destblogid);
-
- // check if the category is valid
- if (!$blog || !$blog->isValidCategory($catid))
- return _ERROR_NOSUCHCATEGORY;
-
- // don't allow default category to be moved
- if ($blog->getDefaultCategory() == $catid)
- return _ERROR_MOVEDEFCATEGORY;
-
- $manager->notify(
- 'PreMoveCategory',
- array(
- 'catid' => &$catid,
- 'sourceblog' => &$blog,
- 'destblog' => &$destblog
- )
- );
-
- // update comments table (cblog)
- $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
- $items = sql_query($query);
- while ($oItem = mysql_fetch_object($items)) {
- sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
- }
-
- // update items (iblog)
- $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
- sql_query($query);
-
- // move category
- $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
- sql_query($query);
-
- $manager->notify(
- 'PostMoveCategory',
- array(
- 'catid' => &$catid,
- 'sourceblog' => &$blog,
- 'destblog' => $destblog
- )
- );
-
- }
-
- /**
- * @todo document this
- */
- function action_blogsettingsupdate() {
- global $member, $manager;
-
- $blogid = intRequestVar('blogid');
-
- $member->blogAdminRights($blogid) or $this->disallow();
-
- $blog =& $manager->getBlog($blogid);
-
- $notify = 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) {
- $not =& new NOTIFICATION($notify);
- if (!$not->validAddresses())
- $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);
- $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->setPingUserland(postVar('pinguserland'));
- $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::_applyPluginOptions($aOptions);
- $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
-
-
- $this->action_overview(_MSG_SETTINGSCHANGED);
- }
-
- /**
- * @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();
- ?>
-
-
-
-
-
-
- getName())?>
-
-
-
-
- addTicketHidden() ?>
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- 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::_deleteOptionValues('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);
- }
-
- /**
- * @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();
- ?>
-
-
- getDisplayName() ?>
-
-
-
- Please note that media files will NOT be deleted. (At least not in this Nucleus version)
-
-
-
-
- addTicketHidden() ?>
-
-
-
- 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);
- }
-
- /**
- * @static
- * @todo document this
- */
- 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 */
- $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
- .'" WHERE cmember='.$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::_deleteOptionValues('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();
-
- echo '(',_BACKTOMANAGE,')
';
- ?>
-
-
- 注æäºé
-
- ä½æã«ããã£ã¦ãä¸è¨ã®æ³¨æäºé
ãã¾ããèªã¿ä¸ãã
-
- æ°ããweblogãä½æããå¾ã«ããã®blogã«ã¢ã¯ã»ã¹ããããã®æ¹æ³ãç´¹ä»ãã¦ããã¾ããæ¹æ³ã¯2ã¤ããã¾ã:
-
-
- ç°¡åãªæ¹æ³: index.php
ã®è¤è£½ãä½ããæ°ããblogã表示ããããã«å¤æ´ãå ãã¾ãã ãã®å¤æ´ã®è©³ç´°ã¯ãä½æå¾ã«è¡¨ç¤ºããã¾ãã
- é«åº¦ãªæ¹æ³: ç¾å¨ã®blogã§ä½¿ç¨ãã¦ããã¹ãã³ã«otherblog
ã¨ããã³ã¼ãã使ã£ãè¨è¿°ãå ãã¾ãããã®æ¹æ³ã§ã¯ãåããã¼ã¸å
ã§è¤æ°ã®blogãå±éãããã¨ãå¯è½ã¨ãªãã¾ãã
-
-
- Weblogã®ä½æ
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- 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' => &$bdescription,
- 'defaultskin' => &$bdefskin
- )
- );
-
-
- // add slashes for sql queries
- $bname = addslashes($bname);
- $bshortname = addslashes($bshortname);
- $btimeoffset = addslashes($btimeoffset);
- $bdesc = addslashes($bdesc);
- $bdefskin = addslashes($bdefskin);
-
- // create blog
- $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
- sql_query($query);
- $blogid = mysql_insert_id();
- $blog =& $manager->getBlog($blogid);
-
- // create new category
- sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, 'General','Items that do not fit in other categories')");
- $catid = mysql_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 ($memberid, $blogid, 1)";
- sql_query($query);
-
-
- $blog->additem($blog->getDefaultCategory(),'First Item','ããã¯ããªãã®weblogã«ãããæåã®ã¢ã¤ãã ã§ããèªç±ã«åé¤ãã¦ããã ãã¦ãã¾ãã¾ããã','',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
-
- $manager->notify(
- 'PostAddBlog',
- array(
- 'blog' => &$blog
- )
- );
-
- $manager->notify(
- 'PostAddCategory',
- array(
- 'blog' => &$blog,
- 'name' => 'General',
- 'description' => 'Items that do not fit in other categories',
- 'catid' => $catid
- )
- );
-
- $this->pagehead();
- ?>
- æ°ããweblogãä½æããã¾ãã
-
- æ°ããweblog ãããä½æããã¾ãããç¶ãã¦ãããã«ã¢ã¯ã»ã¹ããããã«ä»¥ä¸ã®ã©ã¡ããã®æé ã«é²ãã§ãã ããã
-
-
- ç°¡åãªæ¹æ³: ä¸ã®ã³ã¼ããè²¼ä»ãã .php
ã¨ãããã¡ã¤ã«ãä½æãã
- é«åº¦ãªæ¹æ³: ç¾å¨ä½¿ç¨ãã¦ããã¹ãã³ã«æ°ããweblogãå±éãããããã®è¨è¿°ãå ãã
-
-
-
-
- .php
ã¨ãããã¡ã¤ã«ãä½æãã¦ãä¸èº«ã«ä»¥ä¸ã®ã³ã¼ããè²¼ãä»ãã:
-<?php
-
-$CONF['Self'] = '.php ';
-
-include('./config.php ');
-
-selectBlog(' ');
-selector();
-
-?>
-
- ãã§ã«ããindex.php
ã¨åããã£ã¬ã¯ããªã«ã¢ãããã¼ããã¾ãã
-
- æ°ããweblogã®ä½æãå®äºããããã«ã¯ãä¸ã«ãã®ãã¡ã¤ã«ã®URLãå
¥åãã¦ãã ããã (ãã§ã«ç¨æããå¤ã§åã£ã¦ããã¨ã¯æãã¾ããä¿è¨¼ã¯ãã¾ãã):
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
- æ°ããweblogã®ä½æãå®äºããããã«ã¯ãä¸ã«URLãå
¥åãã¦ãã ããã (大æµã¯æ¢åblogã¨åãURL)
-
-
-
- addTicketHidden() ?>
-
-
-
-
- pagefoot();
-
- }
-
- /**
- * @todo document this
- */
- function action_addnewlog2() {
- global $member, $manager;
-
- $member->blogAdminRights($blogid) or $this->disallow();
-
- $burl = requestVar('url');
- $blogid = intRequestVar('blogid');
-
- $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();
-
- echo '(',_BACKTOMANAGE,')
';
-
- ?>
-
-
-
- 0) {
- ?>
-
-
- addTicketHidden() ?>
-
-
- $skinfile) {
- $html = htmlspecialchars($skinfile);
- echo '',$skinname,' ';
- }
- ?>
-
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
- sdnumber;
- echo ' ';
- echo '',htmlspecialchars($skinObj->sdname),' ';
- echo '',htmlspecialchars($skinObj->sddesc),' ';
- echo ' ';
- }
-
- echo '',_SKINIE_EXPORT_TEMPLATES,' ';
-
- // show list of templates
- $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
- while ($templateObj = mysql_fetch_object($res)) {
- $id = 'templateexp' . $templateObj->tdnumber;
- echo ' ';
- echo '',htmlspecialchars($templateObj->tdname),' ';
- echo '',htmlspecialchars($templateObj->tddesc),' ';
- echo ' ';
- }
-
- ?>
-
-
-
-
-
-
-
-
-
-
- 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 '(',_BACK,')
';
- ?>
-
-
-
- getInfo())?>
- '._AND.' ',$importer->getSkinNames())?>
- '._AND.' ',$importer->getTemplateNames())?>
-
- '._AND.' ',$skinNameClashes)?>
- '._AND.' ',$templateNameClashes)?>
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
- 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 '(',_BACKTOMANAGE,')
';
- ?>
-
-
-
- getInfo())?>
- '._AND.' ',$importer->getSkinNames())?>
- '._AND.' ',$importer->getTemplateNames())?>
-
-
- 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 '(',_BACKTOMANAGE,')
';
-
- echo '' . _TEMPLATE_TITLE . ' ';
- echo '' . _TEMPLATE_AVAILABLE_TITLE . ' ';
-
- $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
- $template['content'] = 'templatelist';
- $template['tabindex'] = 10;
- showlist($query,'table',$template);
-
- echo '' . _TEMPLATE_NEW_TITLE . ' ';
-
- ?>
-
-
-
- addTicketHidden() ?>
-
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_templateedit($msg = '') {
- global $member, $manager;
-
- $templateid = intRequestVar('templateid');
-
- $member->isAdmin() or $this->disallow();
-
- $extrahead = '';
- $extrahead .= '';
-
- $this->pagehead($extrahead);
-
- $templatename = TEMPLATE::getNameFromId($templateid);
- $templatedescription = TEMPLATE::getDesc($templateid);
- $template =& $manager->getTemplate($templatename);
-
- ?>
-
- ()
-
-
- ''
-
- "._MESSAGE.": $msg";
- ?>
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-_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);
-?>
-
-
-_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);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
- $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
- $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 160);
- $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 170);
- $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 180);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 190);
- $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 200);
- $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 210);
- $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 220);
- $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 230);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 240);
- $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 250);
- $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 260);
-?>
-
-
-_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',270);
- $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',280);
-?>
-
-
-
-
-
-
-
-
-
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
- static $count = 1;
- ?>
-
-
-
- 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 = addslashes($name);
- $desc = addslashes($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, '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'));
-
-
- // jump back to template edit
- $this->action_templateedit(_TEMPLATE_UPDATED);
-
- }
-
- /**
- * @todo document this
- */
- function addToTemplate($id, $partname, $content) {
- $partname = addslashes($partname);
- $content = addslashes($content);
-
- $id = intval($id);
-
- // don't add empty parts:
- if (!trim($content)) return -1;
-
- $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
- . "VALUES ($id, '$partname', '$content')";
- sql_query($query) or die("Query error: " . mysql_error());
- return mysql_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);
-
- ?>
-
-
-
- ()
-
-
-
-
- addTicketHidden() ?>
-
-
-
- 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 = mysql_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 '(',_BACKTOMANAGE,')
';
-
- echo '' . _SKIN_EDIT_TITLE . ' ';
-
- echo '' . _SKIN_AVAILABLE_TITLE . ' ';
-
- $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
- $template['content'] = 'skinlist';
- $template['tabindex'] = 10;
- showlist($query,'table',$template);
-
- echo '' . _SKIN_NEW_TITLE . ' ';
-
- ?>
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- 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();
- ?>
-
- ()
-
- 'getName() ?>'
-
-
-
-
-
- ' . _SKIN_PARTS_SPECIAL . '';
- echo '' . "\r\n";
- echo ' ' . "\r\n";
- echo ' ' . "\r\n";
- echo ' ' . "\r\n";
- echo ' ' . "\r\n";
- echo ' ' . "\r\n";
-
- if ($res && mysql_num_rows($res) > 0) {
- echo '';
- }
-
- ?>
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
- 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();
- ?>
- ( )
-
- 'getName() ?>':
-
- "._MESSAGE.": $msg";
- ?>
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- (skin type: )
-
-
-
- getContent($type)) ?>
-
-
-
-
- (skin type: )
-
-
-
- ";
- if (count($actions) != 0) echo ", ";
- }
- ?>
-
- Short blog names:
- 'shortblognames'));
- ?>
-
-
- Template names:
- 'shortnames'));
- ?>
-
-
-
-
-
-
- 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 = mysql_fetch_object($r))
- $this->error(_ERROR_SKINDEFDELETE . $o->bname);
-
- $this->pagehead();
-
- $skin =& new SKIN($skinid);
- $name = $skin->getName();
- $desc = $skin->getDescription();
-
- ?>
-
-
-
- ()
-
-
-
-
- addTicketHidden() ?>
-
-
-
- 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 = mysql_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();
-
- ?>
-
-
-
- () ()
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
- 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 = mysql_fetch_assoc($res)) {
- $this->skinclonetype($skin, $newid, $row['stype']);
- }
-
- $this->action_skinoverview();
-
- }
-
- /**
- * @todo document this
- */
- function skinclonetype($skin, $newid, $type) {
- $newid = intval($newid);
- $content = $skin->getContent($type);
- if ($content) {
- $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
- sql_query($query);
- }
- }
-
- /**
- * @todo document this
- */
- function action_settingsedit() {
- global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
-
- $member->isAdmin() or $this->disallow();
-
- $this->pagehead();
-
- echo '(',_BACKTOMANAGE,')
';
- ?>
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- $name";
- }
- }
- closedir($dirhandle);
-
- ?>
-
-
-
-
-
-
- input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
-
- URL:
-
-
-
-
-
-
-
-
-
-
-
-
- input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
-
- ",_SETTINGS_JSTOOLBAR_NONE,"";
- $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
- echo "",_SETTINGS_JSTOOLBAR_SIMPLE," ";
- $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
- echo "",_SETTINGS_JSTOOLBAR_FULL," ";
- ?>
-
-
-
-
- input_yesno('URLMode',$CONF['URLMode'],10077,
- 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
-
- echo ' ', _SETTINGS_URLMODE_HELP;
-
- ?>
-
-
-
-
-
-
-
-
- " . _WARNING_NOTADIR . " ";
- if (!is_readable($DIR_MEDIA))
- echo "" . _WARNING_NOTREADABLE . " ";
- if (!is_writeable($DIR_MEDIA))
- echo "" . _WARNING_NOTWRITABLE . " ";
- ?>
-
-
-
-
-
-
-
-
- input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?>
-
-
-
-
-
-
-
-
-
-
-
-
- input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?>
-
-
-
-
-
- input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?>
-
-
-
-
- input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
-
-
-
-
-
- input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
-
-
-
-
-
- input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
-
-
-
-
-
- input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
-
-
-
-
-
- input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?>
-
-
- input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
- 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
-
-
-
- input_yesno('LastVisit',$CONF['LastVisit'],10200); ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
- ',_PLUGINS_EXTRA,'';
-
- $manager->notify(
- 'GeneralSettingsFormExtras',
- array()
- );
-
- $this->pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_settingsupdate() {
- global $member, $CONF;
-
- $member->isAdmin() or $this->disallow();
-
- // check if email address for admin is valid
- if (!isValidMailAddress(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('Language', postVar('Language'));
- $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'));
-
- // load new config and redirect (this way, the new language 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;
-
- }
-
- /**
- * @todo document this
- */
- function updateConfig($name, $val) {
- $name = addslashes($name);
- $val = trim(addslashes($val));
-
- $query = 'UPDATE '.sql_table('config')
- . " SET value='$val'"
- . " WHERE name='$name'";
-
- sql_query($query) or die("Query error: " . mysql_error());
- return mysql_insert_id();
- }
-
- /**
- * Error message
- * @param string $msg message that will be shown
- */
- function error($msg) {
- $this->pagehead();
- ?>
- Error!
- ";
- echo ""._BACK." ";
- $this->pagefoot();
- exit;
- }
-
- /**
- * @todo document this
- */
- function disallow() {
- ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
-
- $this->error(_ERROR_DISALLOWED);
- }
-
- /**
- * @todo document this
- */
- function pagehead($extrahead = '') {
- global $member, $nucleus, $CONF, $manager;
-
- $manager->notify(
- 'AdminPrePageHead',
- array(
- 'extrahead' => &$extrahead,
- 'action' => $this->action
- )
- );
-
- $baseUrl = htmlspecialchars($CONF['AdminURL']);
-
- ?>
-
-
-
-
- - Admin
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- isLoggedIn())
- echo _LOGGEDINAS . ' ' . $member->getDisplayName()
- ." -
" . _LOGOUT. " "
- . "
" . _ADMINHOME . " - ";
- else
- echo '
' , _NOTLOGGEDIN , ' ';
-
- echo "
"._YOURSITE." ";
-
- echo '
(';
-
- // Note(JP): disabled code name description
-/*
- if ($member->isLoggedIn() && $member->isAdmin())
- echo '
Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '" ';
- else
- echo 'Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"';
-*/
- if ($member->isLoggedIn() && $member->isAdmin())
- echo '
Nucleus CMS ', $nucleus['version'], ' ';
- else
- echo 'Nucleus CMS ', $nucleus['version'];
- echo ')';
- echo '
';
- }
-
- /**
- * @todo document this
- */
- function pagefoot() {
- global $action, $member, $manager;
-
- $manager->notify(
- 'AdminPrePageFoot',
- array(
- 'action' => $this->action
- )
- );
-
- if ($member->isLoggedIn() && ($action != 'showlogin')) {
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- teamRights($blogid) or $this->disallow();
-
- // header-code stolen from phpMyAdmin
- // REGEDIT and bookmarklet code stolen from GreyMatter
-
- $sjisBlogName = getBlogNameFromID($blogid);
- $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
-
- 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\\Post To &Nucleus (".$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 '(',_BACKHOME,')
';
-
- ?>
-
- Bookmarklet
-
-
- Bookmarklet ã¨ã¯ãã¯ãªãã¯1åã§è¨äºã®æ稿ãã§ããã·ã¹ãã ã§ãã ãã® Bookmarklet ãã¤ã³ã¹ãã¼ã«ããã¨ããã©ã¦ã¶ã®ãã¼ã«ãã¼ã®'add to weblog'ãã¿ã³ãå©ç¨å¯è½ã¨ãªããNucleusã®æ°è¦ã¢ã¤ãã ã®è¿½å ã¦ã£ã³ãã¦ããããã¢ãããã¾ããä»»æã®Webãã¼ã¸ãéããç¶æ
ã§ãã®ãã¿ã³ãæ¼ãã°ããã®Webãã¼ã¸ã®ã¿ã¤ãã«ã¨ããã®ãã¼ã¸ã¸ã®ãªã³ã¯ã¿ã°ããã§ã«åãè¾¼ã¾ããç¶æ
ã§ã¢ã¤ãã 追å ã¦ã£ã³ãã¦ãéããããã«ããã®ãã¼ã¸å
ã«å¼ç¨ãããæãé¸æããç¶æ
ã§ããã°ãã®å¼ç¨æãèªåçã«å¼ç¨ãã¾ãã
-
-
- Bookmarklet
-
- ä¸ã®ãªã³ã¯é¨åãããæ°ã«å
¥ãããããã¯ãã¼ã«ãã¼ã«ãã©ãã°ã§ãã¾ãã(ãã®åã«ãã¹ããã¦ã¿ããå ´åã¯åç´ã«ä¸ã®ãªã³ã¯ãã¯ãªãã¯ãã¦ã¿ã¦ãã ãã)
-
-
- Add to getShortName()?> (ã»ã¨ãã©ã®ãã©ã¦ã¶ã§åä½ãã¾ã)
-
-
- å³ã¯ãªãã¯ã¡ãã¥ã¼ã«ã¤ã³ã¹ãã¼ã« (Windowsã§IE使ç¨æ)
-
- addTicketToUrl($url);
- ?>
- ãããã¯å³ã¯ãªãã¯ã¡ãã¥ã¼ ã«ã¤ã³ã¹ãã¼ã«ãããã¨ãã§ãã¾ã (ãéãããé¸æããã°ç´æ¥ã¬ã¸ã¹ããªã«ç»é²ãã¾ã)
-
-
-
- ãã®ã¤ã³ã¹ãã¼ã«ããå³ã¯ãªãã¯ã¡ãã¥ã¼ã表示ããããã«ã¯IEã®åèµ·åãå¿
è¦ã§ãã
-
-
- ã¢ã³ã¤ã³ã¹ãã¼ã«
-
- ããæ°ã«å
¥ãããããã¯ãã¼ã«ãã¼ããæ¶ãã«ã¯ãåã«åé¤ããã ãã§ãã
-
-
-
- å³ã¯ãªãã¯ã¡ãã¥ã¼ããæ¶ãããæã¯ã以ä¸ã®æé ãè¸ãã§ãã ãã:
-
-
-
- ã¹ã¿ã¼ãã¡ãã¥ã¼ããããã¡ã¤ã«ãæå®ãã¦å®è¡...ããé¸æ
- "regedit" ã¨å
¥å
- "OK" ãã¿ã³ãæ¼ã
- "\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt" ãããªã¼ã®ä¸ããæ¤ç´¢
- "add to weblog" ã¨ã³ããªãåé¤
-
-
- pagefoot();
-
- }
-
- /**
- * @todo document this
- */
- function action_actionlog() {
- global $member, $manager;
-
- $member->isAdmin() or $this->disallow();
-
- $this->pagehead();
-
- echo '(',_BACKTOMANAGE,')
';
-
- $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
-
- ?>
-
-
- ' . _ACTIONLOG_TITLE . '';
-
- $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 '(',_BACKHOME,')
';
-
- echo '' . _BAN_TITLE . " '". $this->bloglink($blog) ."' ";
-
- $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 ''._BAN_NEW_TITLE.' ';
- echo ""._BAN_NEW_TEXT."
";
-
-
- $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);
-
- $this->pagehead();
- ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Only blog 'getName())?>'
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- 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 '(',_BACK,') ';
- echo ''._BAN_REMOVED_TITLE.' ';
- echo ""._BAN_REMOVED_TEXT."
";
-
- echo "";
- foreach ($deleted as $delblog) {
- $b =& $manager->getBlog($delblog);
- echo "" . htmlspecialchars($b->getName()). " ";
- }
- echo " ";
-
- $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();
- ?>
-
-
-
-
-
-
-
-
-
-
- An example : "134.58.253.193" will only block one computer, while "134.58.253" will block 256 IP addresses, including the one from the first example.
-
-
-
-
-
-
- Custom:
- ";
- echo " ";
- }
- ?>
-
-
-
-
-
-
-
-
- 'getName())?>'
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- 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 '(',_BACKTOMANAGE,')
';
- ?>
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_backupcreate() {
- global $member, $DIR_LIBS;
-
- $member->isAdmin() or $this->disallow();
-
- // use compression ?
- $useGzip = intval(postVar('gzip'));
-
- include($DIR_LIBS . 'backup.php');
-
- // try to extend time limit
- // (creating/restoring dumps might take a while)
- @set_time_limit(1200);
-
- do_backup($useGzip);
- exit;
- }
-
- /**
- * @todo document this
- */
- 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 = do_restore();
- if ($message != '')
- $this->error($message);
-
- $this->pagehead();
- ?>
-
- pagefoot();
-
- }
-
- /**
- * @todo document this
- */
- function action_pluginlist() {
- global $member, $manager;
-
- // check if allowed
- $member->isAdmin() or $this->disallow();
-
- $this->pagehead();
-
- echo '(',_BACKTOMANAGE,')
';
-
- echo '' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), ' ';
-
- echo '' , _PLUGS_TITLE_INSTALLED , ' ';
-
-
- $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
-
- $template['content'] = 'pluginlist';
- $template['tabindex'] = 10;
- showlist($query, 'table', $template);
-
- ?>
-
-
-
-
-
-
- addTicketHidden() ?>
-
-
-
-
-
- 0) {
- ?>
-
-
-
-
-
-
- addTicketHidden() ?>
-
- ',htmlspecialchars($name),'';
- ?>
-
-
-
-
- ',_PLUGS_NOCANDIDATES,'';
- }
-
- $this->pagefoot();
- }
-
- /**
- * @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 '(',_PLUGS_BACK,')
';
-
- echo '',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),' ';
-
- $plug =& $manager->getPlugin($plugName);
- $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
-
- if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
- @readfile($helpFile);
- } else {
- echo 'Error: ', _ERROR_PLUGNOHELPFILE,'
';
- echo '(',_BACK,')
';
- }
-
-
- $this->pagefoot();
- }
-
- /**
- * @todo document this
- */
- 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 . ' (' . $name . ')');
-
- // get number of currently installed plugins
- $res = sql_query('SELECT * FROM '.sql_table('plugin'));
- $numCurrent = mysql_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.',"'.addslashes($name).'")';
- sql_query($query);
- $iPid = mysql_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 . $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 . $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel());
- }
-
- $pluginList = $plugin->getPluginDep();
- foreach ($pluginList as $pluginName)
- {
-
- $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
- if (mysql_num_rows($res) == 0)
- {
- // uninstall plugin again...
- $this->deleteOnePlugin($plugin->getID());
-
- $this->error(_ERROR_INSREQPLUGIN . $pluginName);
- }
- }
-
- // call the install method of the plugin
- $plugin->install();
-
- $manager->notify(
- 'PostAddPlugin',
- array(
- 'plugin' => &$plugin
- )
- );
-
- // update all events
- $this->action_pluginupdate();
- }
-
- /**
- * @todo document this
- */
- function action_pluginupdate() {
- global $member, $manager;
-
- // 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 = mysql_fetch_object($res)) {
- $pid = $o->pid;
- $plug =& $manager->getPlugin($o->pfile);
- if ($plug)
- {
- $eventList = $plug->getEventList();
- foreach ($eventList as $eventName)
- sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
- }
- }
-
- $this->action_pluginlist();
- }
-
- /**
- * @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();
- ?>
-
-
- ?
-
-
- addTicketHidden() ?>
-
-
-
-
- pagefoot();
- }
-
- /**
- * @todo document this
- */
- function action_plugindeleteconfirm() {
- global $member, $manager;
-
- // check if allowed
- $member->isAdmin() or $this->disallow();
-
- $pid = intPostVar('plugid');
-
- $error = $this->deleteOnePlugin($pid, 1);
- if ($error) {
- $this->error($error);
- }
-
- $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 = mysql_fetch_object($res)) {
- $plug =& $manager->getPlugin($o->pfile);
- if ($plug)
- {
- $depList = $plug->getPluginDep();
- foreach ($depList as $depName)
- {
- if ($name == $depName)
- {
- return _ERROR_DELREQPLUGIN . $o->pfile;
- }
- }
- }
- }
-
- $manager->notify('PreDeletePlugin', array('plugid' => $pid));
-
- // 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 = mysql_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 = mysql_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;
-
- // 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 = mysql_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();
- }
-
- /**
- * @todo document this
- */
- function action_plugindown() {
- global $member, $manager;
-
- // 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 = mysql_fetch_object($res);
- $oldOrder = $o->porder;
-
- $res = sql_query('SELECT * FROM '.sql_table('plugin'));
- $maxOrder = mysql_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();
- }
-
- /**
- * @todo document this
- */
- function action_pluginoptions($message = '') {
- global $member, $manager;
-
- // check if allowed
- $member->isAdmin() or $this->disallow();
-
- $pid = intRequestVar('plugid');
- if (!$manager->pidInstalled($pid))
- $this->error(_ERROR_NOSUCHPLUGIN);
-
- $extrahead = '';
- $this->pagehead($extrahead);
-
- ?>
- ()
-
- Options for
-
-
-
-
-
-
-
-
- addTicketHidden();
-
- $aOptions = array();
- $aOIDs = array();
- $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
- $r = sql_query($query);
- while ($o = mysql_fetch_object($r)) {
- array_push($aOIDs, $o->oid);
- $aOptions[$o->oid] = array(
- 'oid' => $o->oid,
- 'value' => $o->odef,
- 'name' => $o->oname,
- 'description' => $o->odesc,
- 'type' => $o->otype,
- 'typeinfo' => $o->oextra,
- 'contextid' => 0
- );
- }
- // fill out actual values
- if (count($aOIDs) > 0) {
- $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
- while ($o = mysql_fetch_object($r))
- $aOptions[$o->oid]['value'] = $o->ovalue;
- }
-
- // call plugins
- $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
-
- $template['content'] = 'plugoptionlist';
- $amount = showlist($aOptions,'table',$template);
- if ($amount == 0)
- echo '
',_ERROR_NOPLUGOPTIONS,'
';
-
- ?>
-
-
- pagefoot();
-
-
-
- }
-
- /**
- * @todo document this
- */
- function action_pluginoptionsupdate() {
- global $member, $manager;
-
- // check if allowed
- $member->isAdmin() or $this->disallow();
-
- $pid = intRequestVar('plugid');
- if (!$manager->pidInstalled($pid))
- $this->error(_ERROR_NOSUCHPLUGIN);
-
- $aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
-
- $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
-
- $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
- }
-
- /**
- * @static
- * @todo document this
- */
- 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 ($o = mysql_fetch_object($res)) {
- $aIdToValue[$o->oid] = $o->ovalue;
- }
-
- // get list of oids per pid
- $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
- . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
- $res = sql_query($query);
- $aOptions = array();
- while ($o = mysql_fetch_object($res)) {
- if (in_array($o->oid, array_keys($aIdToValue)))
- $value = $aIdToValue[$o->oid];
- else
- $value = $o->odef;
-
- array_push($aOptions, array(
- 'pid' => $o->pid,
- 'pfile' => $o->pfile,
- 'oid' => $o->oid,
- 'value' => $value,
- 'name' => $o->oname,
- 'description' => $o->odesc,
- 'type' => $o->otype,
- 'typeinfo' => $o->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'];
-
- echo ' Options for ', htmlspecialchars($aOption['pfile']),' ';
- }
-
- echo '';
- listplug_plugOptionRow($aOption);
- echo ' ';
-
- }
-
-
- }
-
- /**
- * Helper functions to create option forms etc.
- * @todo document parameters
- */
- function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
- $id = htmlspecialchars($name);
- $id = str_replace('[','-',$id);
- $id = str_replace(']','-',$id);
- $id1 = $id . htmlspecialchars($value1);
- $id2 = $id . htmlspecialchars($value2);
-
- if ($name=="admin") {
- echo '' . $yesval . ' ';
- echo ' ';
- if ($name=="admin") {
- echo '' . $noval . ' ';
- }
-
-} // class ADMIN
-
-?>
+ action_xxxx method)
+ */
+ var $action;
+
+ /**
+ * Class constructor
+ */
+ function ADMIN() {
+
+ }
+
+ /**
+ * Executes an action
+ *
+ * @param string $action action to be performed
+ */
+ function action($action) {
+ global $CONF, $manager;
+
+ // list of action aliases
+ $alias = array(
+ 'login' => 'overview',
+ '' => 'overview'
+ );
+
+ 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'
+ );
+/*
+ // 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');
+*/
+ if (!in_array($this->action, $aActionsNotToCheck))
+ {
+ if (!$manager->checkTicket())
+ $this->error(_ERROR_BADTICKET);
+ }
+
+ if (method_exists($this, $methodName))
+ call_user_func(array(&$this, $methodName));
+ else
+ $this->error(_BADACTION . htmlspecialchars(" ($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->pagehead();
+
+ echo '', _LOGIN ,' ';
+ if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pagefoot();
+ }
+
+
+ /**
+ * provides a screen with the overview of the actions available
+ * @todo document parameter
+ */
+ function action_overview($msg = '') {
+ global $member;
+
+ $this->pagehead();
+
+ if ($msg)
+ echo _MESSAGE , ': ', $msg;
+
+ /* ---- add items ---- */
+ echo '' . _OVERVIEW_YRBLOGS . ' ';
+
+ $showAll = requestVar('showall');
+
+ if (($member->isAdmin()) && ($showAll == 'yes')) {
+ // Super-Admins have access to all blogs! (no add item support though)
+ $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
+ . ' FROM ' . sql_table('blog')
+ . ' ORDER BY bname';
+ } else {
+ $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
+ . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
+ . ' WHERE tblog=bnumber and tmember=' . $member->getID()
+ . ' ORDER BY bname';
+ }
+ $template['content'] = 'bloglist';
+ $template['superadmin'] = $member->isAdmin();
+ $amount = showlist($query,'table',$template);
+
+ if (($showAll != 'yes') && ($member->isAdmin())) {
+ $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
+ if ($total > $amount)
+ echo '' . _OVERVIEW_SHOWALL . '
';
+ }
+
+ if ($amount == 0)
+ echo _OVERVIEW_NOBLOGS;
+
+ if ($amount != 0) {
+ echo '' . _OVERVIEW_YRDRAFTS . ' ';
+ $query = 'SELECT ititle, inumber, bshortname'
+ . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
+ . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
+ $template['content'] = 'draftlist';
+ $amountdrafts = showlist($query, 'table', $template);
+ if ($amountdrafts == 0)
+ echo _OVERVIEW_NODRAFTS;
+ }
+
+ /* ---- user settings ---- */
+ echo '' . _OVERVIEW_YRSETTINGS . ' ';
+ echo '';
+
+ /* ---- general settings ---- */
+ if ($member->isAdmin()) {
+ echo '' . _OVERVIEW_MANAGEMENT. ' ';
+ echo '';
+ }
+
+
+ $this->pagefoot();
+ }
+
+ /**
+ * Returns a link to a weblog
+ * @param object BLOG
+ */
+ function bloglink(&$blog) {
+ return ''. htmlspecialchars( $blog->getName() ) .' ';
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_manage($msg = '') {
+ global $member;
+
+ $member->isAdmin() or $this->disallow();
+
+ $this->pagehead();
+
+ echo '(',_BACKHOME,')
';
+
+ if ($msg)
+ echo '' , _MESSAGE , ': ', $msg , '
';
+
+
+ echo '' . _MANAGE_GENERAL. ' ';
+
+ echo '';
+
+ echo '' . _MANAGE_SKINS . ' ';
+ echo '';
+
+ echo '' . _MANAGE_EXTRA . ' ';
+ echo '';
+
+ $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();
+ $blog =& $manager->getBlog($blogid);
+
+ echo '(',_BACKHOME,')
';
+ echo '' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . ' ';
+
+ // start index
+ if (postVar('start'))
+ $start = intPostVar('start');
+ else
+ $start = 0;
+
+ if ($start == 0)
+ echo '',_ITEMLIST_ADDNEW,'
';
+
+ // amount of items to show
+ if (postVar('amount'))
+ $amount = intPostVar('amount');
+ else {
+ $amount = intval($CONF['DefaultListSize']);
+ if ($amount < 1)
+ $amount = 10;
+ }
+
+ $search = postVar('search'); // search through items
+
+ $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime, bnumber, catid'
+ . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
+ . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
+
+ if ($search)
+ $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
+
+ // non-blog-admins can only edit/delete their own items
+ if (!$member->blogAdminRights($blogid))
+ $query .= ' and iauthor=' . $member->getID();
+
+
+ $query .= ' ORDER BY itime DESC'
+ . " LIMIT $start,$amount";
+
+ $template['content'] = 'itemlist';
+ $template['now'] = $blog->getCorrectTime(time());
+
+ $manager->loadClass("ENCAPSULATE");
+ $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+ $navList->showBatchList('item',$query,'table',$template);
+
+
+ $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();
+
+ echo '(',_BACKHOME,') ';
+ echo '',_BATCH_ITEMS,' ';
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
+ echo '';
+
+
+ // walk over all itemids and perform action
+ foreach ($selected as $itemid) {
+ $itemid = intval($itemid);
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONITEM,' ', $itemid, ' ...';
+
+ // perform action, display errors if needed
+ switch($action) {
+ case 'delete':
+ $error = $this->deleteOneItem($itemid);
+ break;
+ case 'move':
+ $error = $this->moveOneItem($itemid, $destCatid);
+ break;
+ default:
+ $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+ }
+
+ echo '',($error ? $error : _BATCH_SUCCESS),' ';
+ echo ' ';
+ }
+
+ echo ' ';
+ echo '',_BATCH_DONE,' ';
+
+ $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();
+
+ echo '(',_BACKHOME,') ';
+ echo '',_BATCH_COMMENTS,' ';
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
+ echo '';
+
+ // walk over all itemids and perform action
+ foreach ($selected as $commentid) {
+ $commentid = intval($commentid);
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONCOMMENT,' ', $commentid, ' ...';
+
+ // perform action, display errors if needed
+ switch($action) {
+ case 'delete':
+ $error = $this->deleteOneComment($commentid);
+ break;
+ default:
+ $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+ }
+
+ echo '',($error ? $error : _BATCH_SUCCESS),' ';
+ echo ' ';
+ }
+
+ echo ' ';
+ echo '',_BATCH_DONE,' ';
+
+ $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();
+
+ echo '(',_MEMBERS_BACKTOOVERVIEW,') ';
+ echo '',_BATCH_MEMBERS,' ';
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
+ echo '';
+
+ // walk over all itemids and perform action
+ foreach ($selected as $memberid) {
+ $memberid = intval($memberid);
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONMEMBER,' ', $memberid, ' ...';
+
+ // perform action, display errors if needed
+ switch($action) {
+ case 'delete':
+ $error = $this->deleteOneMember($memberid);
+ break;
+ case 'setadmin':
+ // always succeeds
+ sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
+ $error = '';
+ break;
+ case 'unsetadmin':
+ // there should always remain at least one super-admin
+ $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
+ if (sql_num_rows($r) < 2)
+ $error = _ERROR_ATLEASTONEADMIN;
+ else
+ sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
+ break;
+ default:
+ $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+ }
+
+ echo '',($error ? $error : _BATCH_SUCCESS),' ';
+ echo ' ';
+ }
+
+ echo ' ';
+ echo '',_BATCH_DONE,' ';
+
+ $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();
+
+ echo '(',_BACK,')
';
+
+ echo '',_BATCH_TEAM,' ';
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
+ echo '';
+
+ // walk over all itemids and perform action
+ foreach ($selected as $memberid) {
+ $memberid = intval($memberid);
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONTEAM,' ', $memberid, ' ...';
+
+ // perform action, display errors if needed
+ switch($action) {
+ case 'delete':
+ $error = $this->deleteOneTeamMember($blogid, $memberid);
+ break;
+ case 'setadmin':
+ // always succeeds
+ sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
+ $error = '';
+ break;
+ case 'unsetadmin':
+ // there should always remain at least one admin
+ $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
+ if (sql_num_rows($r) < 2)
+ $error = _ERROR_ATLEASTONEBLOGADMIN;
+ else
+ sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
+ break;
+ default:
+ $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+ }
+
+ echo '',($error ? $error : _BATCH_SUCCESS),' ';
+ echo ' ';
+ }
+
+ echo ' ';
+ echo '',_BATCH_DONE,' ';
+
+ $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();
+
+ echo '(',_BACKHOME,') ';
+ echo '',BATCH_CATEGORIES,' ';
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),'
';
+ echo '';
+
+ // walk over all itemids and perform action
+ foreach ($selected as $catid) {
+ $catid = intval($catid);
+ echo '',_BATCH_EXECUTING,' ',htmlspecialchars($action),' ',_BATCH_ONCATEGORY,' ', $catid, ' ...';
+
+ // perform action, display errors if needed
+ switch($action) {
+ case 'delete':
+ $error = $this->deleteOneCategory($catid);
+ break;
+ case 'move':
+ $error = $this->moveOneCategory($catid, $destBlogId);
+ break;
+ default:
+ $error = _BATCH_UNKNOWN . htmlspecialchars($action);
+ }
+
+ echo '',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),' ';
+ echo ' ';
+ }
+
+ echo ' ';
+ echo '',_BATCH_DONE,' ';
+
+ $this->pagefoot();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function batchMoveSelectDestination($type, $ids) {
+ global $manager;
+ $this->pagehead();
+ ?>
+
+
+
+
+
+ addTicketHidden();
+
+ // insert selected item numbers
+ $idx = 0;
+ foreach ($ids as $id)
+ echo ' ';
+
+ // show blog/category selection list
+ $this->selectBlogCategory('destcatid');
+
+ ?>
+
+
+
+
+
+ pagefoot();
+ exit;
+ }
+
+ /**
+ * @todo document this
+ */
+ function batchMoveCategorySelectDestination($type, $ids) {
+ global $manager;
+ $this->pagehead();
+ ?>
+
+
+
+
+
+ addTicketHidden();
+
+ // insert selected item numbers
+ $idx = 0;
+ foreach ($ids as $id)
+ echo ' ';
+
+ // show blog/category selection list
+ $this->selectBlog('destblogid');
+
+ ?>
+
+
+
+
+
+ pagefoot();
+ exit;
+ }
+
+ /**
+ * @todo document this
+ */
+ function batchAskDeleteConfirmation($type, $ids) {
+ global $manager;
+
+ $this->pagehead();
+ ?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+ ';
+
+ // add hidden vars for team & comment
+ if ($type == 'team')
+ {
+ echo ' ';
+ }
+ if ($type == 'comment')
+ {
+ echo ' ';
+ }
+
+ ?>
+
+
+
+
+ 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;
+
+ echo '';
+
+ // 1. select blogs (we'll create optiongroups)
+ // (only select those blogs that have the user on the team)
+ $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
+ $blogs = sql_query($queryBlogs);
+ if ($mode == 'category') {
+ if (sql_num_rows($blogs) > 1)
+ $multipleBlogs = 1;
+
+ while ($oBlog = sql_fetch_object($blogs)) {
+ if ($multipleBlogs)
+ echo '';
+
+ // show selection to create new category when allowed/wanted
+ if ($showNewCat) {
+ // check if allowed to do so
+ if ($member->blogAdminRights($oBlog->bnumber))
+ echo '',_ADD_NEWCAT,' ';
+ }
+
+ // 2. for each category in that blog
+ $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
+ while ($oCat = sql_fetch_object($categories)) {
+ if ($oCat->catid == $selected)
+ $selectText = ' selected="selected" ';
+ else
+ $selectText = '';
+ echo '',htmlspecialchars($oCat->cname),' ';
+ }
+
+ if ($multipleBlogs)
+ echo ' ';
+ }
+ } else {
+ // blog mode
+ while ($oBlog = sql_fetch_object($blogs)) {
+ echo 'bnumber == $selected)
+ echo ' selected="selected"';
+ echo'>',htmlspecialchars($oBlog->bname),' ';
+ }
+ }
+ echo ' ';
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_browseownitems() {
+ global $member, $manager, $CONF;
+
+ $this->pagehead();
+
+ echo '(',_BACKHOME,')
';
+ echo '' . _ITEMLIST_YOUR. ' ';
+
+ // start index
+ if (postVar('start'))
+ $start = intPostVar('start');
+ else
+ $start = 0;
+
+ // amount of items to show
+ if (postVar('amount'))
+ $amount = intPostVar('amount');
+ else {
+ $amount = intval($CONF['DefaultListSize']);
+ if ($amount < 1)
+ $amount = 10;
+ }
+
+ $search = postVar('search'); // search through items
+
+ $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
+ . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
+ . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
+
+ if ($search)
+ $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
+
+ $query .= ' ORDER BY itime DESC'
+ . " LIMIT $start,$amount";
+
+ $template['content'] = 'itemlist';
+ $template['now'] = time();
+
+ $manager->loadClass("ENCAPSULATE");
+ $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
+ $navList->showBatchList('item',$query,'table',$template);
+
+ $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');
+
+ // only allow if user is allowed to alter item
+ $member->canAlterItem($itemid) or $this->disallow();
+
+ $blogid = getBlogIdFromItemId($itemid);
+
+ $this->pagehead();
+
+ // start index
+ if (postVar('start'))
+ $start = intPostVar('start');
+ else
+ $start = 0;
+
+ // amount of items to show
+ if (postVar('amount'))
+ $amount = intPostVar('amount');
+ else {
+ $amount = intval($CONF['DefaultListSize']);
+ if ($amount < 1)
+ $amount = 10;
+ }
+
+ $search = postVar('search');
+
+ echo '(',_BACKTOOVERVIEW,' )
';
+ echo '',_COMMENTS,' ';
+
+ $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
+
+ if ($search)
+ $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
+
+ $query .= ' ORDER BY ctime ASC'
+ . " LIMIT $start,$amount";
+
+ $template['content'] = 'commentlist';
+ $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
+
+ $manager->loadClass("ENCAPSULATE");
+ $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
+ $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
+
+ $this->pagefoot();
+ }
+
+ /**
+ * Browse own comments
+ */
+ function action_browseowncomments() {
+ global $member, $manager, $CONF;
+
+ // start index
+ if (postVar('start'))
+ $start = intPostVar('start');
+ else
+ $start = 0;
+
+ // amount of items to show
+ if (postVar('amount'))
+ $amount = intPostVar('amount');
+ else {
+ $amount = intval($CONF['DefaultListSize']);
+ if ($amount < 1)
+ $amount = 10;
+ }
+
+ $search = postVar('search');
+
+
+ $query = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
+
+ if ($search)
+ $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
+
+ $query .= ' ORDER BY ctime DESC'
+ . " LIMIT $start,$amount";
+
+ $this->pagehead();
+
+ echo '(',_BACKHOME,')
';
+ echo '', _COMMENTS_YOUR ,' ';
+
+ $template['content'] = 'commentlist';
+ $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
+
+ $manager->loadClass("ENCAPSULATE");
+ $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
+ $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
+
+ $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();
+
+ // start index
+ if (postVar('start'))
+ $start = intPostVar('start');
+ else
+ $start = 0;
+
+ // amount of items to show
+ if (postVar('amount'))
+ $amount = intPostVar('amount');
+ else {
+ $amount = intval($CONF['DefaultListSize']);
+ if ($amount < 1)
+ $amount = 10;
+ }
+
+ $search = postVar('search'); // search through comments
+
+
+ $query = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
+
+ if ($search != '')
+ $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
+
+
+ $query .= ' ORDER BY ctime DESC'
+ . " LIMIT $start,$amount";
+
+
+ $blog =& $manager->getBlog($blogid);
+
+ $this->pagehead();
+
+ echo '(',_BACKHOME,')
';
+ echo '', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), ' ';
+
+ $template['content'] = 'commentlist';
+ $template['canAddBan'] = $member->blogAdminRights($blogid);
+
+ $manager->loadClass("ENCAPSULATE");
+ $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
+ $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
+
+ $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();
+
+ // generate the add-item form
+ $formfactory =& new PAGEFACTORY($blogid);
+ $formfactory->createAddForm('admin');
+
+ $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));
+
+ $manager->notify('PrepareItemForEdit', array('item' => &$item));
+
+ if ($blog->convertBreaks()) {
+ $item['body'] = removeBreaks($item['body']);
+ $item['more'] = removeBreaks($item['more']);
+ }
+
+ // form to edit blog items
+ $this->pagehead();
+ $formfactory =& new PAGEFACTORY($blog->getID());
+ $formfactory->createEditForm('admin',$item);
+ $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
+ $this->action_itemlist(getBlogIDFromItemID($itemid));
+ }
+ }
+
+ /**
+ * @todo document this
+ */
+ 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);
+
+ $item =& $manager->getItem($itemid,1,1);
+ $title = htmlspecialchars(strip_tags($item['title']));
+ $body = strip_tags($item['body']);
+ $body = htmlspecialchars(shorten($body,300,'...'));
+
+ $this->pagehead();
+ ?>
+
+
+
+
+
+ ""
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @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);
+ }
+
+ /**
+ * Update a blog's future posted flag
+ * @param int $blogid
+ */
+ function updateFuturePosted($blogid) {
+ global $manager;
+
+ $blog =& $manager->getBlog($blogid);
+ $currenttime = $blog->getCorrectTime(time());
+ $result = sql_query("SELECT * FROM ".sql_table('item').
+ " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
+ if (sql_num_rows($result) > 0) {
+ $blog->setFuturePost();
+ }
+ else {
+ $blog->clearFuturePost();
+ }
+ }
+
+ /**
+ * @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();
+
+ $item =& $manager->getItem($itemid,1,1);
+
+ $this->pagehead();
+ ?>
+
+
+
+
+
+ addTicketHidden();
+ $this->selectBlogCategory('catid',$item['catid'],10,1);
+ ?>
+
+
+
+ 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();
+
+ $comment = COMMENT::getComment($commentid);
+
+ $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
+
+ // change to \n
+ $comment['body'] = str_replace(' ','',$comment['body']);
+
+ // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
+ /* original eregi_replace: eregi_replace("[^<]* ", "\\1", $comment['body']) */
+ $comment['body'] = preg_replace("#[^<]* #I", "\\1", $comment['body']);
+
+ $this->pagehead();
+
+ ?>
+
+
+
+
+
+ addTicketHidden(); ?>
+
+
+
+
+ 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 (strlen($body) < 3) {
+ $this->error(_ERROR_COMMENT_NOCOMMENT);
+ }
+ if (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();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_commentdelete() {
+ global $member, $manager;
+
+ $commentid = intRequestVar('commentid');
+
+ $member->canAlterComment($commentid) or $this->disallow();
+
+ $comment = COMMENT::getComment($commentid);
+
+ $body = strip_tags($comment['body']);
+ $body = htmlspecialchars(shorten($body, 300, '...'));
+
+ if ($comment['member'])
+ $author = $comment['member'];
+ else
+ $author = $comment['user'];
+
+ $this->pagehead();
+ ?>
+
+
+
+
+
+
+ :
+
+ :
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @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();
+
+ echo '(',_BACKTOMANAGE,')
';
+
+ echo '' . _MEMBERS_TITLE .' ';
+
+ echo '' . _MEMBERS_CURRENT .' ';
+
+ // show list of members with actions
+ $query = 'SELECT *'
+ . ' FROM '.sql_table('member');
+ $template['content'] = 'memberlist';
+ $template['tabindex'] = 10;
+
+ $manager->loadClass("ENCAPSULATE");
+ $batch =& new BATCH('member');
+ $batch->showlist($query,'table',$template);
+
+ echo '' . _MEMBERS_NEW .' ';
+ ?>
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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();
+
+ // check if allowed
+ ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
+
+ $extrahead = '';
+ $this->pagehead($extrahead);
+
+ // show message to go back to member overview (only for admins)
+ if ($member->isAdmin())
+ echo '(' ._MEMBERS_BACKTOOVERVIEW. ') ';
+ else
+ echo '(' ._BACKHOME. ') ';
+
+ echo '' . _MEMBERS_EDIT . ' ';
+
+ $mem = MEMBER::createFromID($memberid);
+
+ ?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+ isAdmin()) { ?>
+
+ getDisplayName());
+ }
+ ?>
+
+
+
+
+
+ isAdmin()) { ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ isAdmin()) {
+ ?>
+
+
+ input_yesno('admin',$mem->isAdmin(),60); ?>
+
+
+ input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?>
+
+
+
+
+
+
+
+
+
+
+
+ getLanguage() )
+ {
+ echo " selected=\"selected\"";
+ }
+ echo ">$name";
+ }
+ }
+ closedir($dirhandle);
+
+ ?>
+
+
+
+
+
+
+ input_yesno('autosave', $mem->getAutosave(), 87); ?>
+
+ _insertPluginOptions('member',$memberid);
+ ?>
+
+
+
+
+
+
+
+
+
+ ',_PLUGINS_EXTRA,'';
+
+ $manager->notify(
+ 'MemberSettingsFormExtras',
+ array(
+ 'member' => &$mem
+ )
+ );
+
+ $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'));
+
+ # 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'));
+ $deflang = postVar('deflang');
+
+ $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 && (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 (!isValidMailAddress($email))
+ $this->error(_ERROR_BADMAILADDRESS);
+
+
+ if (!$realname)
+ $this->error(_ERROR_REALNAMEMISSING);
+
+ if (($deflang != '') && (!checkLanguage($deflang)))
+ $this->error(_ERROR_NOSUCHLANGUAGE);
+
+ // 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->setLanguage($deflang);
+
+
+ // 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::_applyPluginOptions($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);
+ }
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_memberadd() {
+ global $member, $manager;
+
+ // check if allowed
+ $member->isAdmin() or $this->disallow();
+
+ if (postVar('password') != postVar('repeatpassword'))
+ $this->error(_ERROR_PASSWORDMISMATCH);
+ if (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();
+ }
+
+ /**
+ * 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);
+
+ $text = '';
+ $title = '';
+ $bNeedsPasswordChange = true;
+
+ switch ($info->vtype)
+ {
+ case 'forgot':
+ $title = _ACTIVATE_FORGOT_TITLE;
+ $text = _ACTIVATE_FORGOT_TEXT;
+ break;
+ case 'register':
+ $title = _ACTIVATE_REGISTER_TITLE;
+ $text = _ACTIVATE_REGISTER_TEXT;
+ break;
+ case 'addresschange':
+ $title = _ACTIVATE_CHANGE_TITLE;
+ $text = _ACTIVATE_CHANGE_TEXT;
+ $bNeedsPasswordChange = false;
+ MEMBER::activate($key);
+ break;
+ }
+
+ $aVars = array(
+ 'memberName' => htmlspecialchars($mem->getDisplayName())
+ );
+ $title = TEMPLATE::fill($title, $aVars);
+ $text = TEMPLATE::fill($text, $aVars);
+
+ $this->pagehead();
+
+ echo '' , $title, ' ';
+ echo '' , $text, '
';
+
+ if ($message != '')
+ {
+ echo '',$message,'
';
+ }
+
+ if ($bNeedsPasswordChange)
+ {
+ ?>
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+ 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 && (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();
+ echo '',_ACTIVATE_SUCCESS_TITLE,' ';
+ echo '',_ACTIVATE_SUCCESS_TEXT,'
';
+ $this->pagefoot();
+ }
+
+ /**
+ * Manage team
+ */
+ function action_manageteam() {
+ global $member, $manager;
+
+ $blogid = intRequestVar('blogid');
+
+ // check if allowed
+ $member->blogAdminRights($blogid) or $this->disallow();
+
+ $this->pagehead();
+
+ echo "(",_BACK_TO_BLOGSETTINGS,")
";
+
+ echo '' . _TEAM_TITLE . getBlogNameFromID($blogid) . ' ';
+
+ echo '' . _TEAM_CURRENT . ' ';
+
+
+
+ $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
+ . ' FROM '.sql_table('member').', '.sql_table('team')
+ . ' WHERE tmember=mnumber and tblog=' . $blogid;
+
+ $template['content'] = 'teamlist';
+ $template['tabindex'] = 10;
+
+ $manager->loadClass("ENCAPSULATE");
+ $batch =& new BATCH('team');
+ $batch->showlist($query, 'table', $template);
+
+ ?>
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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();
+ ?>
+
+
+ getDisplayName()) ?> getName())) ?>
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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 = '';
+ $this->pagehead($extrahead);
+
+ echo '(',_BACKHOME,')
';
+ ?>
+ : 'bloglink($blog)?>'
+
+
+
+
+ mname) . ' (' . htmlspecialchars($o->mrealname). ')');
+ echo implode(',', $aMemberNames);
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getDefaultSkin();
+ $template['tabindex'] = 50;
+ showlist($query,'select',$template);
+ ?>
+
+
+
+
+
+ input_yesno('convertbreaks',$blog->convertBreaks(),55); ?>
+
+
+
+ input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?>
+
+
+
+ input_yesno('comments',$blog->commentsEnabled(),60); ?>
+
+
+
+ input_yesno('public',$blog->isPublic(),70); ?>
+
+
+
+ input_yesno('reqemail',$blog->emailRequired(),72); ?>
+
+
+
+
+
+
+ notifyOnComment()) echo "checked='checked'" ?>
+ />
+
+ notifyOnVote()) echo "checked='checked'" ?>
+ />
+
+ notifyOnNewItem()) echo "checked='checked'" ?>
+ />
+
+
+
+
+
+
+
+
+
+
+ getID();
+ $template['name'] = 'defcat';
+ $template['selected'] = $blog->getDefaultCategory();
+ $template['tabindex'] = 110;
+ showlist($query,'select',$template);
+ ?>
+
+
+
+
+ getCorrectTime()); ?>
+
+
+
+
+ input_yesno('searchable',$blog->getSearchable(),122); ?>
+
+ _insertPluginOptions('blog',$blogid);
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ getID().' ORDER BY cname';
+ $template['content'] = 'categorylist';
+ $template['tabindex'] = 200;
+
+ $manager->loadClass("ENCAPSULATE");
+ $batch =& new BATCH('category');
+ $batch->showlist($query,'table',$template);
+
+ ?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+ ',_PLUGINS_EXTRA,'';
+
+ $manager->notify(
+ 'BlogSettingsFormExtras',
+ array(
+ 'blog' => &$blog
+ )
+ );
+
+ $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);
+
+ $member->blogAdminRights($blogid) or $this->disallow();
+
+ $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
+ $obj = sql_fetch_object($res);
+
+ $cname = $obj->cname;
+ $cdesc = $obj->cdesc;
+
+ $extrahead = '';
+ $this->pagehead($extrahead);
+
+ echo "(",_BACK_TO_BLOGSETTINGS,")
";
+
+ ?>
+ ''
+
+
+
+
+
+ addTicketHidden(); ?>
+
+
+
+
+ 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=$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=" . $catid;
+
+ sql_query($query);
+
+ // store plugin options
+ $aOptions = requestArray('plugoption');
+ NucleusPlugin::_applyPluginOptions($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();
+ ?>
+
+
+
+ getCategoryName($catid))?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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();
+ }
+
+ /**
+ * @todo document this
+ */
+ 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::_deleteOptionValues('category', $catid);
+
+ // delete category
+ $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
+ sql_query($query);
+
+ $manager->notify('PostDeleteCategory', array('catid' => $catid));
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function moveOneCategory($catid, $destblogid) {
+ global $manager, $member;
+
+ $catid = intval($catid);
+ $destblogid = intval($destblogid);
+
+ $blogid = getBlogIDFromCatID($catid);
+
+ // mover should have admin rights on both blogs
+ if (!$member->blogAdminRights($blogid))
+ return _ERROR_DISALLOWED;
+ if (!$member->blogAdminRights($destblogid))
+ return _ERROR_DISALLOWED;
+
+ // cannot move to self
+ if ($blogid == $destblogid)
+ return _ERROR_MOVETOSELF;
+
+ // get blogs
+ $blog =& $manager->getBlog($blogid);
+ $destblog =& $manager->getBlog($destblogid);
+
+ // check if the category is valid
+ if (!$blog || !$blog->isValidCategory($catid))
+ return _ERROR_NOSUCHCATEGORY;
+
+ // don't allow default category to be moved
+ if ($blog->getDefaultCategory() == $catid)
+ return _ERROR_MOVEDEFCATEGORY;
+
+ $manager->notify(
+ 'PreMoveCategory',
+ array(
+ 'catid' => &$catid,
+ 'sourceblog' => &$blog,
+ 'destblog' => &$destblog
+ )
+ );
+
+ // update comments table (cblog)
+ $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
+ $items = sql_query($query);
+ while ($oItem = sql_fetch_object($items)) {
+ sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
+ }
+
+ // update items (iblog)
+ $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
+ sql_query($query);
+
+ // move category
+ $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
+ sql_query($query);
+
+ $manager->notify(
+ 'PostMoveCategory',
+ array(
+ 'catid' => &$catid,
+ 'sourceblog' => &$blog,
+ 'destblog' => $destblog
+ )
+ );
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_blogsettingsupdate() {
+ global $member, $manager;
+
+ $blogid = intRequestVar('blogid');
+
+ $member->blogAdminRights($blogid) or $this->disallow();
+
+ $blog =& $manager->getBlog($blogid);
+
+ $notify = 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) {
+ $not =& new NOTIFICATION($notify);
+ if (!$not->validAddresses())
+ $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);
+ $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::_applyPluginOptions($aOptions);
+ $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
+
+
+ $this->action_overview(_MSG_SETTINGSCHANGED);
+ }
+
+ /**
+ * @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();
+ ?>
+
+
+
+
+
+
+ getName())?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ 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::_deleteOptionValues('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);
+ }
+
+ /**
+ * @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();
+ ?>
+
+
+ getDisplayName()) ?>
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ 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);
+ }
+
+ /**
+ * @static
+ * @todo document this
+ */
+ 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 ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
+ .'" WHERE cmember='.$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::_deleteOptionValues('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();
+
+ echo '(',_BACKTOMANAGE,')
';
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ 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));
+// sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
+ $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 ($memberid, $blogid, 1)";
+ sql_query($query);
+
+ $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);
+ //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$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
+ )
+ );
+
+ $this->pagehead();
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+<?php
+
+$CONF['Self'] = '.php ';
+
+include('./config.php ');
+
+selectBlog(' ');
+selector();
+
+?>
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ pagefoot();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_addnewlog2() {
+ global $member, $manager;
+
+ $member->blogAdminRights($blogid) or $this->disallow();
+
+ $burl = requestVar('url');
+ $blogid = intRequestVar('blogid');
+
+ $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();
+
+ echo '(',_BACKTOMANAGE,')
';
+
+ ?>
+
+
+
+ 0) {
+ ?>
+
+
+ addTicketHidden() ?>
+
+
+ $skinfile) {
+ $html = htmlspecialchars($skinfile);
+ echo '',$skinname,' ';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+ sdnumber;
+ echo ' ';
+ echo '',htmlspecialchars($skinObj->sdname),' ';
+ echo '',htmlspecialchars($skinObj->sddesc),' ';
+ echo ' ';
+ }
+
+ echo '',_SKINIE_EXPORT_TEMPLATES,' ';
+
+ // show list of templates
+ $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
+ while ($templateObj = sql_fetch_object($res)) {
+ $id = 'templateexp' . $templateObj->tdnumber;
+ echo ' ';
+ echo '',htmlspecialchars($templateObj->tdname),' ';
+ echo '',htmlspecialchars($templateObj->tddesc),' ';
+ echo ' ';
+ }
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+ 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 '(',_BACK,')
';
+ ?>
+
+
+
+ getInfo())?>
+ '._AND.' ',$importer->getSkinNames())?>
+ '._AND.' ',$importer->getTemplateNames())?>
+
+ '._AND.' ',$skinNameClashes)?>
+ '._AND.' ',$templateNameClashes)?>
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+ 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 '(',_BACKTOMANAGE,')
';
+ ?>
+
+
+
+ getInfo())?>
+ '._AND.' ',$importer->getSkinNames())?>
+ '._AND.' ',$importer->getTemplateNames())?>
+
+
+ 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 '(',_BACKTOMANAGE,')
';
+
+ echo '' . _TEMPLATE_TITLE . ' ';
+ echo '' . _TEMPLATE_AVAILABLE_TITLE . ' ';
+
+ $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
+ $template['content'] = 'templatelist';
+ $template['tabindex'] = 10;
+ showlist($query,'table',$template);
+
+ echo '' . _TEMPLATE_NEW_TITLE . ' ';
+
+ ?>
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_templateedit($msg = '') {
+ global $member, $manager;
+
+ $templateid = intRequestVar('templateid');
+
+ $member->isAdmin() or $this->disallow();
+
+ $extrahead = '';
+ $extrahead .= '';
+
+ $this->pagehead($extrahead);
+
+ $templatename = TEMPLATE::getNameFromId($templateid);
+ $templatedescription = TEMPLATE::getDesc($templateid);
+ $template =& $manager->getTemplate($templatename);
+
+ ?>
+
+ ()
+
+
+ ''
+
+ "._MESSAGE.": $msg";
+ ?>
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+_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);
+?>
+
+
+_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);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
+ $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
+ $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
+ $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
+ $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
+ $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
+ $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
+?>
+
+
+_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);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
+ $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
+ $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
+?>
+
+
+_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
+ $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
+?>
+
+
+notify('TemplateExtraFields',array('fields'=>&$pluginfields));
+
+ foreach ($pluginfields as $pfkey=>$pfvalue) {
+ echo " \n";
+ echo ''.htmlentities($pfkey)." \n";
+ foreach ($pfvalue as $pffield=>$pfdesc) {
+ $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
+ }
+ }
+?>
+
+
+
+
+
+
+
+
+
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
+ static $count = 1;
+ if (!isset($template[$name])) $template[$name] = '';
+ ?>
+
+
+
+ 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);
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function addToTemplate($id, $partname, $content) {
+ $partname = sql_real_escape_string($partname);
+ $content = sql_real_escape_string($content);
+
+ $id = intval($id);
+
+ // don't add empty parts:
+ if (!trim($content)) return -1;
+
+ $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
+ . "VALUES ($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);
+
+ ?>
+
+
+
+ ()
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ 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 '(',_BACKTOMANAGE,')
';
+
+ echo '' . _SKIN_EDIT_TITLE . ' ';
+
+ echo '' . _SKIN_AVAILABLE_TITLE . ' ';
+
+ $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
+ $template['content'] = 'skinlist';
+ $template['tabindex'] = 10;
+ showlist($query,'table',$template);
+
+ echo '' . _SKIN_NEW_TITLE . ' ';
+
+ ?>
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ 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();
+ ?>
+
+ ()
+
+ 'getName() ?>'
+
+
+
+
+
+ ' . _SKIN_PARTS_SPECIAL . '';
+ echo '' . "\r\n";
+ echo ' ' . "\r\n";
+ echo ' ' . "\r\n";
+ echo ' ' . "\r\n";
+ echo ' ' . "\r\n";
+ echo ' ' . "\r\n";
+
+ if ($res && sql_num_rows($res) > 0) {
+ echo '';
+ }
+
+ ?>
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+ 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();
+ ?>
+ ( )
+
+ 'getName()) ?>':
+
+ "._MESSAGE.": $msg";
+ ?>
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ (skin type: )
+
+
+
+ getContent($type)) ?>
+
+
+
+
+ (skin type: )
+
+
+
+ ";
+ if (count($actions) != 0) echo ", ";
+ }
+ echo ' ' . _SKINEDIT_ALLOWEDBLOGS;
+ $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
+ showlist($query,'table',array('content'=>'shortblognames'));
+ echo ' ' . _SKINEDIT_ALLOWEDTEMPLATESS;
+ $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
+ showlist($query,'table',array('content'=>'shortnames'));
+ echo '
';
+ $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 . htmlspecialchars($o->bname));
+
+ $this->pagehead();
+
+ $skin =& new SKIN($skinid);
+ $name = $skin->getName();
+ $desc = $skin->getDescription();
+
+ ?>
+
+
+
+ ()
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+ 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();
+
+ ?>
+
+
+
+ () ()
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function skinclonetype($skin, $newid, $type) {
+ $newid = intval($newid);
+ $content = $skin->getContent($type);
+ if ($content) {
+ $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
+ sql_query($query);
+ }
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_settingsedit() {
+ global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
+
+ $member->isAdmin() or $this->disallow();
+
+ $this->pagehead();
+
+ echo '(',_BACKTOMANAGE,')
';
+ ?>
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $name";
+ }
+ }
+ closedir($dirhandle);
+
+ ?>
+
+
+
+
+
+
+ input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
+
+ ",_SETTINGS_JSTOOLBAR_NONE,"";
+ $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
+ echo "",_SETTINGS_JSTOOLBAR_SIMPLE," ";
+ $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
+ echo "",_SETTINGS_JSTOOLBAR_FULL," ";
+ ?>
+
+
+
+
+ input_yesno('URLMode',$CONF['URLMode'],10077,
+ 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
+
+ echo ' ', _SETTINGS_URLMODE_HELP;
+
+ ?>
+
+
+
+
+ input_yesno('DebugVars',$CONF['DebugVars'],10078);
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ " . _WARNING_NOTADIR . " ";
+ if (!is_readable($DIR_MEDIA))
+ echo "" . _WARNING_NOTREADABLE . " ";
+ if (!is_writeable($DIR_MEDIA))
+ echo "" . _WARNING_NOTWRITABLE . " ";
+ ?>
+
+
+
+
+
+
+
+
+ input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?>
+
+
+
+
+
+ input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?>
+
+
+
+
+ input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
+
+
+
+
+
+ input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
+
+
+
+
+
+ input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
+
+
+
+
+
+ input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
+
+
+
+
+
+ input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?>
+
+
+ input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
+ 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
+
+
+
+ input_yesno('LastVisit',$CONF['LastVisit'],10200); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ',_PLUGINS_EXTRA,'';
+
+ $manager->notify(
+ 'GeneralSettingsFormExtras',
+ array()
+ );
+
+ $this->pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_settingsupdate() {
+ global $member, $CONF;
+
+ $member->isAdmin() or $this->disallow();
+
+ // check if email address for admin is valid
+ if (!isValidMailAddress(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('Language', postVar('Language'));
+ $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'));
+
+ // load new config and redirect (this way, the new language 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;
+
+ }
+
+ /**
+ * Give an overview over the used system
+ */
+ function action_systemoverview() {
+ global $member, $nucleus, $CONF;
+
+ $this->pagehead();
+
+ echo '' . _ADMIN_SYSTEMOVERVIEW_HEADING . " \n";
+
+ if ($member->isLoggedIn() && $member->isAdmin()) {
+
+ // Information about the used PHP and MySQL installation
+ echo '' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . " \n";
+
+ // Version of PHP MySQL
+ echo "\n";
+ echo "\t\n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . " \n";
+ echo "\t\t" . '' . phpversion() . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . " \n";
+ echo "\t\t" . '' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . " \n";
+ echo "\t ";
+ echo "
\n";
+
+ // Important PHP settings
+ echo "\n";
+ echo "\t\n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . " \n";
+ echo "\t \n";
+ echo "\t\t" . 'magic_quotes_gpc' . " \n";
+ $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
+ echo "\t\t" . '' . $mqg . " \n";
+ echo "\t \n";
+ echo "\t\t" . 'magic_quotes_runtime' . " \n";
+ $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
+ echo "\t\t" . '' . $mqr . " \n";
+ echo "\t \n";
+ echo "\t\t" . 'register_globals' . " \n";
+ $rg = ini_get('register_globals') ? 'On' : 'Off';
+ echo "\t\t" . '' . $rg . " \n";
+ echo "\t ";
+ echo "
\n";
+
+ // Information about GD library
+ $gdinfo = gd_info();
+ echo "\n";
+ echo "\t";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . " \n";
+ echo "\t \n";
+ foreach ($gdinfo as $key=>$value) {
+ if (is_bool($value)) {
+ $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
+ } else {
+ $value = htmlspecialchars($value, ENT_QUOTES);
+ }
+ echo "\t";
+ echo "\t\t" . '' . $key . " \n";
+ echo "\t\t" . '' . $value . " \n";
+ echo "\t \n";
+ }
+ echo "
\n";
+
+ // Check if special modules are loaded
+ ob_start();
+ phpinfo(INFO_MODULES);
+ $im = ob_get_contents();
+ ob_clean();
+ echo "\n";
+ echo "\t";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_MODULES . " \n";
+ echo "\t \n";
+ echo "\t\t" . 'mod_rewrite' . " \n";
+ $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
+ _ADMIN_SYSTEMOVERVIEW_ENABLE :
+ _ADMIN_SYSTEMOVERVIEW_DISABLE;
+ echo "\t\t" . '' . $modrewrite . " \n";
+ echo "\t \n";
+ echo "
\n";
+
+ // Information about the used Nucleus CMS
+ echo '' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . " \n";
+ global $nucleus;
+ $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
+ $np = getNucleusPatchLevel();
+ echo "\n";
+ echo "\t";
+ echo "\t\t" . 'Nucleus CMS' . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . " \n";
+ echo "\t\t" . '' . $nv . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . " \n";
+ echo "\t\t" . '' . $np . " \n";
+ echo "\t \n";
+ echo "
\n";
+
+ // Important settings of the installation
+ echo "\n";
+ echo "\t";
+ echo "\t\t" . '' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . '$CONF[' . "'Self'] \n";
+ echo "\t\t" . '' . $CONF['Self'] . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . '$CONF[' . "'ItemURL'] \n";
+ echo "\t\t" . '' . $CONF['ItemURL'] . " \n";
+ echo "\t \n";
+ echo "\t\t" . '' . '$CONF[' . "'alertOnHeadersSent'] \n";
+ $ohs = $CONF['alertOnHeadersSent'] ?
+ _ADMIN_SYSTEMOVERVIEW_ENABLE :
+ _ADMIN_SYSTEMOVERVIEW_DISABLE;
+ echo "\t\t" . '' . $ohs . " \n";
+ echo "\t \n";
+ echo "
\n";
+
+ // Link to the online version test at the Nucleus CMS website
+ echo '' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . " \n";
+ if ($nucleus['codename'] != '') {
+ $codenamestring = ' "' . $nucleus['codename'] . '"';
+ } else {
+ $codenamestring = '';
+ }
+ echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
+ $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
+ echo '';
+ echo 'Nucleus CMS ' . $nv . $codenamestring;
+ echo ' ';
+ //echo ' ';
+ }
+ else {
+ echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
+ }
+
+ $this->pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ function updateConfig($name, $val) {
+ $name = sql_real_escape_string($name);
+ $val = trim(sql_real_escape_string($val));
+
+ $query = 'UPDATE '.sql_table('config')
+ . " SET value='$val'"
+ . " WHERE name='$name'";
+
+ sql_query($query) or die(_ADMIN_SQLDIE_QUERYERROR . sql_error());
+ return sql_insert_id();
+ }
+
+ /**
+ * Error message
+ * @param string $msg message that will be shown
+ */
+ function error($msg) {
+ $this->pagehead();
+ ?>
+ Error!
+ ";
+ echo ""._BACK." ";
+ $this->pagefoot();
+ exit;
+ }
+
+ /**
+ * @todo document this
+ */
+ function disallow() {
+ ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
+
+ $this->error(_ERROR_DISALLOWED);
+ }
+
+ /**
+ * @todo document this
+ */
+ function pagehead($extrahead = '') {
+ global $member, $nucleus, $CONF, $manager;
+
+ $manager->notify(
+ 'AdminPrePageHead',
+ array(
+ 'extrahead' => &$extrahead,
+ 'action' => $this->action
+ )
+ );
+
+ $baseUrl = htmlspecialchars($CONF['AdminURL']);
+
+ ?>
+
+ >
+
+
+ - Admin
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ isLoggedIn())
+ echo _LOGGEDINAS . ' ' . $member->getDisplayName()
+ ." -
" . _LOGOUT. " "
+ . "
" . _ADMINHOME . " - ";
+ else
+ echo '
' , _NOTLOGGEDIN , ' ';
+
+ echo "
"._YOURSITE." ";
+
+ echo '
(';
+
+ $codenamestring = ($nucleus['codename']!='')? ' "'.$nucleus['codename'].'"':'';
+
+ if ($member->isLoggedIn() && $member->isAdmin()) {
+ $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
+ echo '
Nucleus CMS ' . $nucleus['version'] . $codenamestring . ' ';
+ $newestVersion = getLatestVersion();
+ $newestCompare = str_replace('/','.',$newestVersion);
+ $newestCompare = intval($newestCompare);
+ $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
+ if ($newestVersion && version_compare($newestCompare,$currentVersion) > 0) {
+ echo '
'._ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT.$newestVersion.' ';
+ }
+ } else {
+ echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
+ }
+ echo ')';
+ echo '
';
+ }
+
+ /**
+ * @todo document this
+ */
+ function pagefoot() {
+ global $action, $member, $manager;
+
+ $manager->notify(
+ 'AdminPrePageFoot',
+ array(
+ 'action' => $this->action
+ )
+ );
+
+ if ($member->isLoggedIn() && ($action != 'showlogin')) {
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ teamRights($blogid) or $this->disallow();
+
+ // header-code stolen from phpMyAdmin
+ // REGEDIT and bookmarklet code stolen from GreyMatter
+
+ $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
+ $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
+
+ 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 '(',_BACKHOME,')
';
+
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+ ' . sprintf(_BOOKMARKLET_ANCHOR, htmlspecialchars($blog->getName(), ENT_QUOTES)) . '' . _BOOKMARKLET_BMARKFOLLOW; ?>
+
+
+
+
+ addTicketToUrl($url);
+ ?>
+ ' . _BOOKMARKLET_RIGHTLABEL . '' . _BOOKMARKLET_RIGHTTEXT2; ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pagefoot();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_actionlog() {
+ global $member, $manager;
+
+ $member->isAdmin() or $this->disallow();
+
+ $this->pagehead();
+
+ echo '(',_BACKTOMANAGE,')
';
+
+ $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
+
+ ?>
+
+
+ ' . _ACTIONLOG_TITLE . '';
+
+ $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 '(',_BACKHOME,')
';
+
+ echo '' . _BAN_TITLE . " '". $this->bloglink($blog) ."' ";
+
+ $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 ''._BAN_NEW_TITLE.' ';
+ echo ""._BAN_NEW_TEXT."
";
+
+
+ $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 = htmlspecialchars($blog->getName(), ENT_QUOTES);
+
+ $this->pagehead();
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ 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 '(',_BACK,') ';
+ echo ''._BAN_REMOVED_TITLE.' ';
+ echo ""._BAN_REMOVED_TEXT."
";
+
+ echo "";
+ foreach ($deleted as $delblog) {
+ $b =& $manager->getBlog($delblog);
+ echo "" . htmlspecialchars($b->getName()). " ";
+ }
+ echo " ";
+
+ $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();
+ ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ";
+ echo " ";
+ }
+ ?>
+
+
+
+
+
+
+
+
+ 'getName())?>'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ 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 '(',_BACKTOMANAGE,')
';
+ ?>
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+
+
+ pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_backupcreate() {
+ global $member, $DIR_LIBS;
+
+ $member->isAdmin() or $this->disallow();
+
+ // use compression ?
+ $useGzip = intval(postVar('gzip'));
+
+ include($DIR_LIBS . 'backup.php');
+
+ // try to extend time limit
+ // (creating/restoring dumps might take a while)
+ @set_time_limit(1200);
+
+ $bu = new Backup();
+ $bu->do_backup($useGzip);
+ exit;
+ }
+
+ /**
+ * @todo document this
+ */
+ 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);
+
+ $bu = new Backup();
+ $message = $bu->do_restore();
+ if ($message != '')
+ $this->error($message);
+
+ $this->pagehead();
+ ?>
+
+ pagefoot();
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_pluginlist() {
+ global $member, $manager;
+
+ // check if allowed
+ $member->isAdmin() or $this->disallow();
+
+ $this->pagehead();
+
+ echo '(',_BACKTOMANAGE,')
';
+
+ echo '' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), ' ';
+
+ echo '' , _PLUGS_TITLE_INSTALLED , ' ', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, ' ';
+
+
+ $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
+
+ $template['content'] = 'pluginlist';
+ $template['tabindex'] = 10;
+ showlist($query, 'table', $template);
+
+ ?>
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+
+
+
+
+ 0)
+ {
+ ?>
+
+
+
+
+
+
+ addTicketHidden() ?>
+
+ ',htmlspecialchars($name),'';
+ }
+ ?>
+
+
+
+
+ ',_PLUGS_NOCANDIDATES,'';
+ }
+
+ $this->pagefoot();
+ }
+
+ /**
+ * @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 '(',_PLUGS_BACK,')
';
+
+ echo '',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),' ';
+
+ $plug =& $manager->getPlugin($plugName);
+ $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
+
+ if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
+ @readfile($helpFile);
+ } else {
+ echo 'Error: ', _ERROR_PLUGNOHELPFILE,'
';
+ echo '(',_BACK,')
';
+ }
+
+
+ $this->pagefoot();
+ }
+
+ /**
+ * @todo document this
+ */
+ 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 . ' (' . htmlspecialchars($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 . htmlspecialchars($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 . htmlspecialchars( $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, htmlspecialchars($pluginName, ENT_QUOTES)));
+ }
+ }
+
+ // call the install method of the plugin
+ $plugin->install();
+
+ $manager->notify(
+ 'PostAddPlugin',
+ array(
+ 'plugin' => &$plugin
+ )
+ );
+
+ // update all events
+ $this->action_pluginupdate();
+ }
+
+ /**
+ * @todo document this
+ */
+ 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)
+ sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
+ }
+ }
+
+ redirect($CONF['AdminURL'] . '?action=pluginlist');
+// $this->action_pluginlist();
+ }
+
+ /**
+ * @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();
+ ?>
+
+
+ ?
+
+
+ addTicketHidden() ?>
+
+
+
+
+ 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');
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_pluginoptions($message = '') {
+ global $member, $manager;
+
+ // check if allowed
+ $member->isAdmin() or $this->disallow();
+
+ $pid = intRequestVar('plugid');
+ if (!$manager->pidInstalled($pid))
+ $this->error(_ERROR_NOSUCHPLUGIN);
+
+ $extrahead = '';
+ $pluginName = htmlspecialchars(getPluginNameFromPid($pid), ENT_QUOTES);
+ $this->pagehead($extrahead);
+
+ ?>
+ ()
+
+
+
+
+
+
+
+
+
+
+ addTicketHidden();
+
+ $aOptions = array();
+ $aOIDs = array();
+ $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
+ $r = sql_query($query);
+ while ($o = sql_fetch_object($r)) {
+ array_push($aOIDs, $o->oid);
+ $aOptions[$o->oid] = array(
+ 'oid' => $o->oid,
+ 'value' => $o->odef,
+ 'name' => $o->oname,
+ 'description' => $o->odesc,
+ 'type' => $o->otype,
+ 'typeinfo' => $o->oextra,
+ 'contextid' => 0
+ );
+ }
+ // fill out actual values
+ if (count($aOIDs) > 0) {
+ $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
+ while ($o = sql_fetch_object($r))
+ $aOptions[$o->oid]['value'] = $o->ovalue;
+ }
+
+ // call plugins
+ $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
+
+ $template['content'] = 'plugoptionlist';
+ $amount = showlist($aOptions,'table',$template);
+ if ($amount == 0)
+ echo '
',_ERROR_NOPLUGOPTIONS,'
';
+
+ ?>
+
+
+ pagefoot();
+
+
+
+ }
+
+ /**
+ * @todo document this
+ */
+ function action_pluginoptionsupdate() {
+ global $member, $manager;
+
+ // check if allowed
+ $member->isAdmin() or $this->disallow();
+
+ $pid = intRequestVar('plugid');
+ if (!$manager->pidInstalled($pid))
+ $this->error(_ERROR_NOSUCHPLUGIN);
+
+ $aOptions = requestArray('plugoption');
+ NucleusPlugin::_applyPluginOptions($aOptions);
+
+ $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
+
+ $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
+ }
+
+ /**
+ * @static
+ * @todo document this
+ */
+ 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 ($o = sql_fetch_object($res)) {
+ $aIdToValue[$o->oid] = $o->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 ($o = sql_fetch_object($res)) {
+ if (in_array($o->oid, array_keys($aIdToValue)))
+ $value = $aIdToValue[$o->oid];
+ else
+ $value = $o->odef;
+
+ array_push($aOptions, array(
+ 'pid' => $o->pid,
+ 'pfile' => $o->pfile,
+ 'oid' => $o->oid,
+ 'value' => $value,
+ 'name' => $o->oname,
+ 'description' => $o->odesc,
+ 'type' => $o->otype,
+ 'typeinfo' => $o->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 ' '.sprintf(_PLUGIN_OPTIONS_TITLE, htmlspecialchars($aOption['pfile'], ENT_QUOTES)).' ';
+ }
+
+ $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
+ if (@$meta['access'] != 'hidden') {
+ echo '';
+ listplug_plugOptionRow($aOption);
+ echo ' ';
+ }
+ }
+ }
+
+ /**
+ * Helper functions to create option forms etc.
+ * @todo document parameters
+ */
+ function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
+ $id = htmlspecialchars($name);
+ $id = str_replace('[','-',$id);
+ $id = str_replace(']','-',$id);
+ $id1 = $id . htmlspecialchars($value1);
+ $id2 = $id . htmlspecialchars($value2);
+
+ if ($name=="admin") {
+ echo '' . $yesval . ' ';
+ echo ' ';
+ if ($name=="admin") {
+ echo '' . $noval . ' ';
+ }
+
+} // class ADMIN
+
+?>
\ No newline at end of file