3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * The code for the Nucleus admin area
15 * @license http://nucleuscms.org/license.txt GNU General Public License
16 * @copyright Copyright (C) 2002-2009 The Nucleus Group
17 * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
29 private $xml_version_info = '1.0';
30 private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
31 private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
32 private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
35 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
49 * @param string $action action to be performed
51 function action($action) {
52 global $CONF, $manager;
54 // list of action aliases
56 'login' => 'overview',
60 if (isset($alias[$action]))
61 $action = $alias[$action];
63 $methodName = 'action_' . $action;
65 $this->action = strtolower($action);
67 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
68 // is an action that requires user interaction before something is actually done)
69 // all safe actions are in this array:
70 $aActionsNotToCheck = array(
101 'banlistnewfromitem',
122 // the rest of the actions needs to be checked
123 $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');
125 if (!in_array($this->action, $aActionsNotToCheck))
127 if (!$manager->checkTicket())
128 $this->error(_ERROR_BADTICKET);
131 if (method_exists($this, $methodName))
132 call_user_func(array(&$this, $methodName));
134 $this->error(_BADACTION . ENTITY::hsc(" ($action)"));
139 * @todo document this
141 function action_showlogin() {
143 $this->action_login($error);
147 * @todo document this
149 function action_login($msg = '', $passvars = 1) {
152 // skip to overview when allowed
153 if ($member->isLoggedIn() && $member->canLogin()) {
154 $this->action_overview();
160 echo '<h2>', _LOGIN ,'</h2>';
161 if ($msg) echo _MESSAGE , ': ', ENTITY::hsc($msg);
164 <form action="index.php" method="post"><p>
165 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
167 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
169 <input name="action" value="login" type="hidden" />
171 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
174 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
175 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
177 <?php // pass through vars
179 $oldaction = postVar('oldaction');
180 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
187 <?php $this->pagefoot();
192 * provides a screen with the overview of the actions available
193 * @todo document parameter
195 function action_overview($msg = '') {
201 echo _MESSAGE , ': ', $msg;
203 /* ---- add items ---- */
204 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
206 $showAll = requestVar('showall');
208 if (($member->isAdmin()) && ($showAll == 'yes')) {
209 // Super-Admins have access to all blogs! (no add item support though)
210 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
211 . ' FROM ' . sql_table('blog')
214 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
215 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
216 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
219 $template['content'] = 'bloglist';
220 $template['superadmin'] = $member->isAdmin();
221 $amount = showlist($query,'table',$template);
223 if (($showAll != 'yes') && ($member->isAdmin())) {
224 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
225 if ($total > $amount)
226 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
230 echo _OVERVIEW_NOBLOGS;
233 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
234 $query = 'SELECT ititle, inumber, bshortname'
235 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
236 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
237 $template['content'] = 'draftlist';
238 $amountdrafts = showlist($query, 'table', $template);
239 if ($amountdrafts == 0)
240 echo _OVERVIEW_NODRAFTS;
244 $yrBlogs = $member->getAdminBlogs();
245 if ($showAll != 'yes') {
247 foreach ($yrBlogs as $value) {
248 if ($member->isBlogAdmin(intval($value))) {
249 $admBlogs[] = intval($value);
252 $yrBlogs = $admBlogs;
255 if (count($yrBlogs) > 0) {
256 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
257 $query = 'SELECT ititle, inumber, bshortname, mname'
258 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
259 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
260 . ' ORDER BY iblog ASC';
261 $template['content'] = 'otherdraftlist';
262 $amountdrafts = showlist($query, 'table', $template);
263 if ($amountdrafts == 0)
264 echo _OVERVIEW_NODRAFTS;
268 /* ---- user settings ---- */
269 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
271 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
272 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
273 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
276 /* ---- general settings ---- */
277 if ($member->isAdmin()) {
278 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
280 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
289 * Returns a link to a weblog
292 function bloglink(&$blog) {
293 return '<a href="'.ENTITY::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. ENTITY::hsc( $blog->getName() ) .'</a>';
297 * @todo document this
299 function action_manage($msg = '') {
302 $member->isAdmin() or $this->disallow();
306 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
309 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
312 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
315 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
316 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
317 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
318 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
321 echo '<h2>' . _MANAGE_SKINS . '</h2>';
323 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
324 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
325 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
328 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
330 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
331 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
338 * @todo document this
340 function action_itemlist($blogid = '') {
341 global $member, $manager, $CONF;
344 $blogid = intRequestVar('blogid');
346 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
349 $blog =& $manager->getBlog($blogid);
351 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
352 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
355 if (postVar('start'))
356 $start = intPostVar('start');
361 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
363 // amount of items to show
364 if (postVar('amount'))
365 $amount = intPostVar('amount');
367 $amount = intval($CONF['DefaultListSize']);
372 $search = postVar('search'); // search through items
374 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
375 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
376 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
379 $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) . '%"))';
381 // non-blog-admins can only edit/delete their own items
382 if (!$member->blogAdminRights($blogid))
383 $query .= ' and iauthor=' . $member->getID();
386 $query .= ' ORDER BY itime DESC'
387 . " LIMIT $start,$amount";
389 $template['content'] = 'itemlist';
390 $template['now'] = $blog->getCorrectTime(time());
392 $manager->loadClass("ENCAPSULATE");
393 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
394 $navList->showBatchList('item',$query,'table',$template);
401 * @todo document this
403 function action_batchitem() {
404 global $member, $manager;
406 // check if logged in
407 $member->isLoggedIn() or $this->disallow();
409 // more precise check will be done for each performed operation
411 // get array of itemids from request
412 $selected = requestIntArray('batch');
413 $action = requestVar('batchaction');
415 // Show error when no items were selected
416 if (!is_array($selected) || sizeof($selected) == 0)
417 $this->error(_BATCH_NOSELECTION);
419 // On move: when no destination blog/category chosen, show choice now
420 $destCatid = intRequestVar('destcatid');
421 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
422 $this->batchMoveSelectDestination('item',$selected);
424 // On delete: check if confirmation has been given
425 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
426 $this->batchAskDeleteConfirmation('item',$selected);
430 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
431 echo '<h2>',_BATCH_ITEMS,'</h2>';
432 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
436 // walk over all itemids and perform action
437 foreach ($selected as $itemid) {
438 $itemid = intval($itemid);
439 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
441 // perform action, display errors if needed
444 $error = $this->deleteOneItem($itemid);
447 $error = $this->moveOneItem($itemid, $destCatid);
450 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
453 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
458 echo '<b>',_BATCH_DONE,'</b>';
466 * @todo document this
468 function action_batchcomment() {
471 // check if logged in
472 $member->isLoggedIn() or $this->disallow();
474 // more precise check will be done for each performed operation
476 // get array of itemids from request
477 $selected = requestIntArray('batch');
478 $action = requestVar('batchaction');
480 // Show error when no items were selected
481 if (!is_array($selected) || sizeof($selected) == 0)
482 $this->error(_BATCH_NOSELECTION);
484 // On delete: check if confirmation has been given
485 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
486 $this->batchAskDeleteConfirmation('comment',$selected);
490 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
491 echo '<h2>',_BATCH_COMMENTS,'</h2>';
492 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
495 // walk over all itemids and perform action
496 foreach ($selected as $commentid) {
497 $commentid = intval($commentid);
498 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
500 // perform action, display errors if needed
503 $error = $this->deleteOneComment($commentid);
506 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
509 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
514 echo '<b>',_BATCH_DONE,'</b>';
522 * @todo document this
524 function action_batchmember() {
527 // check if logged in and admin
528 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
530 // get array of itemids from request
531 $selected = requestIntArray('batch');
532 $action = requestVar('batchaction');
534 // Show error when no members selected
535 if (!is_array($selected) || sizeof($selected) == 0)
536 $this->error(_BATCH_NOSELECTION);
538 // On delete: check if confirmation has been given
539 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
540 $this->batchAskDeleteConfirmation('member',$selected);
544 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
545 echo '<h2>',_BATCH_MEMBERS,'</h2>';
546 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
549 // walk over all itemids and perform action
550 foreach ($selected as $memberid) {
551 $memberid = intval($memberid);
552 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
554 // perform action, display errors if needed
557 $error = $this->deleteOneMember($memberid);
561 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
565 // there should always remain at least one super-admin
566 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
567 if (sql_num_rows($r) < 2)
568 $error = _ERROR_ATLEASTONEADMIN;
570 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
573 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
576 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
581 echo '<b>',_BATCH_DONE,'</b>';
589 * @todo document this
591 function action_batchteam() {
594 $blogid = intRequestVar('blogid');
596 // check if logged in and admin
597 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
599 // get array of itemids from request
600 $selected = requestIntArray('batch');
601 $action = requestVar('batchaction');
603 // Show error when no members selected
604 if (!is_array($selected) || sizeof($selected) == 0)
605 $this->error(_BATCH_NOSELECTION);
607 // On delete: check if confirmation has been given
608 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
609 $this->batchAskDeleteConfirmation('team',$selected);
613 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
615 echo '<h2>',_BATCH_TEAM,'</h2>';
616 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
619 // walk over all itemids and perform action
620 foreach ($selected as $memberid) {
621 $memberid = intval($memberid);
622 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
624 // perform action, display errors if needed
627 $error = $this->deleteOneTeamMember($blogid, $memberid);
631 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
635 // there should always remain at least one admin
636 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
637 if (sql_num_rows($r) < 2)
638 $error = _ERROR_ATLEASTONEBLOGADMIN;
640 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
643 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
646 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
651 echo '<b>',_BATCH_DONE,'</b>';
659 * @todo document this
661 function action_batchcategory() {
662 global $member, $manager;
664 // check if logged in
665 $member->isLoggedIn() or $this->disallow();
667 // more precise check will be done for each performed operation
669 // get array of itemids from request
670 $selected = requestIntArray('batch');
671 $action = requestVar('batchaction');
673 // Show error when no items were selected
674 if (!is_array($selected) || sizeof($selected) == 0)
675 $this->error(_BATCH_NOSELECTION);
677 // On move: when no destination blog chosen, show choice now
678 $destBlogId = intRequestVar('destblogid');
679 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
680 $this->batchMoveCategorySelectDestination('category',$selected);
682 // On delete: check if confirmation has been given
683 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
684 $this->batchAskDeleteConfirmation('category',$selected);
688 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
689 echo '<h2>',BATCH_CATEGORIES,'</h2>';
690 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
693 // walk over all itemids and perform action
694 foreach ($selected as $catid) {
695 $catid = intval($catid);
696 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
698 // perform action, display errors if needed
701 $error = $this->deleteOneCategory($catid);
704 $error = $this->moveOneCategory($catid, $destBlogId);
707 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
710 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
715 echo '<b>',_BATCH_DONE,'</b>';
722 * @todo document this
724 function batchMoveSelectDestination($type, $ids) {
728 <h2><?php echo _MOVE_TITLE?></h2>
729 <form method="post" action="index.php"><div>
731 <input type="hidden" name="action" value="batch<?php echo $type?>" />
732 <input type="hidden" name="batchaction" value="move" />
734 $manager->addTicketHidden();
736 // insert selected item numbers
738 foreach ($ids as $id)
739 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
741 // show blog/category selection list
742 $this->selectBlogCategory('destcatid');
747 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
750 <?php $this->pagefoot();
755 * @todo document this
757 function batchMoveCategorySelectDestination($type, $ids) {
761 <h2><?php echo _MOVECAT_TITLE?></h2>
762 <form method="post" action="index.php"><div>
764 <input type="hidden" name="action" value="batch<?php echo $type?>" />
765 <input type="hidden" name="batchaction" value="move" />
767 $manager->addTicketHidden();
769 // insert selected item numbers
771 foreach ($ids as $id)
772 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
774 // show blog/category selection list
775 $this->selectBlog('destblogid');
780 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
783 <?php $this->pagefoot();
788 * @todo document this
790 function batchAskDeleteConfirmation($type, $ids) {
795 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
796 <form method="post" action="index.php"><div>
798 <input type="hidden" name="action" value="batch<?php echo $type?>" />
799 <?php $manager->addTicketHidden() ?>
800 <input type="hidden" name="batchaction" value="delete" />
801 <input type="hidden" name="confirmation" value="yes" />
802 <?php // insert selected item numbers
804 foreach ($ids as $id)
805 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
807 // add hidden vars for team & comment
810 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
812 if ($type == 'comment')
814 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
819 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
822 <?php $this->pagefoot();
828 * Inserts a HTML select element with choices for all categories to which the current
830 * @see function selectBlog
832 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
833 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
837 * Inserts a HTML select element with choices for all blogs to which the user has access
838 * mode = 'blog' => shows blognames and values are blogids
839 * mode = 'category' => show category names and values are catids
841 * @param $iForcedBlogInclude
842 * ID of a blog that always needs to be included, without checking if the
843 * member is on the blog team (-1 = none)
844 * @todo document parameters
846 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
847 global $member, $CONF;
849 // 0. get IDs of blogs to which member can post items (+ forced blog)
851 if ($iForcedBlogInclude != -1)
852 $aBlogIds[] = intval($iForcedBlogInclude);
854 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
855 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
857 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
858 $rblogids = sql_query($queryBlogs);
859 while ($o = sql_fetch_object($rblogids))
860 if ($o->bnumber != $iForcedBlogInclude)
861 $aBlogIds[] = intval($o->bnumber);
863 if (count($aBlogIds) == 0)
866 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
868 // 1. select blogs (we'll create optiongroups)
869 // (only select those blogs that have the user on the team)
870 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
871 $blogs = sql_query($queryBlogs);
872 if ($mode == 'category') {
873 if (sql_num_rows($blogs) > 1)
876 while ($oBlog = sql_fetch_object($blogs)) {
878 echo '<optgroup label="',ENTITY::hsc($oBlog->bname),'">';
880 // show selection to create new category when allowed/wanted
882 // check if allowed to do so
883 if ($member->blogAdminRights($oBlog->bnumber))
884 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
887 // 2. for each category in that blog
888 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
889 while ($oCat = sql_fetch_object($categories)) {
890 if ($oCat->catid == $selected)
891 $selectText = ' selected="selected" ';
894 echo '<option value="',$oCat->catid,'" ', $selectText,'>',ENTITY::hsc($oCat->cname),'</option>';
902 while ($oBlog = sql_fetch_object($blogs)) {
903 echo '<option value="',$oBlog->bnumber,'"';
904 if ($oBlog->bnumber == $selected)
905 echo ' selected="selected"';
906 echo'>',ENTITY::hsc($oBlog->bname),'</option>';
914 * @todo document this
916 function action_browseownitems() {
917 global $member, $manager, $CONF;
921 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
922 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
925 if (postVar('start'))
926 $start = intPostVar('start');
930 // amount of items to show
931 if (postVar('amount'))
932 $amount = intPostVar('amount');
934 $amount = intval($CONF['DefaultListSize']);
939 $search = postVar('search'); // search through items
941 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
942 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
943 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
946 $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) . '%"))';
948 $query .= ' ORDER BY itime DESC'
949 . " LIMIT $start,$amount";
951 $template['content'] = 'itemlist';
952 $template['now'] = time();
954 $manager->loadClass("ENCAPSULATE");
955 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
956 $navList->showBatchList('item',$query,'table',$template);
963 * Show all the comments for a given item
966 function action_itemcommentlist($itemid = '') {
967 global $member, $manager, $CONF;
970 $itemid = intRequestVar('itemid');
972 // only allow if user is allowed to alter item
973 $member->canAlterItem($itemid) or $this->disallow();
975 $blogid = getBlogIdFromItemId($itemid);
980 if (postVar('start'))
981 $start = intPostVar('start');
985 // amount of items to show
986 if (postVar('amount'))
987 $amount = intPostVar('amount');
989 $amount = intval($CONF['DefaultListSize']);
994 $search = postVar('search');
996 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
997 echo '<h2>',_COMMENTS,'</h2>';
999 $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;
1002 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1004 $query .= ' ORDER BY ctime ASC'
1005 . " LIMIT $start,$amount";
1007 $template['content'] = 'commentlist';
1008 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1010 $manager->loadClass("ENCAPSULATE");
1011 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1012 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1018 * Browse own comments
1020 function action_browseowncomments() {
1021 global $member, $manager, $CONF;
1024 if (postVar('start'))
1025 $start = intPostVar('start');
1029 // amount of items to show
1030 if (postVar('amount'))
1031 $amount = intPostVar('amount');
1033 $amount = intval($CONF['DefaultListSize']);
1038 $search = postVar('search');
1041 $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();
1044 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1046 $query .= ' ORDER BY ctime DESC'
1047 . " LIMIT $start,$amount";
1051 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1052 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
1054 $template['content'] = 'commentlist';
1055 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1057 $manager->loadClass("ENCAPSULATE");
1058 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1059 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1065 * Browse all comments for a weblog
1066 * @param int $blogid
1068 function action_blogcommentlist($blogid = '')
1070 global $member, $manager, $CONF;
1073 $blogid = intRequestVar('blogid');
1075 $blogid = intval($blogid);
1077 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1080 if (postVar('start'))
1081 $start = intPostVar('start');
1085 // amount of items to show
1086 if (postVar('amount'))
1087 $amount = intPostVar('amount');
1089 $amount = intval($CONF['DefaultListSize']);
1094 $search = postVar('search'); // search through comments
1097 $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);
1100 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1103 $query .= ' ORDER BY ctime DESC'
1104 . " LIMIT $start,$amount";
1107 $blog =& $manager->getBlog($blogid);
1111 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1112 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1114 $template['content'] = 'commentlist';
1115 $template['canAddBan'] = $member->blogAdminRights($blogid);
1117 $manager->loadClass("ENCAPSULATE");
1118 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1119 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1125 * Provide a page to item a new item to the given blog
1127 function action_createitem() {
1128 global $member, $manager;
1130 $blogid = intRequestVar('blogid');
1133 $member->teamRights($blogid) or $this->disallow();
1135 $memberid = $member->getID();
1137 $blog =& $manager->getBlog($blogid);
1141 // generate the add-item form
1142 $formfactory = new PAGEFACTORY($blogid);
1143 $formfactory->createAddForm('admin');
1149 * @todo document this
1151 function action_itemedit()
1153 global $member, $manager;
1155 $itemid = intRequestVar('itemid');
1157 // only allow if user is allowed to alter item
1158 $member->canAlterItem($itemid) or $this->disallow();
1160 $item =& $manager->getItem($itemid, 1, 1);
1161 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1163 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1165 if ($blog->convertBreaks())
1167 $item['body'] = removeBreaks($item['body']);
1168 $item['more'] = removeBreaks($item['more']);
1171 // form to edit blog items
1173 $formfactory = new PAGEFACTORY($blog->getID());
1174 $formfactory->createEditForm('admin', $item);
1179 * @todo document this
1181 function action_itemupdate() {
1182 global $member, $manager, $CONF;
1184 $itemid = intRequestVar('itemid');
1185 $catid = postVar('catid');
1187 // only allow if user is allowed to alter item
1188 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1190 $actiontype = postVar('actiontype');
1192 // delete actions are handled by itemdelete (which has confirmation)
1193 if ($actiontype == 'delete') {
1194 $this->action_itemdelete();
1198 $body = postVar('body');
1199 $title = postVar('title');
1200 $more = postVar('more');
1201 $closed = intPostVar('closed');
1202 $draftid = intPostVar('draftid');
1204 // default action = add now
1206 $actiontype='addnow';
1208 // create new category if needed
1209 if (strstr($catid,'newcat')) {
1211 list($blogid) = sscanf($catid,"newcat-%d");
1214 $blog =& $manager->getBlog($blogid);
1215 $catid = $blog->createNewCategory();
1217 // show error when sth goes wrong
1219 $this->doError(_ERROR_CATCREATEFAIL);
1223 set some variables based on actiontype
1226 draft items -> addnow, addfuture, adddraft, delete
1227 non-draft items -> edit, changedate, delete
1230 $timestamp: set to a nonzero value for future dates or date changes
1231 $wasdraft: set to 1 when the item used to be a draft item
1232 $publish: set to 1 when the edited item is not a draft
1234 $blogid = getBlogIDFromItemID($itemid);
1235 $blog =& $manager->getBlog($blogid);
1237 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1238 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1239 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1240 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1241 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1246 // edit the item for real
1247 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1249 $this->updateFuturePosted($blogid);
1252 // delete permission is checked inside ITEM::delete()
1253 ITEM::delete($draftid);
1256 // show category edit window when we created a new category
1257 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1258 if ($catid != intPostVar('catid')) {
1259 $this->action_categoryedit(
1262 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1265 // TODO: set start item correctly for itemlist
1266 $this->action_itemlist(getBlogIDFromItemID($itemid));
1271 * @todo document this
1273 function action_itemdelete() {
1274 global $member, $manager;
1276 $itemid = intRequestVar('itemid');
1278 // only allow if user is allowed to alter item
1279 $member->canAlterItem($itemid) or $this->disallow();
1281 if (!$manager->existsItem($itemid,1,1))
1282 $this->error(_ERROR_NOSUCHITEM);
1284 $item =& $manager->getItem($itemid,1,1);
1285 $title = ENTITY::hsc(strip_tags($item['title']));
1286 $body = strip_tags($item['body']);
1287 $body = ENTITY::hsc(shorten($body,300,'...'));
1291 <h2><?php echo _DELETE_CONFIRM?></h2>
1293 <p><?php echo _CONFIRMTXT_ITEM?></p>
1296 <b>"<?php echo $title ?>"</b>
1301 <form method="post" action="index.php"><div>
1302 <input type="hidden" name="action" value="itemdeleteconfirm" />
1303 <?php $manager->addTicketHidden() ?>
1304 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1305 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1312 * @todo document this
1314 function action_itemdeleteconfirm() {
1317 $itemid = intRequestVar('itemid');
1319 // only allow if user is allowed to alter item
1320 $member->canAlterItem($itemid) or $this->disallow();
1323 $blogid = getBlogIdFromItemId($itemid);
1325 // delete item (note: some checks will be performed twice)
1326 $this->deleteOneItem($itemid);
1328 $this->action_itemlist($blogid);
1332 * Deletes one item and returns error if something goes wrong
1333 * @param int $itemid
1335 function deleteOneItem($itemid) {
1336 global $member, $manager;
1338 // only allow if user is allowed to alter item (also checks if itemid exists)
1339 if (!$member->canAlterItem($itemid))
1340 return _ERROR_DISALLOWED;
1342 // need to get blogid before the item is deleted
1343 $blogid = getBlogIDFromItemId($itemid);
1345 $manager->loadClass('ITEM');
1346 ITEM::delete($itemid);
1348 // update blog's futureposted
1349 $this->updateFuturePosted($blogid);
1353 * Update a blog's future posted flag
1354 * @param int $blogid
1356 function updateFuturePosted($blogid) {
1359 $blog =& $manager->getBlog($blogid);
1360 $currenttime = $blog->getCorrectTime(time());
1361 $result = sql_query("SELECT * FROM ".sql_table('item').
1362 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1363 if (sql_num_rows($result) > 0) {
1364 $blog->setFuturePost();
1367 $blog->clearFuturePost();
1372 * @todo document this
1374 function action_itemmove() {
1375 global $member, $manager;
1377 $itemid = intRequestVar('itemid');
1379 // only allow if user is allowed to alter item
1380 $member->canAlterItem($itemid) or $this->disallow();
1382 $item =& $manager->getItem($itemid,1,1);
1386 <h2><?php echo _MOVE_TITLE?></h2>
1387 <form method="post" action="index.php"><div>
1388 <input type="hidden" name="action" value="itemmoveto" />
1389 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1393 $manager->addTicketHidden();
1394 $this->selectBlogCategory('catid',$item['catid'],10,1);
1397 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1404 * @todo document this
1406 function action_itemmoveto() {
1407 global $member, $manager;
1409 $itemid = intRequestVar('itemid');
1410 $catid = requestVar('catid');
1412 // create new category if needed
1413 if (strstr($catid,'newcat')) {
1415 list($blogid) = sscanf($catid,'newcat-%d');
1418 $blog =& $manager->getBlog($blogid);
1419 $catid = $blog->createNewCategory();
1421 // show error when sth goes wrong
1423 $this->doError(_ERROR_CATCREATEFAIL);
1426 // only allow if user is allowed to alter item
1427 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1429 $old_blogid = getBlogIDFromItemId($itemid);
1431 ITEM::move($itemid, $catid);
1433 // set the futurePosted flag on the blog
1434 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1436 // reset the futurePosted in case the item is moved from one blog to another
1437 $this->updateFuturePosted($old_blogid);
1439 if ($catid != intRequestVar('catid'))
1440 $this->action_categoryedit($catid, $blog->getID());
1442 $this->action_itemlist(getBlogIDFromCatID($catid));
1446 * Moves one item to a given category (category existance should be checked by caller)
1447 * errors are returned
1448 * @param int $itemid
1449 * @param int $destCatid category ID to which the item will be moved
1451 function moveOneItem($itemid, $destCatid) {
1454 // only allow if user is allowed to move item
1455 if (!$member->canUpdateItem($itemid, $destCatid))
1456 return _ERROR_DISALLOWED;
1458 ITEM::move($itemid, $destCatid);
1462 * Adds a item to the chosen blog
1464 function action_additem() {
1465 global $manager, $CONF;
1467 $manager->loadClass('ITEM');
1469 $result = ITEM::createFromRequest();
1471 if ($result['status'] == 'error')
1472 $this->error($result['message']);
1474 $blogid = getBlogIDFromItemID($result['itemid']);
1475 $blog =& $manager->getBlog($blogid);
1476 $btimestamp = $blog->getCorrectTime();
1477 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1479 if ($result['status'] == 'newcategory') {
1480 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1481 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1483 $methodName = 'action_itemList';
1484 call_user_func(array(&$this, $methodName), $blogid);
1489 * Allows to edit previously made comments
1491 function action_commentedit() {
1493 global $member, $manager;
1495 $commentid = intRequestVar('commentid');
1497 $member->canAlterComment($commentid) or $this->disallow();
1499 $comment = COMMENT::getComment($commentid);
1501 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1503 // change <br /> to \n
1504 $comment['body'] = str_replace('<br />', '', $comment['body']);
1506 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1507 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1509 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1514 <h2><?php echo _EDITC_TITLE?></h2>
1516 <form action="index.php" method="post"><div>
1518 <input type="hidden" name="action" value="commentupdate" />
1519 <?php $manager->addTicketHidden(); ?>
1520 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1522 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1524 <td><?php echo _EDITC_WHO?></td>
1526 <?php if ($comment['member'])
1527 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1529 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1533 <td><?php echo _EDITC_WHEN?></td>
1534 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1536 <td><?php echo _EDITC_HOST?></td>
1537 <td><?php echo $comment['host']; ?></td>
1540 <td><?php echo _EDITC_URL; ?></td>
1541 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1544 <td><?php echo _EDITC_EMAIL; ?></td>
1545 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1548 <td><?php echo _EDITC_TEXT?></td>
1550 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1551 echo $comment['body'];
1555 <td><?php echo _EDITC_EDIT?></td>
1556 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1565 * @todo document this
1567 function action_commentupdate() {
1568 global $member, $manager;
1570 $commentid = intRequestVar('commentid');
1572 $member->canAlterComment($commentid) or $this->disallow();
1574 $url = postVar('url');
1575 $email = postVar('email');
1576 $body = postVar('body');
1578 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1579 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1580 # important note that '\' must be matched with '\\\\' in preg* expressions
1582 // intercept words that are too long
1583 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1585 $this->error(_ERROR_COMMENT_LONGWORD);
1589 if (i18n::strlen($body) < 3)
1591 $this->error(_ERROR_COMMENT_NOCOMMENT);
1594 if (i18n::strlen($body) > 5000)
1596 $this->error(_ERROR_COMMENT_TOOLONG);
1600 $body = COMMENT::prepareBody($body);
1603 $manager->notify('PreUpdateComment',array('body' => &$body));
1605 $query = 'UPDATE ' . sql_table('comment')
1606 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1607 . " WHERE cnumber = " . $commentid;
1611 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1612 $o = sql_fetch_object($res);
1613 $itemid = $o->citem;
1615 if ($member->canAlterItem($itemid))
1616 $this->action_itemcommentlist($itemid);
1618 $this->action_browseowncomments();
1623 * @todo document this
1625 function action_commentdelete() {
1626 global $member, $manager;
1628 $commentid = intRequestVar('commentid');
1630 $member->canAlterComment($commentid) or $this->disallow();
1632 $comment = COMMENT::getComment($commentid);
1634 $body = strip_tags($comment['body']);
1635 $body = ENTITY::hsc(shorten($body, 300, '...'));
1637 if ($comment['member'])
1638 $author = $comment['member'];
1640 $author = $comment['user'];
1645 <h2><?php echo _DELETE_CONFIRM?></h2>
1647 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1650 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1652 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1655 <form method="post" action="index.php"><div>
1656 <input type="hidden" name="action" value="commentdeleteconfirm" />
1657 <?php $manager->addTicketHidden() ?>
1658 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1659 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1666 * @todo document this
1668 function action_commentdeleteconfirm() {
1671 $commentid = intRequestVar('commentid');
1673 // get item id first
1674 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1675 $o = sql_fetch_object($res);
1676 $itemid = $o->citem;
1678 $error = $this->deleteOneComment($commentid);
1680 $this->doError($error);
1682 if ($member->canAlterItem($itemid))
1683 $this->action_itemcommentlist($itemid);
1685 $this->action_browseowncomments();
1689 * @todo document this
1691 function deleteOneComment($commentid) {
1692 global $member, $manager;
1694 $commentid = intval($commentid);
1696 if (!$member->canAlterComment($commentid))
1697 return _ERROR_DISALLOWED;
1699 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1701 // delete the comments associated with the item
1702 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1705 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1711 * Usermanagement main
1713 function action_usermanagement() {
1714 global $member, $manager;
1717 $member->isAdmin() or $this->disallow();
1721 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1723 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1725 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1727 // show list of members with actions
1729 . ' FROM '.sql_table('member');
1730 $template['content'] = 'memberlist';
1731 $template['tabindex'] = 10;
1733 $manager->loadClass("ENCAPSULATE");
1734 $batch = new BATCH('member');
1735 $batch->showlist($query,'table',$template);
1737 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1739 <form method="post" action="index.php" name="memberedit"><div>
1741 <input type="hidden" name="action" value="memberadd" />
1742 <?php $manager->addTicketHidden() ?>
1746 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1748 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1749 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1751 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1753 <td><?php echo _MEMBERS_REALNAME?></td>
1754 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1756 <td><?php echo _MEMBERS_PWD?></td>
1757 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1759 <td><?php echo _MEMBERS_REPPWD?></td>
1760 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1762 <td><?php echo _MEMBERS_EMAIL?></td>
1763 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1765 <td><?php echo _MEMBERS_URL?></td>
1766 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1768 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1769 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1771 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1772 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1774 <td><?php echo _MEMBERS_NOTES?></td>
1775 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1777 <td><?php echo _MEMBERS_NEW?></td>
1778 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1787 * Edit member settings
1789 function action_memberedit() {
1790 $this->action_editmembersettings(intRequestVar('memberid'));
1794 * @todo document this
1796 function action_editmembersettings($memberid = '') {
1797 global $member, $manager, $CONF;
1799 if ($memberid == '')
1801 $memberid = $member->getID();
1805 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1807 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1808 $this->pagehead($extrahead);
1810 // show message to go back to member overview (only for admins)
1811 if ($member->isAdmin())
1813 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1817 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1819 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1821 $mem = MEMBER::createFromID($memberid);
1823 <form method="post" action="index.php" name="memberedit"><div>
1825 <input type="hidden" name="action" value="changemembersettings" />
1826 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1827 <?php $manager->addTicketHidden() ?>
1830 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1832 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1833 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1836 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1837 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo ENTITY::hsc($mem->getDisplayName()); ?>" />
1839 echo ENTITY::hsc($member->getDisplayName());
1844 <td><?php echo _MEMBERS_REALNAME?></td>
1845 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo ENTITY::hsc($mem->getRealName()); ?>" /></td>
1847 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1848 <td><?php echo _MEMBERS_PWD?></td>
1849 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1851 <td><?php echo _MEMBERS_REPPWD?></td>
1852 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1855 <td><?php echo _MEMBERS_EMAIL?>
1856 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1858 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo ENTITY::hsc($mem->getEmail()); ?>" /></td>
1860 <td><?php echo _MEMBERS_URL?></td>
1861 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getURL()); ?>" /></td>
1862 <?php // only allow to change this by super-admins
1863 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1864 if ($member->isAdmin()) {
1867 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1868 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1870 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1871 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1874 <td><?php echo _MEMBERS_NOTES?></td>
1875 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getNotes()); ?>" /></td>
1877 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1881 <select name="deflang" tabindex="85">
1883 $locales = i18n::get_available_locale_list();
1884 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1886 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1890 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1893 foreach( $locales as $locale )
1895 if( $locale == $mem->getLocale() )
1897 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1901 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1910 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1911 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1915 $this->_insertPluginOptions('member',$memberid);
1918 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1920 <td><?php echo _MEMBERS_EDIT?></td>
1921 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1927 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1930 'MemberSettingsFormExtras',
1939 * @todo document this
1941 function action_changemembersettings() {
1942 global $member, $CONF, $manager;
1944 $memberid = intRequestVar('memberid');
1947 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1949 $name = trim(strip_tags(postVar('name')));
1950 $realname = trim(strip_tags(postVar('realname')));
1951 $password = postVar('password');
1952 $repeatpassword = postVar('repeatpassword');
1953 $email = strip_tags(postVar('email'));
1954 $url = strip_tags(postVar('url'));
1956 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1957 # original eregi: !eregi("^https?://", $url)
1959 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1960 if (!preg_match('#^https?://#', $url) )
1962 $url = 'http://' . $url;
1965 $admin = postVar('admin');
1966 $canlogin = postVar('canlogin');
1967 $notes = strip_tags(postVar('notes'));
1968 $locale = postVar('deflang');
1970 $mem = MEMBER::createFromID($memberid);
1972 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1974 if (!isValidDisplayName($name))
1975 $this->error(_ERROR_BADNAME);
1977 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1978 $this->error(_ERROR_NICKNAMEINUSE);
1980 if ($password != $repeatpassword)
1981 $this->error(_ERROR_PASSWORDMISMATCH);
1983 if ($password && (i18n::strlen($password) < 6))
1984 $this->error(_ERROR_PASSWORDTOOSHORT);
1989 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
1991 $this->error($pwderror);
1996 if ( !NOTIFICATION::address_validation($email) )
1998 $this->error(_ERROR_BADMAILADDRESS);
2002 $this->error(_ERROR_REALNAMEMISSING);
2004 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2005 $this->error(_ERROR_NOSUCHLANGUAGE);
2007 // check if there will remain at least one site member with both the logon and admin rights
2008 // (check occurs when taking away one of these rights from such a member)
2009 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2010 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2013 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2014 if (sql_num_rows($r) < 2)
2015 $this->error(_ERROR_ATLEASTONEADMIN);
2018 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2019 $mem->setDisplayName($name);
2021 $mem->setPassword($password);
2024 $oldEmail = $mem->getEmail();
2026 $mem->setRealName($realname);
2027 $mem->setEmail($email);
2029 $mem->setNotes($notes);
2030 $mem->setLocale($locale);
2033 // only allow super-admins to make changes to the admin status
2034 if ($member->isAdmin()) {
2035 $mem->setAdmin($admin);
2036 $mem->setCanLogin($canlogin);
2039 $autosave = postVar ('autosave');
2040 $mem->setAutosave($autosave);
2044 // store plugin options
2045 $aOptions = requestArray('plugoption');
2046 NucleusPlugin::apply_plugin_options($aOptions);
2047 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2049 // if email changed, generate new password
2050 if ($oldEmail != $mem->getEmail())
2052 $mem->sendActivationLink('addresschange', $oldEmail);
2054 $mem->newCookieKey();
2056 // only log out if the member being edited is the current member.
2057 if ($member->getID() == $memberid)
2059 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2064 if ( ( $mem->getID() == $member->getID() )
2065 && ( $mem->getDisplayName() != $member->getDisplayName() )
2067 $mem->newCookieKey();
2069 $this->action_login(_MSG_LOGINAGAIN, 0);
2071 $this->action_overview(_MSG_SETTINGSCHANGED);
2076 * @todo document this
2078 function action_memberadd() {
2079 global $member, $manager;
2082 $member->isAdmin() or $this->disallow();
2084 if (postVar('password') != postVar('repeatpassword'))
2085 $this->error(_ERROR_PASSWORDMISMATCH);
2086 if (i18n::strlen(postVar('password')) < 6)
2087 $this->error(_ERROR_PASSWORDTOOSHORT);
2089 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2093 // fire PostRegister event
2094 $newmem = new MEMBER();
2095 $newmem->readFromName(postVar('name'));
2096 $manager->notify('PostRegister',array('member' => &$newmem));
2098 $this->action_usermanagement();
2102 * Account activation
2106 function action_activate() {
2108 $key = getVar('key');
2109 $this->_showActivationPage($key);
2113 * @todo document this
2115 function _showActivationPage($key, $message = '')
2119 // clean up old activation keys
2120 MEMBER::cleanupActivationTable();
2122 // get activation info
2123 $info = MEMBER::getActivationInfo($key);
2126 $this->error(_ERROR_ACTIVATE);
2128 $mem = MEMBER::createFromId($info->vmember);
2131 $this->error(_ERROR_ACTIVATE);
2135 $bNeedsPasswordChange = true;
2137 switch ($info->vtype)
2140 $title = _ACTIVATE_FORGOT_TITLE;
2141 $text = _ACTIVATE_FORGOT_TEXT;
2144 $title = _ACTIVATE_REGISTER_TITLE;
2145 $text = _ACTIVATE_REGISTER_TEXT;
2147 case 'addresschange':
2148 $title = _ACTIVATE_CHANGE_TITLE;
2149 $text = _ACTIVATE_CHANGE_TEXT;
2150 $bNeedsPasswordChange = false;
2151 MEMBER::activate($key);
2156 'memberName' => ENTITY::hsc($mem->getDisplayName())
2158 $title = TEMPLATE::fill($title, $aVars);
2159 $text = TEMPLATE::fill($text, $aVars);
2163 echo '<h2>' , $title, '</h2>';
2164 echo '<p>' , $text, '</p>';
2168 echo '<p class="error">',$message,'</p>';
2171 if ($bNeedsPasswordChange)
2174 <div><form action="index.php" method="post">
2176 <input type="hidden" name="action" value="activatesetpwd" />
2177 <?php $manager->addTicketHidden() ?>
2178 <input type="hidden" name="key" value="<?php echo ENTITY::hsc($key) ?>" />
2181 <td><?php echo _MEMBERS_PWD?></td>
2182 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2184 <td><?php echo _MEMBERS_REPPWD?></td>
2185 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2189 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2193 <td><?php echo _MEMBERS_SETPWD ?></td>
2194 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2209 * Account activation - set password part
2213 function action_activatesetpwd() {
2215 $key = postVar('key');
2217 // clean up old activation keys
2218 MEMBER::cleanupActivationTable();
2220 // get activation info
2221 $info = MEMBER::getActivationInfo($key);
2223 if (!$info || ($info->type == 'addresschange'))
2224 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2226 $mem = MEMBER::createFromId($info->vmember);
2229 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2231 $password = postVar('password');
2232 $repeatpassword = postVar('repeatpassword');
2234 if ($password != $repeatpassword)
2235 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2237 if ($password && (i18n::strlen($password) < 6))
2238 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2244 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2246 return $this->_showActivationPage($key,$pwderror);
2252 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2254 return $this->_showActivationPage($key, $error);
2258 $mem->setPassword($password);
2261 // do the activation
2262 MEMBER::activate($key);
2265 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2266 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2273 function action_manageteam() {
2274 global $member, $manager;
2276 $blogid = intRequestVar('blogid');
2279 $member->blogAdminRights($blogid) or $this->disallow();
2283 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2285 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2287 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2291 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2292 . ' FROM '.sql_table('member').', '.sql_table('team')
2293 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2295 $template['content'] = 'teamlist';
2296 $template['tabindex'] = 10;
2298 $manager->loadClass("ENCAPSULATE");
2299 $batch = new BATCH('team');
2300 $batch->showlist($query, 'table', $template);
2303 <h3><?php echo _TEAM_ADDNEW?></h3>
2305 <form method='post' action='index.php'><div>
2307 <input type='hidden' name='action' value='teamaddmember' />
2308 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2309 <?php $manager->addTicketHidden() ?>
2312 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2313 <td><?php // TODO: try to make it so only non-team-members are listed
2314 $query = 'SELECT mname as text, mnumber as value'
2315 . ' FROM '.sql_table('member');
2317 $template['name'] = 'memberid';
2318 $template['tabindex'] = 10000;
2319 showlist($query,'select',$template);
2322 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2323 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2325 <td><?php echo _TEAM_ADD?></td>
2326 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2335 * Add member to team
2337 function action_teamaddmember() {
2338 global $member, $manager;
2340 $memberid = intPostVar('memberid');
2341 $blogid = intPostVar('blogid');
2342 $admin = intPostVar('admin');
2345 $member->blogAdminRights($blogid) or $this->disallow();
2347 $blog =& $manager->getBlog($blogid);
2348 if (!$blog->addTeamMember($memberid, $admin))
2349 $this->error(_ERROR_ALREADYONTEAM);
2351 $this->action_manageteam();
2356 * @todo document this
2358 function action_teamdelete() {
2359 global $member, $manager;
2361 $memberid = intRequestVar('memberid');
2362 $blogid = intRequestVar('blogid');
2365 $member->blogAdminRights($blogid) or $this->disallow();
2367 $teammem = MEMBER::createFromID($memberid);
2368 $blog =& $manager->getBlog($blogid);
2372 <h2><?php echo _DELETE_CONFIRM?></h2>
2374 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo ENTITY::hsc($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo ENTITY::hsc(strip_tags($blog->getName())) ?></b>
2378 <form method="post" action="index.php"><div>
2379 <input type="hidden" name="action" value="teamdeleteconfirm" />
2380 <?php $manager->addTicketHidden() ?>
2381 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2382 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2383 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2390 * @todo document this
2392 function action_teamdeleteconfirm() {
2395 $memberid = intRequestVar('memberid');
2396 $blogid = intRequestVar('blogid');
2398 $error = $this->deleteOneTeamMember($blogid, $memberid);
2400 $this->error($error);
2403 $this->action_manageteam();
2407 * @todo document this
2409 function deleteOneTeamMember($blogid, $memberid) {
2410 global $member, $manager;
2412 $blogid = intval($blogid);
2413 $memberid = intval($memberid);
2416 if (!$member->blogAdminRights($blogid))
2417 return _ERROR_DISALLOWED;
2419 // check if: - there remains at least one blog admin
2420 // - (there remains at least one team member)
2421 $tmem = MEMBER::createFromID($memberid);
2423 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2425 if ($tmem->isBlogAdmin($blogid)) {
2426 // check if there are more blog members left and at least one admin
2427 // (check for at least two admins before deletion)
2428 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2429 $r = sql_query($query);
2430 if (sql_num_rows($r) < 2)
2431 return _ERROR_ATLEASTONEBLOGADMIN;
2434 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2437 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2443 * @todo document this
2445 function action_teamchangeadmin() {
2448 $blogid = intRequestVar('blogid');
2449 $memberid = intRequestVar('memberid');
2452 $member->blogAdminRights($blogid) or $this->disallow();
2454 $mem = MEMBER::createFromID($memberid);
2456 // don't allow when there is only one admin at this moment
2457 if ($mem->isBlogAdmin($blogid)) {
2458 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2459 if (sql_num_rows($r) == 1)
2460 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2463 if ($mem->isBlogAdmin($blogid))
2468 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2471 // only show manageteam if member did not change its own admin privileges
2472 if ($member->isBlogAdmin($blogid))
2473 $this->action_manageteam();
2475 $this->action_overview(_MSG_ADMINCHANGED);
2479 * @todo document this
2481 function action_blogsettings() {
2482 global $member, $manager;
2484 $blogid = intRequestVar('blogid');
2487 $member->blogAdminRights($blogid) or $this->disallow();
2489 $blog =& $manager->getBlog($blogid);
2491 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2492 $this->pagehead($extrahead);
2494 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2496 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2498 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2500 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2502 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2503 $aMemberNames = array();
2504 while ($o = sql_fetch_object($res))
2505 array_push($aMemberNames, ENTITY::hsc($o->mname) . ' (' . ENTITY::hsc($o->mrealname). ')');
2506 echo implode(',', $aMemberNames);
2513 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2516 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2518 <form method="post" action="index.php"><div>
2520 <input type="hidden" name="action" value="blogsettingsupdate" />
2521 <?php $manager->addTicketHidden() ?>
2522 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2524 <td><?php echo _EBLOG_NAME?></td>
2525 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getName()) ?>" /></td>
2527 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2528 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2530 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo ENTITY::hsc($blog->getShortName()) ?>" /></td>
2532 <td><?php echo _EBLOG_DESC?></td>
2533 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo ENTITY::hsc($blog->getDescription()) ?>" /></td>
2535 <td><?php echo _EBLOG_URL?></td>
2536 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo ENTITY::hsc($blog->getURL()) ?>" /></td>
2538 <td><?php echo _EBLOG_DEFSKIN?>
2539 <?php help('blogdefaultskin'); ?>
2543 $query = 'SELECT sdname as text, sdnumber as value'
2544 . ' FROM '.sql_table('skin_desc');
2545 $template['name'] = 'defskin';
2546 $template['selected'] = $blog->getDefaultSkin();
2547 $template['tabindex'] = 50;
2548 showlist($query,'select',$template);
2553 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2555 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2557 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2559 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2561 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2563 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2565 <td><?php echo _EBLOG_ANONYMOUS?>
2567 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2569 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2571 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2573 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2574 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo ENTITY::hsc($blog->getNotifyAddress()); ?>" /></td>
2576 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2578 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2579 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2580 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2582 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2583 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2584 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2586 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2587 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2588 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2591 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2592 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo ENTITY::hsc($blog->getMaxComments()); ?>" /></td>
2594 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2595 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getUpdateFile()) ?>" /></td>
2597 <td><?php echo _EBLOG_DEFCAT?></td>
2600 $query = 'SELECT cname as text, catid as value'
2601 . ' FROM '.sql_table('category')
2602 . ' WHERE cblog=' . $blog->getID();
2603 $template['name'] = 'defcat';
2604 $template['selected'] = $blog->getDefaultCategory();
2605 $template['tabindex'] = 110;
2606 showlist($query,'select',$template);
2610 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2611 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
2612 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2614 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo ENTITY::hsc($blog->getTimeOffset()); ?>" /></td>
2616 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2617 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2621 $this->_insertPluginOptions('blog',$blogid);
2624 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2626 <td><?php echo _EBLOG_CHANGE?></td>
2627 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2632 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2636 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2637 $template['content'] = 'categorylist';
2638 $template['tabindex'] = 200;
2640 $manager->loadClass("ENCAPSULATE");
2641 $batch = new BATCH('category');
2642 $batch->showlist($query,'table',$template);
2647 <form action="index.php" method="post"><div>
2648 <input name="action" value="categorynew" type="hidden" />
2649 <?php $manager->addTicketHidden() ?>
2650 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2653 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2655 <td><?php echo _EBLOG_CAT_NAME?></td>
2656 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2658 <td><?php echo _EBLOG_CAT_DESC?></td>
2659 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2661 <td><?php echo _EBLOG_CAT_CREATE?></td>
2662 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2669 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2672 'BlogSettingsFormExtras',
2682 * @todo document this
2684 function action_categorynew() {
2685 global $member, $manager;
2687 $blogid = intRequestVar('blogid');
2689 $member->blogAdminRights($blogid) or $this->disallow();
2691 $cname = postVar('cname');
2692 $cdesc = postVar('cdesc');
2694 if (!isValidCategoryName($cname))
2695 $this->error(_ERROR_BADCATEGORYNAME);
2697 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2698 $res = sql_query($query);
2699 if (sql_num_rows($res) > 0)
2700 $this->error(_ERROR_DUPCATEGORYNAME);
2702 $blog =& $manager->getBlog($blogid);
2703 $newCatID = $blog->createNewCategory($cname, $cdesc);
2705 $this->action_blogsettings();
2709 * @todo document this
2711 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2712 global $member, $manager;
2715 $blogid = intGetVar('blogid');
2717 $blogid = intval($blogid);
2719 $catid = intGetVar('catid');
2721 $catid = intval($catid);
2723 $member->blogAdminRights($blogid) or $this->disallow();
2725 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2726 $obj = sql_fetch_object($res);
2728 $cname = $obj->cname;
2729 $cdesc = $obj->cdesc;
2731 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2732 $this->pagehead($extrahead);
2734 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2737 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo ENTITY::hsc($cname)?>'</h2>
2738 <form method='post' action='index.php'><div>
2739 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2740 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2741 <input name="desturl" type="hidden" value="<?php echo ENTITY::hsc($desturl) ?>" />
2742 <input name="action" type="hidden" value="categoryupdate" />
2743 <?php $manager->addTicketHidden(); ?>
2746 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2748 <td><?php echo _EBLOG_CAT_NAME?></td>
2749 <td><input type="text" name="cname" value="<?php echo ENTITY::hsc($cname)?>" size="40" maxlength="40" /></td>
2751 <td><?php echo _EBLOG_CAT_DESC?></td>
2752 <td><input type="text" name="cdesc" value="<?php echo ENTITY::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2755 // insert plugin options
2756 $this->_insertPluginOptions('category',$catid);
2759 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2761 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2762 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2771 * @todo document this
2773 function action_categoryupdate() {
2774 global $member, $manager;
2776 $blogid = intPostVar('blogid');
2777 $catid = intPostVar('catid');
2778 $cname = postVar('cname');
2779 $cdesc = postVar('cdesc');
2780 $desturl = postVar('desturl');
2782 $member->blogAdminRights($blogid) or $this->disallow();
2784 if (!isValidCategoryName($cname))
2785 $this->error(_ERROR_BADCATEGORYNAME);
2787 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2788 $res = sql_query($query);
2789 if (sql_num_rows($res) > 0)
2790 $this->error(_ERROR_DUPCATEGORYNAME);
2792 $query = 'UPDATE '.sql_table('category').' SET'
2793 . " cname='" . sql_real_escape_string($cname) . "',"
2794 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2795 . " WHERE catid=" . $catid;
2799 // store plugin options
2800 $aOptions = requestArray('plugoption');
2801 NucleusPlugin::apply_plugin_options($aOptions);
2802 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2809 $this->action_blogsettings();
2814 * @todo document this
2816 function action_categorydelete() {
2817 global $member, $manager;
2819 $blogid = intRequestVar('blogid');
2820 $catid = intRequestVar('catid');
2822 $member->blogAdminRights($blogid) or $this->disallow();
2824 $blog =& $manager->getBlog($blogid);
2826 // check if the category is valid
2827 if (!$blog->isValidCategory($catid))
2828 $this->error(_ERROR_NOSUCHCATEGORY);
2830 // don't allow deletion of default category
2831 if ($blog->getDefaultCategory() == $catid)
2832 $this->error(_ERROR_DELETEDEFCATEGORY);
2834 // check if catid is the only category left for blogid
2835 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2836 $res = sql_query($query);
2837 if (sql_num_rows($res) == 1)
2838 $this->error(_ERROR_DELETELASTCATEGORY);
2843 <h2><?php echo _DELETE_CONFIRM?></h2>
2846 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo ENTITY::hsc($blog->getCategoryName($catid))?></b>
2849 <form method="post" action="index.php"><div>
2850 <input type="hidden" name="action" value="categorydeleteconfirm" />
2851 <?php $manager->addTicketHidden() ?>
2852 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2853 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2854 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2861 * @todo document this
2863 function action_categorydeleteconfirm() {
2864 global $member, $manager;
2866 $blogid = intRequestVar('blogid');
2867 $catid = intRequestVar('catid');
2869 $member->blogAdminRights($blogid) or $this->disallow();
2871 $error = $this->deleteOneCategory($catid);
2873 $this->error($error);
2875 $this->action_blogsettings();
2879 * @todo document this
2881 function deleteOneCategory($catid) {
2882 global $manager, $member;
2884 $catid = intval($catid);
2886 $blogid = getBlogIDFromCatID($catid);
2888 if (!$member->blogAdminRights($blogid))
2889 return ERROR_DISALLOWED;
2892 $blog =& $manager->getBlog($blogid);
2894 // check if the category is valid
2895 if (!$blog || !$blog->isValidCategory($catid))
2896 return _ERROR_NOSUCHCATEGORY;
2898 $destcatid = $blog->getDefaultCategory();
2900 // don't allow deletion of default category
2901 if ($blog->getDefaultCategory() == $catid)
2902 return _ERROR_DELETEDEFCATEGORY;
2904 // check if catid is the only category left for blogid
2905 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2906 $res = sql_query($query);
2907 if (sql_num_rows($res) == 1)
2908 return _ERROR_DELETELASTCATEGORY;
2910 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2912 // change category for all items to the default category
2913 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2916 // delete all associated plugin options
2917 NucleusPlugin::_deleteOptionValues('category', $catid);
2920 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2923 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2928 * @todo document this
2930 function moveOneCategory($catid, $destblogid) {
2931 global $manager, $member;
2933 $catid = intval($catid);
2934 $destblogid = intval($destblogid);
2936 $blogid = getBlogIDFromCatID($catid);
2938 // mover should have admin rights on both blogs
2939 if (!$member->blogAdminRights($blogid))
2940 return _ERROR_DISALLOWED;
2941 if (!$member->blogAdminRights($destblogid))
2942 return _ERROR_DISALLOWED;
2944 // cannot move to self
2945 if ($blogid == $destblogid)
2946 return _ERROR_MOVETOSELF;
2949 $blog =& $manager->getBlog($blogid);
2950 $destblog =& $manager->getBlog($destblogid);
2952 // check if the category is valid
2953 if (!$blog || !$blog->isValidCategory($catid))
2954 return _ERROR_NOSUCHCATEGORY;
2956 // don't allow default category to be moved
2957 if ($blog->getDefaultCategory() == $catid)
2958 return _ERROR_MOVEDEFCATEGORY;
2964 'sourceblog' => &$blog,
2965 'destblog' => &$destblog
2969 // update comments table (cblog)
2970 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2971 $items = sql_query($query);
2972 while ($oItem = sql_fetch_object($items)) {
2973 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2976 // update items (iblog)
2977 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2981 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2988 'sourceblog' => &$blog,
2989 'destblog' => $destblog
2996 * ADMIN::action_blogsettingsupdate
2997 * Updating blog settings
3002 function action_blogsettingsupdate()
3004 global $member, $manager;
3006 $blogid = intRequestVar('blogid');
3008 $member->blogAdminRights($blogid) or $this->disallow();
3010 $blog =& $manager->getBlog($blogid);
3012 $notify_address = trim(postVar('notify'));
3013 $shortname = trim(postVar('shortname'));
3014 $updatefile = trim(postVar('update'));
3016 $notifyComment = intPostVar('notifyComment');
3017 $notifyVote = intPostVar('notifyVote');
3018 $notifyNewItem = intPostVar('notifyNewItem');
3020 if ( $notifyComment == 0 )
3024 if ( $notifyVote == 0 )
3028 if ( $notifyNewItem == 0 )
3032 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3034 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
3036 $this->error(_ERROR_BADNOTIFY);
3039 if ( !isValidShortName($shortname) )
3041 $this->error(_ERROR_BADSHORTBLOGNAME);
3044 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
3046 $this->error(_ERROR_DUPSHORTBLOGNAME);
3048 // check if update file is writable
3049 if ( $updatefile && !is_writeable($updatefile) )
3051 $this->error(_ERROR_UPDATEFILE);
3054 $blog->setName(trim(postVar('name')));
3055 $blog->setShortName($shortname);
3056 $blog->setNotifyAddress($notify_address);
3057 $blog->setNotifyType($notifyType);
3058 $blog->setMaxComments(postVar('maxcomments'));
3059 $blog->setCommentsEnabled(postVar('comments'));
3060 $blog->setTimeOffset(postVar('timeoffset'));
3061 $blog->setUpdateFile($updatefile);
3062 $blog->setURL(trim(postVar('url')));
3063 $blog->setDefaultSkin(intPostVar('defskin'));
3064 $blog->setDescription(trim(postVar('desc')));
3065 $blog->setPublic(postVar('public'));
3066 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3067 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3068 $blog->setDefaultCategory(intPostVar('defcat'));
3069 $blog->setSearchable(intPostVar('searchable'));
3070 $blog->setEmailRequired(intPostVar('reqemail'));
3071 $blog->writeSettings();
3073 // store plugin options
3074 $aOptions = requestArray('plugoption');
3075 NucleusPlugin::apply_plugin_options($aOptions);
3076 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3078 $this->action_overview(_MSG_SETTINGSCHANGED);
3083 * @todo document this
3085 function action_deleteblog() {
3086 global $member, $CONF, $manager;
3088 $blogid = intRequestVar('blogid');
3090 $member->blogAdminRights($blogid) or $this->disallow();
3092 // check if blog is default blog
3093 if ($CONF['DefaultBlog'] == $blogid)
3094 $this->error(_ERROR_DELDEFBLOG);
3096 $blog =& $manager->getBlog($blogid);
3100 <h2><?php echo _DELETE_CONFIRM?></h2>
3102 <p><?php echo _WARNINGTXT_BLOGDEL?>
3106 <?php echo _CONFIRMTXT_BLOG?><b><?php echo ENTITY::hsc($blog->getName())?></b>
3109 <form method="post" action="index.php"><div>
3110 <input type="hidden" name="action" value="deleteblogconfirm" />
3111 <?php $manager->addTicketHidden() ?>
3112 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3113 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3120 * @todo document this
3122 function action_deleteblogconfirm() {
3123 global $member, $CONF, $manager;
3125 $blogid = intRequestVar('blogid');
3127 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3129 $member->blogAdminRights($blogid) or $this->disallow();
3131 // check if blog is default blog
3132 if ($CONF['DefaultBlog'] == $blogid)
3133 $this->error(_ERROR_DELDEFBLOG);
3135 // delete all comments
3136 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3140 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3143 // delete all team members
3144 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3148 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3151 // delete all categories
3152 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3155 // delete all associated plugin options
3156 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3158 // delete the blog itself
3159 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3162 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3164 $this->action_overview(_DELETED_BLOG);
3168 * @todo document this
3170 function action_memberdelete() {
3171 global $member, $manager;
3173 $memberid = intRequestVar('memberid');
3175 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3177 $mem = MEMBER::createFromID($memberid);
3181 <h2><?php echo _DELETE_CONFIRM?></h2>
3183 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo ENTITY::hsc($mem->getDisplayName()) ?></b>
3187 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3190 <form method="post" action="index.php"><div>
3191 <input type="hidden" name="action" value="memberdeleteconfirm" />
3192 <?php $manager->addTicketHidden() ?>
3193 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3194 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3201 * @todo document this
3203 function action_memberdeleteconfirm() {
3206 $memberid = intRequestVar('memberid');
3208 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3210 $error = $this->deleteOneMember($memberid);
3212 $this->error($error);
3214 if ($member->isAdmin())
3215 $this->action_usermanagement();
3217 $this->action_overview(_DELETED_MEMBER);
3222 * @todo document this
3224 function deleteOneMember($memberid) {
3227 $memberid = intval($memberid);
3228 $mem = MEMBER::createFromID($memberid);
3230 if (!$mem->canBeDeleted())
3231 return _ERROR_DELETEMEMBER;
3233 $manager->notify('PreDeleteMember', array('member' => &$mem));
3235 /* unlink comments from memberid */
3237 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. sql_real_escape_string($mem->getDisplayName())
3238 .'" WHERE cmember='.$memberid;
3242 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3245 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3248 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3251 // delete all associated plugin options
3252 NucleusPlugin::_deleteOptionValues('member', $memberid);
3254 $manager->notify('PostDeleteMember', array('member' => &$mem));
3260 * @todo document this
3262 function action_createnewlog() {
3263 global $member, $CONF, $manager;
3265 // Only Super-Admins can do this
3266 $member->isAdmin() or $this->disallow();
3270 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3272 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3274 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3276 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3278 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3281 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3282 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3285 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3288 <?php echo _EBLOG_CREATE_TEXT?>
3291 <form method="post" action="index.php"><div>
3293 <input type="hidden" name="action" value="addnewlog" />
3294 <?php $manager->addTicketHidden() ?>
3298 <td><?php echo _EBLOG_NAME?></td>
3299 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3301 <td><?php echo _EBLOG_SHORTNAME?>
3302 <?php help('shortblogname'); ?>
3304 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3306 <td><?php echo _EBLOG_DESC?></td>
3307 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3309 <td><?php echo _EBLOG_DEFSKIN?>
3310 <?php help('blogdefaultskin'); ?>
3314 $query = 'SELECT sdname as text, sdnumber as value'
3315 . ' FROM '.sql_table('skin_desc');
3316 $template['name'] = 'defskin';
3317 $template['tabindex'] = 50;
3318 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3319 showlist($query,'select',$template);
3323 <td><?php echo _EBLOG_OFFSET?>
3324 <?php help('blogtimeoffset'); ?>
3325 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
3327 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3329 <td><?php echo _EBLOG_ADMIN?>
3330 <?php help('teamadmin'); ?>
3332 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3334 <td><?php echo _EBLOG_CREATE?></td>
3335 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3344 * @todo document this
3346 function action_addnewlog() {
3347 global $member, $manager, $CONF;
3349 // Only Super-Admins can do this
3350 $member->isAdmin() or $this->disallow();
3352 $bname = trim(postVar('name'));
3353 $bshortname = trim(postVar('shortname'));
3354 $btimeoffset = postVar('timeoffset');
3355 $bdesc = trim(postVar('desc'));
3356 $bdefskin = postVar('defskin');
3358 if (!isValidShortName($bshortname))
3359 $this->error(_ERROR_BADSHORTBLOGNAME);
3361 if ($manager->existsBlog($bshortname))
3362 $this->error(_ERROR_DUPSHORTBLOGNAME);
3368 'shortname' => &$bshortname,
3369 'timeoffset' => &$btimeoffset,
3370 'description' => &$bdesc,
3371 'defaultskin' => &$bdefskin
3376 // add slashes for sql queries
3377 $bname = sql_real_escape_string($bname);
3378 $bshortname = sql_real_escape_string($bshortname);
3379 $btimeoffset = sql_real_escape_string($btimeoffset);
3380 $bdesc = sql_real_escape_string($bdesc);
3381 $bdefskin = sql_real_escape_string($bdefskin);
3384 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3386 $blogid = sql_insert_id();
3387 $blog =& $manager->getBlog($blogid);
3389 // create new category
3390 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3391 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3392 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3393 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3394 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3395 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3396 $catid = sql_insert_id();
3398 // set as default category
3399 $blog->setDefaultCategory($catid);
3400 $blog->writeSettings();
3402 // create team member
3403 $memberid = $member->getID();
3404 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3407 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3408 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3410 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3411 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3426 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3427 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3434 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3436 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, ENTITY::hsc($bname)) ?></p>
3439 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, ENTITY::hsc($bshortname)) ?></a></li>
3440 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3443 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, ENTITY::hsc($bshortname)) ?></a></h3>
3445 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, ENTITY::hsc($bshortname)) ?></p>
3448 $CONF['Self'] = '<b><?php echo ENTITY::hsc($bshortname)?>.php</b>';
3450 include('<i>./config.php</i>');
3452 selectBlog('<b><?php echo ENTITY::hsc($bshortname)?></b>');
3457 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3459 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3461 <form action="index.php" method="post"><div>
3462 <input type="hidden" name="action" value="addnewlog2" />
3463 <?php $manager->addTicketHidden() ?>
3464 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3466 <td><?php echo _EBLOG_URL?></td>
3467 <td><input name="url" maxlength="100" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3469 <td><?php echo _EBLOG_CREATE?></td>
3470 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3474 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3476 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3478 <form action="index.php" method="post"><div>
3479 <input type="hidden" name="action" value="addnewlog2" />
3480 <?php $manager->addTicketHidden() ?>
3481 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3483 <td><?php echo _EBLOG_URL?></td>
3484 <td><input name="url" maxlength="100" size="40" /></td>
3486 <td><?php echo _EBLOG_CREATE?></td>
3487 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3491 <?php $this->pagefoot();
3496 * @todo document this
3498 function action_addnewlog2() {
3499 global $member, $manager;
3501 $member->blogAdminRights($blogid) or $this->disallow();
3503 $burl = requestVar('url');
3504 $blogid = intRequestVar('blogid');
3506 $blog =& $manager->getBlog($blogid);
3507 $blog->setURL(trim($burl));
3508 $blog->writeSettings();
3510 $this->action_overview(_MSG_NEWBLOG);
3514 * @todo document this
3516 function action_skinieoverview() {
3517 global $member, $DIR_LIBS, $manager;
3519 $member->isAdmin() or $this->disallow();
3521 // load skinie class
3522 include_once($DIR_LIBS . 'skinie.php');
3526 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3529 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3531 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3532 <?php global $DIR_SKINS;
3534 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3536 if (sizeof($candidates) > 0) {
3538 <form method="post" action="index.php"><div>
3539 <input type="hidden" name="action" value="skinieimport" />
3540 <?php $manager->addTicketHidden() ?>
3541 <input type="hidden" name="mode" value="file" />
3542 <select name="skinfile" id="skinie_import_local">
3543 <?php foreach ($candidates as $skinname => $skinfile) {
3544 $html = ENTITY::hsc($skinfile);
3545 echo '<option value="',$html,'">',$skinname,'</option>';
3549 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3552 echo _SKINIE_NOCANDIDATES;
3557 <p><em><?php echo _OR?></em></p>
3559 <form method="post" action="index.php"><p>
3560 <?php $manager->addTicketHidden() ?>
3561 <input type="hidden" name="action" value="skinieimport" />
3562 <input type="hidden" name="mode" value="url" />
3563 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3564 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3565 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3569 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3570 <form method="post" action="index.php"><div>
3571 <input type="hidden" name="action" value="skinieexport" />
3572 <?php $manager->addTicketHidden() ?>
3574 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3577 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3579 <?php // show list of skins
3580 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3581 while ($skinObj = sql_fetch_object($res)) {
3582 $id = 'skinexp' . $skinObj->sdnumber;
3583 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3584 echo '<label for="',$id,'">',ENTITY::hsc($skinObj->sdname),'</label></td>';
3585 echo '<td>',ENTITY::hsc($skinObj->sddesc),'</td>';
3589 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3591 // show list of templates
3592 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3593 while ($templateObj = sql_fetch_object($res)) {
3594 $id = 'templateexp' . $templateObj->tdnumber;
3595 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3596 echo '<label for="',$id,'">',ENTITY::hsc($templateObj->tdname),'</label></td>';
3597 echo '<td>',ENTITY::hsc($templateObj->tddesc),'</td>';
3602 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3604 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3606 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3608 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3618 * @todo document this
3620 function action_skinieimport() {
3621 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3623 $member->isAdmin() or $this->disallow();
3625 // load skinie class
3626 include_once($DIR_LIBS . 'skinie.php');
3628 $skinFileRaw= postVar('skinfile');
3629 $mode = postVar('mode');
3631 $importer = new SKINIMPORT();
3633 // get full filename
3634 if ($mode == 'file')
3636 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3638 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3639 if (!file_exists($skinFile))
3640 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3642 $skinFile = $skinFileRaw;
3645 // read only metadata
3646 $error = $importer->readFile($skinFile, 1);
3649 $skinNameClashes = $importer->checkSkinNameClashes();
3650 $templateNameClashes = $importer->checkTemplateNameClashes();
3651 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3653 if ($error) $this->error($error);
3657 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3659 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3662 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3663 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3664 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3666 if ($hasNameClashes)
3669 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3670 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3672 } // if (hasNameClashes)
3676 <form method="post" action="index.php"><div>
3677 <input type="hidden" name="action" value="skiniedoimport" />
3678 <?php $manager->addTicketHidden() ?>
3679 <input type="hidden" name="skinfile" value="<?php echo ENTITY::hsc(postVar('skinfile'))?>" />
3680 <input type="hidden" name="mode" value="<?php echo ENTITY::hsc($mode)?>" />
3681 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3683 if ($hasNameClashes)
3687 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3689 } // if (hasNameClashes)
3699 * @todo document this
3701 function action_skiniedoimport() {
3702 global $member, $DIR_LIBS, $DIR_SKINS;
3704 $member->isAdmin() or $this->disallow();
3706 // load skinie class
3707 include_once($DIR_LIBS . 'skinie.php');
3709 $skinFileRaw= postVar('skinfile');
3710 $mode = postVar('mode');
3712 $allowOverwrite = intPostVar('overwrite');
3714 // get full filename
3715 if ($mode == 'file')
3717 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3719 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3720 if (!file_exists($skinFile))
3721 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3724 $skinFile = $skinFileRaw;
3727 $importer = new SKINIMPORT();
3729 $error = $importer->readFile($skinFile);
3732 $this->error($error);
3734 $error = $importer->writeToDatabase($allowOverwrite);
3737 $this->error($error);
3741 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3743 <h2><?php echo _SKINIE_DONE?></h2>
3746 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3747 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3748 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3751 <?php $this->pagefoot();
3756 * @todo document this
3758 function action_skinieexport() {
3759 global $member, $DIR_LIBS;
3761 $member->isAdmin() or $this->disallow();
3763 // load skinie class
3764 include_once($DIR_LIBS . 'skinie.php');
3766 $aSkins = requestIntArray('skin');
3767 $aTemplates = requestIntArray('template');
3769 if (!is_array($aTemplates)) $aTemplates = array();
3770 if (!is_array($aSkins)) $aSkins = array();
3772 $skinList = array_keys($aSkins);
3773 $templateList = array_keys($aTemplates);
3775 $info = postVar('info');
3777 $exporter = new SKINEXPORT();
3778 foreach ($skinList as $skinId) {
3779 $exporter->addSkin($skinId);
3781 foreach ($templateList as $templateId) {
3782 $exporter->addTemplate($templateId);
3784 $exporter->setInfo($info);
3786 $exporter->export();
3790 * @todo document this
3792 function action_templateoverview() {
3793 global $member, $manager;
3795 $member->isAdmin() or $this->disallow();
3799 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3801 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3802 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3804 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3805 $template['content'] = 'templatelist';
3806 $template['tabindex'] = 10;
3807 showlist($query,'table',$template);
3809 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3812 <form method="post" action="index.php"><div>
3814 <input name="action" value="templatenew" type="hidden" />
3815 <?php $manager->addTicketHidden() ?>
3817 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3818 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3820 <td><?php echo _TEMPLATE_DESC?></td>
3821 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3823 <td><?php echo _TEMPLATE_CREATE?></td>
3824 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3834 * @todo document this
3836 function action_templateedit($msg = '') {
3837 global $member, $manager;
3839 $templateid = intRequestVar('templateid');
3841 $member->isAdmin() or $this->disallow();
3843 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3844 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3846 $this->pagehead($extrahead);
3848 $templatename = TEMPLATE::getNameFromId($templateid);
3849 $templatedescription = TEMPLATE::getDesc($templateid);
3850 $template =& $manager->getTemplate($templatename);
3854 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3857 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo ENTITY::hsc($templatename); ?>'</h2>
3859 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3862 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3864 <form method="post" action="index.php">
3867 <input type="hidden" name="action" value="templateupdate" />
3868 <?php $manager->addTicketHidden() ?>
3869 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3872 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3874 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3875 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo ENTITY::hsc($templatename) ?>" /></td>
3877 <td><?php echo _TEMPLATE_DESC?></td>
3878 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo ENTITY::hsc($templatedescription) ?>" /></td>
3880 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3882 <td><?php echo _TEMPLATE_UPDATE?></td>
3884 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3885 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3888 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3889 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3890 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3891 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3892 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3893 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3894 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3897 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3898 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3899 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3900 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3901 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3902 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3903 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3904 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3907 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3909 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3912 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3913 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3916 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3917 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3918 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3919 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3922 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3923 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3924 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3925 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3928 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3929 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3930 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3931 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3934 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3935 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3936 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3937 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3938 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3939 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3942 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3943 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3944 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3945 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3948 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3949 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3950 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3953 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3956 $pluginfields = array();
3957 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3959 foreach ($pluginfields as $pfkey=>$pfvalue) {
3961 echo '<th colspan="2">' . ENTITY::hen($pfkey) . "</th>\n";
3962 foreach ($pfvalue as $pffield=>$pfdesc) {
3963 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3968 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3970 <td><?php echo _TEMPLATE_UPDATE?></td>
3972 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3973 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3984 * @todo document this
3986 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3988 if (!isset($template[$name])) $template[$name] = '';
3991 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3992 <td id="td<?php echo $count?>"><textarea class="templateedit" name="<?php echo $name?>" tabindex="<?php echo $tabindex?>" cols="50" rows="<?php echo $big?10:5?>" id="textarea<?php echo $count?>"><?php echo ENTITY::hsc($template[$name]); ?></textarea></td>
3997 * @todo document this
3999 function action_templateupdate() {
4000 global $member,$manager;
4002 $templateid = intRequestVar('templateid');
4004 $member->isAdmin() or $this->disallow();
4006 $name = postVar('tname');
4007 $desc = postVar('tdesc');
4009 if (!isValidTemplateName($name))
4010 $this->error(_ERROR_BADTEMPLATENAME);
4012 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
4013 $this->error(_ERROR_DUPTEMPLATENAME);
4016 $name = sql_real_escape_string($name);
4017 $desc = sql_real_escape_string($desc);
4019 // 1. Remove all template parts
4020 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4023 // 2. Update description
4024 $query = 'UPDATE '.sql_table('template_desc').' SET'
4025 . " tdname='" . $name . "',"
4026 . " tddesc='" . $desc . "'"
4027 . " WHERE tdnumber=" . $templateid;
4030 // 3. Add non-empty template parts
4031 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4032 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4033 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4034 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4035 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4036 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4037 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4038 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4039 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4040 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4041 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4042 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4043 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4044 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4045 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4046 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4047 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4048 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4049 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4050 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4051 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4052 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4053 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4054 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4055 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4056 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4057 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4058 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4059 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4060 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4061 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4062 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4063 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4064 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4066 $pluginfields = array();
4067 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4068 foreach ($pluginfields as $pfkey=>$pfvalue) {
4069 foreach ($pfvalue as $pffield=>$pfdesc) {
4070 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4074 // jump back to template edit
4075 $this->action_templateedit(_TEMPLATE_UPDATED);
4080 * @todo document this
4082 function addToTemplate($id, $partname, $content) {
4083 $partname = sql_real_escape_string($partname);
4084 $content = sql_real_escape_string($content);
4088 // don't add empty parts:
4089 if (!trim($content)) return -1;
4091 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
4092 . "VALUES ($id, '$partname', '$content')";
4093 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4094 return sql_insert_id();
4098 * @todo document this
4100 function action_templatedelete() {
4101 global $member, $manager;
4103 $member->isAdmin() or $this->disallow();
4105 $templateid = intRequestVar('templateid');
4106 // TODO: check if template can be deleted
4110 $name = TEMPLATE::getNameFromId($templateid);
4111 $desc = TEMPLATE::getDesc($templateid);
4114 <h2><?php echo _DELETE_CONFIRM?></h2>
4117 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo ENTITY::hsc($name)?></b> (<?php echo ENTITY::hsc($desc) ?>)
4120 <form method="post" action="index.php"><div>
4121 <input type="hidden" name="action" value="templatedeleteconfirm" />
4122 <?php $manager->addTicketHidden() ?>
4123 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4124 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4131 * @todo document this
4133 function action_templatedeleteconfirm() {
4134 global $member, $manager;
4136 $templateid = intRequestVar('templateid');
4138 $member->isAdmin() or $this->disallow();
4140 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4142 // 1. delete description
4143 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4146 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4148 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4150 $this->action_templateoverview();
4154 * @todo document this
4156 function action_templatenew() {
4159 $member->isAdmin() or $this->disallow();
4161 $name = postVar('name');
4162 $desc = postVar('desc');
4164 if (!isValidTemplateName($name))
4165 $this->error(_ERROR_BADTEMPLATENAME);
4167 if (TEMPLATE::exists($name))
4168 $this->error(_ERROR_DUPTEMPLATENAME);
4170 $newTemplateId = TEMPLATE::createNew($name, $desc);
4172 $this->action_templateoverview();
4176 * @todo document this
4178 function action_templateclone() {
4181 $templateid = intRequestVar('templateid');
4183 $member->isAdmin() or $this->disallow();
4185 // 1. read old template
4186 $name = TEMPLATE::getNameFromId($templateid);
4187 $desc = TEMPLATE::getDesc($templateid);
4189 // 2. create desc thing
4190 $name = "cloned" . $name;
4192 // if a template with that name already exists:
4193 if (TEMPLATE::exists($name)) {
4195 while (TEMPLATE::exists($name . $i))
4200 $newid = TEMPLATE::createNew($name, $desc);
4203 // go through parts of old template and add them to the new one
4204 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4205 while ($o = sql_fetch_object($res)) {
4206 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4209 $this->action_templateoverview();
4213 * @todo document this
4215 function action_skinoverview() {
4216 global $member, $manager;
4218 $member->isAdmin() or $this->disallow();
4222 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4224 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4226 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4228 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4229 $template['content'] = 'skinlist';
4230 $template['tabindex'] = 10;
4231 showlist($query,'table',$template);
4233 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4236 <form method="post" action="index.php">
4239 <input name="action" value="skinnew" type="hidden" />
4240 <?php $manager->addTicketHidden() ?>
4242 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4243 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4245 <td><?php echo _SKIN_DESC?></td>
4246 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4248 <td><?php echo _SKIN_CREATE?></td>
4249 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4260 * @todo document this
4262 function action_skinnew() {
4265 $member->isAdmin() or $this->disallow();
4267 $name = trim(postVar('name'));
4268 $desc = trim(postVar('desc'));
4270 if (!isValidSkinName($name))
4271 $this->error(_ERROR_BADSKINNAME);
4273 if (SKIN::exists($name))
4274 $this->error(_ERROR_DUPSKINNAME);
4276 $newId = SKIN::createNew($name, $desc);
4278 $this->action_skinoverview();
4282 * @todo document this
4284 function action_skinedit() {
4285 global $member, $manager;
4287 $skinid = intRequestVar('skinid');
4289 $member->isAdmin() or $this->disallow();
4291 $skin = new SKIN($skinid);
4296 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4298 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4300 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4301 <?php echo _SKIN_PARTS_MSG?>
4303 <li><a tabindex="10" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
4304 <li><a tabindex="20" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
4305 <li><a tabindex="30" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
4306 <li><a tabindex="40" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
4307 <li><a tabindex="50" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
4308 <li><a tabindex="60" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
4309 <li><a tabindex="70" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
4310 <li><a tabindex="75" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
4315 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4316 $res = sql_query($query);
4318 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4319 echo '<form method="get" action="index.php">' . "\r\n";
4320 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4321 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4322 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4323 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4324 echo '</form>' . "\r\n";
4326 if ($res && sql_num_rows($res) > 0) {
4330 while ($row = sql_fetch_assoc($res)) {
4331 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">' . ENTITY::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
4339 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4340 <form method="post" action="index.php">
4343 <input type="hidden" name="action" value="skineditgeneral" />
4344 <?php $manager->addTicketHidden() ?>
4345 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4347 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4348 <td><input name="name" tabindex="90" value="<?php echo ENTITY::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4350 <td><?php echo _SKIN_DESC?></td>
4351 <td><input name="desc" tabindex="100" value="<?php echo ENTITY::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4353 <td><?php echo _SKIN_TYPE?></td>
4354 <td><input name="type" tabindex="110" value="<?php echo ENTITY::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4356 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4357 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4359 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4360 <td><input name="inc_prefix" tabindex="130" value="<?php echo ENTITY::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4362 <td><?php echo _SKIN_CHANGE?></td>
4363 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4370 <?php $this->pagefoot();
4374 * @todo document this
4376 function action_skineditgeneral() {
4379 $skinid = intRequestVar('skinid');
4381 $member->isAdmin() or $this->disallow();
4383 $name = postVar('name');
4384 $desc = postVar('desc');
4385 $type = postVar('type');
4386 $inc_mode = postVar('inc_mode');
4387 $inc_prefix = postVar('inc_prefix');
4389 $skin = new SKIN($skinid);
4392 if (!isValidSkinName($name))
4393 $this->error(_ERROR_BADSKINNAME);
4395 if (($skin->getName() != $name) && SKIN::exists($name))
4396 $this->error(_ERROR_DUPSKINNAME);
4398 if (!$type) $type = 'text/html';
4399 if (!$inc_mode) $inc_mode = 'normal';
4401 // 2. Update description
4402 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4404 $this->action_skinedit();
4409 * @todo document this
4411 function action_skinedittype($msg = '') {
4412 global $member, $manager;
4414 $skinid = intRequestVar('skinid');
4415 $type = requestVar('type');
4417 $member->isAdmin() or $this->disallow();
4419 $type = trim($type);
4420 $type = strtolower($type);
4422 if (!isValidShortName($type)) {
4423 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4426 $skin = new SKIN($skinid);
4428 $friendlyNames = SKIN::getFriendlyNames();
4432 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4434 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo ENTITY::hsc($skin->getName()) ?>': <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4436 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4440 <form method="post" action="index.php">
4443 <input type="hidden" name="action" value="skinupdate" />
4444 <?php $manager->addTicketHidden() ?>
4445 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4446 <input type="hidden" name="type" value="<?php echo $type ?>" />
4448 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4449 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4450 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4451 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4452 help('skinpart' . $type);
4454 help('skinpartspecial');
4458 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo ENTITY::hsc($skin->getContent($type)) ?></textarea>
4461 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4462 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4463 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4466 <?php echo _SKIN_ALLOWEDVARS?>
4467 <?php $actions = SKIN::getAllowedActionsForType($type);
4471 while ($current = array_shift($actions)) {
4472 // skip deprecated vars
4473 if ($current == 'ifcat') continue;
4474 if ($current == 'imagetext') continue;
4475 if ($current == 'vars') continue;
4477 echo helplink('skinvar-' . $current) . "$current</a>";
4478 if (count($actions) != 0) echo ", ";
4480 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4481 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4482 showlist($query,'table',array('content'=>'shortblognames'));
4483 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4484 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4485 showlist($query,'table',array('content'=>'shortnames'));
4486 echo '</div></form>';
4491 * @todo document this
4493 function action_skinupdate() {
4496 $skinid = intRequestVar('skinid');
4497 $content = trim(postVar('content'));
4498 $type = postVar('type');
4500 $member->isAdmin() or $this->disallow();
4502 $skin = new SKIN($skinid);
4503 $skin->update($type, $content);
4505 $this->action_skinedittype(_SKIN_UPDATED);
4509 * @todo document this
4511 function action_skindelete() {
4512 global $member, $manager, $CONF;
4514 $skinid = intRequestVar('skinid');
4516 $member->isAdmin() or $this->disallow();
4518 // don't allow default skin to be deleted
4519 if ($skinid == $CONF['BaseSkin'])
4520 $this->error(_ERROR_DEFAULTSKIN);
4522 // don't allow deletion of default skins for blogs
4523 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4524 $r = sql_query($query);
4525 if ($o = sql_fetch_object($r))
4526 $this->error(_ERROR_SKINDEFDELETE . ENTITY::hsc($o->bname));
4530 $skin = new SKIN($skinid);
4531 $name = $skin->getName();
4532 $desc = $skin->getDescription();
4535 <h2><?php echo _DELETE_CONFIRM?></h2>
4538 <?php echo _CONFIRMTXT_SKIN?><b><?php echo ENTITY::hsc($name) ?></b> (<?php echo ENTITY::hsc($desc)?>)
4541 <form method="post" action="index.php"><div>
4542 <input type="hidden" name="action" value="skindeleteconfirm" />
4543 <?php $manager->addTicketHidden() ?>
4544 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4545 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4552 * @todo document this
4554 function action_skindeleteconfirm() {
4555 global $member, $CONF, $manager;
4557 $skinid = intRequestVar('skinid');
4559 $member->isAdmin() or $this->disallow();
4561 // don't allow default skin to be deleted
4562 if ($skinid == $CONF['BaseSkin'])
4563 $this->error(_ERROR_DEFAULTSKIN);
4565 // don't allow deletion of default skins for blogs
4566 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4567 $r = sql_query($query);
4568 if ($o = sql_fetch_object($r))
4569 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4571 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4573 // 1. delete description
4574 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4577 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4579 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4581 $this->action_skinoverview();
4585 * @todo document this
4587 function action_skinremovetype() {
4588 global $member, $manager, $CONF;
4590 $skinid = intRequestVar('skinid');
4591 $skintype = requestVar('type');
4593 if (!isValidShortName($skintype)) {
4594 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4597 $member->isAdmin() or $this->disallow();
4599 // don't allow default skinparts to be deleted
4600 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4601 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4606 $skin = new SKIN($skinid);
4607 $name = $skin->getName();
4608 $desc = $skin->getDescription();
4611 <h2><?php echo _DELETE_CONFIRM?></h2>
4614 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo ENTITY::hsc($skintype); ?> (<?php echo ENTITY::hsc($name); ?>)</b> (<?php echo ENTITY::hsc($desc)?>)
4617 <form method="post" action="index.php"><div>
4618 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4619 <?php $manager->addTicketHidden() ?>
4620 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4621 <input type="hidden" name="type" value="<?php echo ENTITY::hsc($skintype); ?>" />
4622 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4629 * @todo document this
4631 function action_skinremovetypeconfirm() {
4632 global $member, $CONF, $manager;
4634 $skinid = intRequestVar('skinid');
4635 $skintype = requestVar('type');
4637 if (!isValidShortName($skintype)) {
4638 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4641 $member->isAdmin() or $this->disallow();
4643 // don't allow default skinparts to be deleted
4644 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4645 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4648 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4651 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4653 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4655 $this->action_skinedit();
4659 * @todo document this
4661 function action_skinclone() {
4664 $skinid = intRequestVar('skinid');
4666 $member->isAdmin() or $this->disallow();
4668 // 1. read skin to clone
4669 $skin = new SKIN($skinid);
4671 $name = "clone_" . $skin->getName();
4673 // if a skin with that name already exists:
4674 if (SKIN::exists($name)) {
4676 while (SKIN::exists($name . $i))
4681 // 2. create skin desc
4682 $newid = SKIN::createNew(
4684 $skin->getDescription(),
4685 $skin->getContentType(),
4686 $skin->getIncludeMode(),
4687 $skin->getIncludePrefix()
4693 $this->skinclonetype($skin, $newid, 'index');
4694 $this->skinclonetype($skin, $newid, 'item');
4695 $this->skinclonetype($skin, $newid, 'archivelist');
4696 $this->skinclonetype($skin, $newid, 'archive');
4697 $this->skinclonetype($skin, $newid, 'search');
4698 $this->skinclonetype($skin, $newid, 'error');
4699 $this->skinclonetype($skin, $newid, 'member');
4700 $this->skinclonetype($skin, $newid, 'imagepopup');
4703 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4704 $res = sql_query($query);
4705 while ($row = sql_fetch_assoc($res)) {
4706 $this->skinclonetype($skin, $newid, $row['stype']);
4709 $this->action_skinoverview();
4714 * @todo document this
4716 function skinclonetype($skin, $newid, $type) {
4717 $newid = intval($newid);
4718 $content = $skin->getContent($type);
4720 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". sql_real_escape_string($content)."', '". sql_real_escape_string($type)."')";
4726 * @todo document this
4728 function action_settingsedit() {
4729 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4731 $member->isAdmin() or $this->disallow();
4735 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4738 <h2><?php echo _SETTINGS_TITLE?></h2>
4740 <form action="index.php" method="post">
4743 <input type="hidden" name="action" value="settingsupdate" />
4744 <?php $manager->addTicketHidden() ?>
4747 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4749 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4752 $query = 'SELECT bname as text, bnumber as value'
4753 . ' FROM '.sql_table('blog');
4754 $template['name'] = 'DefaultBlog';
4755 $template['selected'] = $CONF['DefaultBlog'];
4756 $template['tabindex'] = 10;
4757 showlist($query,'select',$template);
4761 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4764 $query = 'SELECT sdname as text, sdnumber as value'
4765 . ' FROM '.sql_table('skin_desc');
4766 $template['name'] = 'BaseSkin';
4767 $template['selected'] = $CONF['BaseSkin'];
4768 $template['tabindex'] = 1;
4769 showlist($query,'select',$template);
4773 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4774 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo ENTITY::hsc($CONF['AdminEmail']) ?>" /></td>
4776 <td><?php echo _SETTINGS_SITENAME?></td>
4777 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo ENTITY::hsc($CONF['SiteName']) ?>" /></td>
4779 <td><?php echo _SETTINGS_SITEURL?></td>
4780 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL']) ?>" /></td>
4782 <td><?php echo _SETTINGS_ADMINURL?></td>
4783 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo ENTITY::hsc($CONF['AdminURL']) ?>" /></td>
4785 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4786 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo ENTITY::hsc($CONF['PluginURL']) ?>" /></td>
4788 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4789 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo ENTITY::hsc($CONF['SkinsURL']) ?>" /></td>
4791 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4792 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo ENTITY::hsc($CONF['ActionURL']) ?>" /></td>
4794 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4797 <select name="Language" tabindex="10050">
4799 $locales = i18n::get_available_locale_list();
4800 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4802 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4806 echo "<option value=\"\">en_Latn_US</option>\n";
4809 foreach ( $locales as $locale )
4811 if ( $locale == 'en_Latn_US' )
4815 if ( $locale == i18n::get_current_locale() )
4817 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4821 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4829 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4831 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4833 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo ENTITY::hsc($CONF['DisableSiteURL'])?>" />
4836 <td><?php echo _SETTINGS_DIRS?></td>
4837 <td><?php echo ENTITY::hsc($DIR_NUCLEUS) ?>
4838 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4840 <td><?php echo _SETTINGS_DBLOGIN?></td>
4841 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4845 echo _SETTINGS_JSTOOLBAR
4846 /* =_SETTINGS_DISABLEJS
4848 I temporary changed the meaning of DisableJsTools, until I can find a good
4849 way to select the javascript version to use
4853 1 : all javascript disabled
4854 2 : 'simpler' javascript (for mozilla/opera/mac)
4858 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4859 <select name="DisableJsTools" tabindex="10075">
4860 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4861 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4862 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4863 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4864 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4865 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4870 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4873 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4874 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4876 echo ' ', _SETTINGS_URLMODE_HELP;
4882 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4885 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4891 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4894 if (!array_key_exists('DefaultListSize',$CONF)) {
4895 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4896 $CONF['DefaultListSize'] = 10;
4899 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo ENTITY::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4902 <td><?php echo _SETTINGS_ADMINCSS?>
4906 <select name="AdminCSS" tabindex="10080">
4907 <?php // show a dropdown list of all available admin css files
4908 global $DIR_NUCLEUS;
4910 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4912 while ($filename = readdir($dirhandle) )
4915 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4916 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4918 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4921 $name = $matches[1];
4922 echo "<option value=\"$name\"";
4924 if ($name == $CONF['AdminCSS'])
4926 echo " selected=\"selected\"";
4929 echo ">$name</option>";
4935 closedir($dirhandle);
4942 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4944 <td><?php echo _SETTINGS_MEDIADIR?></td>
4945 <td><?php echo ENTITY::hsc($DIR_MEDIA) ?>
4946 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4947 <?php if (!is_dir($DIR_MEDIA))
4948 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4949 if (!is_readable($DIR_MEDIA))
4950 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4951 if (!is_writeable($DIR_MEDIA))
4952 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4956 <td><?php echo _SETTINGS_MEDIAURL?></td>
4958 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo ENTITY::hsc($CONF['MediaURL']) ?>" />
4961 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4962 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4964 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4966 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo ENTITY::hsc($CONF['AllowedTypes']) ?>" />
4969 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4971 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo ENTITY::hsc($CONF['MaxUploadSize']) ?>" />
4974 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4975 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4978 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4980 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4981 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4983 <td><?php echo _SETTINGS_ALLOWCREATE?>
4984 <?php help('allowaccountcreation'); ?>
4986 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4989 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4990 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4992 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4995 <td><?php echo _SETTINGS_MEMBERMSGS?>
4996 <?php help('messageservice'); ?>
4998 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
5001 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
5002 <?php help('messageservice'); ?>
5004 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5007 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5008 <?php help('protectmemnames'); ?>
5010 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5016 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5018 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5019 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePrefix'])?>" /></td>
5021 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5022 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo ENTITY::hsc($CONF['CookieDomain'])?>" /></td>
5024 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5025 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePath'])?>" /></td>
5027 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5028 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5030 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5031 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5032 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5035 <td><?php echo _SETTINGS_LASTVISIT?></td>
5036 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5041 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5043 <td><?php echo _SETTINGS_UPDATE?></td>
5044 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5051 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5054 'GeneralSettingsFormExtras',
5062 * ADMIN::action_settingsupdate()
5063 * Update $CONFIG and redirect
5068 function action_settingsupdate() {
5069 global $member, $CONF;
5071 $member->isAdmin() or $this->disallow();
5073 // check if email address for admin is valid
5074 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5076 $this->error(_ERROR_BADMAILADDRESS);
5080 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5081 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5082 $this->updateConfig('IndexURL', postVar('IndexURL'));
5083 $this->updateConfig('AdminURL', postVar('AdminURL'));
5084 $this->updateConfig('PluginURL', postVar('PluginURL'));
5085 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5086 $this->updateConfig('ActionURL', postVar('ActionURL'));
5087 $this->updateConfig('Language', postVar('Language'));
5088 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5089 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5090 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5091 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5092 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5093 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5094 $this->updateConfig('SiteName', postVar('SiteName'));
5095 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5096 $this->updateConfig('DisableSite', postVar('DisableSite'));
5097 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5098 $this->updateConfig('LastVisit', postVar('LastVisit'));
5099 $this->updateConfig('MediaURL', postVar('MediaURL'));
5100 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5101 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5102 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5103 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5104 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5105 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5106 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5107 $this->updateConfig('CookiePath', postVar('CookiePath'));
5108 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5109 $this->updateConfig('URLMode', postVar('URLMode'));
5110 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5111 $this->updateConfig('DebugVars', postVar('DebugVars'));
5112 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5113 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5115 // load new config and redirect (this way, the new language will be used is necessary)
5116 // note that when changing cookie settings, this redirect might cause the user
5117 // to have to log in again.
5119 redirect($CONF['AdminURL'] . '?action=manage');
5124 * ADMIN::action_systemoverview()
5125 * Output system overview
5130 function action_systemoverview()
5132 global $member, $nucleus, $CONF;
5136 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5138 if ( $member->isLoggedIn() && $member->isAdmin() )
5140 // Information about the used PHP and MySQL installation
5141 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5143 // Version of PHP MySQL
5144 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5147 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5152 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5153 echo '<td>' . phpversion() . "</td>\n";
5156 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5157 echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5160 echo "</table>\n\n";
5162 // Important PHP settings
5163 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5166 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5171 echo '<td>magic_quotes_gpc' . "</td>\n";
5172 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5173 echo '<td>' . $mqg . "</td>\n";
5176 echo '<td>magic_quotes_runtime' . "</td>\n";
5177 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5178 echo '<td>' . $mqr . "</td>\n";
5181 echo '<td>register_globals' . "</td>\n";
5182 $rg = ini_get('register_globals') ? 'On' : 'Off';
5183 echo '<td>' . $rg . "</td>\n";
5186 echo "</table>\n\n";
5188 // Information about GD library
5189 $gdinfo = gd_info();
5190 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5193 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5197 foreach ( $gdinfo as $key=>$value )
5199 if ( is_bool($value) )
5201 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5205 $value = ENTITY::hsc($value);
5208 echo '<td>' . $key . "</td>\n";
5209 echo '<td>' . $value . "</td>\n";
5213 echo "</table>\n\n";
5215 // Check if special modules are loaded
5217 phpinfo(INFO_MODULES);
5218 $im = ob_get_contents();
5220 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5223 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5227 echo '<td>mod_rewrite' . "</td>\n";
5228 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5229 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5230 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5231 echo '<td>' . $modrewrite . "</td>\n";
5234 echo "</table>\n\n";
5236 // Information about the used Nucleus CMS
5237 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5239 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5240 $np = getNucleusPatchLevel();
5241 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5244 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5249 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5250 echo '<td>' . $nv . "</td>\n";
5253 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5254 echo '<td>' . $np . "</td>\n";
5257 echo "</table>\n\n";
5259 // Important settings of the installation
5260 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5263 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5268 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5269 echo '<td>' . $CONF['Self'] . "</td>\n";
5272 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5273 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5276 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5277 $ohs = $CONF['alertOnHeadersSent'] ?
5278 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5279 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5280 echo '<td>' . $ohs . "</td>\n";
5283 echo "<td>i18n::get_current_charset()</td>\n";
5284 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5287 echo "</table>\n\n";
5289 // Link to the online version test at the Nucleus CMS website
5290 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5291 if ( $nucleus['codename'] != '')
5293 $codenamestring = ' "' . $nucleus['codename'] . '"';
5297 $codenamestring = '';
5299 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5300 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5301 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5302 echo 'Nucleus CMS ' . $nv . $codenamestring;
5307 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5313 * ADMIN::updateConfig()
5315 * @param string $name
5316 * @param string $val
5317 * @return integer return the ID in which the latest query posted
5319 function updateConfig($name, $val)
5321 $name = sql_real_escape_string($name);
5322 $val = trim(sql_real_escape_string($val));
5324 $query = "UPDATE %s SET value='%s' WHERE name='%s'";
5325 $query = sprintf($query, sql_table('config'), $val, $name);
5326 sql_query($query) or die("Query error: " . sql_error());
5327 return sql_insert_id();
5332 * @param string $msg message that will be shown
5334 function error($msg)
5338 echo "<h2>Error!</h2>\n";
5341 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5348 * add error log and show error page
5355 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5356 $this->error(_ERROR_DISALLOWED);
5361 * Output admin page head
5366 function pagehead($extrahead = '')
5368 global $member, $nucleus, $CONF, $manager;
5373 'extrahead' => &$extrahead,
5374 'action' => $this->action));
5376 $baseUrl = ENTITY::hsc($CONF['AdminURL']);
5377 if ( !array_key_exists('AdminCSS',$CONF) )
5379 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5380 $CONF['AdminCSS'] = 'original';
5383 /* HTTP 1.1 application for no caching */
5384 header("Cache-Control: no-cache, must-revalidate");
5385 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5387 $root_element = 'html';
5388 $charset = i18n::get_current_charset();
5389 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5391 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5392 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5393 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5395 echo '<title>' . ENTITY::hsc($CONF['SiteName']) . " - Admin</title>\n";
5396 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5397 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5398 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5399 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5400 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5401 echo "{$extrahead}\n";
5404 echo "<div id=\"adminwrapper\">\n";
5405 echo "<div class=\"header\">\n";
5406 echo '<h1>' . ENTITY::hsc($CONF['SiteName']) . "</h1>\n";
5408 echo "<div id=\"container\">\n";
5409 echo "<div id=\"content\">\n";
5410 echo "<div class=\"loginname\">\n";
5411 if ( $member->isLoggedIn() )
5413 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5414 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5418 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5420 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5423 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5425 $codenamestring = ' "' . $nucleus['codename'].'"';
5429 $codenamestring = '';
5432 if ( $member->isLoggedIn() && $member->isAdmin() )
5434 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5435 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5437 $newestVersion = getLatestVersion();
5438 $newestCompare = str_replace('/','.',$newestVersion);
5439 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5440 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5443 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5444 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5450 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5459 * Output admin page foot include quickmenu
5466 global $action, $member, $manager;
5470 array('action' => $this->action)
5473 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5475 echo '<h2>' . _LOGOUT . "</h2>\n";
5477 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5478 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5482 echo "<div class=\"foot\">\n";
5483 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5485 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5488 echo "<!-- content -->\n";
5489 echo "<div id=\"quickmenu\">\n";
5491 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5494 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5497 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5498 echo "<form method=\"get\" action=\"index.php\">\n";
5500 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5502 $showAll = requestVar('showall');
5504 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5506 // Super-Admins have access to all blogs! (no add item support though)
5507 $query = 'SELECT bnumber as value, bname as text'
5508 . ' FROM ' . sql_table('blog')
5509 . ' ORDER BY bname';
5513 $query = 'SELECT bnumber as value, bname as text'
5514 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5515 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5516 . ' ORDER BY bname';
5518 $template['name'] = 'blogid';
5519 $template['tabindex'] = 15000;
5520 $template['extra'] = _QMENU_ADD_SELECT;
5521 $template['selected'] = -1;
5522 $template['shorten'] = 10;
5523 $template['shortenel'] = '';
5524 $template['javascript'] = 'onchange="return form.submit()"';
5525 showlist($query,'select',$template);
5530 echo "<h2>{$member->getDisplayName()}</h2>\n";
5532 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5533 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5534 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5537 // ---- general settings ----
5538 if ( $member->isAdmin() )
5540 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5542 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5543 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5544 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5545 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5546 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5547 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5548 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5551 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5553 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5554 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5555 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5559 $aPluginExtras = array();
5563 'options' => &$aPluginExtras));
5565 if ( count($aPluginExtras) > 0 )
5567 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5569 foreach ( $aPluginExtras as $aInfo )
5571 echo '<li><a href="' . ENTITY::hsc($aInfo['url']) . '" title="' . ENTITY::hsc($aInfo['tooltip']) . '">' . ENTITY::hsc($aInfo['title']) . "</a></li>\n";
5576 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5579 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5583 // introduction text on login screen
5584 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5587 echo "<!-- quickmenu -->\n";
5590 echo "<!-- content -->\n";
5593 echo "<!-- container -->\n";
5596 echo "<!-- adminwrapper -->\n";
5605 * @todo document this
5607 function action_regfile() {
5608 global $member, $CONF;
5610 $blogid = intRequestVar('blogid');
5612 $member->teamRights($blogid) or $this->disallow();
5614 // header-code stolen from phpMyAdmin
5615 // REGEDIT and bookmarklet code stolen from GreyMatter
5617 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5620 header('Content-Type: application/octetstream');
5621 header('Content-Disposition: filename="nucleus.reg"');
5622 header('Pragma: no-cache');
5623 header('Expires: 0');
5626 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5627 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5628 echo '"contexts"=hex:31';
5632 * @todo document this
5634 function action_bookmarklet() {
5635 global $member, $manager;
5637 $blogid = intRequestVar('blogid');
5639 $member->teamRights($blogid) or $this->disallow();
5641 $blog =& $manager->getBlog($blogid);
5642 $bm = getBookmarklet($blogid);
5646 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5650 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5653 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5656 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5658 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5661 <?php echo '<a href="' . ENTITY::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, ENTITY::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5664 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5667 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5668 $url = $manager->addTicketToUrl($url);
5670 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . ENTITY::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5674 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5677 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5679 <?php echo _BOOKMARKLET_DELETEBAR ?>
5683 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5687 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5688 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5689 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5690 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5691 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5700 * @todo document this
5702 function action_actionlog() {
5703 global $member, $manager;
5705 $member->isAdmin() or $this->disallow();
5709 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5711 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5714 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5715 <p><a href="<?php echo ENTITY::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5717 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5719 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5720 $template['content'] = 'actionlist';
5721 $amount = showlist($query,'table',$template);
5728 * @todo document this
5730 function action_banlist() {
5731 global $member, $manager;
5733 $blogid = intRequestVar('blogid');
5735 $member->blogAdminRights($blogid) or $this->disallow();
5737 $blog =& $manager->getBlog($blogid);
5741 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5743 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5745 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5746 $template['content'] = 'banlist';
5747 $amount = showlist($query,'table',$template);
5752 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5753 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5761 * @todo document this
5763 function action_banlistdelete() {
5764 global $member, $manager;
5766 $blogid = intRequestVar('blogid');
5767 $iprange = requestVar('iprange');
5769 $member->blogAdminRights($blogid) or $this->disallow();
5771 $blog =& $manager->getBlog($blogid);
5772 $banBlogName = ENTITY::hsc($blog->getName());
5776 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5778 <form method="post" action="index.php">
5780 <h3><?php echo _BAN_IPRANGE?></h3>
5783 <?php echo _CONFIRMTXT_BAN?> <?php echo ENTITY::hsc($iprange) ?>
5784 <input name="iprange" type="hidden" value="<?php echo ENTITY::hsc($iprange)?>" />
5787 <h3><?php echo _BAN_BLOGS?></h3>
5790 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5791 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5792 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5794 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5797 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5800 <?php $manager->addTicketHidden() ?>
5801 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5802 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5811 * @todo document this
5813 function action_banlistdeleteconfirm() {
5814 global $member, $manager;
5816 $blogid = intPostVar('blogid');
5817 $allblogs = postVar('allblogs');
5818 $iprange = postVar('iprange');
5820 $member->blogAdminRights($blogid) or $this->disallow();
5825 if (BAN::removeBan($blogid, $iprange))
5826 array_push($deleted, $blogid);
5828 // get blogs fot which member has admin rights
5829 $adminblogs = $member->getAdminBlogs();
5830 foreach ($adminblogs as $blogje) {
5831 if (BAN::removeBan($blogje, $iprange))
5832 array_push($deleted, $blogje);
5836 if (sizeof($deleted) == 0)
5837 $this->error(_ERROR_DELETEBAN);
5841 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5842 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5843 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5846 foreach ($deleted as $delblog) {
5847 $b =& $manager->getBlog($delblog);
5848 echo "<li>" . ENTITY::hsc($b->getName()). "</li>";
5857 * @todo document this
5859 function action_banlistnewfromitem() {
5860 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5864 * @todo document this
5866 function action_banlistnew($blogid = '') {
5867 global $member, $manager;
5870 $blogid = intRequestVar('blogid');
5872 $ip = requestVar('ip');
5874 $member->blogAdminRights($blogid) or $this->disallow();
5876 $blog =& $manager->getBlog($blogid);
5880 <h2><?php echo _BAN_ADD_TITLE?></h2>
5883 <form method="post" action="index.php">
5885 <h3><?php echo _BAN_IPRANGE?></h3>
5887 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5890 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5891 <?php echo _BAN_EXAMPLE_TEXT ?>
5897 $iprangeVal = ENTITY::hsc($ip);
5899 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5900 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5902 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5903 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5904 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5907 echo "<input name='iprange' value='custom' type='hidden' />";
5908 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5913 <h3><?php echo _BAN_BLOGS?></h3>
5915 <p><?php echo _BAN_BLOGS_TEXT?></p>
5918 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5919 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo ENTITY::hsc($blog->getName())?>'</label>
5921 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5924 <h3><?php echo _BAN_REASON_TITLE?></h3>
5926 <p><?php echo _BAN_REASON_TEXT?></p>
5928 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5930 <h3><?php echo _BAN_ADD_TITLE?></h3>
5933 <input name="action" type="hidden" value="banlistadd" />
5934 <?php $manager->addTicketHidden() ?>
5935 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5940 <?php $this->pagefoot();
5944 * @todo document this
5946 function action_banlistadd() {
5949 $blogid = intPostVar('blogid');
5950 $allblogs = postVar('allblogs');
5951 $iprange = postVar('iprange');
5952 if ($iprange == "custom")
5953 $iprange = postVar('customiprange');
5954 $reason = postVar('reason');
5956 $member->blogAdminRights($blogid) or $this->disallow();
5958 // TODO: check IP range validity
5961 if (!BAN::addBan($blogid, $iprange, $reason))
5962 $this->error(_ERROR_ADDBAN);
5964 // get blogs fot which member has admin rights
5965 $adminblogs = $member->getAdminBlogs();
5967 foreach ($adminblogs as $blogje) {
5968 if (!BAN::addBan($blogje, $iprange, $reason))
5972 $this->error(_ERROR_ADDBAN);
5975 $this->action_banlist();
5980 * @todo document this
5982 function action_clearactionlog() {
5985 $member->isAdmin() or $this->disallow();
5989 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5993 * @todo document this
5995 function action_backupoverview() {
5996 global $member, $manager;
5998 $member->isAdmin() or $this->disallow();
6002 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6004 <h2><?php echo _BACKUPS_TITLE?></h2>
6006 <h3><?php echo _BACKUP_TITLE?></h3>
6008 <p><?php echo _BACKUP_INTRO?></p>
6010 <form method="post" action="index.php"><p>
6011 <input type="hidden" name="action" value="backupcreate" />
6012 <?php $manager->addTicketHidden() ?>
6014 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
6016 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
6018 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
6022 <div class="note"><?php echo _BACKUP_NOTE?></div>
6025 <h3><?php echo _RESTORE_TITLE?></h3>
6027 <div class="note"><?php echo _RESTORE_NOTE?></div>
6029 <p><?php echo _RESTORE_INTRO?></p>
6031 <form method="post" action="index.php" enctype="multipart/form-data"><p>
6032 <input type="hidden" name="action" value="backuprestore" />
6033 <?php $manager->addTicketHidden() ?>
6034 <input name="backup_file" type="file" tabindex="30" />
6036 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
6037 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
6038 <br /><?php echo _RESTORE_WARNING?>
6041 <?php $this->pagefoot();
6045 * @todo document this
6047 function action_backupcreate() {
6048 global $member, $DIR_LIBS;
6050 $member->isAdmin() or $this->disallow();
6052 // use compression ?
6053 $useGzip = intval(postVar('gzip'));
6055 include($DIR_LIBS . 'backup.php');
6057 // try to extend time limit
6058 // (creating/restoring dumps might take a while)
6059 @set_time_limit(1200);
6062 $bu->do_backup($useGzip);
6067 * @todo document this
6069 function action_backuprestore() {
6070 global $member, $DIR_LIBS;
6072 $member->isAdmin() or $this->disallow();
6074 if (intPostVar('letsgo') != 1)
6075 $this->error(_ERROR_BACKUP_NOTSURE);
6077 include($DIR_LIBS . 'backup.php');
6079 // try to extend time limit
6080 // (creating/restoring dumps might take a while)
6081 @set_time_limit(1200);
6084 $message = $bu->do_restore();
6086 $this->error($message);
6090 <h2><?php echo _RESTORE_COMPLETE?></h2>
6091 <?php $this->pagefoot();
6096 * @todo document this
6098 function action_pluginlist() {
6099 global $member, $manager;
6102 $member->isAdmin() or $this->disallow();
6106 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6108 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6110 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6113 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6115 $template['content'] = 'pluginlist';
6116 $template['tabindex'] = 10;
6117 showlist($query, 'table', $template);
6120 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
6122 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
6124 <form method="post" action="index.php"><div>
6125 <input type="hidden" name="action" value="pluginupdate" />
6126 <?php $manager->addTicketHidden() ?>
6127 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
6130 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
6133 // find a list of possibly non-installed plugins
6134 $candidates = array();
6136 global $DIR_PLUGINS;
6138 $dirhandle = opendir($DIR_PLUGINS);
6140 while ($filename = readdir($dirhandle) )
6143 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
6144 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
6146 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6149 $name = $matches[1];
6150 // only show in list when not yet installed
6151 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
6153 if (sql_num_rows($res) == 0)
6155 array_push($candidates, $name);
6162 closedir($dirhandle);
6164 if (sizeof($candidates) > 0)
6167 <p><?php echo _PLUGS_ADD_TEXT?></p>
6169 <form method='post' action='index.php'><div>
6170 <input type='hidden' name='action' value='pluginadd' />
6171 <?php $manager->addTicketHidden() ?>
6172 <select name="filename" tabindex="30">
6174 foreach($candidates as $name)
6176 echo '<option value="NP_',$name,'">',ENTITY::hsc($name),'</option>';
6180 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
6187 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6195 * @todo document this
6197 function action_pluginhelp() {
6198 global $member, $manager, $DIR_PLUGINS, $CONF;
6201 $member->isAdmin() or $this->disallow();
6203 $plugid = intGetVar('plugid');
6205 if (!$manager->pidInstalled($plugid))
6206 $this->error(_ERROR_NOSUCHPLUGIN);
6208 $plugName = getPluginNameFromPid($plugid);
6212 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6214 echo '<h2>',_PLUGS_HELP_TITLE,': ',ENTITY::hsc($plugName),'</h2>';
6216 $plug =& $manager->getPlugin($plugName);
6217 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6219 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6220 @readfile($helpFile);
6222 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6223 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6231 * @todo document this
6233 function action_pluginadd() {
6234 global $member, $manager, $DIR_PLUGINS;
6237 $member->isAdmin() or $this->disallow();
6239 $name = postVar('filename');
6241 if ($manager->pluginInstalled($name))
6242 $this->error(_ERROR_DUPPLUGIN);
6243 if (!checkPlugin($name))
6244 $this->error(_ERROR_PLUGFILEERROR . ' (' . ENTITY::hsc($name) . ')');
6246 // get number of currently installed plugins
6247 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6248 $numCurrent = sql_num_rows($res);
6250 // plugin will be added as last one in the list
6251 $newOrder = $numCurrent + 1;
6260 // do this before calling getPlugin (in case the plugin id is used there)
6261 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6263 $iPid = sql_insert_id();
6265 $manager->clearCachedInfo('installedPlugins');
6267 // Load the plugin for condition checking and instalation
6268 $plugin =& $manager->getPlugin($name);
6270 // check if it got loaded (could have failed)
6273 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6274 $manager->clearCachedInfo('installedPlugins');
6275 $this->error(_ERROR_PLUGIN_LOAD);
6278 // check if plugin needs a newer Nucleus version
6279 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
6281 // uninstall plugin again...
6282 $this->deleteOnePlugin($plugin->getID());
6284 // ...and show error
6285 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc($plugin->getMinNucleusVersion()));
6288 // check if plugin needs a newer Nucleus version
6289 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
6291 // uninstall plugin again...
6292 $this->deleteOnePlugin($plugin->getID());
6294 // ...and show error
6295 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6298 $pluginList = $plugin->getPluginDep();
6299 foreach ($pluginList as $pluginName)
6302 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6303 if (sql_num_rows($res) == 0)
6305 // uninstall plugin again...
6306 $this->deleteOnePlugin($plugin->getID());
6308 $this->error(sprintf(_ERROR_INSREQPLUGIN, ENTITY::hsc($pluginName)));
6312 // call the install method of the plugin
6318 'plugin' => &$plugin
6322 // update all events
6323 $this->action_pluginupdate();
6327 * @todo document this
6329 function action_pluginupdate() {
6330 global $member, $manager, $CONF;
6333 $member->isAdmin() or $this->disallow();
6335 // delete everything from plugin_events
6336 sql_query('DELETE FROM '.sql_table('plugin_event'));
6338 // loop over all installed plugins
6339 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6340 while($o = sql_fetch_object($res)) {
6342 $plug =& $manager->getPlugin($o->pfile);
6345 $eventList = $plug->getEventList();
6346 foreach ($eventList as $eventName)
6347 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.sql_real_escape_string($eventName).'\')');
6351 redirect($CONF['AdminURL'] . '?action=pluginlist');
6352 // $this->action_pluginlist();
6356 * @todo document this
6358 function action_plugindelete() {
6359 global $member, $manager;
6362 $member->isAdmin() or $this->disallow();
6364 $pid = intGetVar('plugid');
6366 if (!$manager->pidInstalled($pid))
6367 $this->error(_ERROR_NOSUCHPLUGIN);
6371 <h2><?php echo _DELETE_CONFIRM?></h2>
6373 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6375 <form method="post" action="index.php"><div>
6376 <?php $manager->addTicketHidden() ?>
6377 <input type="hidden" name="action" value="plugindeleteconfirm" />
6378 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6379 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6386 * @todo document this
6388 function action_plugindeleteconfirm() {
6389 global $member, $manager, $CONF;
6392 $member->isAdmin() or $this->disallow();
6394 $pid = intPostVar('plugid');
6396 $error = $this->deleteOnePlugin($pid, 1);
6398 $this->error($error);
6401 redirect($CONF['AdminURL'] . '?action=pluginlist');
6402 // $this->action_pluginlist();
6406 * @todo document this
6408 function deleteOnePlugin($pid, $callUninstall = 0) {
6411 $pid = intval($pid);
6413 if (!$manager->pidInstalled($pid))
6414 return _ERROR_NOSUCHPLUGIN;
6416 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6418 /* // call the unInstall method of the plugin
6419 if ($callUninstall) {
6420 $plugin =& $manager->getPlugin($name);
6421 if ($plugin) $plugin->unInstall();
6424 // check dependency before delete
6425 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6426 while($o = sql_fetch_object($res)) {
6427 $plug =& $manager->getPlugin($o->pfile);
6430 $depList = $plug->getPluginDep();
6431 foreach ($depList as $depName)
6433 if ($name == $depName)
6435 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6441 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6443 // call the unInstall method of the plugin
6444 if ($callUninstall) {
6445 $plugin =& $manager->getPlugin($name);
6446 if ($plugin) $plugin->unInstall();
6449 // delete all subscriptions
6450 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6452 // delete all options
6453 // get OIDs from plugin_option_desc
6454 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6456 while ($o = sql_fetch_object($res)) {
6457 array_push($aOIDs, $o->oid);
6460 // delete from plugin_option and plugin_option_desc
6461 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6462 if (count($aOIDs) > 0)
6463 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6465 // update order numbers
6466 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6467 $o = sql_fetch_object($res);
6468 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6471 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6473 $manager->clearCachedInfo('installedPlugins');
6474 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6480 * @todo document this
6482 function action_pluginup() {
6483 global $member, $manager, $CONF;
6486 $member->isAdmin() or $this->disallow();
6488 $plugid = intGetVar('plugid');
6490 if (!$manager->pidInstalled($plugid))
6491 $this->error(_ERROR_NOSUCHPLUGIN);
6493 // 1. get old order number
6494 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6495 $o = sql_fetch_object($res);
6496 $oldOrder = $o->porder;
6498 // 2. calculate new order number
6499 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6501 // 3. update plug numbers
6502 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6503 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6505 //$this->action_pluginlist();
6506 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6507 redirect($CONF['AdminURL'] . '?action=pluginlist');
6511 * @todo document this
6513 function action_plugindown() {
6514 global $member, $manager, $CONF;
6517 $member->isAdmin() or $this->disallow();
6519 $plugid = intGetVar('plugid');
6520 if (!$manager->pidInstalled($plugid))
6521 $this->error(_ERROR_NOSUCHPLUGIN);
6523 // 1. get old order number
6524 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6525 $o = sql_fetch_object($res);
6526 $oldOrder = $o->porder;
6528 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6529 $maxOrder = sql_num_rows($res);
6531 // 2. calculate new order number
6532 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6534 // 3. update plug numbers
6535 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6536 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6538 //$this->action_pluginlist();
6539 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6540 redirect($CONF['AdminURL'] . '?action=pluginlist');
6544 * ADMIN::action_pluginoptions()
6546 * Output Plugin option page
6549 * @param string $message message when fallbacked
6553 public function action_pluginoptions($message = '')
6555 global $member, $manager;
6558 $member->isAdmin() or $this->disallow();
6560 $pid = (integer) requestVar('plugid');
6561 if ( !$manager->pidInstalled($pid) )
6563 $this->error(_ERROR_NOSUCHPLUGIN);
6566 $pname = getPluginNameFromPid($pid);
6568 /* just for including translation */
6569 $manager->getPlugin($pname);
6571 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6572 $this->pagehead($extrahead);
6573 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6574 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($pname)) . "</h2>\n";
6576 if ( isset($message) )
6581 echo "<form action=\"index.php\" method=\"post\">\n";
6583 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6584 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6585 $manager->addTicketHidden();
6587 $aOptions = array();
6589 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6590 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6591 $result = sql_query($query);
6592 while ( $object = sql_fetch_object($result) )
6594 array_push($aOIDs, $object->oid);
6595 $aOptions[$object->oid] = array(
6596 'oid' => $object->oid,
6597 'value' => $object->odef,
6598 'name' => $object->oname,
6599 'description' => $object->odesc,
6600 'type' => $object->otype,
6601 'typeinfo' => $object->oextra,
6605 // fill out actual values
6606 if ( count($aOIDs) > 0 )
6608 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6609 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6610 $result = sql_query($query);
6611 while ( $object = sql_fetch_object($result) )
6613 $aOptions[$object->oid]['value'] = $object->ovalue;
6618 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
6619 $manager->notify('PrePluginOptionsEdit',$data);
6621 $template['content'] = 'plugoptionlist';
6622 $amount = showlist($aOptions,'table',$template);
6625 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6635 * ADMIN::action_pluginoptionsupdate()
6637 * Update plugin options and fallback to plugin option page
6643 public function action_pluginoptionsupdate()
6645 global $member, $manager;
6648 $member->isAdmin() or $this->disallow();
6650 $pid = (integer) requestVar('plugid');
6651 if ( !$manager->pidInstalled($pid) )
6653 $this->error(_ERROR_NOSUCHPLUGIN);
6656 $aOptions = requestArray('plugoption');
6657 NucleusPlugin::apply_plugin_options($aOptions);
6659 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6661 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6666 * ADMIN::_insertPluginOptions()
6668 * Output plugin option field
6671 * @param string $context plugin option context
6672 * @param integer $contextid plugin option context id
6675 public function _insertPluginOptions($context, $contextid = 0)
6677 // get all current values for this contextid
6678 // (note: this might contain doubles for overlapping contextids)
6679 $aIdToValue = array();
6680 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6681 while ( $object = sql_fetch_object($res) )
6683 $aIdToValue[$object->oid] = $object->ovalue;
6686 // get list of oids per pid
6687 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6688 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6689 $res = sql_query($query);
6690 $aOptions = array();
6691 while ( $object = sql_fetch_object($res) )
6693 if (in_array($object->oid, array_keys($aIdToValue)))
6695 $value = $aIdToValue[$object->oid];
6699 $value = $object->odef;
6702 array_push($aOptions, array(
6703 'pid' => $object->pid,
6704 'pfile' => $object->pfile,
6705 'oid' => $object->oid,
6707 'name' => $object->oname,
6708 'description' => $object->odesc,
6709 'type' => $object->otype,
6710 'typeinfo' => $object->oextra,
6711 'contextid' => $contextid,
6716 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6719 foreach ($aOptions as $aOption)
6722 if ( $iPrevPid != $aOption['pid'] )
6724 $iPrevPid = $aOption['pid'];
6725 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
6727 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6729 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($aOption['pfile'])).'</th></tr>';
6732 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6733 if ( @$meta['access'] != 'hidden' )
6736 listplug_plugOptionRow($aOption);
6744 * ADMIN::input_yesno()
6745 * Output input elements with radio attribute for yes/no options
6747 * @param string $name name attribute
6748 * @param string $value_current current value attribute
6749 * @param integer $tabindex tab index
6750 * @param string $value_yes value attribute for yes option
6751 * @param string $value_no value attribute for no option
6752 * @param string $text_yes child text element for yes option
6753 * @param string $text_no child text element for no option
6754 * @param boolean $isAdmin have admin right or not
6757 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
6759 $id = preg_replace('#\[|\]#', '-', $name);
6760 $id_yes = $id . $value_yes;
6761 $id_no = $id . $value_no;
6764 echo '<input type="radio" id="' . ENTITY::hsc($id_yes) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_yes) . '"';
6765 if ( $name=="admin" )
6767 echo ' onclick="selectCanLogin(true);"';
6769 if ( $value_current == $value_yes )
6771 echo " tabindex='$tabindex' checked='checked'";
6774 echo '<label for="' . ENTITY::hsc($id_yes) . '">' . ENTITY::hsc($text_yes) . "</label>\n";
6777 echo '<input type="radio" id="' . ENTITY::hsc($id_no) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_no) . '"';
6778 if ( $name=="admin" )
6780 echo ' onclick="selectCanLogin(false);"';
6782 if ( $value_current != $value_yes )
6784 echo " tabindex='$tabindex' checked='checked'";
6786 if ($isAdmin && $name=="canlogin")
6788 echo ' disabled="disabled"';
6791 echo '<label for="' . ENTITY::hsc($id_no) . '">' . ENTITY::hsc($text_no) . "</label>\n";