3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2012 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-2012 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 * Admin::action_createitem()
1126 * Provide a page to item a new item to the given blog
1131 public function action_createitem()
1133 global $member, $manager;
1135 $blogid = intRequestVar('blogid');
1138 $member->teamRights($blogid) or $this->disallow();
1140 $memberid = $member->getID();
1142 $blog =& $manager->getBlog($blogid);
1146 // generate the add-item form
1147 $formfactory = new PageFactory($blogid);
1148 $formfactory->createAddForm('admin');
1155 * Admin::action_itemedit()
1160 public function action_itemedit()
1162 global $member, $manager;
1164 $itemid = intRequestVar('itemid');
1166 // only allow if user is allowed to alter item
1167 $member->canAlterItem($itemid) or $this->disallow();
1169 $item =& $manager->getItem($itemid, 1, 1);
1170 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1172 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1174 if ( $blog->convertBreaks() )
1176 $item['body'] = removeBreaks($item['body']);
1177 $item['more'] = removeBreaks($item['more']);
1180 // form to edit blog items
1182 $formfactory = new PageFactory($blog->getID());
1183 $formfactory->createEditForm('admin', $item);
1189 * @todo document this
1191 function action_itemupdate() {
1192 global $member, $manager, $CONF;
1194 $itemid = intRequestVar('itemid');
1195 $catid = postVar('catid');
1197 // only allow if user is allowed to alter item
1198 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1200 $actiontype = postVar('actiontype');
1202 // delete actions are handled by itemdelete (which has confirmation)
1203 if ($actiontype == 'delete') {
1204 $this->action_itemdelete();
1208 $body = postVar('body');
1209 $title = postVar('title');
1210 $more = postVar('more');
1211 $closed = intPostVar('closed');
1212 $draftid = intPostVar('draftid');
1214 // default action = add now
1216 $actiontype='addnow';
1218 // create new category if needed
1219 if (strstr($catid,'newcat')) {
1221 list($blogid) = sscanf($catid,"newcat-%d");
1224 $blog =& $manager->getBlog($blogid);
1225 $catid = $blog->createNewCategory();
1227 // show error when sth goes wrong
1229 $this->doError(_ERROR_CATCREATEFAIL);
1233 set some variables based on actiontype
1236 draft items -> addnow, addfuture, adddraft, delete
1237 non-draft items -> edit, changedate, delete
1240 $timestamp: set to a nonzero value for future dates or date changes
1241 $wasdraft: set to 1 when the item used to be a draft item
1242 $publish: set to 1 when the edited item is not a draft
1244 $blogid = getBlogIDFromItemID($itemid);
1245 $blog =& $manager->getBlog($blogid);
1247 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1248 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1249 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1250 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1251 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1256 // edit the item for real
1257 Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1259 $this->updateFuturePosted($blogid);
1262 // delete permission is checked inside Item::delete()
1263 Item::delete($draftid);
1266 // show category edit window when we created a new category
1267 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1268 if ($catid != intPostVar('catid')) {
1269 $this->action_categoryedit(
1272 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1275 // TODO: set start item correctly for itemlist
1276 $this->action_itemlist(getBlogIDFromItemID($itemid));
1281 * Admin::action_itemdelete()
1287 function action_itemdelete()
1289 global $member, $manager;
1291 $itemid = intRequestVar('itemid');
1293 // only allow if user is allowed to alter item
1294 $member->canAlterItem($itemid) or $this->disallow();
1296 if ( !$manager->existsItem($itemid,1,1) )
1298 $this->error(_ERROR_NOSUCHITEM);
1301 $item =& $manager->getItem($itemid,1,1);
1302 $title = Entity::hsc(strip_tags($item['title']));
1303 $body = strip_tags($item['body']);
1304 $body = Entity::hsc(Entity::shorten($body,300,'...'));
1307 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1308 echo '<p>' . _CONFIRMTXT_ITEM . "</p>\n";
1309 echo "<div class=\"note\">\n";
1310 echo "<b>{$title}</b>\n";
1314 echo "<form method=\"post\" action=\"index.php\">\n";
1316 echo "<input type=\"hidden\" name=\"action\" value=\"itemdeleteconfirm\" />\n";
1317 echo $manager->addTicketHidden() . "\n";
1318 echo "<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\" />\n";
1319 echo '<input type="submit" value="' . _DELETE_CONFIRM_BTN . "\" tabindex=\"10\" />\n";
1327 * @todo document this
1329 function action_itemdeleteconfirm() {
1332 $itemid = intRequestVar('itemid');
1334 // only allow if user is allowed to alter item
1335 $member->canAlterItem($itemid) or $this->disallow();
1338 $blogid = getBlogIdFromItemId($itemid);
1340 // delete item (note: some checks will be performed twice)
1341 $this->deleteOneItem($itemid);
1343 $this->action_itemlist($blogid);
1347 * Deletes one item and returns error if something goes wrong
1348 * @param int $itemid
1350 function deleteOneItem($itemid) {
1351 global $member, $manager;
1353 // only allow if user is allowed to alter item (also checks if itemid exists)
1354 if (!$member->canAlterItem($itemid))
1355 return _ERROR_DISALLOWED;
1357 // need to get blogid before the item is deleted
1358 $blogid = getBlogIDFromItemId($itemid);
1360 $manager->loadClass('ITEM');
1361 Item::delete($itemid);
1363 // update blog's futureposted
1364 $this->updateFuturePosted($blogid);
1368 * Admin::updateFuturePosted()
1369 * Update a blog's future posted flag
1371 * @param integer $blogid
1375 function updateFuturePosted($blogid)
1379 $blog =& $manager->getBlog($blogid);
1380 $currenttime = $blog->getCorrectTime(time());
1382 $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
1383 $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));
1384 $result = sql_query($query);
1386 if ( sql_num_rows($result) > 0 )
1388 $blog->setFuturePost();
1392 $blog->clearFuturePost();
1398 * @todo document this
1400 function action_itemmove() {
1401 global $member, $manager;
1403 $itemid = intRequestVar('itemid');
1405 // only allow if user is allowed to alter item
1406 $member->canAlterItem($itemid) or $this->disallow();
1408 $item =& $manager->getItem($itemid,1,1);
1412 <h2><?php echo _MOVE_TITLE?></h2>
1413 <form method="post" action="index.php"><div>
1414 <input type="hidden" name="action" value="itemmoveto" />
1415 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1419 $manager->addTicketHidden();
1420 $this->selectBlogCategory('catid',$item['catid'],10,1);
1423 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1430 * @todo document this
1432 function action_itemmoveto() {
1433 global $member, $manager;
1435 $itemid = intRequestVar('itemid');
1436 $catid = requestVar('catid');
1438 // create new category if needed
1439 if (strstr($catid,'newcat')) {
1441 list($blogid) = sscanf($catid,'newcat-%d');
1444 $blog =& $manager->getBlog($blogid);
1445 $catid = $blog->createNewCategory();
1447 // show error when sth goes wrong
1449 $this->doError(_ERROR_CATCREATEFAIL);
1452 // only allow if user is allowed to alter item
1453 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1455 $old_blogid = getBlogIDFromItemId($itemid);
1457 Item::move($itemid, $catid);
1459 // set the futurePosted flag on the blog
1460 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1462 // reset the futurePosted in case the item is moved from one blog to another
1463 $this->updateFuturePosted($old_blogid);
1465 if ($catid != intRequestVar('catid'))
1466 $this->action_categoryedit($catid, $blog->getID());
1468 $this->action_itemlist(getBlogIDFromCatID($catid));
1472 * Moves one item to a given category (category existance should be checked by caller)
1473 * errors are returned
1474 * @param int $itemid
1475 * @param int $destCatid category ID to which the item will be moved
1477 function moveOneItem($itemid, $destCatid) {
1480 // only allow if user is allowed to move item
1481 if (!$member->canUpdateItem($itemid, $destCatid))
1482 return _ERROR_DISALLOWED;
1484 Item::move($itemid, $destCatid);
1488 * Adds a item to the chosen blog
1490 function action_additem() {
1491 global $manager, $CONF;
1493 $manager->loadClass('ITEM');
1495 $result = Item::createFromRequest();
1497 if ($result['status'] == 'error')
1498 $this->error($result['message']);
1500 $blogid = getBlogIDFromItemID($result['itemid']);
1501 $blog =& $manager->getBlog($blogid);
1502 $btimestamp = $blog->getCorrectTime();
1503 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1505 if ($result['status'] == 'newcategory') {
1506 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1507 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1509 $methodName = 'action_itemList';
1510 call_user_func(array(&$this, $methodName), $blogid);
1515 * Allows to edit previously made comments
1517 function action_commentedit() {
1519 global $member, $manager;
1521 $commentid = intRequestVar('commentid');
1523 $member->canAlterComment($commentid) or $this->disallow();
1525 $comment = Comment::getComment($commentid);
1527 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1529 // change <br /> to \n
1530 $comment['body'] = str_replace('<br />', '', $comment['body']);
1532 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1533 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1535 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1540 <h2><?php echo _EDITC_TITLE?></h2>
1542 <form action="index.php" method="post"><div>
1544 <input type="hidden" name="action" value="commentupdate" />
1545 <?php $manager->addTicketHidden(); ?>
1546 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1548 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1550 <td><?php echo _EDITC_WHO?></td>
1552 <?php if ($comment['member'])
1553 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1555 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1559 <td><?php echo _EDITC_WHEN?></td>
1560 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1562 <td><?php echo _EDITC_HOST?></td>
1563 <td><?php echo $comment['host']; ?></td>
1566 <td><?php echo _EDITC_URL; ?></td>
1567 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1570 <td><?php echo _EDITC_EMAIL; ?></td>
1571 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1574 <td><?php echo _EDITC_TEXT?></td>
1576 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1577 echo $comment['body'];
1581 <td><?php echo _EDITC_EDIT?></td>
1582 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1591 * @todo document this
1593 function action_commentupdate() {
1594 global $member, $manager;
1596 $commentid = intRequestVar('commentid');
1598 $member->canAlterComment($commentid) or $this->disallow();
1600 $url = postVar('url');
1601 $email = postVar('email');
1602 $body = postVar('body');
1604 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1605 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1606 # important note that '\' must be matched with '\\\\' in preg* expressions
1608 // intercept words that are too long
1609 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1611 $this->error(_ERROR_COMMENT_LONGWORD);
1615 if (i18n::strlen($body) < 3)
1617 $this->error(_ERROR_COMMENT_NOCOMMENT);
1620 if (i18n::strlen($body) > 5000)
1622 $this->error(_ERROR_COMMENT_TOOLONG);
1626 $body = Comment::prepareBody($body);
1629 $manager->notify('PreUpdateComment',array('body' => &$body));
1631 $query = 'UPDATE ' . sql_table('comment')
1632 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1633 . " WHERE cnumber = " . $commentid;
1637 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1638 $o = sql_fetch_object($res);
1639 $itemid = $o->citem;
1641 if ($member->canAlterItem($itemid))
1642 $this->action_itemcommentlist($itemid);
1644 $this->action_browseowncomments();
1649 * Admin::action_commentdelete()
1655 function action_commentdelete()
1657 global $member, $manager;
1659 $commentid = intRequestVar('commentid');
1660 $member->canAlterComment($commentid) or $this->disallow();
1661 $comment = Comment::getComment($commentid);
1663 $body = strip_tags($comment['body']);
1664 $body = Entity::hsc(Entity::shorten($body, 300, '...'));
1666 if ( $comment['member'] )
1668 $author = $comment['member'];
1672 $author = $comment['user'];
1677 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1678 echo '<p>' . _CONFIRMTXT_COMMENT . "</p>\n";
1679 echo "<div class=\"note\">\n";
1680 echo '<b>' . _EDITC_WHO . ":</b>{$author}<br />\n";
1681 echo '<b>' . _EDITC_TEXT . ":</b>{$body}\n";
1683 echo "<form method=\"post\" action=\"index.php\">\n";
1685 echo "<input type=\"hidden\" name=\"action\" value=\"commentdeleteconfirm\" />\n";
1686 echo $manager->addTicketHidden() . "\n";
1687 echo "<input type=\"hidden\" name=\"commentid\" value=\"{$commentid}\" />\n";
1688 echo '<input type="submit" tabindex="10" value="'. _DELETE_CONFIRM_BTN . "\" />\n";
1696 * @todo document this
1698 function action_commentdeleteconfirm() {
1701 $commentid = intRequestVar('commentid');
1703 // get item id first
1704 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1705 $o = sql_fetch_object($res);
1706 $itemid = $o->citem;
1708 $error = $this->deleteOneComment($commentid);
1710 $this->doError($error);
1712 if ($member->canAlterItem($itemid))
1713 $this->action_itemcommentlist($itemid);
1715 $this->action_browseowncomments();
1719 * @todo document this
1721 function deleteOneComment($commentid) {
1722 global $member, $manager;
1724 $commentid = intval($commentid);
1726 if (!$member->canAlterComment($commentid))
1727 return _ERROR_DISALLOWED;
1729 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1731 // delete the comments associated with the item
1732 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1735 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1741 * Usermanagement main
1743 function action_usermanagement() {
1744 global $member, $manager;
1747 $member->isAdmin() or $this->disallow();
1751 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1753 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1755 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1757 // show list of members with actions
1759 . ' FROM '.sql_table('member');
1760 $template['content'] = 'memberlist';
1761 $template['tabindex'] = 10;
1763 $manager->loadClass("ENCAPSULATE");
1764 $batch = new Batch('member');
1765 $batch->showlist($query,'table',$template);
1767 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1769 <form method="post" action="index.php" name="memberedit"><div>
1771 <input type="hidden" name="action" value="memberadd" />
1772 <?php $manager->addTicketHidden() ?>
1776 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1778 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1779 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1781 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1783 <td><?php echo _MEMBERS_REALNAME?></td>
1784 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1786 <td><?php echo _MEMBERS_PWD?></td>
1787 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1789 <td><?php echo _MEMBERS_REPPWD?></td>
1790 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1792 <td><?php echo _MEMBERS_EMAIL?></td>
1793 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1795 <td><?php echo _MEMBERS_URL?></td>
1796 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1798 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1799 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1801 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1802 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1804 <td><?php echo _MEMBERS_NOTES?></td>
1805 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1807 <td><?php echo _MEMBERS_NEW?></td>
1808 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1817 * Edit member settings
1819 function action_memberedit() {
1820 $this->action_editmembersettings(intRequestVar('memberid'));
1824 * @todo document this
1826 function action_editmembersettings($memberid = '') {
1827 global $member, $manager, $CONF;
1829 if ($memberid == '')
1831 $memberid = $member->getID();
1835 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1837 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1838 $this->pagehead($extrahead);
1840 // show message to go back to member overview (only for admins)
1841 if ($member->isAdmin())
1843 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1847 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1849 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1851 $mem = Member::createFromID($memberid);
1853 <form method="post" action="index.php" name="memberedit"><div>
1855 <input type="hidden" name="action" value="changemembersettings" />
1856 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1857 <?php $manager->addTicketHidden() ?>
1860 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1862 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1863 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1866 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1867 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo Entity::hsc($mem->getDisplayName()); ?>" />
1869 echo Entity::hsc($member->getDisplayName());
1874 <td><?php echo _MEMBERS_REALNAME?></td>
1875 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo Entity::hsc($mem->getRealName()); ?>" /></td>
1877 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1878 <td><?php echo _MEMBERS_PWD?></td>
1879 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1881 <td><?php echo _MEMBERS_REPPWD?></td>
1882 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1885 <td><?php echo _MEMBERS_EMAIL?>
1886 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1888 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo Entity::hsc($mem->getEmail()); ?>" /></td>
1890 <td><?php echo _MEMBERS_URL?></td>
1891 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getURL()); ?>" /></td>
1892 <?php // only allow to change this by super-admins
1893 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1894 if ($member->isAdmin()) {
1897 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1898 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1900 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1901 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1904 <td><?php echo _MEMBERS_NOTES?></td>
1905 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getNotes()); ?>" /></td>
1907 <td><?php echo _MEMBERS_LOCALE?> <?php help('locale'); ?>
1911 <select name="locale" tabindex="85">
1913 $locales = i18n::get_available_locale_list();
1914 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1916 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1920 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1923 foreach( $locales as $locale )
1925 if( $locale == $mem->getLocale() )
1927 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1931 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1940 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1941 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1945 $this->_insertPluginOptions('member',$memberid);
1948 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1950 <td><?php echo _MEMBERS_EDIT?></td>
1951 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1957 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1960 'MemberSettingsFormExtras',
1969 * @todo document this
1971 function action_changemembersettings() {
1972 global $member, $CONF, $manager;
1974 $memberid = intRequestVar('memberid');
1977 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1979 $name = trim(strip_tags(postVar('name')));
1980 $realname = trim(strip_tags(postVar('realname')));
1981 $password = postVar('password');
1982 $repeatpassword = postVar('repeatpassword');
1983 $email = strip_tags(postVar('email'));
1984 $url = strip_tags(postVar('url'));
1986 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1987 # original eregi: !eregi("^https?://", $url)
1989 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1990 if (!preg_match('#^https?://#', $url) )
1992 $url = 'http://' . $url;
1995 $admin = postVar('admin');
1996 $canlogin = postVar('canlogin');
1997 $notes = strip_tags(postVar('notes'));
1998 $locale = postVar('locale');
2000 $mem = Member::createFromID($memberid);
2002 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2004 if (!isValidDisplayName($name))
2005 $this->error(_ERROR_BADNAME);
2007 if (($name != $mem->getDisplayName()) && Member::exists($name))
2008 $this->error(_ERROR_NICKNAMEINUSE);
2010 if ($password != $repeatpassword)
2011 $this->error(_ERROR_PASSWORDMISMATCH);
2013 if ($password && (i18n::strlen($password) < 6))
2014 $this->error(_ERROR_PASSWORDTOOSHORT);
2019 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2021 $this->error($pwderror);
2026 if ( !NOTIFICATION::address_validation($email) )
2028 $this->error(_ERROR_BADMAILADDRESS);
2032 $this->error(_ERROR_REALNAMEMISSING);
2034 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2035 $this->error(_ERROR_NOSUCHTRANSLATION);
2037 // check if there will remain at least one site member with both the logon and admin rights
2038 // (check occurs when taking away one of these rights from such a member)
2039 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2040 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2043 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2044 if (sql_num_rows($r) < 2)
2045 $this->error(_ERROR_ATLEASTONEADMIN);
2048 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2049 $mem->setDisplayName($name);
2051 $mem->setPassword($password);
2054 $oldEmail = $mem->getEmail();
2056 $mem->setRealName($realname);
2057 $mem->setEmail($email);
2059 $mem->setNotes($notes);
2060 $mem->setLocale($locale);
2063 // only allow super-admins to make changes to the admin status
2064 if ($member->isAdmin()) {
2065 $mem->setAdmin($admin);
2066 $mem->setCanLogin($canlogin);
2069 $autosave = postVar ('autosave');
2070 $mem->setAutosave($autosave);
2074 // store plugin options
2075 $aOptions = requestArray('plugoption');
2076 NucleusPlugin::apply_plugin_options($aOptions);
2077 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2079 // if email changed, generate new password
2080 if ($oldEmail != $mem->getEmail())
2082 $mem->sendActivationLink('addresschange', $oldEmail);
2084 $mem->newCookieKey();
2086 // only log out if the member being edited is the current member.
2087 if ($member->getID() == $memberid)
2089 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2094 if ( ( $mem->getID() == $member->getID() )
2095 && ( $mem->getDisplayName() != $member->getDisplayName() )
2097 $mem->newCookieKey();
2099 $this->action_login(_MSG_LOGINAGAIN, 0);
2101 $this->action_overview(_MSG_SETTINGSCHANGED);
2106 * Admin::action_memberadd()
2112 function action_memberadd()
2114 global $member, $manager;
2117 $member->isAdmin() or $this->disallow();
2119 if ( postVar('password') != postVar('repeatpassword') )
2121 $this->error(_ERROR_PASSWORDMISMATCH);
2124 if ( i18n::strlen(postVar('password')) < 6 )
2126 $this->error(_ERROR_PASSWORDTOOSHORT);
2129 $res = Member::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2135 // fire PostRegister event
2136 $newmem = new Member();
2137 $newmem->readFromName(postVar('name'));
2138 $manager->notify('PostRegister',array('member' => &$newmem));
2140 $this->action_usermanagement();
2145 * Account activation
2149 function action_activate() {
2151 $key = getVar('key');
2152 $this->_showActivationPage($key);
2156 * @todo document this
2158 function _showActivationPage($key, $message = '')
2162 // clean up old activation keys
2163 Member::cleanupActivationTable();
2165 // get activation info
2166 $info = Member::getActivationInfo($key);
2169 $this->error(_ERROR_ACTIVATE);
2171 $mem = Member::createFromId($info->vmember);
2174 $this->error(_ERROR_ACTIVATE);
2178 $bNeedsPasswordChange = true;
2180 switch ($info->vtype)
2183 $title = _ACTIVATE_FORGOT_TITLE;
2184 $text = _ACTIVATE_FORGOT_TEXT;
2187 $title = _ACTIVATE_REGISTER_TITLE;
2188 $text = _ACTIVATE_REGISTER_TEXT;
2190 case 'addresschange':
2191 $title = _ACTIVATE_CHANGE_TITLE;
2192 $text = _ACTIVATE_CHANGE_TEXT;
2193 $bNeedsPasswordChange = false;
2194 Member::activate($key);
2199 'memberName' => Entity::hsc($mem->getDisplayName())
2201 $title = Template::fill($title, $aVars);
2202 $text = Template::fill($text, $aVars);
2206 echo '<h2>' , $title, '</h2>';
2207 echo '<p>' , $text, '</p>';
2211 echo '<p class="error">',$message,'</p>';
2214 if ($bNeedsPasswordChange)
2217 <div><form action="index.php" method="post">
2219 <input type="hidden" name="action" value="activatesetpwd" />
2220 <?php $manager->addTicketHidden() ?>
2221 <input type="hidden" name="key" value="<?php echo Entity::hsc($key) ?>" />
2224 <td><?php echo _MEMBERS_PWD?></td>
2225 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2227 <td><?php echo _MEMBERS_REPPWD?></td>
2228 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2232 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2236 <td><?php echo _MEMBERS_SETPWD ?></td>
2237 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2252 * Account activation - set password part
2256 function action_activatesetpwd() {
2258 $key = postVar('key');
2260 // clean up old activation keys
2261 Member::cleanupActivationTable();
2263 // get activation info
2264 $info = Member::getActivationInfo($key);
2266 if (!$info || ($info->type == 'addresschange'))
2267 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2269 $mem = Member::createFromId($info->vmember);
2272 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2274 $password = postVar('password');
2275 $repeatpassword = postVar('repeatpassword');
2277 if ($password != $repeatpassword)
2278 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2280 if ($password && (i18n::strlen($password) < 6))
2281 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2287 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2289 return $this->_showActivationPage($key,$pwderror);
2295 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2297 return $this->_showActivationPage($key, $error);
2301 $mem->setPassword($password);
2304 // do the activation
2305 Member::activate($key);
2308 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2309 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2316 function action_manageteam() {
2317 global $member, $manager;
2319 $blogid = intRequestVar('blogid');
2322 $member->blogAdminRights($blogid) or $this->disallow();
2326 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2328 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2330 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2334 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2335 . ' FROM '.sql_table('member').', '.sql_table('team')
2336 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2338 $template['content'] = 'teamlist';
2339 $template['tabindex'] = 10;
2341 $manager->loadClass("ENCAPSULATE");
2342 $batch = new Batch('team');
2343 $batch->showlist($query, 'table', $template);
2346 <h3><?php echo _TEAM_ADDNEW?></h3>
2348 <form method='post' action='index.php'><div>
2350 <input type='hidden' name='action' value='teamaddmember' />
2351 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2352 <?php $manager->addTicketHidden() ?>
2355 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2356 <td><?php // TODO: try to make it so only non-team-members are listed
2357 $query = 'SELECT mname as text, mnumber as value'
2358 . ' FROM '.sql_table('member');
2360 $template['name'] = 'memberid';
2361 $template['tabindex'] = 10000;
2362 showlist($query,'select',$template);
2365 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2366 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2368 <td><?php echo _TEAM_ADD?></td>
2369 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2378 * Add member to team
2380 function action_teamaddmember() {
2381 global $member, $manager;
2383 $memberid = intPostVar('memberid');
2384 $blogid = intPostVar('blogid');
2385 $admin = intPostVar('admin');
2388 $member->blogAdminRights($blogid) or $this->disallow();
2390 $blog =& $manager->getBlog($blogid);
2391 if (!$blog->addTeamMember($memberid, $admin))
2392 $this->error(_ERROR_ALREADYONTEAM);
2394 $this->action_manageteam();
2399 * @todo document this
2401 function action_teamdelete() {
2402 global $member, $manager;
2404 $memberid = intRequestVar('memberid');
2405 $blogid = intRequestVar('blogid');
2408 $member->blogAdminRights($blogid) or $this->disallow();
2410 $teammem = Member::createFromID($memberid);
2411 $blog =& $manager->getBlog($blogid);
2415 <h2><?php echo _DELETE_CONFIRM?></h2>
2417 <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>
2421 <form method="post" action="index.php"><div>
2422 <input type="hidden" name="action" value="teamdeleteconfirm" />
2423 <?php $manager->addTicketHidden() ?>
2424 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2425 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2426 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2433 * @todo document this
2435 function action_teamdeleteconfirm() {
2438 $memberid = intRequestVar('memberid');
2439 $blogid = intRequestVar('blogid');
2441 $error = $this->deleteOneTeamMember($blogid, $memberid);
2443 $this->error($error);
2446 $this->action_manageteam();
2450 * @todo document this
2452 function deleteOneTeamMember($blogid, $memberid) {
2453 global $member, $manager;
2455 $blogid = intval($blogid);
2456 $memberid = intval($memberid);
2459 if (!$member->blogAdminRights($blogid))
2460 return _ERROR_DISALLOWED;
2462 // check if: - there remains at least one blog admin
2463 // - (there remains at least one team member)
2464 $tmem = Member::createFromID($memberid);
2466 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2468 if ($tmem->isBlogAdmin($blogid)) {
2469 // check if there are more blog members left and at least one admin
2470 // (check for at least two admins before deletion)
2471 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2472 $r = sql_query($query);
2473 if (sql_num_rows($r) < 2)
2474 return _ERROR_ATLEASTONEBLOGADMIN;
2477 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2480 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2486 * @todo document this
2488 function action_teamchangeadmin() {
2491 $blogid = intRequestVar('blogid');
2492 $memberid = intRequestVar('memberid');
2495 $member->blogAdminRights($blogid) or $this->disallow();
2497 $mem = Member::createFromID($memberid);
2499 // don't allow when there is only one admin at this moment
2500 if ($mem->isBlogAdmin($blogid)) {
2501 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2502 if (sql_num_rows($r) == 1)
2503 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2506 if ($mem->isBlogAdmin($blogid))
2511 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2514 // only show manageteam if member did not change its own admin privileges
2515 if ($member->isBlogAdmin($blogid))
2516 $this->action_manageteam();
2518 $this->action_overview(_MSG_ADMINCHANGED);
2522 * @todo document this
2524 function action_blogsettings() {
2525 global $member, $manager;
2527 $blogid = intRequestVar('blogid');
2530 $member->blogAdminRights($blogid) or $this->disallow();
2532 $blog =& $manager->getBlog($blogid);
2534 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2535 $this->pagehead($extrahead);
2537 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2539 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2541 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2543 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2545 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2546 $aMemberNames = array();
2547 while ($o = sql_fetch_object($res))
2548 array_push($aMemberNames, Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')');
2549 echo implode(',', $aMemberNames);
2556 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2559 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2561 <form method="post" action="index.php"><div>
2563 <input type="hidden" name="action" value="blogsettingsupdate" />
2564 <?php $manager->addTicketHidden() ?>
2565 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2567 <td><?php echo _EBLOG_NAME?></td>
2568 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo Entity::hsc($blog->getName()) ?>" /></td>
2570 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2571 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2573 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo Entity::hsc($blog->getShortName()) ?>" /></td>
2575 <td><?php echo _EBLOG_DESC?></td>
2576 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo Entity::hsc($blog->getDescription()) ?>" /></td>
2578 <td><?php echo _EBLOG_URL?></td>
2579 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo Entity::hsc($blog->getURL()) ?>" /></td>
2581 <td><?php echo _EBLOG_DEFSKIN?>
2582 <?php help('blogdefaultskin'); ?>
2586 $query = 'SELECT sdname as text, sdnumber as value'
2587 . ' FROM '.sql_table('skin_desc');
2588 $template['name'] = 'defskin';
2589 $template['selected'] = $blog->getDefaultSkin();
2590 $template['tabindex'] = 50;
2591 showlist($query,'select',$template);
2596 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2598 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2600 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2602 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2604 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2606 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2608 <td><?php echo _EBLOG_ANONYMOUS?>
2610 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2612 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2614 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2616 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2617 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo Entity::hsc($blog->getNotifyAddress()); ?>" /></td>
2619 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2621 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2622 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2623 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2625 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2626 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2627 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2629 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2630 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2631 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2634 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2635 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo Entity::hsc($blog->getMaxComments()); ?>" /></td>
2637 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2638 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo Entity::hsc($blog->getUpdateFile()) ?>" /></td>
2640 <td><?php echo _EBLOG_DEFCAT?></td>
2643 $query = 'SELECT cname as text, catid as value'
2644 . ' FROM '.sql_table('category')
2645 . ' WHERE cblog=' . $blog->getID();
2646 $template['name'] = 'defcat';
2647 $template['selected'] = $blog->getDefaultCategory();
2648 $template['tabindex'] = 110;
2649 showlist($query,'select',$template);
2653 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2654 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::formatted_datetime('%H:%M', time()); ?></b>
2655 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::formatted_datetime('%H:%M', $blog->getCorrectTime()); ?></b>
2657 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo Entity::hsc($blog->getTimeOffset()); ?>" /></td>
2659 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2660 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2664 $this->_insertPluginOptions('blog',$blogid);
2667 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2669 <td><?php echo _EBLOG_CHANGE?></td>
2670 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2675 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2679 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2680 $template['content'] = 'categorylist';
2681 $template['tabindex'] = 200;
2683 $manager->loadClass("ENCAPSULATE");
2684 $batch = new Batch('category');
2685 $batch->showlist($query,'table',$template);
2690 <form action="index.php" method="post"><div>
2691 <input name="action" value="categorynew" type="hidden" />
2692 <?php $manager->addTicketHidden() ?>
2693 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2696 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2698 <td><?php echo _EBLOG_CAT_NAME?></td>
2699 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2701 <td><?php echo _EBLOG_CAT_DESC?></td>
2702 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2704 <td><?php echo _EBLOG_CAT_CREATE?></td>
2705 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2712 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2715 'BlogSettingsFormExtras',
2725 * @todo document this
2727 function action_categorynew() {
2728 global $member, $manager;
2730 $blogid = intRequestVar('blogid');
2732 $member->blogAdminRights($blogid) or $this->disallow();
2734 $cname = postVar('cname');
2735 $cdesc = postVar('cdesc');
2737 if (!isValidCategoryName($cname))
2738 $this->error(_ERROR_BADCATEGORYNAME);
2740 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2741 $res = sql_query($query);
2742 if (sql_num_rows($res) > 0)
2743 $this->error(_ERROR_DUPCATEGORYNAME);
2745 $blog =& $manager->getBlog($blogid);
2746 $newCatID = $blog->createNewCategory($cname, $cdesc);
2748 $this->action_blogsettings();
2752 * @todo document this
2754 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2755 global $member, $manager;
2758 $blogid = intGetVar('blogid');
2760 $blogid = intval($blogid);
2762 $catid = intGetVar('catid');
2764 $catid = intval($catid);
2766 $member->blogAdminRights($blogid) or $this->disallow();
2768 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2769 $obj = sql_fetch_object($res);
2771 $cname = $obj->cname;
2772 $cdesc = $obj->cdesc;
2774 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2775 $this->pagehead($extrahead);
2777 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2780 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo Entity::hsc($cname)?>'</h2>
2781 <form method='post' action='index.php'><div>
2782 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2783 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2784 <input name="desturl" type="hidden" value="<?php echo Entity::hsc($desturl) ?>" />
2785 <input name="action" type="hidden" value="categoryupdate" />
2786 <?php $manager->addTicketHidden(); ?>
2789 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2791 <td><?php echo _EBLOG_CAT_NAME?></td>
2792 <td><input type="text" name="cname" value="<?php echo Entity::hsc($cname)?>" size="40" maxlength="40" /></td>
2794 <td><?php echo _EBLOG_CAT_DESC?></td>
2795 <td><input type="text" name="cdesc" value="<?php echo Entity::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2798 // insert plugin options
2799 $this->_insertPluginOptions('category',$catid);
2802 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2804 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2805 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2814 * @todo document this
2816 function action_categoryupdate() {
2817 global $member, $manager;
2819 $blogid = intPostVar('blogid');
2820 $catid = intPostVar('catid');
2821 $cname = postVar('cname');
2822 $cdesc = postVar('cdesc');
2823 $desturl = postVar('desturl');
2825 $member->blogAdminRights($blogid) or $this->disallow();
2827 if (!isValidCategoryName($cname))
2828 $this->error(_ERROR_BADCATEGORYNAME);
2830 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2831 $res = sql_query($query);
2832 if (sql_num_rows($res) > 0)
2833 $this->error(_ERROR_DUPCATEGORYNAME);
2835 $query = 'UPDATE '.sql_table('category').' SET'
2836 . " cname='" . sql_real_escape_string($cname) . "',"
2837 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2838 . " WHERE catid=" . $catid;
2842 // store plugin options
2843 $aOptions = requestArray('plugoption');
2844 NucleusPlugin::apply_plugin_options($aOptions);
2845 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2852 $this->action_blogsettings();
2857 * @todo document this
2859 function action_categorydelete() {
2860 global $member, $manager;
2862 $blogid = intRequestVar('blogid');
2863 $catid = intRequestVar('catid');
2865 $member->blogAdminRights($blogid) or $this->disallow();
2867 $blog =& $manager->getBlog($blogid);
2869 // check if the category is valid
2870 if (!$blog->isValidCategory($catid))
2871 $this->error(_ERROR_NOSUCHCATEGORY);
2873 // don't allow deletion of default category
2874 if ($blog->getDefaultCategory() == $catid)
2875 $this->error(_ERROR_DELETEDEFCATEGORY);
2877 // check if catid is the only category left for blogid
2878 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2879 $res = sql_query($query);
2880 if (sql_num_rows($res) == 1)
2881 $this->error(_ERROR_DELETELASTCATEGORY);
2886 <h2><?php echo _DELETE_CONFIRM?></h2>
2889 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo Entity::hsc($blog->getCategoryName($catid))?></b>
2892 <form method="post" action="index.php"><div>
2893 <input type="hidden" name="action" value="categorydeleteconfirm" />
2894 <?php $manager->addTicketHidden() ?>
2895 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2896 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2897 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2904 * @todo document this
2906 function action_categorydeleteconfirm() {
2907 global $member, $manager;
2909 $blogid = intRequestVar('blogid');
2910 $catid = intRequestVar('catid');
2912 $member->blogAdminRights($blogid) or $this->disallow();
2914 $error = $this->deleteOneCategory($catid);
2916 $this->error($error);
2918 $this->action_blogsettings();
2922 * Admin::deleteOneCategory()
2923 * Delete a category by its id
2925 * @param String $catid category id for deleting
2928 function deleteOneCategory($catid)
2930 global $manager, $member;
2932 $catid = intval($catid);
2933 $blogid = getBlogIDFromCatID($catid);
2935 if ( !$member->blogAdminRights($blogid) )
2937 return ERROR_DISALLOWED;
2941 $blog =& $manager->getBlog($blogid);
2943 // check if the category is valid
2944 if ( !$blog || !$blog->isValidCategory($catid) )
2946 return _ERROR_NOSUCHCATEGORY;
2949 $destcatid = $blog->getDefaultCategory();
2951 // don't allow deletion of default category
2952 if ( $blog->getDefaultCategory() == $catid )
2954 return _ERROR_DELETEDEFCATEGORY;
2957 // check if catid is the only category left for blogid
2958 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2959 $res = sql_query($query);
2960 if ( sql_num_rows($res) == 1 )
2962 return _ERROR_DELETELASTCATEGORY;
2965 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2967 // change category for all items to the default category
2968 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2971 // delete all associated plugin options
2972 NucleusPlugin::delete_option_values('category', $catid);
2975 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2978 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2983 * Admin::action_blogsettingsupdate
2984 * Updating blog settings
2989 function action_blogsettingsupdate()
2991 global $member, $manager;
2993 $blogid = intRequestVar('blogid');
2995 $member->blogAdminRights($blogid) or $this->disallow();
2997 $blog =& $manager->getBlog($blogid);
2999 $notify_address = trim(postVar('notify'));
3000 $shortname = trim(postVar('shortname'));
3001 $updatefile = trim(postVar('update'));
3003 $notifyComment = intPostVar('notifyComment');
3004 $notifyVote = intPostVar('notifyVote');
3005 $notifyNewItem = intPostVar('notifyNewItem');
3007 if ( $notifyComment == 0 )
3011 if ( $notifyVote == 0 )
3015 if ( $notifyNewItem == 0 )
3019 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3021 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
3023 $this->error(_ERROR_BADNOTIFY);
3026 if ( !isValidShortName($shortname) )
3028 $this->error(_ERROR_BADSHORTBLOGNAME);
3031 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
3033 $this->error(_ERROR_DUPSHORTBLOGNAME);
3035 // check if update file is writable
3036 if ( $updatefile && !is_writeable($updatefile) )
3038 $this->error(_ERROR_UPDATEFILE);
3041 $blog->setName(trim(postVar('name')));
3042 $blog->setShortName($shortname);
3043 $blog->setNotifyAddress($notify_address);
3044 $blog->setNotifyType($notifyType);
3045 $blog->setMaxComments(postVar('maxcomments'));
3046 $blog->setCommentsEnabled(postVar('comments'));
3047 $blog->setTimeOffset(postVar('timeoffset'));
3048 $blog->setUpdateFile($updatefile);
3049 $blog->setURL(trim(postVar('url')));
3050 $blog->setDefaultSkin(intPostVar('defskin'));
3051 $blog->setDescription(trim(postVar('desc')));
3052 $blog->setPublic(postVar('public'));
3053 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3054 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3055 $blog->setDefaultCategory(intPostVar('defcat'));
3056 $blog->setSearchable(intPostVar('searchable'));
3057 $blog->setEmailRequired(intPostVar('reqemail'));
3058 $blog->writeSettings();
3060 // store plugin options
3061 $aOptions = requestArray('plugoption');
3062 NucleusPlugin::apply_plugin_options($aOptions);
3063 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3065 $this->action_overview(_MSG_SETTINGSCHANGED);
3070 * @todo document this
3072 function action_deleteblog() {
3073 global $member, $CONF, $manager;
3075 $blogid = intRequestVar('blogid');
3077 $member->blogAdminRights($blogid) or $this->disallow();
3079 // check if blog is default blog
3080 if ($CONF['DefaultBlog'] == $blogid)
3081 $this->error(_ERROR_DELDEFBLOG);
3083 $blog =& $manager->getBlog($blogid);
3087 <h2><?php echo _DELETE_CONFIRM?></h2>
3089 <p><?php echo _WARNINGTXT_BLOGDEL?>
3093 <?php echo _CONFIRMTXT_BLOG?><b><?php echo Entity::hsc($blog->getName())?></b>
3096 <form method="post" action="index.php"><div>
3097 <input type="hidden" name="action" value="deleteblogconfirm" />
3098 <?php $manager->addTicketHidden() ?>
3099 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3100 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3107 * Admin::action_deleteblogconfirm()
3113 function action_deleteblogconfirm()
3115 global $member, $CONF, $manager;
3117 $blogid = intRequestVar('blogid');
3118 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3119 $member->blogAdminRights($blogid) or $this->disallow();
3121 // check if blog is default blog
3122 if ( $CONF['DefaultBlog'] == $blogid )
3124 $this->error(_ERROR_DELDEFBLOG);
3127 // delete all comments
3128 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3132 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3135 // delete all team members
3136 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3140 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3143 // delete all categories
3144 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3147 // delete all associated plugin options
3148 NucleusPlugin::delete_option_values('blog', $blogid);
3150 // delete the blog itself
3151 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3154 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3156 $this->action_overview(_DELETED_BLOG);
3161 * @todo document this
3163 function action_memberdelete() {
3164 global $member, $manager;
3166 $memberid = intRequestVar('memberid');
3168 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3170 $mem = Member::createFromID($memberid);
3174 <h2><?php echo _DELETE_CONFIRM?></h2>
3176 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo Entity::hsc($mem->getDisplayName()) ?></b>
3180 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3183 <form method="post" action="index.php"><div>
3184 <input type="hidden" name="action" value="memberdeleteconfirm" />
3185 <?php $manager->addTicketHidden() ?>
3186 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3187 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3194 * @todo document this
3196 function action_memberdeleteconfirm() {
3199 $memberid = intRequestVar('memberid');
3201 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3203 $error = $this->deleteOneMember($memberid);
3205 $this->error($error);
3207 if ($member->isAdmin())
3208 $this->action_usermanagement();
3210 $this->action_overview(_DELETED_MEMBER);
3214 * Admin::deleteOneMember()
3215 * Delete a member by id
3218 * @params Integer $memberid member id
3219 * @return String null string or error messages
3221 function deleteOneMember($memberid)
3225 $memberid = intval($memberid);
3226 $mem = Member::createFromID($memberid);
3228 if ( !$mem->canBeDeleted() )
3230 return _ERROR_DELETEMEMBER;
3233 $manager->notify('PreDeleteMember', array('member' => &$mem));
3235 /* unlink comments from memberid */
3238 $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";
3239 $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);
3243 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3246 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3249 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3252 // delete all associated plugin options
3253 NucleusPlugin::delete_option_values('member', $memberid);
3255 $manager->notify('PostDeleteMember', array('member' => &$mem));
3261 * @todo document this
3263 function action_createnewlog() {
3264 global $member, $CONF, $manager;
3266 // Only Super-Admins can do this
3267 $member->isAdmin() or $this->disallow();
3271 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3273 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3275 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3277 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3279 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3282 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3283 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3286 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3289 <?php echo _EBLOG_CREATE_TEXT?>
3292 <form method="post" action="index.php"><div>
3294 <input type="hidden" name="action" value="addnewlog" />
3295 <?php $manager->addTicketHidden() ?>
3299 <td><?php echo _EBLOG_NAME?></td>
3300 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3302 <td><?php echo _EBLOG_SHORTNAME?>
3303 <?php help('shortblogname'); ?>
3305 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3307 <td><?php echo _EBLOG_DESC?></td>
3308 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3310 <td><?php echo _EBLOG_DEFSKIN?>
3311 <?php help('blogdefaultskin'); ?>
3315 $query = 'SELECT sdname as text, sdnumber as value'
3316 . ' FROM '.sql_table('skin_desc');
3317 $template['name'] = 'defskin';
3318 $template['tabindex'] = 50;
3319 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3320 showlist($query,'select',$template);
3324 <td><?php echo _EBLOG_OFFSET?>
3325 <?php help('blogtimeoffset'); ?>
3326 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::formatted_datetime('%H:%M',time()); ?></b>
3328 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3330 <td><?php echo _EBLOG_ADMIN?>
3331 <?php help('teamadmin'); ?>
3333 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3335 <td><?php echo _EBLOG_CREATE?></td>
3336 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3345 * @todo document this
3347 function action_addnewlog() {
3348 global $member, $manager, $CONF;
3350 // Only Super-Admins can do this
3351 $member->isAdmin() or $this->disallow();
3353 $bname = trim(postVar('name'));
3354 $bshortname = trim(postVar('shortname'));
3355 $btimeoffset = postVar('timeoffset');
3356 $bdesc = trim(postVar('desc'));
3357 $bdefskin = postVar('defskin');
3359 if (!isValidShortName($bshortname))
3360 $this->error(_ERROR_BADSHORTBLOGNAME);
3362 if ($manager->existsBlog($bshortname))
3363 $this->error(_ERROR_DUPSHORTBLOGNAME);
3369 'shortname' => &$bshortname,
3370 'timeoffset' => &$btimeoffset,
3371 'description' => &$bdesc,
3372 'defaultskin' => &$bdefskin
3377 // add slashes for sql queries
3378 $bname = sql_real_escape_string($bname);
3379 $bshortname = sql_real_escape_string($bshortname);
3380 $btimeoffset = sql_real_escape_string($btimeoffset);
3381 $bdesc = sql_real_escape_string($bdesc);
3382 $bdefskin = sql_real_escape_string($bdefskin);
3385 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3387 $blogid = sql_insert_id();
3388 $blog =& $manager->getBlog($blogid);
3390 // create new category
3391 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3392 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3393 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3394 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3395 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3396 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3397 $catid = sql_insert_id();
3399 // set as default category
3400 $blog->setDefaultCategory($catid);
3401 $blog->writeSettings();
3403 // create team member
3404 $memberid = $member->getID();
3405 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3408 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3409 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3411 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3412 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3427 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3428 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3435 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3437 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, Entity::hsc($bname)) ?></p>
3440 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, Entity::hsc($bshortname)) ?></a></li>
3441 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3444 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, Entity::hsc($bshortname)) ?></a></h3>
3446 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, Entity::hsc($bshortname)) ?></p>
3449 $CONF['Self'] = '<b><?php echo Entity::hsc($bshortname)?>.php</b>';
3451 include('<i>./config.php</i>');
3453 selectBlog('<b><?php echo Entity::hsc($bshortname)?></b>');
3458 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3460 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3462 <form action="index.php" method="post"><div>
3463 <input type="hidden" name="action" value="addnewlog2" />
3464 <?php $manager->addTicketHidden() ?>
3465 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3467 <td><?php echo _EBLOG_URL?></td>
3468 <td><input name="url" maxlength="100" size="40" value="<?php echo Entity::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3470 <td><?php echo _EBLOG_CREATE?></td>
3471 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3475 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3477 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3479 <form action="index.php" method="post"><div>
3480 <input type="hidden" name="action" value="addnewlog2" />
3481 <?php $manager->addTicketHidden() ?>
3482 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3484 <td><?php echo _EBLOG_URL?></td>
3485 <td><input name="url" maxlength="100" size="40" /></td>
3487 <td><?php echo _EBLOG_CREATE?></td>
3488 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3492 <?php $this->pagefoot();
3497 * @todo document this
3499 function action_addnewlog2() {
3500 global $member, $manager;
3502 $member->blogAdminRights($blogid) or $this->disallow();
3504 $burl = requestVar('url');
3505 $blogid = intRequestVar('blogid');
3507 $blog =& $manager->getBlog($blogid);
3508 $blog->setURL(trim($burl));
3509 $blog->writeSettings();
3511 $this->action_overview(_MSG_NEWBLOG);
3515 * @todo document this
3517 function action_skinieoverview() {
3518 global $member, $DIR_LIBS, $manager;
3520 $member->isAdmin() or $this->disallow();
3522 // load skinie class
3523 include_once($DIR_LIBS . 'skinie.php');
3527 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3530 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3532 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3533 <?php global $DIR_SKINS;
3535 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
3537 if (sizeof($candidates) > 0) {
3539 <form method="post" action="index.php"><div>
3540 <input type="hidden" name="action" value="skinieimport" />
3541 <?php $manager->addTicketHidden() ?>
3542 <input type="hidden" name="mode" value="file" />
3543 <select name="skinfile" id="skinie_import_local">
3544 <?php foreach ($candidates as $skinname => $skinfile) {
3545 $html = Entity::hsc($skinfile);
3546 echo '<option value="',$html,'">',$skinname,'</option>';
3550 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3553 echo _SKINIE_NOCANDIDATES;
3558 <p><em><?php echo _OR?></em></p>
3560 <form method="post" action="index.php"><p>
3561 <?php $manager->addTicketHidden() ?>
3562 <input type="hidden" name="action" value="skinieimport" />
3563 <input type="hidden" name="mode" value="url" />
3564 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3565 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3566 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3570 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3571 <form method="post" action="index.php"><div>
3572 <input type="hidden" name="action" value="skinieexport" />
3573 <?php $manager->addTicketHidden() ?>
3575 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3578 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3580 <?php // show list of skins
3581 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3582 while ($skinObj = sql_fetch_object($res)) {
3583 $id = 'skinexp' . $skinObj->sdnumber;
3584 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3585 echo '<label for="',$id,'">',Entity::hsc($skinObj->sdname),'</label></td>';
3586 echo '<td>',Entity::hsc($skinObj->sddesc),'</td>';
3590 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3592 // show list of templates
3593 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3594 while ($templateObj = sql_fetch_object($res)) {
3595 $id = 'templateexp' . $templateObj->tdnumber;
3596 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3597 echo '<label for="',$id,'">',Entity::hsc($templateObj->tdname),'</label></td>';
3598 echo '<td>',Entity::hsc($templateObj->tddesc),'</td>';
3603 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3605 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3607 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3609 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3619 * @todo document this
3621 function action_skinieimport() {
3622 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3624 $member->isAdmin() or $this->disallow();
3626 // load skinie class
3627 include_once($DIR_LIBS . 'skinie.php');
3629 $skinFileRaw= postVar('skinfile');
3630 $mode = postVar('mode');
3632 $importer = new SkinImport();
3634 // get full filename
3635 if ($mode == 'file')
3637 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3639 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3640 if (!file_exists($skinFile))
3641 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3643 $skinFile = $skinFileRaw;
3646 // read only metadata
3647 $error = $importer->readFile($skinFile, 1);
3650 $skinNameClashes = $importer->checkSkinNameClashes();
3651 $templateNameClashes = $importer->checkTemplateNameClashes();
3652 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3654 if ($error) $this->error($error);
3658 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3660 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3663 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
3664 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3665 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3667 if ($hasNameClashes)
3670 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3671 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3673 } // if (hasNameClashes)
3677 <form method="post" action="index.php"><div>
3678 <input type="hidden" name="action" value="skiniedoimport" />
3679 <?php $manager->addTicketHidden() ?>
3680 <input type="hidden" name="skinfile" value="<?php echo Entity::hsc(postVar('skinfile'))?>" />
3681 <input type="hidden" name="mode" value="<?php echo Entity::hsc($mode)?>" />
3682 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3684 if ($hasNameClashes)
3688 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3690 } // if (hasNameClashes)
3700 * @todo document this
3702 function action_skiniedoimport() {
3703 global $member, $DIR_LIBS, $DIR_SKINS;
3705 $member->isAdmin() or $this->disallow();
3707 // load skinie class
3708 include_once($DIR_LIBS . 'skinie.php');
3710 $skinFileRaw= postVar('skinfile');
3711 $mode = postVar('mode');
3713 $allowOverwrite = intPostVar('overwrite');
3715 // get full filename
3716 if ($mode == 'file')
3718 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3720 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3721 if (!file_exists($skinFile))
3722 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3725 $skinFile = $skinFileRaw;
3728 $importer = new SkinImport();
3730 $error = $importer->readFile($skinFile);
3733 $this->error($error);
3735 $error = $importer->writeToDatabase($allowOverwrite);
3738 $this->error($error);
3742 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3744 <h2><?php echo _SKINIE_DONE?></h2>
3747 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
3748 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3749 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3752 <?php $this->pagefoot();
3757 * @todo document this
3759 function action_skinieexport() {
3760 global $member, $DIR_LIBS;
3762 $member->isAdmin() or $this->disallow();
3764 // load skinie class
3765 include_once($DIR_LIBS . 'skinie.php');
3767 $aSkins = requestIntArray('skin');
3768 $aTemplates = requestIntArray('template');
3770 if (!is_array($aTemplates)) $aTemplates = array();
3771 if (!is_array($aSkins)) $aSkins = array();
3773 $skinList = array_keys($aSkins);
3774 $templateList = array_keys($aTemplates);
3776 $info = postVar('info');
3778 $exporter = new SkinExport();
3779 foreach ($skinList as $skinId) {
3780 $exporter->addSkin($skinId);
3782 foreach ($templateList as $templateId) {
3783 $exporter->addTemplate($templateId);
3785 $exporter->setInfo($info);
3787 $exporter->export();
3791 * @todo document this
3793 function action_templateoverview() {
3794 global $member, $manager;
3796 $member->isAdmin() or $this->disallow();
3800 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3802 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3803 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3805 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3806 $template['content'] = 'templatelist';
3807 $template['tabindex'] = 10;
3808 showlist($query,'table',$template);
3810 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3813 <form method="post" action="index.php"><div>
3815 <input name="action" value="templatenew" type="hidden" />
3816 <?php $manager->addTicketHidden() ?>
3818 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3819 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3821 <td><?php echo _TEMPLATE_DESC?></td>
3822 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3824 <td><?php echo _TEMPLATE_CREATE?></td>
3825 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3835 * @todo document this
3837 function action_templateedit($msg = '') {
3838 global $member, $manager;
3840 $templateid = intRequestVar('templateid');
3842 $member->isAdmin() or $this->disallow();
3844 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3845 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3847 $this->pagehead($extrahead);
3849 $templatename = Template::getNameFromId($templateid);
3850 $templatedescription = Template::getDesc($templateid);
3851 $template =& $manager->getTemplate($templatename);
3855 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3858 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo Entity::hsc($templatename); ?>'</h2>
3860 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3863 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3865 <form method="post" action="index.php">
3868 <input type="hidden" name="action" value="templateupdate" />
3869 <?php $manager->addTicketHidden() ?>
3870 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3873 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3875 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3876 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo Entity::hsc($templatename) ?>" /></td>
3878 <td><?php echo _TEMPLATE_DESC?></td>
3879 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo Entity::hsc($templatedescription) ?>" /></td>
3881 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3883 <td><?php echo _TEMPLATE_UPDATE?></td>
3885 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3886 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3889 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3890 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3891 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3892 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3893 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3894 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3895 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3898 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3899 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3900 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3901 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3902 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3903 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3904 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3905 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3908 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3910 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3913 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3914 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3917 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3918 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3919 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3920 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3923 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3924 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3925 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3926 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3929 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3930 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3931 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3932 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3935 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3936 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3937 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3938 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3939 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3940 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3943 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3944 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3945 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3946 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3949 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3950 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3951 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3954 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3957 $pluginfields = array();
3958 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3960 foreach ($pluginfields as $pfkey=>$pfvalue) {
3962 echo '<th colspan="2">' . Entity::hen($pfkey) . "</th>\n";
3963 foreach ($pfvalue as $pffield=>$pfdesc) {
3964 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3969 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3971 <td><?php echo _TEMPLATE_UPDATE?></td>
3973 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3974 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3985 * @todo document this
3987 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3989 if (!isset($template[$name])) $template[$name] = '';
3992 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3993 <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>
3998 * @todo document this
4000 function action_templateupdate() {
4001 global $member,$manager;
4003 $templateid = intRequestVar('templateid');
4005 $member->isAdmin() or $this->disallow();
4007 $name = postVar('tname');
4008 $desc = postVar('tdesc');
4010 if (!isValidTemplateName($name))
4011 $this->error(_ERROR_BADTEMPLATENAME);
4013 if ((Template::getNameFromId($templateid) != $name) && Template::exists($name))
4014 $this->error(_ERROR_DUPTEMPLATENAME);
4017 $name = sql_real_escape_string($name);
4018 $desc = sql_real_escape_string($desc);
4020 // 1. Remove all template parts
4021 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4024 // 2. Update description
4025 $query = 'UPDATE '.sql_table('template_desc').' SET'
4026 . " tdname='" . $name . "',"
4027 . " tddesc='" . $desc . "'"
4028 . " WHERE tdnumber=" . $templateid;
4031 // 3. Add non-empty template parts
4032 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4033 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4034 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4035 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4036 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4037 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4038 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4039 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4040 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4041 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4042 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4043 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4044 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4045 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4046 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4047 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4048 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4049 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4050 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4051 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4052 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4053 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4054 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4055 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4056 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4057 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4058 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4059 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4060 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4061 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4062 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4063 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4064 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4065 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4067 $pluginfields = array();
4068 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4069 foreach ($pluginfields as $pfkey=>$pfvalue) {
4070 foreach ($pfvalue as $pffield=>$pfdesc) {
4071 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4075 // jump back to template edit
4076 $this->action_templateedit(_TEMPLATE_UPDATED);
4081 * Admin::addToTemplate()
4083 * @param Integer $id ID for template
4084 * @param String $partname parts name
4085 * @param String $content template contents
4086 * @return Integer record index
4089 function addToTemplate($id, $partname, $content)
4091 // don't add empty parts:
4092 if ( !trim($content) )
4097 $partname = sql_real_escape_string($partname);
4098 $content = sql_real_escape_string($content);
4100 $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, '%s', '%s')";
4101 $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
4102 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4103 return sql_insert_id();
4107 * @todo document this
4109 function action_templatedelete() {
4110 global $member, $manager;
4112 $member->isAdmin() or $this->disallow();
4114 $templateid = intRequestVar('templateid');
4115 // TODO: check if template can be deleted
4119 $name = Template::getNameFromId($templateid);
4120 $desc = Template::getDesc($templateid);
4123 <h2><?php echo _DELETE_CONFIRM?></h2>
4126 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo Entity::hsc($name)?></b> (<?php echo Entity::hsc($desc) ?>)
4129 <form method="post" action="index.php"><div>
4130 <input type="hidden" name="action" value="templatedeleteconfirm" />
4131 <?php $manager->addTicketHidden() ?>
4132 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4133 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4140 * @todo document this
4142 function action_templatedeleteconfirm() {
4143 global $member, $manager;
4145 $templateid = intRequestVar('templateid');
4147 $member->isAdmin() or $this->disallow();
4149 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4151 // 1. delete description
4152 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4155 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4157 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4159 $this->action_templateoverview();
4163 * @todo document this
4165 function action_templatenew() {
4168 $member->isAdmin() or $this->disallow();
4170 $name = postVar('name');
4171 $desc = postVar('desc');
4173 if (!isValidTemplateName($name))
4174 $this->error(_ERROR_BADTEMPLATENAME);
4176 if (Template::exists($name))
4177 $this->error(_ERROR_DUPTEMPLATENAME);
4179 $newTemplateId = Template::createNew($name, $desc);
4181 $this->action_templateoverview();
4185 * @todo document this
4187 function action_templateclone() {
4190 $templateid = intRequestVar('templateid');
4192 $member->isAdmin() or $this->disallow();
4194 // 1. read old template
4195 $name = Template::getNameFromId($templateid);
4196 $desc = Template::getDesc($templateid);
4198 // 2. create desc thing
4199 $name = "cloned" . $name;
4201 // if a template with that name already exists:
4202 if (Template::exists($name)) {
4204 while (Template::exists($name . $i))
4209 $newid = Template::createNew($name, $desc);
4212 // go through parts of old template and add them to the new one
4213 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4214 while ($o = sql_fetch_object($res)) {
4215 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4218 $this->action_templateoverview();
4222 * @todo document this
4224 function action_skinoverview() {
4225 global $member, $manager;
4227 $member->isAdmin() or $this->disallow();
4231 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4233 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4235 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4237 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4238 $template['content'] = 'skinlist';
4239 $template['tabindex'] = 10;
4240 showlist($query,'table',$template);
4242 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4245 <form method="post" action="index.php">
4248 <input name="action" value="skinnew" type="hidden" />
4249 <?php $manager->addTicketHidden() ?>
4251 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4252 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4254 <td><?php echo _SKIN_DESC?></td>
4255 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4257 <td><?php echo _SKIN_CREATE?></td>
4258 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4269 * @todo document this
4271 function action_skinnew() {
4274 $member->isAdmin() or $this->disallow();
4276 $name = trim(postVar('name'));
4277 $desc = trim(postVar('desc'));
4279 if (!isValidSkinName($name))
4280 $this->error(_ERROR_BADSKINNAME);
4282 if (SKIN::exists($name))
4283 $this->error(_ERROR_DUPSKINNAME);
4285 $newId = SKIN::createNew($name, $desc);
4287 $this->action_skinoverview();
4291 * @todo document this
4293 function action_skinedit() {
4294 global $member, $manager;
4296 $skinid = intRequestVar('skinid');
4298 $member->isAdmin() or $this->disallow();
4300 $skin = new SKIN($skinid);
4305 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4307 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4309 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4310 <?php echo _SKIN_PARTS_MSG?>
4312 <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>
4313 <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>
4314 <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>
4315 <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>
4316 <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>
4317 <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>
4318 <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>
4319 <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>
4324 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4325 $res = sql_query($query);
4327 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4328 echo '<form method="get" action="index.php">' . "\r\n";
4329 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4330 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4331 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4332 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4333 echo '</form>' . "\r\n";
4335 if ($res && sql_num_rows($res) > 0) {
4339 while ($row = sql_fetch_assoc($res)) {
4340 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>';
4348 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4349 <form method="post" action="index.php">
4352 <input type="hidden" name="action" value="skineditgeneral" />
4353 <?php $manager->addTicketHidden() ?>
4354 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4356 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4357 <td><input name="name" tabindex="90" value="<?php echo Entity::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4359 <td><?php echo _SKIN_DESC?></td>
4360 <td><input name="desc" tabindex="100" value="<?php echo Entity::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4362 <td><?php echo _SKIN_TYPE?></td>
4363 <td><input name="type" tabindex="110" value="<?php echo Entity::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4365 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4366 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4368 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4369 <td><input name="inc_prefix" tabindex="130" value="<?php echo Entity::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4371 <td><?php echo _SKIN_CHANGE?></td>
4372 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4379 <?php $this->pagefoot();
4383 * @todo document this
4385 function action_skineditgeneral() {
4388 $skinid = intRequestVar('skinid');
4390 $member->isAdmin() or $this->disallow();
4392 $name = postVar('name');
4393 $desc = postVar('desc');
4394 $type = postVar('type');
4395 $inc_mode = postVar('inc_mode');
4396 $inc_prefix = postVar('inc_prefix');
4398 $skin = new SKIN($skinid);
4401 if (!isValidSkinName($name))
4402 $this->error(_ERROR_BADSKINNAME);
4404 if (($skin->getName() != $name) && SKIN::exists($name))
4405 $this->error(_ERROR_DUPSKINNAME);
4407 if (!$type) $type = 'text/html';
4408 if (!$inc_mode) $inc_mode = 'normal';
4410 // 2. Update description
4411 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4413 $this->action_skinedit();
4418 * @todo document this
4420 function action_skinedittype($msg = '') {
4421 global $member, $manager;
4423 $skinid = intRequestVar('skinid');
4424 $type = requestVar('type');
4426 $member->isAdmin() or $this->disallow();
4428 $type = trim($type);
4429 $type = strtolower($type);
4431 if (!isValidShortName($type)) {
4432 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4435 $skin = new SKIN($skinid);
4437 $friendlyNames = SKIN::getFriendlyNames();
4441 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4443 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo Entity::hsc($skin->getName()) ?>': <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4445 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4449 <form method="post" action="index.php">
4452 <input type="hidden" name="action" value="skinupdate" />
4453 <?php $manager->addTicketHidden() ?>
4454 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4455 <input type="hidden" name="type" value="<?php echo $type ?>" />
4457 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4458 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4459 (skin type: <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4460 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4461 help('skinpart' . $type);
4463 help('skinpartspecial');
4467 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo Entity::hsc($skin->getContent($type)) ?></textarea>
4470 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4471 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4472 (skin type: <?php echo Entity::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4475 <?php echo _SKIN_ALLOWEDVARS?>
4476 <?php $actions = SKIN::getAllowedActionsForType($type);
4480 while ($current = array_shift($actions)) {
4481 // skip deprecated vars
4482 if ($current == 'ifcat') continue;
4483 if ($current == 'imagetext') continue;
4484 if ($current == 'vars') continue;
4486 echo helplink('skinvar-' . $current) . "$current</a>";
4487 if (count($actions) != 0) echo ", ";
4489 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4490 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4491 showlist($query,'table',array('content'=>'shortblognames'));
4492 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4493 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4494 showlist($query,'table',array('content'=>'shortnames'));
4495 echo '</div></form>';
4500 * @todo document this
4502 function action_skinupdate() {
4505 $skinid = intRequestVar('skinid');
4506 $content = trim(postVar('content'));
4507 $type = postVar('type');
4509 $member->isAdmin() or $this->disallow();
4511 $skin = new SKIN($skinid);
4512 $skin->update($type, $content);
4514 $this->action_skinedittype(_SKIN_UPDATED);
4518 * @todo document this
4520 function action_skindelete() {
4521 global $member, $manager, $CONF;
4523 $skinid = intRequestVar('skinid');
4525 $member->isAdmin() or $this->disallow();
4527 // don't allow default skin to be deleted
4528 if ($skinid == $CONF['BaseSkin'])
4529 $this->error(_ERROR_DEFAULTSKIN);
4531 // don't allow deletion of default skins for blogs
4532 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4533 $r = sql_query($query);
4534 if ($o = sql_fetch_object($r))
4535 $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($o->bname));
4539 $skin = new SKIN($skinid);
4540 $name = $skin->getName();
4541 $desc = $skin->getDescription();
4544 <h2><?php echo _DELETE_CONFIRM?></h2>
4547 <?php echo _CONFIRMTXT_SKIN?><b><?php echo Entity::hsc($name) ?></b> (<?php echo Entity::hsc($desc)?>)
4550 <form method="post" action="index.php"><div>
4551 <input type="hidden" name="action" value="skindeleteconfirm" />
4552 <?php $manager->addTicketHidden() ?>
4553 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4554 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4561 * @todo document this
4563 function action_skindeleteconfirm() {
4564 global $member, $CONF, $manager;
4566 $skinid = intRequestVar('skinid');
4568 $member->isAdmin() or $this->disallow();
4570 // don't allow default skin to be deleted
4571 if ($skinid == $CONF['BaseSkin'])
4572 $this->error(_ERROR_DEFAULTSKIN);
4574 // don't allow deletion of default skins for blogs
4575 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4576 $r = sql_query($query);
4577 if ($o = sql_fetch_object($r))
4578 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4580 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4582 // 1. delete description
4583 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4586 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4588 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4590 $this->action_skinoverview();
4594 * @todo document this
4596 function action_skinremovetype() {
4597 global $member, $manager, $CONF;
4599 $skinid = intRequestVar('skinid');
4600 $skintype = requestVar('type');
4602 if (!isValidShortName($skintype)) {
4603 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4606 $member->isAdmin() or $this->disallow();
4608 // don't allow default skinparts to be deleted
4609 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4610 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4615 $skin = new SKIN($skinid);
4616 $name = $skin->getName();
4617 $desc = $skin->getDescription();
4620 <h2><?php echo _DELETE_CONFIRM?></h2>
4623 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo Entity::hsc($skintype); ?> (<?php echo Entity::hsc($name); ?>)</b> (<?php echo Entity::hsc($desc)?>)
4626 <form method="post" action="index.php"><div>
4627 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4628 <?php $manager->addTicketHidden() ?>
4629 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4630 <input type="hidden" name="type" value="<?php echo Entity::hsc($skintype); ?>" />
4631 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4638 * @todo document this
4640 function action_skinremovetypeconfirm() {
4641 global $member, $CONF, $manager;
4643 $skinid = intRequestVar('skinid');
4644 $skintype = requestVar('type');
4646 if (!isValidShortName($skintype)) {
4647 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4650 $member->isAdmin() or $this->disallow();
4652 // don't allow default skinparts to be deleted
4653 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4654 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4657 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4660 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4662 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4664 $this->action_skinedit();
4668 * @todo document this
4670 function action_skinclone() {
4673 $skinid = intRequestVar('skinid');
4675 $member->isAdmin() or $this->disallow();
4677 // 1. read skin to clone
4678 $skin = new SKIN($skinid);
4680 $name = "clone_" . $skin->getName();
4682 // if a skin with that name already exists:
4683 if (SKIN::exists($name)) {
4685 while (SKIN::exists($name . $i))
4690 // 2. create skin desc
4691 $newid = SKIN::createNew(
4693 $skin->getDescription(),
4694 $skin->getContentType(),
4695 $skin->getIncludeMode(),
4696 $skin->getIncludePrefix()
4702 $this->skinclonetype($skin, $newid, 'index');
4703 $this->skinclonetype($skin, $newid, 'item');
4704 $this->skinclonetype($skin, $newid, 'archivelist');
4705 $this->skinclonetype($skin, $newid, 'archive');
4706 $this->skinclonetype($skin, $newid, 'search');
4707 $this->skinclonetype($skin, $newid, 'error');
4708 $this->skinclonetype($skin, $newid, 'member');
4709 $this->skinclonetype($skin, $newid, 'imagepopup');
4712 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4713 $res = sql_query($query);
4714 while ($row = sql_fetch_assoc($res)) {
4715 $this->skinclonetype($skin, $newid, $row['stype']);
4718 $this->action_skinoverview();
4723 * Admin::skinclonetype()
4725 * @param String $skin Skin object
4726 * @param Integer $newid ID for this clone
4727 * @param String $type type of skin
4730 function skinclonetype($skin, $newid, $type)
4732 $newid = intval($newid);
4733 $content = $skin->getContent($type);
4737 $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
4738 $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
4745 * Admin::action_settingsedit()
4750 function action_settingsedit() {
4751 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4753 $member->isAdmin() or $this->disallow();
4757 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4760 <h2><?php echo _SETTINGS_TITLE?></h2>
4762 <form action="index.php" method="post">
4765 <input type="hidden" name="action" value="settingsupdate" />
4766 <?php $manager->addTicketHidden() ?>
4769 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4771 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4774 $query = 'SELECT bname as text, bnumber as value'
4775 . ' FROM '.sql_table('blog');
4776 $template['name'] = 'DefaultBlog';
4777 $template['selected'] = $CONF['DefaultBlog'];
4778 $template['tabindex'] = 10;
4779 showlist($query,'select',$template);
4783 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4786 $query = 'SELECT sdname as text, sdnumber as value'
4787 . ' FROM '.sql_table('skin_desc');
4788 $template['name'] = 'BaseSkin';
4789 $template['selected'] = $CONF['BaseSkin'];
4790 $template['tabindex'] = 1;
4791 showlist($query,'select',$template);
4795 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4796 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo Entity::hsc($CONF['AdminEmail']) ?>" /></td>
4798 <td><?php echo _SETTINGS_SITENAME?></td>
4799 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo Entity::hsc($CONF['SiteName']) ?>" /></td>
4801 <td><?php echo _SETTINGS_SITEURL?></td>
4802 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo Entity::hsc($CONF['IndexURL']) ?>" /></td>
4804 <td><?php echo _SETTINGS_ADMINURL?></td>
4805 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo Entity::hsc($CONF['AdminURL']) ?>" /></td>
4807 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4808 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo Entity::hsc($CONF['PluginURL']) ?>" /></td>
4810 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4811 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo Entity::hsc($CONF['SkinsURL']) ?>" /></td>
4813 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4814 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo Entity::hsc($CONF['ActionURL']) ?>" /></td>
4816 <td><?php echo _SETTINGS_LOCALE?> <?php help('locale'); ?>
4819 <select name="Locale" tabindex="10050">
4821 $locales = i18n::get_available_locale_list();
4822 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4824 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4828 echo "<option value=\"\">en_Latn_US</option>\n";
4831 foreach ( $locales as $locale )
4833 if ( $locale == 'en_Latn_US' )
4837 if ( $locale == i18n::get_current_locale() )
4839 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4843 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4851 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4853 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4855 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo Entity::hsc($CONF['DisableSiteURL'])?>" />
4858 <td><?php echo _SETTINGS_DIRS?></td>
4859 <td><?php echo Entity::hsc($DIR_NUCLEUS) ?>
4860 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4862 <td><?php echo _SETTINGS_DBLOGIN?></td>
4863 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4867 echo _SETTINGS_JSTOOLBAR
4868 /* =_SETTINGS_DISABLEJS
4870 I temporary changed the meaning of DisableJsTools, until I can find a good
4871 way to select the javascript version to use
4875 1 : all javascript disabled
4876 2 : 'simpler' javascript (for mozilla/opera/mac)
4880 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4881 <select name="DisableJsTools" tabindex="10075">
4882 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4883 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4884 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4885 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4886 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4887 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4892 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4895 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4896 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4898 echo ' ', _SETTINGS_URLMODE_HELP;
4904 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4907 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4913 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4916 if (!array_key_exists('DefaultListSize',$CONF)) {
4917 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4918 $CONF['DefaultListSize'] = 10;
4921 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo Entity::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4924 <td><?php echo _SETTINGS_ADMINCSS?>
4928 <select name="AdminCSS" tabindex="10080">
4929 <?php // show a dropdown list of all available admin css files
4930 global $DIR_NUCLEUS;
4932 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4934 while ($filename = readdir($dirhandle) )
4937 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4938 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4940 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4943 $name = $matches[1];
4944 echo "<option value=\"$name\"";
4946 if ($name == $CONF['AdminCSS'])
4948 echo " selected=\"selected\"";
4951 echo ">$name</option>";
4957 closedir($dirhandle);
4964 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4966 <td><?php echo _SETTINGS_MEDIADIR?></td>
4967 <td><?php echo Entity::hsc($DIR_MEDIA) ?>
4968 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4969 <?php if (!is_dir($DIR_MEDIA))
4970 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4971 if (!is_readable($DIR_MEDIA))
4972 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4973 if (!is_writeable($DIR_MEDIA))
4974 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4978 <td><?php echo _SETTINGS_MEDIAURL?></td>
4980 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo Entity::hsc($CONF['MediaURL']) ?>" />
4983 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4984 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4986 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4988 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo Entity::hsc($CONF['AllowedTypes']) ?>" />
4991 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4993 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo Entity::hsc($CONF['MaxUploadSize']) ?>" />
4996 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4997 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
5000 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
5002 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
5003 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
5005 <td><?php echo _SETTINGS_ALLOWCREATE?>
5006 <?php help('allowaccountcreation'); ?>
5008 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
5011 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
5012 <br /><?php echo _SETTINGS_NEWLOGIN2?>
5014 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
5017 <td><?php echo _SETTINGS_MEMBERMSGS?>
5018 <?php help('messageservice'); ?>
5020 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
5023 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
5024 <?php help('messageservice'); ?>
5026 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5029 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5030 <?php help('protectmemnames'); ?>
5032 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5038 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5040 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5041 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo Entity::hsc($CONF['CookiePrefix'])?>" /></td>
5043 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5044 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo Entity::hsc($CONF['CookieDomain'])?>" /></td>
5046 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5047 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo Entity::hsc($CONF['CookiePath'])?>" /></td>
5049 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5050 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5052 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5053 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5054 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5057 <td><?php echo _SETTINGS_LASTVISIT?></td>
5058 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5063 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5065 <td><?php echo _SETTINGS_UPDATE?></td>
5066 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5073 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5076 'GeneralSettingsFormExtras',
5084 * Admin::action_settingsupdate()
5085 * Update $CONFIG and redirect
5090 function action_settingsupdate() {
5091 global $member, $CONF;
5093 $member->isAdmin() or $this->disallow();
5095 // check if email address for admin is valid
5096 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5098 $this->error(_ERROR_BADMAILADDRESS);
5102 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5103 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5104 $this->updateConfig('IndexURL', postVar('IndexURL'));
5105 $this->updateConfig('AdminURL', postVar('AdminURL'));
5106 $this->updateConfig('PluginURL', postVar('PluginURL'));
5107 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5108 $this->updateConfig('ActionURL', postVar('ActionURL'));
5109 $this->updateConfig('Locale', postVar('Locale'));
5110 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5111 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5112 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5113 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5114 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5115 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5116 $this->updateConfig('SiteName', postVar('SiteName'));
5117 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5118 $this->updateConfig('DisableSite', postVar('DisableSite'));
5119 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5120 $this->updateConfig('LastVisit', postVar('LastVisit'));
5121 $this->updateConfig('MediaURL', postVar('MediaURL'));
5122 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5123 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5124 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5125 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5126 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5127 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5128 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5129 $this->updateConfig('CookiePath', postVar('CookiePath'));
5130 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5131 $this->updateConfig('URLMode', postVar('URLMode'));
5132 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5133 $this->updateConfig('DebugVars', postVar('DebugVars'));
5134 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5135 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5137 // load new config and redirect (this way, the new locale will be used is necessary)
5138 // note that when changing cookie settings, this redirect might cause the user
5139 // to have to log in again.
5141 redirect($CONF['AdminURL'] . '?action=manage');
5146 * Admin::action_systemoverview()
5147 * Output system overview
5152 function action_systemoverview()
5154 global $member, $nucleus, $CONF;
5158 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5160 if ( $member->isLoggedIn() && $member->isAdmin() )
5162 // Information about the used PHP and MySQL installation
5163 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5165 // Version of PHP MySQL
5166 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5169 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5174 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5175 echo '<td>' . phpversion() . "</td>\n";
5178 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5179 echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5182 echo "</table>\n\n";
5184 // Important PHP settings
5185 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5188 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5193 echo '<td>magic_quotes_gpc' . "</td>\n";
5194 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5195 echo '<td>' . $mqg . "</td>\n";
5198 echo '<td>magic_quotes_runtime' . "</td>\n";
5199 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5200 echo '<td>' . $mqr . "</td>\n";
5203 echo '<td>register_globals' . "</td>\n";
5204 $rg = ini_get('register_globals') ? 'On' : 'Off';
5205 echo '<td>' . $rg . "</td>\n";
5208 echo "</table>\n\n";
5210 // Information about GD library
5211 $gdinfo = gd_info();
5212 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5215 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5219 foreach ( $gdinfo as $key=>$value )
5221 if ( is_bool($value) )
5223 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5227 $value = Entity::hsc($value);
5230 echo '<td>' . $key . "</td>\n";
5231 echo '<td>' . $value . "</td>\n";
5235 echo "</table>\n\n";
5237 // Check if special modules are loaded
5239 phpinfo(INFO_MODULES);
5240 $im = ob_get_contents();
5242 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5245 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5249 echo '<td>mod_rewrite' . "</td>\n";
5250 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5251 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5252 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5253 echo '<td>' . $modrewrite . "</td>\n";
5256 echo "</table>\n\n";
5258 // Information about the used Nucleus CMS
5259 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5261 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5262 $np = getNucleusPatchLevel();
5263 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5266 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5271 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5272 echo '<td>' . $nv . "</td>\n";
5275 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5276 echo '<td>' . $np . "</td>\n";
5279 echo "</table>\n\n";
5281 // Important settings of the installation
5282 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5285 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5290 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5291 echo '<td>' . $CONF['Self'] . "</td>\n";
5294 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5295 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5298 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5299 $ohs = $CONF['alertOnHeadersSent'] ?
5300 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5301 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5302 echo '<td>' . $ohs . "</td>\n";
5305 echo "<td>i18n::get_current_charset()</td>\n";
5306 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5309 echo "</table>\n\n";
5311 // Link to the online version test at the Nucleus CMS website
5312 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5313 if ( $nucleus['codename'] != '')
5315 $codenamestring = ' "' . $nucleus['codename'] . '"';
5319 $codenamestring = '';
5321 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5322 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5323 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5324 echo 'Nucleus CMS ' . $nv . $codenamestring;
5329 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5335 * Admin::updateConfig()
5337 * @param string $name
5338 * @param string $val
5339 * @return integer return the ID in which the latest query posted
5341 function updateConfig($name, $val)
5343 $name = sql_real_escape_string($name);
5344 $val = trim(sql_real_escape_string($val));
5346 $query = "UPDATE %s SET value='%s' WHERE name='%s'";
5347 $query = sprintf($query, sql_table('config'), $val, $name);
5348 sql_query($query) or die("Query error: " . sql_error());
5349 return sql_insert_id();
5354 * @param string $msg message that will be shown
5356 function error($msg)
5360 echo "<h2>Error!</h2>\n";
5363 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5370 * add error log and show error page
5377 ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5378 $this->error(_ERROR_DISALLOWED);
5383 * Output admin page head
5388 function pagehead($extrahead = '')
5390 global $member, $nucleus, $CONF, $manager;
5395 'extrahead' => &$extrahead,
5396 'action' => $this->action));
5398 $baseUrl = Entity::hsc($CONF['AdminURL']);
5399 if ( !array_key_exists('AdminCSS',$CONF) )
5401 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5402 $CONF['AdminCSS'] = 'original';
5405 /* HTTP 1.1 application for no caching */
5406 header("Cache-Control: no-cache, must-revalidate");
5407 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5409 $root_element = 'html';
5410 $charset = i18n::get_current_charset();
5411 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5413 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5414 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5415 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5417 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5418 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5419 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5420 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5421 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5422 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5423 echo "{$extrahead}\n";
5426 echo "<div id=\"adminwrapper\">\n";
5427 echo "<div class=\"header\">\n";
5428 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5430 echo "<div id=\"container\">\n";
5431 echo "<div id=\"content\">\n";
5432 echo "<div class=\"loginname\">\n";
5433 if ( $member->isLoggedIn() )
5435 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5436 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5440 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5442 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5445 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5447 $codenamestring = ' "' . $nucleus['codename'].'"';
5451 $codenamestring = '';
5454 if ( $member->isLoggedIn() && $member->isAdmin() )
5456 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5457 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5459 $newestVersion = getLatestVersion();
5460 $newestCompare = str_replace('/','.',$newestVersion);
5461 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5462 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5465 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5466 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5472 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5481 * Output admin page foot include quickmenu
5488 global $action, $member, $manager;
5492 array('action' => $this->action)
5495 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5497 echo '<h2>' . _LOGOUT . "</h2>\n";
5499 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5500 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5504 echo "<div class=\"foot\">\n";
5505 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5507 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5510 echo "<!-- content -->\n";
5511 echo "<div id=\"quickmenu\">\n";
5513 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5516 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5519 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5520 echo "<form method=\"get\" action=\"index.php\">\n";
5522 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5524 $showAll = requestVar('showall');
5526 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5528 // Super-Admins have access to all blogs! (no add item support though)
5529 $query = 'SELECT bnumber as value, bname as text'
5530 . ' FROM ' . sql_table('blog')
5531 . ' ORDER BY bname';
5535 $query = 'SELECT bnumber as value, bname as text'
5536 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5537 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5538 . ' ORDER BY bname';
5540 $template['name'] = 'blogid';
5541 $template['tabindex'] = 15000;
5542 $template['extra'] = _QMENU_ADD_SELECT;
5543 $template['selected'] = -1;
5544 $template['shorten'] = 10;
5545 $template['shortenel'] = '';
5546 $template['javascript'] = 'onchange="return form.submit()"';
5547 showlist($query,'select',$template);
5552 echo "<h2>{$member->getDisplayName()}</h2>\n";
5554 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5555 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5556 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5559 // ---- general settings ----
5560 if ( $member->isAdmin() )
5562 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5564 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5565 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5566 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5567 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5568 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5569 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5570 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5573 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5575 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5576 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5577 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5581 $aPluginExtras = array();
5585 'options' => &$aPluginExtras));
5587 if ( count($aPluginExtras) > 0 )
5589 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5591 foreach ( $aPluginExtras as $aInfo )
5593 echo '<li><a href="' . Entity::hsc($aInfo['url']) . '" title="' . Entity::hsc($aInfo['tooltip']) . '">' . Entity::hsc($aInfo['title']) . "</a></li>\n";
5598 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5601 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5605 // introduction text on login screen
5606 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5609 echo "<!-- quickmenu -->\n";
5612 echo "<!-- content -->\n";
5615 echo "<!-- container -->\n";
5618 echo "<!-- adminwrapper -->\n";
5627 * @todo document this
5629 function action_regfile() {
5630 global $member, $CONF;
5632 $blogid = intRequestVar('blogid');
5634 $member->teamRights($blogid) or $this->disallow();
5636 // header-code stolen from phpMyAdmin
5637 // REGEDIT and bookmarklet code stolen from GreyMatter
5639 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5642 header('Content-Type: application/octetstream');
5643 header('Content-Disposition: filename="nucleus.reg"');
5644 header('Pragma: no-cache');
5645 header('Expires: 0');
5648 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5649 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5650 echo '"contexts"=hex:31';
5654 * @todo document this
5656 function action_bookmarklet() {
5657 global $member, $manager;
5659 $blogid = intRequestVar('blogid');
5661 $member->teamRights($blogid) or $this->disallow();
5663 $blog =& $manager->getBlog($blogid);
5664 $bm = getBookmarklet($blogid);
5668 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5672 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5675 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5678 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5680 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5683 <?php echo '<a href="' . Entity::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, Entity::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5686 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5689 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5690 $url = $manager->addTicketToUrl($url);
5692 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . Entity::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5696 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5699 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5701 <?php echo _BOOKMARKLET_DELETEBAR ?>
5705 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5709 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5710 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5711 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5712 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5713 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5722 * @todo document this
5724 function action_actionlog() {
5725 global $member, $manager;
5727 $member->isAdmin() or $this->disallow();
5731 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5733 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5736 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5737 <p><a href="<?php echo Entity::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5739 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5741 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5742 $template['content'] = 'actionlist';
5743 $amount = showlist($query,'table',$template);
5750 * @todo document this
5752 function action_banlist() {
5753 global $member, $manager;
5755 $blogid = intRequestVar('blogid');
5757 $member->blogAdminRights($blogid) or $this->disallow();
5759 $blog =& $manager->getBlog($blogid);
5763 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5765 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5767 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5768 $template['content'] = 'banlist';
5769 $amount = showlist($query,'table',$template);
5774 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5775 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5783 * @todo document this
5785 function action_banlistdelete() {
5786 global $member, $manager;
5788 $blogid = intRequestVar('blogid');
5789 $iprange = requestVar('iprange');
5791 $member->blogAdminRights($blogid) or $this->disallow();
5793 $blog =& $manager->getBlog($blogid);
5794 $banBlogName = Entity::hsc($blog->getName());
5798 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5800 <form method="post" action="index.php">
5802 <h3><?php echo _BAN_IPRANGE?></h3>
5805 <?php echo _CONFIRMTXT_BAN?> <?php echo Entity::hsc($iprange) ?>
5806 <input name="iprange" type="hidden" value="<?php echo Entity::hsc($iprange)?>" />
5809 <h3><?php echo _BAN_BLOGS?></h3>
5812 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5813 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5814 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5816 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5819 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5822 <?php $manager->addTicketHidden() ?>
5823 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5824 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5833 * @todo document this
5835 function action_banlistdeleteconfirm() {
5836 global $member, $manager;
5838 $blogid = intPostVar('blogid');
5839 $allblogs = postVar('allblogs');
5840 $iprange = postVar('iprange');
5842 $member->blogAdminRights($blogid) or $this->disallow();
5847 if (Ban::removeBan($blogid, $iprange))
5848 array_push($deleted, $blogid);
5850 // get blogs fot which member has admin rights
5851 $adminblogs = $member->getAdminBlogs();
5852 foreach ($adminblogs as $blogje) {
5853 if (Ban::removeBan($blogje, $iprange))
5854 array_push($deleted, $blogje);
5858 if (sizeof($deleted) == 0)
5859 $this->error(_ERROR_DELETEBAN);
5863 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5864 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5865 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5868 foreach ($deleted as $delblog) {
5869 $b =& $manager->getBlog($delblog);
5870 echo "<li>" . Entity::hsc($b->getName()). "</li>";
5879 * @todo document this
5881 function action_banlistnewfromitem() {
5882 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5886 * @todo document this
5888 function action_banlistnew($blogid = '') {
5889 global $member, $manager;
5892 $blogid = intRequestVar('blogid');
5894 $ip = requestVar('ip');
5896 $member->blogAdminRights($blogid) or $this->disallow();
5898 $blog =& $manager->getBlog($blogid);
5902 <h2><?php echo _BAN_ADD_TITLE?></h2>
5905 <form method="post" action="index.php">
5907 <h3><?php echo _BAN_IPRANGE?></h3>
5909 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5912 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5913 <?php echo _BAN_EXAMPLE_TEXT ?>
5919 $iprangeVal = Entity::hsc($ip);
5921 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5922 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5924 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5925 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5926 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5929 echo "<input name='iprange' value='custom' type='hidden' />";
5930 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5935 <h3><?php echo _BAN_BLOGS?></h3>
5937 <p><?php echo _BAN_BLOGS_TEXT?></p>
5940 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5941 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo Entity::hsc($blog->getName())?>'</label>
5943 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5946 <h3><?php echo _BAN_REASON_TITLE?></h3>
5948 <p><?php echo _BAN_REASON_TEXT?></p>
5950 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5952 <h3><?php echo _BAN_ADD_TITLE?></h3>
5955 <input name="action" type="hidden" value="banlistadd" />
5956 <?php $manager->addTicketHidden() ?>
5957 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5962 <?php $this->pagefoot();
5966 * @todo document this
5968 function action_banlistadd() {
5971 $blogid = intPostVar('blogid');
5972 $allblogs = postVar('allblogs');
5973 $iprange = postVar('iprange');
5974 if ($iprange == "custom")
5975 $iprange = postVar('customiprange');
5976 $reason = postVar('reason');
5978 $member->blogAdminRights($blogid) or $this->disallow();
5980 // TODO: check IP range validity
5983 if (!Ban::addBan($blogid, $iprange, $reason))
5984 $this->error(_ERROR_ADDBAN);
5986 // get blogs fot which member has admin rights
5987 $adminblogs = $member->getAdminBlogs();
5989 foreach ($adminblogs as $blogje) {
5990 if (!Ban::addBan($blogje, $iprange, $reason))
5994 $this->error(_ERROR_ADDBAN);
5997 $this->action_banlist();
6002 * @todo document this
6004 function action_clearactionlog() {
6007 $member->isAdmin() or $this->disallow();
6011 $this->action_manage(_MSG_ACTIONLOGCLEARED);
6015 * @todo document this
6017 function action_backupoverview() {
6018 global $member, $manager;
6020 $member->isAdmin() or $this->disallow();
6024 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6026 <h2><?php echo _BACKUPS_TITLE?></h2>
6028 <h3><?php echo _BACKUP_TITLE?></h3>
6030 <p><?php echo _BACKUP_INTRO?></p>
6032 <form method="post" action="index.php"><p>
6033 <input type="hidden" name="action" value="backupcreate" />
6034 <?php $manager->addTicketHidden() ?>
6036 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
6038 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
6040 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
6044 <div class="note"><?php echo _BACKUP_NOTE?></div>
6047 <h3><?php echo _RESTORE_TITLE?></h3>
6049 <div class="note"><?php echo _RESTORE_NOTE?></div>
6051 <p><?php echo _RESTORE_INTRO?></p>
6053 <form method="post" action="index.php" enctype="multipart/form-data"><p>
6054 <input type="hidden" name="action" value="backuprestore" />
6055 <?php $manager->addTicketHidden() ?>
6056 <input name="backup_file" type="file" tabindex="30" />
6058 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
6059 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
6060 <br /><?php echo _RESTORE_WARNING?>
6063 <?php $this->pagefoot();
6067 * Admin::action_backupcreate()
6068 * create file for backup
6074 function action_backupcreate()
6076 global $member, $DIR_LIBS;
6078 $member->isAdmin() or $this->disallow();
6080 // use compression ?
6081 $useGzip = (integer) postVar('gzip');
6083 include($DIR_LIBS . 'backup.php');
6085 // try to extend time limit
6086 // (creating/restoring dumps might take a while)
6087 @set_time_limit(1200);
6089 Backup::do_backup($useGzip);
6094 * Admin::action_backuprestore()
6095 * restoring from uploaded file
6100 function action_backuprestore()
6102 global $member, $DIR_LIBS;
6104 $member->isAdmin() or $this->disallow();
6106 if ( intPostVar('letsgo') != 1 )
6108 $this->error(_ERROR_BACKUP_NOTSURE);
6111 include($DIR_LIBS . 'backup.php');
6113 // try to extend time limit
6114 // (creating/restoring dumps might take a while)
6115 @set_time_limit(1200);
6117 $message = Backup::do_restore();
6118 if ( $message != '' )
6120 $this->error($message);
6123 echo '<h2>' . _RESTORE_COMPLETE . "</h2>\n";
6129 * Admin::action_pluginlist()
6130 * output the list of installed plugins
6136 function action_pluginlist()
6138 global $DIR_PLUGINS, $member, $manager;
6141 $member->isAdmin() or $this->disallow();
6145 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6147 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6149 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6151 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6153 $template['content'] = 'pluginlist';
6154 $template['tabindex'] = 10;
6155 showlist($query, 'table', $template);
6157 echo '<h3>' . _PLUGS_TITLE_UPDATE . "</h3>\n";
6158 echo '<p>' . _PLUGS_TEXT_UPDATE . "</p>\n";
6159 echo '<form method="post" action="index.php">' . "\n";
6161 echo '<input type="hidden" name="action" value="pluginupdate" />' . "\n";
6162 $manager->addTicketHidden();
6163 echo '<input type="submit" value="' . _PLUGS_BTN_UPDATE . '" tabindex="20" />' . "\n";
6167 echo '<h3>' . _PLUGS_TITLE_NEW . "</h3>\n";
6169 // find a list of possibly non-installed plugins
6170 $candidates = array();
6171 $dirhandle = opendir($DIR_PLUGINS);
6173 while ( $filename = readdir($dirhandle) )
6175 if ( preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6177 $name = $matches[1];
6179 // only show in list when not yet installed
6180 $query = 'SELECT * FROM %s WHERE pfile = "NP_%s"';
6181 $query = sprintf($query, sql_table('plugin'), sql_real_escape_string($name));
6182 $res = sql_query($query);
6184 if ( sql_num_rows($res) == 0 )
6186 array_push($candidates, $name);
6191 closedir($dirhandle);
6193 if ( sizeof($candidates) > 0 )
6195 echo '<p>' . _PLUGS_ADD_TEXT . "</p>\n";
6197 echo '<form method="post" action="index.php">' . "\n";
6199 echo '<input type="hidden" name="action" value="pluginadd" />' . "\n";
6200 $manager->addTicketHidden();
6201 echo '<select name="filename" tabindex="30">' . "\n";
6203 foreach ( $candidates as $name )
6205 echo '<option value="NP_',$name,'">',Entity::hsc($name),'</option>';
6209 echo '<input type="submit" tabindex="40" value="' . _PLUGS_BTN_INSTALL ."\" />\n";
6215 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6223 * @todo document this
6225 function action_pluginhelp() {
6226 global $member, $manager, $DIR_PLUGINS, $CONF;
6229 $member->isAdmin() or $this->disallow();
6231 $plugid = intGetVar('plugid');
6233 if (!$manager->pidInstalled($plugid))
6234 $this->error(_ERROR_NOSUCHPLUGIN);
6236 $plugName = getPluginNameFromPid($plugid);
6240 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6242 echo '<h2>',_PLUGS_HELP_TITLE,': ',Entity::hsc($plugName),'</h2>';
6244 $plug =& $manager->getPlugin($plugName);
6245 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6247 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6248 @readfile($helpFile);
6250 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6251 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6259 * Admin::action_pluginadd()
6265 function action_pluginadd()
6267 global $member, $manager, $DIR_PLUGINS;
6270 $member->isAdmin() or $this->disallow();
6272 $name = postVar('filename');
6274 if ( $manager->pluginInstalled($name) )
6276 $this->error(_ERROR_DUPPLUGIN);
6279 if ( !checkPlugin($name) )
6281 $this->error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');
6284 // get number of currently installed plugins
6285 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6286 $numCurrent = sql_num_rows($res);
6288 // plugin will be added as last one in the list
6289 $newOrder = $numCurrent + 1;
6298 // do this before calling getPlugin (in case the plugin id is used there)
6299 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6301 $iPid = sql_insert_id();
6303 $manager->clearCachedInfo('installedPlugins');
6305 // Load the plugin for condition checking and instalation
6306 $plugin =& $manager->getPlugin($name);
6308 // check if it got loaded (could have failed)
6311 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6312 $manager->clearCachedInfo('installedPlugins');
6313 $this->error(_ERROR_PLUGIN_LOAD);
6316 // check if plugin needs a newer Nucleus version
6317 if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
6319 // uninstall plugin again...
6320 $this->deleteOnePlugin($plugin->getID());
6322 // ...and show error
6323 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));
6326 // check if plugin needs a newer Nucleus version
6327 if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
6329 // uninstall plugin again...
6330 $this->deleteOnePlugin($plugin->getID());
6332 // ...and show error
6333 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6336 $pluginList = $plugin->getPluginDep();
6337 foreach ( $pluginList as $pluginName )
6339 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6340 if (sql_num_rows($res) == 0)
6342 // uninstall plugin again...
6343 $this->deleteOnePlugin($plugin->getID());
6344 $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
6348 // call the install method of the plugin
6354 'plugin' => &$plugin
6358 // update all events
6359 $this->action_pluginupdate();
6364 * ADMIN:action_pluginupdate():
6370 function action_pluginupdate()
6372 global $member, $manager, $CONF;
6375 $member->isAdmin() or $this->disallow();
6377 // delete everything from plugin_events
6378 sql_query('DELETE FROM '.sql_table('plugin_event'));
6380 // loop over all installed plugins
6381 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6382 while ( $o = sql_fetch_object($res) )
6385 $plug =& $manager->getPlugin($o->pfile);
6388 $eventList = $plug->getEventList();
6389 foreach ( $eventList as $eventName )
6391 $query = "INSERT INTO %s (pid, event) VALUES (%d, '%s')";
6392 $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, sql_real_escape_string($eventName));
6397 redirect($CONF['AdminURL'] . '?action=pluginlist');
6402 * @todo document this
6404 function action_plugindelete() {
6405 global $member, $manager;
6408 $member->isAdmin() or $this->disallow();
6410 $pid = intGetVar('plugid');
6412 if (!$manager->pidInstalled($pid))
6413 $this->error(_ERROR_NOSUCHPLUGIN);
6417 <h2><?php echo _DELETE_CONFIRM?></h2>
6419 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6421 <form method="post" action="index.php"><div>
6422 <?php $manager->addTicketHidden() ?>
6423 <input type="hidden" name="action" value="plugindeleteconfirm" />
6424 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6425 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6432 * @todo document this
6434 function action_plugindeleteconfirm() {
6435 global $member, $manager, $CONF;
6438 $member->isAdmin() or $this->disallow();
6440 $pid = intPostVar('plugid');
6442 $error = $this->deleteOnePlugin($pid, 1);
6444 $this->error($error);
6447 redirect($CONF['AdminURL'] . '?action=pluginlist');
6448 // $this->action_pluginlist();
6452 * @todo document this
6454 function deleteOnePlugin($pid, $callUninstall = 0) {
6457 $pid = intval($pid);
6459 if (!$manager->pidInstalled($pid))
6460 return _ERROR_NOSUCHPLUGIN;
6462 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6464 /* // call the unInstall method of the plugin
6465 if ($callUninstall) {
6466 $plugin =& $manager->getPlugin($name);
6467 if ($plugin) $plugin->unInstall();
6470 // check dependency before delete
6471 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6472 while($o = sql_fetch_object($res)) {
6473 $plug =& $manager->getPlugin($o->pfile);
6476 $depList = $plug->getPluginDep();
6477 foreach ($depList as $depName)
6479 if ($name == $depName)
6481 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6487 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6489 // call the unInstall method of the plugin
6490 if ($callUninstall) {
6491 $plugin =& $manager->getPlugin($name);
6492 if ($plugin) $plugin->unInstall();
6495 // delete all subscriptions
6496 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6498 // delete all options
6499 // get OIDs from plugin_option_desc
6500 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6502 while ($o = sql_fetch_object($res)) {
6503 array_push($aOIDs, $o->oid);
6506 // delete from plugin_option and plugin_option_desc
6507 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6508 if (count($aOIDs) > 0)
6509 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6511 // update order numbers
6512 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6513 $o = sql_fetch_object($res);
6514 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6517 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6519 $manager->clearCachedInfo('installedPlugins');
6520 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6526 * @todo document this
6528 function action_pluginup() {
6529 global $member, $manager, $CONF;
6532 $member->isAdmin() or $this->disallow();
6534 $plugid = intGetVar('plugid');
6536 if (!$manager->pidInstalled($plugid))
6537 $this->error(_ERROR_NOSUCHPLUGIN);
6539 // 1. get old order number
6540 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6541 $o = sql_fetch_object($res);
6542 $oldOrder = $o->porder;
6544 // 2. calculate new order number
6545 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6547 // 3. update plug numbers
6548 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6549 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6551 //$this->action_pluginlist();
6552 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6553 redirect($CONF['AdminURL'] . '?action=pluginlist');
6557 * @todo document this
6559 function action_plugindown() {
6560 global $member, $manager, $CONF;
6563 $member->isAdmin() or $this->disallow();
6565 $plugid = intGetVar('plugid');
6566 if (!$manager->pidInstalled($plugid))
6567 $this->error(_ERROR_NOSUCHPLUGIN);
6569 // 1. get old order number
6570 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6571 $o = sql_fetch_object($res);
6572 $oldOrder = $o->porder;
6574 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6575 $maxOrder = sql_num_rows($res);
6577 // 2. calculate new order number
6578 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6580 // 3. update plug numbers
6581 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6582 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6584 //$this->action_pluginlist();
6585 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6586 redirect($CONF['AdminURL'] . '?action=pluginlist');
6590 * Admin::action_pluginoptions()
6592 * Output Plugin option page
6595 * @param string $message message when fallbacked
6599 public function action_pluginoptions($message = '')
6601 global $member, $manager;
6604 $member->isAdmin() or $this->disallow();
6606 $pid = (integer) requestVar('plugid');
6607 if ( !$manager->pidInstalled($pid) )
6609 $this->error(_ERROR_NOSUCHPLUGIN);
6612 $pname = getPluginNameFromPid($pid);
6614 /* just for including translation */
6615 $manager->getPlugin($pname);
6617 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6618 $this->pagehead($extrahead);
6619 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6620 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($pname)) . "</h2>\n";
6622 if ( isset($message) )
6627 echo "<form action=\"index.php\" method=\"post\">\n";
6629 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6630 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6631 $manager->addTicketHidden();
6633 $aOptions = array();
6635 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6636 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6637 $result = sql_query($query);
6638 while ( $object = sql_fetch_object($result) )
6640 array_push($aOIDs, $object->oid);
6641 $aOptions[$object->oid] = array(
6642 'oid' => $object->oid,
6643 'value' => $object->odef,
6644 'name' => $object->oname,
6645 'description' => $object->odesc,
6646 'type' => $object->otype,
6647 'typeinfo' => $object->oextra,
6651 // fill out actual values
6652 if ( count($aOIDs) > 0 )
6654 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6655 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6656 $result = sql_query($query);
6657 while ( $object = sql_fetch_object($result) )
6659 $aOptions[$object->oid]['value'] = $object->ovalue;
6664 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
6665 $manager->notify('PrePluginOptionsEdit',$data);
6667 $template['content'] = 'plugoptionlist';
6668 $amount = showlist($aOptions,'table',$template);
6671 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6681 * Admin::action_pluginoptionsupdate()
6683 * Update plugin options and fallback to plugin option page
6689 public function action_pluginoptionsupdate()
6691 global $member, $manager;
6694 $member->isAdmin() or $this->disallow();
6696 $pid = (integer) requestVar('plugid');
6697 if ( !$manager->pidInstalled($pid) )
6699 $this->error(_ERROR_NOSUCHPLUGIN);
6702 $aOptions = requestArray('plugoption');
6703 NucleusPlugin::apply_plugin_options($aOptions);
6705 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6707 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6712 * Admin::_insertPluginOptions()
6714 * Output plugin option field
6717 * @param string $context plugin option context
6718 * @param integer $contextid plugin option context id
6721 public function _insertPluginOptions($context, $contextid = 0)
6723 // get all current values for this contextid
6724 // (note: this might contain doubles for overlapping contextids)
6725 $aIdToValue = array();
6726 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6727 while ( $object = sql_fetch_object($res) )
6729 $aIdToValue[$object->oid] = $object->ovalue;
6732 // get list of oids per pid
6733 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6734 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6735 $res = sql_query($query);
6736 $aOptions = array();
6737 while ( $object = sql_fetch_object($res) )
6739 if (in_array($object->oid, array_keys($aIdToValue)))
6741 $value = $aIdToValue[$object->oid];
6745 $value = $object->odef;
6748 array_push($aOptions, array(
6749 'pid' => $object->pid,
6750 'pfile' => $object->pfile,
6751 'oid' => $object->oid,
6753 'name' => $object->oname,
6754 'description' => $object->odesc,
6755 'type' => $object->otype,
6756 'typeinfo' => $object->oextra,
6757 'contextid' => $contextid,
6762 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6765 foreach ($aOptions as $aOption)
6768 if ( $iPrevPid != $aOption['pid'] )
6770 $iPrevPid = $aOption['pid'];
6771 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
6773 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6775 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($aOption['pfile'])).'</th></tr>';
6778 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6779 if ( @$meta['access'] != 'hidden' )
6782 listplug_plugOptionRow($aOption);
6790 * Admin::input_yesno()
6791 * Output input elements with radio attribute for yes/no options
6793 * @param string $name name attribute
6794 * @param string $value_current current value attribute
6795 * @param integer $tabindex tab index
6796 * @param string $value_yes value attribute for yes option
6797 * @param string $value_no value attribute for no option
6798 * @param string $text_yes child text element for yes option
6799 * @param string $text_no child text element for no option
6800 * @param boolean $isAdmin have admin right or not
6803 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
6805 $id = preg_replace('#\[|\]#', '-', $name);
6806 $id_yes = $id . $value_yes;
6807 $id_no = $id . $value_no;
6810 echo '<input type="radio" id="' . Entity::hsc($id_yes) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_yes) . '"';
6811 if ( $name=="admin" )
6813 echo ' onclick="selectCanLogin(true);"';
6815 if ( $value_current == $value_yes )
6817 echo " tabindex='$tabindex' checked='checked'";
6820 echo '<label for="' . Entity::hsc($id_yes) . '">' . Entity::hsc($text_yes) . "</label>\n";
6823 echo '<input type="radio" id="' . Entity::hsc($id_no) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_no) . '"';
6824 if ( $name=="admin" )
6826 echo ' onclick="selectCanLogin(false);"';
6828 if ( $value_current != $value_yes )
6830 echo " tabindex='$tabindex' checked='checked'";
6832 if ($isAdmin && $name=="canlogin")
6834 echo ' disabled="disabled"';
6837 echo '<label for="' . Entity::hsc($id_no) . '">' . Entity::hsc($text_no) . "</label>\n";