3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * The code for the Nucleus admin area
15 * @license http://nucleuscms.org/license.txt GNU General Public License
16 * @copyright Copyright (C) 2002-2009 The Nucleus Group
17 * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
29 private $xml_version_info = '1.0';
30 private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
31 private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
32 private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
35 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
49 * @param string $action action to be performed
51 function action($action) {
52 global $CONF, $manager;
54 // list of action aliases
56 'login' => 'overview',
60 if (isset($alias[$action]))
61 $action = $alias[$action];
63 $methodName = 'action_' . $action;
65 $this->action = strtolower($action);
67 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
68 // is an action that requires user interaction before something is actually done)
69 // all safe actions are in this array:
70 $aActionsNotToCheck = array(
101 'banlistnewfromitem',
122 // the rest of the actions needs to be checked
123 $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
125 if (!in_array($this->action, $aActionsNotToCheck))
127 if (!$manager->checkTicket())
128 $this->error(_ERROR_BADTICKET);
131 if (method_exists($this, $methodName))
132 call_user_func(array(&$this, $methodName));
134 $this->error(_BADACTION . Entity::hsc(" ($action)"));
139 * @todo document this
141 function action_showlogin() {
143 $this->action_login($error);
147 * @todo document this
149 function action_login($msg = '', $passvars = 1) {
152 // skip to overview when allowed
153 if ($member->isLoggedIn() && $member->canLogin()) {
154 $this->action_overview();
160 echo '<h2>', _LOGIN ,'</h2>';
161 if ($msg) echo _MESSAGE , ': ', Entity::hsc($msg);
164 <form action="index.php" method="post"><p>
165 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
167 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
169 <input name="action" value="login" type="hidden" />
171 <input type="submit" value="<?php echo _LOGIN ?>" tabindex="30" />
174 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED ?></label>
175 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT ?></a>
177 <?php // pass through vars
179 $oldaction = postVar('oldaction');
180 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
187 <?php $this->pagefoot();
192 * provides a screen with the overview of the actions available
193 * @todo document parameter
195 function action_overview($msg = '') {
201 echo _MESSAGE , ': ', $msg;
203 /* ---- add items ---- */
204 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
206 $showAll = requestVar('showall');
208 if (($member->isAdmin()) && ($showAll == 'yes')) {
209 // Super-Admins have access to all blogs! (no add item support though)
210 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
211 . ' FROM ' . sql_table('blog')
214 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
215 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
216 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
219 $template['content'] = 'bloglist';
220 $template['superadmin'] = $member->isAdmin();
221 $amount = showlist($query,'table',$template);
223 if (($showAll != 'yes') && ($member->isAdmin())) {
224 $total = DB::getValue('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 * Admin::action_itemlist()
340 * @param integer $blogid ID for weblog
343 public function action_itemlist($blogid = '')
345 global $member, $manager, $CONF;
349 $blogid = intRequestVar('blogid');
352 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
355 $blog =& $manager->getBlog($blogid);
357 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
358 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
361 if ( postVar('start') )
363 $start = intPostVar('start');
372 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">' . _ITEMLIST_ADDNEW . "</a></p>\n";
375 // amount of items to show
376 if ( postVar('amount') )
378 $amount = intPostVar('amount');
382 $amount = intval($CONF['DefaultListSize']);
389 $search = postVar('search'); // search through items
391 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
392 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
393 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
397 $query .= " AND ((ititle LIKE " . DB::quoteValue('%'.$search.'%') . ") OR (ibody LIKE " . DB::quoteValue('%'.$search.'%') . ") OR (imore LIKE " . DB::quoteValue('%'.$search.'%') . "))";
400 // non-blog-admins can only edit/delete their own items
401 if ( !$member->blogAdminRights($blogid) )
403 $query .= ' and iauthor=' . $member->getID();
406 $query .= ' ORDER BY itime DESC'
407 . " LIMIT $start, $amount";
409 $template['content'] = 'itemlist';
410 $template['now'] = $blog->getCorrectTime(time());
412 $manager->loadClass("ENCAPSULATE");
413 $navList = new NavList('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
414 $navList->showBatchList('item',$query,'table',$template);
421 * @todo document this
423 function action_batchitem() {
424 global $member, $manager;
426 // check if logged in
427 $member->isLoggedIn() or $this->disallow();
429 // more precise check will be done for each performed operation
431 // get array of itemids from request
432 $selected = requestIntArray('batch');
433 $action = requestVar('batchaction');
435 // Show error when no items were selected
436 if (!is_array($selected) || sizeof($selected) == 0)
437 $this->error(_BATCH_NOSELECTION);
439 // On move: when no destination blog/category chosen, show choice now
440 $destCatid = intRequestVar('destcatid');
441 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
442 $this->batchMoveSelectDestination('item',$selected);
444 // On delete: check if confirmation has been given
445 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
446 $this->batchAskDeleteConfirmation('item',$selected);
450 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
451 echo '<h2>',_BATCH_ITEMS,'</h2>';
452 echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
456 // walk over all itemids and perform action
457 foreach ($selected as $itemid) {
458 $itemid = intval($itemid);
459 echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
461 // perform action, display errors if needed
464 $error = $this->deleteOneItem($itemid);
467 $error = $this->moveOneItem($itemid, $destCatid);
470 $error = _BATCH_UNKNOWN . Entity::hsc($action);
473 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
478 echo '<b>',_BATCH_DONE,'</b>';
486 * @todo document this
488 function action_batchcomment() {
491 // check if logged in
492 $member->isLoggedIn() or $this->disallow();
494 // more precise check will be done for each performed operation
496 // get array of itemids from request
497 $selected = requestIntArray('batch');
498 $action = requestVar('batchaction');
500 // Show error when no items were selected
501 if (!is_array($selected) || sizeof($selected) == 0)
502 $this->error(_BATCH_NOSELECTION);
504 // On delete: check if confirmation has been given
505 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
506 $this->batchAskDeleteConfirmation('comment',$selected);
510 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
511 echo '<h2>',_BATCH_COMMENTS,'</h2>';
512 echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
515 // walk over all itemids and perform action
516 foreach ($selected as $commentid) {
517 $commentid = intval($commentid);
518 echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
520 // perform action, display errors if needed
523 $error = $this->deleteOneComment($commentid);
526 $error = _BATCH_UNKNOWN . Entity::hsc($action);
529 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
534 echo '<b>',_BATCH_DONE,'</b>';
542 * @todo document this
544 function action_batchmember() {
547 // check if logged in and admin
548 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
550 // get array of itemids from request
551 $selected = requestIntArray('batch');
552 $action = requestVar('batchaction');
554 // Show error when no members selected
555 if (!is_array($selected) || sizeof($selected) == 0)
556 $this->error(_BATCH_NOSELECTION);
558 // On delete: check if confirmation has been given
559 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
560 $this->batchAskDeleteConfirmation('member',$selected);
564 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
565 echo '<h2>',_BATCH_MEMBERS,'</h2>';
566 echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
569 // walk over all itemids and perform action
570 foreach ($selected as $memberid) {
571 $memberid = intval($memberid);
572 echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
574 // perform action, display errors if needed
577 $error = $this->deleteOneMember($memberid);
581 DB::execute('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
585 // there should always remain at least one super-admin
586 $r = DB::getResult('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
587 if ($r->rowCount() < 2)
588 $error = _ERROR_ATLEASTONEADMIN;
590 DB::execute('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
593 $error = _BATCH_UNKNOWN . Entity::hsc($action);
596 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
601 echo '<b>',_BATCH_DONE,'</b>';
609 * @todo document this
611 function action_batchteam() {
614 $blogid = intRequestVar('blogid');
616 // check if logged in and admin
617 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
619 // get array of itemids from request
620 $selected = requestIntArray('batch');
621 $action = requestVar('batchaction');
623 // Show error when no members selected
624 if (!is_array($selected) || sizeof($selected) == 0)
625 $this->error(_BATCH_NOSELECTION);
627 // On delete: check if confirmation has been given
628 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
629 $this->batchAskDeleteConfirmation('team',$selected);
633 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
635 echo '<h2>',_BATCH_TEAM,'</h2>';
636 echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
639 // walk over all itemids and perform action
640 foreach ($selected as $memberid) {
641 $memberid = intval($memberid);
642 echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
644 // perform action, display errors if needed
647 $error = $this->deleteOneTeamMember($blogid, $memberid);
651 DB::execute('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
655 // there should always remain at least one admin
656 $r = DB::getResult('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
657 if ($r->rowCount() < 2)
658 $error = _ERROR_ATLEASTONEBLOGADMIN;
660 DB::execute('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
663 $error = _BATCH_UNKNOWN . Entity::hsc($action);
666 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
671 echo '<b>',_BATCH_DONE,'</b>';
679 * @todo document this
681 function action_batchcategory() {
682 global $member, $manager;
684 // check if logged in
685 $member->isLoggedIn() or $this->disallow();
687 // more precise check will be done for each performed operation
689 // get array of itemids from request
690 $selected = requestIntArray('batch');
691 $action = requestVar('batchaction');
693 // Show error when no items were selected
694 if (!is_array($selected) || sizeof($selected) == 0)
695 $this->error(_BATCH_NOSELECTION);
697 // On move: when no destination blog chosen, show choice now
698 $destBlogId = intRequestVar('destblogid');
699 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
700 $this->batchMoveCategorySelectDestination('category',$selected);
702 // On delete: check if confirmation has been given
703 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
704 $this->batchAskDeleteConfirmation('category',$selected);
708 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
709 echo '<h2>',BATCH_CATEGORIES,'</h2>';
710 echo '<p>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b></p>';
713 // walk over all itemids and perform action
714 foreach ($selected as $catid) {
715 $catid = intval($catid);
716 echo '<li>',_BATCH_EXECUTING,' <b>',Entity::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
718 // perform action, display errors if needed
721 $error = $this->deleteOneCategory($catid);
724 $error = $this->moveOneCategory($catid, $destBlogId);
727 $error = _BATCH_UNKNOWN . Entity::hsc($action);
730 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
735 echo '<b>',_BATCH_DONE,'</b>';
742 * @todo document this
744 function batchMoveSelectDestination($type, $ids) {
748 <h2><?php echo _MOVE_TITLE ?></h2>
749 <form method="post" action="index.php"><div>
751 <input type="hidden" name="action" value="batch<?php echo $type ?>" />
752 <input type="hidden" name="batchaction" value="move" />
754 $manager->addTicketHidden();
756 // insert selected item numbers
758 foreach ($ids as $id)
759 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
761 // show blog/category selection list
762 $this->selectBlogCategory('destcatid');
767 <input type="submit" value="<?php echo _MOVE_BTN ?>" onclick="return checkSubmit();" />
770 <?php $this->pagefoot();
775 * @todo document this
777 function batchMoveCategorySelectDestination($type, $ids) {
781 <h2><?php echo _MOVECAT_TITLE ?></h2>
782 <form method="post" action="index.php"><div>
784 <input type="hidden" name="action" value="batch<?php echo $type ?>" />
785 <input type="hidden" name="batchaction" value="move" />
787 $manager->addTicketHidden();
789 // insert selected item numbers
791 foreach ($ids as $id)
792 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
794 // show blog/category selection list
795 $this->selectBlog('destblogid');
800 <input type="submit" value="<?php echo _MOVECAT_BTN ?>" onclick="return checkSubmit();" />
803 <?php $this->pagefoot();
808 * @todo document this
810 function batchAskDeleteConfirmation($type, $ids) {
815 <h2><?php echo _BATCH_DELETE_CONFIRM ?></h2>
816 <form method="post" action="index.php"><div>
818 <input type="hidden" name="action" value="batch<?php echo $type ?>" />
819 <?php $manager->addTicketHidden() ?>
820 <input type="hidden" name="batchaction" value="delete" />
821 <input type="hidden" name="confirmation" value="yes" />
822 <?php // insert selected item numbers
824 foreach ($ids as $id)
825 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
827 // add hidden vars for team & comment
830 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
832 if ($type == 'comment')
834 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
839 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN ?>" onclick="return checkSubmit();" />
842 <?php $this->pagefoot();
848 * Inserts a HTML select element with choices for all categories to which the current
850 * @see function selectBlog
852 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
853 Admin::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
857 * Admin::selectBlog()
858 * Inserts a HTML select element with choices for all blogs to which the user has access
859 * mode = 'blog' => shows blognames and values are blogids
860 * mode = 'category' => show category names and values are catids
862 * @param string $name name of
863 * @param string $mode blog/category
864 * @param integer $selected category ID to be selected
865 * @param integer $tabindex tab index value
866 * @param integer $showNewCat show category to newly be created
867 * @param integer $iForcedBlogInclude ID of a blog that always needs to be included,
868 * without checking if the member is on the blog team (-1 = none)
871 public function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1)
873 global $member, $CONF;
875 // 0. get IDs of blogs to which member can post items (+ forced blog)
877 if ( $iForcedBlogInclude != -1 )
879 $aBlogIds[] = intval($iForcedBlogInclude);
882 if ( !$member->isAdmin() || !array_key_exists('ShowAllBlogs', $CONF) || !$CONF['ShowAllBlogs'] )
884 $query = "SELECT bnumber FROM %s,%s WHERE tblog=bnumber and tmember=%d;";
885 $query = sprintf($query, sql_table('blog'), sql_table('team'), (integer) $member->getID());
889 $query = "SELECT bnumber FROM %s ORDER BY bname;";
890 $query = sprintf($query, sql_table('blog'));
893 $rblogids = DB::getResult($query);
894 foreach ( $rblogids as $row )
896 if ( $row['bnumber'] != $iForcedBlogInclude )
898 $aBlogIds[] = (integer) $row['bnumber'];
901 if ( count($aBlogIds) == 0 )
906 echo "<select name=\"{$name}\" tabindex=\"{$tabindex}\">\n";
908 // 1. select blogs (we'll create optiongroups)
909 // (only select those blogs that have the user on the team)
910 $query = "SELECT bnumber, bname FROM %s WHERE bnumber in (%s) ORDER BY bname;";
911 $query = sprintf($query, sql_table('blog'), implode(',',$aBlogIds));
912 $blogs = DB::getResult($query);
914 if ( $mode == 'category' )
916 if ( $blogs->rowCount() > 1 )
921 foreach ( $blogs as $row )
923 if ( $multipleBlogs )
925 echo '<optgroup label="' . Entity::hsc($row['bname']) . '">' . "\n";
928 // show selection to create new category when allowed/wanted
931 // check if allowed to do so
932 if ( $member->blogAdminRights($row['bnumber']) )
934 echo "<option value=\"newcat-{$row['bnumber']}\">" . _ADD_NEWCAT . "</option>\n";
938 // 2. for each category in that blog
939 $query = "SELECT cname, catid FROM %s WHERE cblog=%d ORDER BY cname ASC;";
940 $query = sprintf($query, sql_table('category'), (integer) $row['bnumber']);
941 $categories = DB::getResult($query);
942 foreach ( $categories as $cat )
944 if ( $cat['catid'] != $selected )
946 echo "<option value=\"{$cat['catid']}\" {$selectText} >" . Entity::hsc($cat['cname']) . "</option>\n";
950 echo "<option value=\"{$cat['catid']}\" selected=\"selected\" >" . Entity::hsc($cat['cname']) . "</option>\n";
954 if ( $multipleBlogs )
956 echo "</optgroup>\n";
963 foreach ( $blogs as $row )
965 if ( $row['bnumber'] != $selected )
967 echo "<option value=\"{$row['bnumber']}\">" . Entity::hsc($row['bname']) . "</option>\n";
971 echo "<option value=\"{$row['bnumber']}\" selected=\"selected\">" . Entity::hsc($row['bname']) . "</option>\n";
980 * Admin::action_browseownitems()
985 public function action_browseownitems()
987 global $member, $manager, $CONF;
991 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
992 echo '<h2>' . _ITEMLIST_YOUR . "</h2>\n";
995 if ( postVar('start') )
997 $start = intPostVar('start');
1004 // amount of items to show
1005 if ( postVar('amount') )
1007 $amount = intPostVar('amount');
1011 $amount = (integer) $CONF['DefaultListSize'];
1018 $search = postVar('search'); // search through items
1020 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
1021 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
1022 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
1026 $query .= " and ((ititle LIKE " . DB::quoteValue('%'.$search.'%') . ") or (ibody LIKE " . DB::quoteValue('%'.$search.'%') . ") or (imore LIKE " . DB::quoteValue('%'.$search.'%') . "))";
1029 $query .= ' ORDER BY itime DESC'
1030 . " LIMIT $start, $amount";
1032 $template['content'] = 'itemlist';
1033 $template['now'] = time();
1035 $manager->loadClass("ENCAPSULATE");
1036 $navList = new NavList('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
1037 $navList->showBatchList('item',$query,'table',$template);
1044 * Admin::action_itemcommentlist()
1046 * Show all the comments for a given item
1047 * @param integer $itemid ID for item
1050 public function action_itemcommentlist($itemid = '')
1052 global $member, $manager, $CONF;
1054 if ( $itemid == '' )
1056 $itemid = intRequestVar('itemid');
1059 // only allow if user is allowed to alter item
1060 $member->canAlterItem($itemid) or $this->disallow();
1062 $blogid = getBlogIdFromItemId($itemid);
1067 if ( postVar('start') )
1069 $start = intPostVar('start');
1076 // amount of items to show
1077 if ( postVar('amount') )
1079 $amount = intPostVar('amount');
1083 $amount = (integer) $CONF['DefaultListSize'];
1090 $search = postVar('search');
1092 echo '<p>(<a href="index.php?action=itemlist&blogid=' . $blogid . '">' . _BACKTOOVERVIEW . "</a>)</p>\n";
1093 echo '<h2>',_COMMENTS,'</h2>';
1095 $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;
1099 $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
1102 $query .= ' ORDER BY ctime ASC'
1103 . " LIMIT $start,$amount";
1105 $template['content'] = 'commentlist';
1106 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1108 $manager->loadClass("ENCAPSULATE");
1109 $navList = new NavList('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1110 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1117 * Admin::action_browseowncomments()
1118 * Browse own comments
1123 public function action_browseowncomments()
1125 global $member, $manager, $CONF;
1128 if ( postVar('start') )
1130 $start = intPostVar('start');
1137 // amount of items to show
1138 if ( postVar('amount') )
1140 $amount = intPostVar('amount');
1144 $amount = intval($CONF['DefaultListSize']);
1151 $search = postVar('search');
1153 $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();
1157 $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
1160 $query .= ' ORDER BY ctime DESC'
1161 . " LIMIT $start,$amount";
1165 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
1166 echo '<h2>' . _COMMENTS_YOUR . "</h2>\n";
1168 $template['content'] = 'commentlist';
1169 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1171 $manager->loadClass("ENCAPSULATE");
1172 $navList = new NavList('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1173 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1180 * Admin::action_blogcommentlist()
1182 * Browse all comments for a weblog
1183 * @param integer $blogid ID for weblog
1186 function action_blogcommentlist($blogid = '')
1188 global $member, $manager, $CONF;
1190 if ( $blogid == '' )
1192 $blogid = intRequestVar('blogid');
1196 $blogid = intval($blogid);
1199 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1202 if ( postVar('start') )
1204 $start = intPostVar('start');
1211 // amount of items to show
1212 if ( postVar('amount') )
1214 $amount = intPostVar('amount');
1218 $amount = intval($CONF['DefaultListSize']);
1225 $search = postVar('search'); // search through comments
1227 $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);
1229 if ( $search != '' )
1231 $query .= " and cbody LIKE " . DB::quoteValue('%'.$search.'%');
1234 $query .= ' ORDER BY ctime DESC'
1235 . " LIMIT $start,$amount";
1237 $blog =& $manager->getBlog($blogid);
1241 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
1242 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1244 $template['content'] = 'commentlist';
1245 $template['canAddBan'] = $member->blogAdminRights($blogid);
1247 $manager->loadClass("ENCAPSULATE");
1248 $navList = new NavList('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1249 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1256 * Admin::action_createitem()
1257 * Provide a page to item a new item to the given blog
1262 public function action_createitem()
1264 global $member, $manager;
1266 $blogid = intRequestVar('blogid');
1269 $member->teamRights($blogid) or $this->disallow();
1271 $memberid = $member->getID();
1273 $blog =& $manager->getBlog($blogid);
1277 // generate the add-item form
1278 $formfactory = new PageFactory($blogid);
1279 $formfactory->createAddForm('admin');
1286 * Admin::action_itemedit()
1291 public function action_itemedit()
1293 global $member, $manager;
1295 $itemid = intRequestVar('itemid');
1297 // only allow if user is allowed to alter item
1298 $member->canAlterItem($itemid) or $this->disallow();
1300 $item =& $manager->getItem($itemid, 1, 1);
1301 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1303 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1305 if ( $blog->convertBreaks() )
1307 $item['body'] = removeBreaks($item['body']);
1308 $item['more'] = removeBreaks($item['more']);
1311 // form to edit blog items
1313 $formfactory = new PageFactory($blog->getID());
1314 $formfactory->createEditForm('admin', $item);
1320 * @todo document this
1322 function action_itemupdate() {
1323 global $member, $manager, $CONF;
1325 $itemid = intRequestVar('itemid');
1326 $catid = postVar('catid');
1328 // only allow if user is allowed to alter item
1329 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1331 $actiontype = postVar('actiontype');
1333 // delete actions are handled by itemdelete (which has confirmation)
1334 if ($actiontype == 'delete') {
1335 $this->action_itemdelete();
1339 $body = postVar('body');
1340 $title = postVar('title');
1341 $more = postVar('more');
1342 $closed = intPostVar('closed');
1343 $draftid = intPostVar('draftid');
1345 // default action = add now
1347 $actiontype='addnow';
1349 // create new category if needed
1350 if (strstr($catid,'newcat')) {
1352 list($blogid) = sscanf($catid,"newcat-%d");
1355 $blog =& $manager->getBlog($blogid);
1356 $catid = $blog->createNewCategory();
1358 // show error when sth goes wrong
1360 $this->doError(_ERROR_CATCREATEFAIL);
1364 set some variables based on actiontype
1367 draft items -> addnow, addfuture, adddraft, delete
1368 non-draft items -> edit, changedate, delete
1371 $timestamp: set to a nonzero value for future dates or date changes
1372 $wasdraft: set to 1 when the item used to be a draft item
1373 $publish: set to 1 when the edited item is not a draft
1375 $blogid = getBlogIDFromItemID($itemid);
1376 $blog =& $manager->getBlog($blogid);
1378 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1379 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1380 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1381 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1382 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1387 // edit the item for real
1388 Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1390 $this->updateFuturePosted($blogid);
1393 // delete permission is checked inside Item::delete()
1394 Item::delete($draftid);
1397 // show category edit window when we created a new category
1398 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1399 if ($catid != intPostVar('catid')) {
1400 $this->action_categoryedit(
1403 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1406 // TODO: set start item correctly for itemlist
1407 $this->action_itemlist(getBlogIDFromItemID($itemid));
1412 * Admin::action_itemdelete()
1418 function action_itemdelete()
1420 global $member, $manager;
1422 $itemid = intRequestVar('itemid');
1424 // only allow if user is allowed to alter item
1425 $member->canAlterItem($itemid) or $this->disallow();
1427 if ( !$manager->existsItem($itemid,1,1) )
1429 $this->error(_ERROR_NOSUCHITEM);
1432 $item =& $manager->getItem($itemid,1,1);
1433 $title = Entity::hsc(strip_tags($item['title']));
1434 $body = strip_tags($item['body']);
1435 $body = Entity::hsc(Entity::shorten($body,300,'...'));
1438 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1439 echo '<p>' . _CONFIRMTXT_ITEM . "</p>\n";
1440 echo "<div class=\"note\">\n";
1441 echo "<b>{$title}</b>\n";
1445 echo "<form method=\"post\" action=\"index.php\">\n";
1447 echo "<input type=\"hidden\" name=\"action\" value=\"itemdeleteconfirm\" />\n";
1448 echo $manager->addTicketHidden() . "\n";
1449 echo "<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\" />\n";
1450 echo '<input type="submit" value="' . _DELETE_CONFIRM_BTN . "\" tabindex=\"10\" />\n";
1458 * @todo document this
1460 function action_itemdeleteconfirm() {
1463 $itemid = intRequestVar('itemid');
1465 // only allow if user is allowed to alter item
1466 $member->canAlterItem($itemid) or $this->disallow();
1469 $blogid = getBlogIdFromItemId($itemid);
1471 // delete item (note: some checks will be performed twice)
1472 $this->deleteOneItem($itemid);
1474 $this->action_itemlist($blogid);
1478 * Deletes one item and returns error if something goes wrong
1479 * @param int $itemid
1481 function deleteOneItem($itemid) {
1482 global $member, $manager;
1484 // only allow if user is allowed to alter item (also checks if itemid exists)
1485 if (!$member->canAlterItem($itemid))
1486 return _ERROR_DISALLOWED;
1488 // need to get blogid before the item is deleted
1489 $blogid = getBlogIDFromItemId($itemid);
1491 $manager->loadClass('ITEM');
1492 Item::delete($itemid);
1494 // update blog's futureposted
1495 $this->updateFuturePosted($blogid);
1499 * Admin::updateFuturePosted()
1500 * Update a blog's future posted flag
1502 * @param integer $blogid
1506 function updateFuturePosted($blogid)
1510 $blog =& $manager->getBlog($blogid);
1511 $currenttime = $blog->getCorrectTime(time());
1513 $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
1514 $query = sprintf($query, sql_table('item'), (integer) $blogid, DB::formatDateTime($currenttime));
1515 $result = DB::getResult($query);
1517 if ( $result->rowCount() > 0 )
1519 $blog->setFuturePost();
1523 $blog->clearFuturePost();
1529 * @todo document this
1531 function action_itemmove() {
1532 global $member, $manager;
1534 $itemid = intRequestVar('itemid');
1536 // only allow if user is allowed to alter item
1537 $member->canAlterItem($itemid) or $this->disallow();
1539 $item =& $manager->getItem($itemid,1,1);
1543 <h2><?php echo _MOVE_TITLE ?></h2>
1544 <form method="post" action="index.php"><div>
1545 <input type="hidden" name="action" value="itemmoveto" />
1546 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1550 $manager->addTicketHidden();
1551 $this->selectBlogCategory('catid',$item['catid'],10,1);
1554 <input type="submit" value="<?php echo _MOVE_BTN ?>" tabindex="10000" onclick="return checkSubmit();" />
1561 * @todo document this
1563 function action_itemmoveto() {
1564 global $member, $manager;
1566 $itemid = intRequestVar('itemid');
1567 $catid = requestVar('catid');
1569 // create new category if needed
1570 if (strstr($catid,'newcat')) {
1572 list($blogid) = sscanf($catid,'newcat-%d');
1575 $blog =& $manager->getBlog($blogid);
1576 $catid = $blog->createNewCategory();
1578 // show error when sth goes wrong
1580 $this->doError(_ERROR_CATCREATEFAIL);
1583 // only allow if user is allowed to alter item
1584 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1586 $old_blogid = getBlogIDFromItemId($itemid);
1588 Item::move($itemid, $catid);
1590 // set the futurePosted flag on the blog
1591 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1593 // reset the futurePosted in case the item is moved from one blog to another
1594 $this->updateFuturePosted($old_blogid);
1596 if ($catid != intRequestVar('catid'))
1597 $this->action_categoryedit($catid, $blog->getID());
1599 $this->action_itemlist(getBlogIDFromCatID($catid));
1603 * Moves one item to a given category (category existance should be checked by caller)
1604 * errors are returned
1605 * @param int $itemid
1606 * @param int $destCatid category ID to which the item will be moved
1608 function moveOneItem($itemid, $destCatid) {
1611 // only allow if user is allowed to move item
1612 if (!$member->canUpdateItem($itemid, $destCatid))
1613 return _ERROR_DISALLOWED;
1615 Item::move($itemid, $destCatid);
1619 * Adds a item to the chosen blog
1621 function action_additem() {
1622 global $manager, $CONF;
1624 $manager->loadClass('ITEM');
1626 $result = Item::createFromRequest();
1628 if ($result['status'] == 'error')
1629 $this->error($result['message']);
1631 $blogid = getBlogIDFromItemID($result['itemid']);
1632 $blog =& $manager->getBlog($blogid);
1633 $btimestamp = $blog->getCorrectTime();
1634 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1636 if ($result['status'] == 'newcategory') {
1637 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1638 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1640 $methodName = 'action_itemList';
1641 call_user_func(array(&$this, $methodName), $blogid);
1646 * Allows to edit previously made comments
1648 function action_commentedit() {
1650 global $member, $manager;
1652 $commentid = intRequestVar('commentid');
1654 $member->canAlterComment($commentid) or $this->disallow();
1656 $comment = Comment::getComment($commentid);
1658 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1660 // change <br /> to \n
1661 $comment['body'] = str_replace('<br />', '', $comment['body']);
1663 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1664 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\") ?>[^<]*</a>", "\\1", $comment['body']) */
1666 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\") ?>[^<]*</a>#i", "\\1", $comment['body']);
1671 <h2><?php echo _EDITC_TITLE ?></h2>
1673 <form action="index.php" method="post"><div>
1675 <input type="hidden" name="action" value="commentupdate" />
1676 <?php $manager->addTicketHidden(); ?>
1677 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1679 <th colspan="2"><?php echo _EDITC_TITLE ?></th>
1681 <td><?php echo _EDITC_WHO ?></td>
1683 <?php if ($comment['member'])
1684 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1686 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1690 <td><?php echo _EDITC_WHEN ?></td>
1691 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1693 <td><?php echo _EDITC_HOST ?></td>
1694 <td><?php echo $comment['host']; ?></td>
1697 <td><?php echo _EDITC_URL; ?></td>
1698 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1701 <td><?php echo _EDITC_EMAIL; ?></td>
1702 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1705 <td><?php echo _EDITC_TEXT ?></td>
1707 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1708 echo $comment['body'];
1712 <td><?php echo _EDITC_EDIT ?></td>
1713 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT ?>" onclick="return checkSubmit();" /></td>
1722 * @todo document this
1724 function action_commentupdate() {
1725 global $member, $manager;
1727 $commentid = intRequestVar('commentid');
1729 $member->canAlterComment($commentid) or $this->disallow();
1731 $url = postVar('url');
1732 $email = postVar('email');
1733 $body = postVar('body');
1735 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1736 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1737 # important note that '\' must be matched with '\\\\' in preg* expressions
1739 // intercept words that are too long
1740 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1742 $this->error(_ERROR_COMMENT_LONGWORD);
1746 if (i18n::strlen($body) < 3)
1748 $this->error(_ERROR_COMMENT_NOCOMMENT);
1751 if (i18n::strlen($body) > 5000)
1753 $this->error(_ERROR_COMMENT_TOOLONG);
1757 $body = Comment::prepareBody($body);
1760 $manager->notify('PreUpdateComment',array('body' => &$body));
1762 $query = 'UPDATE ' . sql_table('comment')
1763 . ' SET cmail = ' . DB::quoteValue($url) . ', cemail = ' . DB::quoteValue($email) . ', cbody = ' . DB::quoteValue($body)
1764 . ' WHERE cnumber = ' . $commentid;
1765 DB::execute($query);
1768 $res = DB::getValue('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1771 if ($member->canAlterItem($itemid))
1772 $this->action_itemcommentlist($itemid);
1774 $this->action_browseowncomments();
1779 * Admin::action_commentdelete()
1785 function action_commentdelete()
1787 global $member, $manager;
1789 $commentid = intRequestVar('commentid');
1790 $member->canAlterComment($commentid) or $this->disallow();
1791 $comment = Comment::getComment($commentid);
1793 $body = strip_tags($comment['body']);
1794 $body = Entity::hsc(Entity::shorten($body, 300, '...'));
1796 if ( $comment['member'] )
1798 $author = $comment['member'];
1802 $author = $comment['user'];
1807 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1808 echo '<p>' . _CONFIRMTXT_COMMENT . "</p>\n";
1809 echo "<div class=\"note\">\n";
1810 echo '<b>' . _EDITC_WHO . ":</b>{$author}<br />\n";
1811 echo '<b>' . _EDITC_TEXT . ":</b>{$body}\n";
1813 echo "<form method=\"post\" action=\"index.php\">\n";
1815 echo "<input type=\"hidden\" name=\"action\" value=\"commentdeleteconfirm\" />\n";
1816 echo $manager->addTicketHidden() . "\n";
1817 echo "<input type=\"hidden\" name=\"commentid\" value=\"{$commentid}\" />\n";
1818 echo '<input type="submit" tabindex="10" value="'. _DELETE_CONFIRM_BTN . "\" />\n";
1826 * @todo document this
1828 function action_commentdeleteconfirm() {
1831 $commentid = intRequestVar('commentid');
1833 // get item id first
1834 $res = DB::getValue('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1837 $error = $this->deleteOneComment($commentid);
1839 $this->doError($error);
1841 if ($member->canAlterItem($itemid))
1842 $this->action_itemcommentlist($itemid);
1844 $this->action_browseowncomments();
1848 * @todo document this
1850 function deleteOneComment($commentid) {
1851 global $member, $manager;
1853 $commentid = intval($commentid);
1855 if (!$member->canAlterComment($commentid))
1856 return _ERROR_DISALLOWED;
1858 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1860 // delete the comments associated with the item
1861 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1862 DB::execute($query);
1864 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1870 * Admin::action_usermanagement()
1872 * Usermanagement main
1876 public function action_usermanagement()
1878 global $member, $manager;
1881 $member->isAdmin() or $this->disallow();
1885 echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
1887 echo '<h2>' . _MEMBERS_TITLE . "</h2>\n";
1889 echo '<h3>' . _MEMBERS_CURRENT . "</h3>\n";
1891 // show list of members with actions
1892 $query = 'SELECT * FROM '.sql_table('member');
1893 $template['content'] = 'memberlist';
1894 $template['tabindex'] = 10;
1896 $manager->loadClass("ENCAPSULATE");
1897 $batch = new Batch('member');
1898 $batch->showlist($query,'table',$template);
1900 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1901 echo "<form method=\"post\" action=\"index.php\" name=\"memberedit\">\n";
1903 echo "<input type=\"hidden\" name=\"action\" value=\"memberadd\" />\n";
1904 $manager->addTicketHidden();
1906 echo '<table frame="box" rules="rules" summary="' . _MEMBERS_NEW . '">' ."\n";
1908 echo '<th colspan="2">' . _MEMBERS_NEW . "</th>\n";
1911 echo '<td>' . _MEMBERS_DISPLAY;
1914 echo '<small>' . _MEMBERS_DISPLAY_INFO . '</small>';
1916 echo "<td><input tabindex=\"10010\" name=\"name\" size=\"32\" maxlength=\"32\" /></td>\n";
1919 echo '<td>' . _MEMBERS_REALNAME . "</td>\n";
1920 echo "<td><input name=\"realname\" tabindex=\"10020\" size=\"40\" maxlength=\"60\" /></td>\n";
1923 echo '<td>' . _MEMBERS_PWD . "</td>\n";
1924 echo "<td><input name=\"password\" tabindex=\"10030\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
1927 echo '<td>' . _MEMBERS_REPPWD . "</td>\n";
1928 echo "<td><input name=\"repeatpassword\" tabindex=\"10035\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
1931 echo '<td>' . _MEMBERS_EMAIL . "</td>\n";
1932 echo "<td><input name=\"email\" tabindex=\"10040\" size=\"40\" maxlength=\"60\" /></td>\n";
1935 echo '<td>' . _MEMBERS_URL . "</td>\n";
1936 echo "<td><input name=\"url\" tabindex=\"10050\" size=\"40\" maxlength=\"100\" /></td>\n";
1939 echo '<td>' . _MEMBERS_SUPERADMIN;
1943 $this->input_yesno('admin',0,10060);
1947 echo '<td>' . _MEMBERS_CANLOGIN;
1951 $this->input_yesno('canlogin',1,10070);
1955 echo '<td>' . _MEMBERS_NOTES . "</td>\n";
1956 echo "<td><input name=\"notes\" maxlength=\"100\" size=\"40\" tabindex=\"10080\" /></td>\n";
1959 echo '<td>' . _MEMBERS_NEW . "</td>\n";
1960 echo '<td><input type="submit" value="' . _MEMBERS_NEW_BTN . '" tabindex="10090" onclick="return checkSubmit();" />' . "</td>\n";
1970 * Edit member settings
1972 function action_memberedit() {
1973 $this->action_editmembersettings(intRequestVar('memberid'));
1977 * @todo document this
1979 function action_editmembersettings($memberid = '') {
1980 global $member, $manager, $CONF;
1982 if ($memberid == '')
1984 $memberid = $member->getID();
1988 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1990 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1991 $this->pagehead($extrahead);
1993 // show message to go back to member overview (only for admins)
1994 if ($member->isAdmin())
1996 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
2000 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
2002 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
2004 $mem = Member::createFromID($memberid);
2006 <form method="post" action="index.php" name="memberedit"><div>
2008 <input type="hidden" name="action" value="changemembersettings" />
2009 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2010 <?php $manager->addTicketHidden() ?>
2013 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
2015 <td><?php echo _MEMBERS_DISPLAY ?> <?php help('shortnames'); ?>
2016 <br /><small><?php echo _MEMBERS_DISPLAY_INFO ?></small>
2019 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
2020 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo Entity::hsc($mem->getDisplayName()); ?>" />
2022 echo Entity::hsc($member->getDisplayName());
2027 <td><?php echo _MEMBERS_REALNAME ?></td>
2028 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo Entity::hsc($mem->getRealName()); ?>" /></td>
2030 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
2031 <td><?php echo _MEMBERS_PWD ?></td>
2032 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
2034 <td><?php echo _MEMBERS_REPPWD ?></td>
2035 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
2038 <td><?php echo _MEMBERS_EMAIL ?>
2039 <br /><small><?php echo _MEMBERS_EMAIL_EDIT ?></small>
2041 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo Entity::hsc($mem->getEmail()); ?>" /></td>
2043 <td><?php echo _MEMBERS_URL ?></td>
2044 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getURL()); ?>" /></td>
2045 <?php // only allow to change this by super-admins
2046 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
2047 if ($member->isAdmin()) {
2050 <td><?php echo _MEMBERS_SUPERADMIN ?> <?php help('superadmin'); ?></td>
2051 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
2053 <td><?php echo _MEMBERS_CANLOGIN ?> <?php help('canlogin'); ?></td>
2054 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
2057 <td><?php echo _MEMBERS_NOTES ?></td>
2058 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getNotes()); ?>" /></td>
2060 <td><?php echo _MEMBERS_LOCALE ?> <?php help('locale'); ?>
2064 <select name="locale" tabindex="85">
2066 $locales = i18n::get_available_locale_list();
2067 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
2069 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2073 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2076 foreach( $locales as $locale )
2078 if( $locale == $mem->getLocale() )
2080 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
2084 echo "<option value=\"{$locale}\">{$locale}</option>\n";
2093 <td><?php echo _MEMBERS_USEAUTOSAVE ?> <?php help('autosave'); ?></td>
2094 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
2098 $this->_insertPluginOptions('member',$memberid);
2101 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
2103 <td><?php echo _MEMBERS_EDIT ?></td>
2104 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN ?>" onclick="return checkSubmit();" /></td>
2110 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2113 'MemberSettingsFormExtras',
2122 * @todo document this
2124 function action_changemembersettings() {
2125 global $member, $CONF, $manager;
2127 $memberid = intRequestVar('memberid');
2130 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
2132 $name = trim(strip_tags(postVar('name')));
2133 $realname = trim(strip_tags(postVar('realname')));
2134 $password = postVar('password');
2135 $repeatpassword = postVar('repeatpassword');
2136 $email = strip_tags(postVar('email'));
2137 $url = strip_tags(postVar('url'));
2139 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
2140 # original eregi: !eregi("^https?://", $url)
2142 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
2143 if (!preg_match('#^https?://#', $url) )
2145 $url = 'http://' . $url;
2148 $admin = postVar('admin');
2149 $canlogin = postVar('canlogin');
2150 $notes = strip_tags(postVar('notes'));
2151 $locale = postVar('locale');
2153 $mem = Member::createFromID($memberid);
2155 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2157 if (!isValidDisplayName($name))
2158 $this->error(_ERROR_BADNAME);
2160 if (($name != $mem->getDisplayName()) && Member::exists($name))
2161 $this->error(_ERROR_NICKNAMEINUSE);
2163 if ($password != $repeatpassword)
2164 $this->error(_ERROR_PASSWORDMISMATCH);
2166 if ($password && (i18n::strlen($password) < 6))
2167 $this->error(_ERROR_PASSWORDTOOSHORT);
2172 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2174 $this->error($pwderror);
2179 if ( !NOTIFICATION::address_validation($email) )
2181 $this->error(_ERROR_BADMAILADDRESS);
2185 $this->error(_ERROR_REALNAMEMISSING);
2187 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2188 $this->error(_ERROR_NOSUCHTRANSLATION);
2190 // check if there will remain at least one site member with both the logon and admin rights
2191 // (check occurs when taking away one of these rights from such a member)
2192 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2193 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2196 $r = DB::getResult('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2197 if ($r->rowCount() < 2)
2198 $this->error(_ERROR_ATLEASTONEADMIN);
2201 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2202 $mem->setDisplayName($name);
2204 $mem->setPassword($password);
2207 $oldEmail = $mem->getEmail();
2209 $mem->setRealName($realname);
2210 $mem->setEmail($email);
2212 $mem->setNotes($notes);
2213 $mem->setLocale($locale);
2216 // only allow super-admins to make changes to the admin status
2217 if ($member->isAdmin()) {
2218 $mem->setAdmin($admin);
2219 $mem->setCanLogin($canlogin);
2222 $autosave = postVar ('autosave');
2223 $mem->setAutosave($autosave);
2227 // store plugin options
2228 $aOptions = requestArray('plugoption');
2229 NucleusPlugin::apply_plugin_options($aOptions);
2230 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2232 // if email changed, generate new password
2233 if ($oldEmail != $mem->getEmail())
2235 $mem->sendActivationLink('addresschange', $oldEmail);
2237 $mem->newCookieKey();
2239 // only log out if the member being edited is the current member.
2240 if ($member->getID() == $memberid)
2242 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2247 if ( ( $mem->getID() == $member->getID() )
2248 && ( $mem->getDisplayName() != $member->getDisplayName() )
2250 $mem->newCookieKey();
2252 $this->action_login(_MSG_LOGINAGAIN, 0);
2254 $this->action_overview(_MSG_SETTINGSCHANGED);
2259 * Admin::action_memberadd()
2265 function action_memberadd()
2267 global $member, $manager;
2270 $member->isAdmin() or $this->disallow();
2272 if ( postVar('password') != postVar('repeatpassword') )
2274 $this->error(_ERROR_PASSWORDMISMATCH);
2277 if ( i18n::strlen(postVar('password')) < 6 )
2279 $this->error(_ERROR_PASSWORDTOOSHORT);
2282 $res = Member::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2288 // fire PostRegister event
2289 $newmem = new Member();
2290 $newmem->readFromName(postVar('name'));
2291 $manager->notify('PostRegister',array('member' => &$newmem));
2293 $this->action_usermanagement();
2298 * Account activation
2302 function action_activate() {
2304 $key = getVar('key');
2305 $this->_showActivationPage($key);
2309 * @todo document this
2311 function _showActivationPage($key, $message = '')
2315 // clean up old activation keys
2316 Member::cleanupActivationTable();
2318 // get activation info
2319 $info = Member::getActivationInfo($key);
2322 $this->error(_ERROR_ACTIVATE);
2324 $mem = Member::createFromId($info['vmember']);
2327 $this->error(_ERROR_ACTIVATE);
2331 $bNeedsPasswordChange = true;
2333 switch ($info['vtype'])
2336 $title = _ACTIVATE_FORGOT_TITLE;
2337 $text = _ACTIVATE_FORGOT_TEXT;
2340 $title = _ACTIVATE_REGISTER_TITLE;
2341 $text = _ACTIVATE_REGISTER_TEXT;
2343 case 'addresschange':
2344 $title = _ACTIVATE_CHANGE_TITLE;
2345 $text = _ACTIVATE_CHANGE_TEXT;
2346 $bNeedsPasswordChange = false;
2347 Member::activate($key);
2352 'memberName' => Entity::hsc($mem->getDisplayName())
2354 $title = Template::fill($title, $aVars);
2355 $text = Template::fill($text, $aVars);
2359 echo '<h2>' , $title, '</h2>';
2360 echo '<p>' , $text, '</p>';
2364 echo '<p class="error">',$message,'</p>';
2367 if ($bNeedsPasswordChange)
2370 <div><form action="index.php" method="post">
2372 <input type="hidden" name="action" value="activatesetpwd" />
2373 <?php $manager->addTicketHidden() ?>
2374 <input type="hidden" name="key" value="<?php echo Entity::hsc($key) ?>" />
2377 <td><?php echo _MEMBERS_PWD ?></td>
2378 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2380 <td><?php echo _MEMBERS_REPPWD ?></td>
2381 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2385 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2389 <td><?php echo _MEMBERS_SETPWD ?></td>
2390 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2405 * Account activation - set password part
2409 function action_activatesetpwd() {
2411 $key = postVar('key');
2413 // clean up old activation keys
2414 Member::cleanupActivationTable();
2416 // get activation info
2417 $info = Member::getActivationInfo($key);
2419 if (!$info || ($info['type'] == 'addresschange'))
2420 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2422 $mem = Member::createFromId($info['vmember']);
2425 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2427 $password = postVar('password');
2428 $repeatpassword = postVar('repeatpassword');
2430 if ($password != $repeatpassword)
2431 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2433 if ($password && (i18n::strlen($password) < 6))
2434 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2440 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2442 return $this->_showActivationPage($key,$pwderror);
2448 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2450 return $this->_showActivationPage($key, $error);
2454 $mem->setPassword($password);
2457 // do the activation
2458 Member::activate($key);
2461 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2462 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2467 * Admin::action_manageteam()
2473 public function action_manageteam()
2475 global $member, $manager;
2477 $blogid = intRequestVar('blogid');
2480 $member->blogAdminRights($blogid) or $this->disallow();
2484 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(" . _BACK_TO_BLOGSETTINGS . ")</a></p>\n";
2486 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . "</h2>\n";
2488 echo '<h3>' . _TEAM_CURRENT . "</h3>\n";
2490 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2491 . ' FROM '.sql_table('member').', '.sql_table('team')
2492 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2494 $template['content'] = 'teamlist';
2495 $template['tabindex'] = 10;
2497 $manager->loadClass("ENCAPSULATE");
2498 $batch = new Batch('team');
2499 $batch->showlist($query, 'table', $template);
2501 echo '<h3>' . _TEAM_ADDNEW . "</h3>\n";
2503 echo "<form method=\"post\" action=\"index.php\">\n";
2506 echo "<input type=\"hidden\" name=\"action\" value=\"teamaddmember\" />\n";
2507 echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
2508 $manager->addTicketHidden();
2510 echo '<table frame="box" rules="all" summary="' . _TEAM_ADDNEW . '">' . "\n";
2512 echo '<td>' . _TEAM_CHOOSEMEMBER . "</td>\n";
2514 // TODO: try to make it so only non-team-members are listed
2517 $query = 'SELECT mname as text, mnumber as value FROM '.sql_table('member');
2518 $template['name'] = 'memberid';
2519 $template['tabindex'] = 10000;
2520 showlist($query,'select',$template);
2525 echo '<td>' . _TEAM_ADMIN;
2529 $this->input_yesno('admin',0,10020);
2533 echo '<td>' . _TEAM_ADD . "</td>\n";
2534 echo '<td><input type="submit" value="' . _TEAM_ADD_BTN . '" tabindex="10030" />' . "</td>\n";
2546 * Add member to team
2548 function action_teamaddmember() {
2549 global $member, $manager;
2551 $memberid = intPostVar('memberid');
2552 $blogid = intPostVar('blogid');
2553 $admin = intPostVar('admin');
2556 $member->blogAdminRights($blogid) or $this->disallow();
2558 $blog =& $manager->getBlog($blogid);
2559 if (!$blog->addTeamMember($memberid, $admin))
2560 $this->error(_ERROR_ALREADYONTEAM);
2562 $this->action_manageteam();
2567 * @todo document this
2569 function action_teamdelete() {
2570 global $member, $manager;
2572 $memberid = intRequestVar('memberid');
2573 $blogid = intRequestVar('blogid');
2576 $member->blogAdminRights($blogid) or $this->disallow();
2578 $teammem = Member::createFromID($memberid);
2579 $blog =& $manager->getBlog($blogid);
2583 <h2><?php echo _DELETE_CONFIRM ?></h2>
2585 <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>
2589 <form method="post" action="index.php"><div>
2590 <input type="hidden" name="action" value="teamdeleteconfirm" />
2591 <?php $manager->addTicketHidden() ?>
2592 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2593 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2594 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
2601 * @todo document this
2603 function action_teamdeleteconfirm() {
2606 $memberid = intRequestVar('memberid');
2607 $blogid = intRequestVar('blogid');
2609 $error = $this->deleteOneTeamMember($blogid, $memberid);
2611 $this->error($error);
2614 $this->action_manageteam();
2618 * @todo document this
2620 function deleteOneTeamMember($blogid, $memberid) {
2621 global $member, $manager;
2623 $blogid = intval($blogid);
2624 $memberid = intval($memberid);
2627 if (!$member->blogAdminRights($blogid))
2628 return _ERROR_DISALLOWED;
2630 // check if: - there remains at least one blog admin
2631 // - (there remains at least one team member)
2632 $tmem = Member::createFromID($memberid);
2634 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2636 if ($tmem->isBlogAdmin($blogid)) {
2637 // check if there are more blog members left and at least one admin
2638 // (check for at least two admins before deletion)
2639 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2640 $r = DB::getResult($query);
2641 if ($r->rowCount() < 2)
2642 return _ERROR_ATLEASTONEBLOGADMIN;
2645 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2646 DB::execute($query);
2648 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2654 * @todo document this
2656 function action_teamchangeadmin() {
2659 $blogid = intRequestVar('blogid');
2660 $memberid = intRequestVar('memberid');
2663 $member->blogAdminRights($blogid) or $this->disallow();
2665 $mem = Member::createFromID($memberid);
2667 // don't allow when there is only one admin at this moment
2668 if ($mem->isBlogAdmin($blogid)) {
2669 $r = DB::getResult('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2670 if ($r->rowCount() == 1)
2671 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2674 if ($mem->isBlogAdmin($blogid))
2679 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2680 DB::execute($query);
2682 // only show manageteam if member did not change its own admin privileges
2683 if ($member->isBlogAdmin($blogid))
2684 $this->action_manageteam();
2686 $this->action_overview(_MSG_ADMINCHANGED);
2690 * Admin::action_blogsettings()
2695 public function action_blogsettings()
2697 global $member, $manager;
2699 $blogid = intRequestVar('blogid');
2702 $member->blogAdminRights($blogid) or $this->disallow();
2704 $blog =& $manager->getBlog($blogid);
2706 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
2707 $this->pagehead($extrahead);
2709 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
2710 echo '<h2>' . _EBLOG_TITLE . ": '{$this->bloglink($blog)}'</h2>\n";
2712 echo '<h3>' . _EBLOG_TEAM_TITLE . "</h3>\n";
2714 echo '<p>' . _EBLOG_CURRENT_TEAM_MEMBER;
2716 $query = "SELECT mname, mrealname FROM %s, %s WHERE mnumber=tmember AND tblog=%d;";
2717 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
2718 $res = DB::getResult($query);
2719 $aMemberNames = array();
2720 foreach ( $res as $row )
2722 $aMemberNames[] = Entity::hsc($row['mname']) . ' (' . Entity::hsc($row['mrealname']). ')';
2724 echo implode(',', $aMemberNames);
2728 echo '<a href="index.php?action=manageteam&blogid=' . $blogid . '">' . _EBLOG_TEAM_TEXT . '</a>';
2731 echo '<h3>' . _EBLOG_SETTINGS_TITLE . "</h3>\n";
2733 echo "<form method=\"post\" action=\"index.php\">\n";
2736 echo "<input type=\"hidden\" name=\"action\" value=\"blogsettingsupdate\" />\n";
2737 $manager->addTicketHidden() . "\n";
2738 echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
2740 echo '<table frame="box" rules="all" summary="' . _EBLOG_SETTINGS_TITLE . '">' . "\n";
2743 echo '<th colspan="2">' . _EBLOG_CHANGE . "</th>\n";
2746 echo '<td>' . _EBLOG_CHANGE . "</td>\n";
2747 echo '<td><input type="submit" tabindex="130" value="' . _EBLOG_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
2752 echo '<td>' . _EBLOG_NAME . "</td>\n";
2753 echo '<td><input name="name" tabindex="10" size="40" maxlength="60" value="' . Entity::hsc($blog->getName()) . '" />' . "</td>\n";
2756 echo '<td>' . _EBLOG_SHORTNAME;
2757 help('shortblogname');
2758 echo _EBLOG_SHORTNAME_EXTRA;
2760 echo '<td><input name="shortname" tabindex="20" maxlength="15" size="15" value="' . Entity::hsc($blog->getShortName()) .'" />' . "</td>\n";
2763 echo '<td>' . _EBLOG_DESC . "</td>\n";
2764 echo '<td><input name="desc" tabindex="30" maxlength="200" size="40" value="' . Entity::hsc($blog->getDescription()) . '" />' . "</td>\n";
2767 echo '<td>' . _EBLOG_URL . "</td>\n";
2768 echo '<td><input name="url" tabindex="40" size="40" maxlength="100" value="' . Entity::hsc($blog->getURL()) . '" />' . "</td>\n";
2771 echo '<td>' . _EBLOG_DEFSKIN;
2772 help('blogdefaultskin');
2776 $query = 'SELECT sdname as text, sdnumber as value FROM ' . sql_table('skin_desc');
2777 $template['name'] = 'defskin';
2778 $template['selected'] = $blog->getDefaultSkin();
2779 $template['tabindex'] = 50;
2780 showlist($query, 'select', $template);
2785 echo '<td>' . _EBLOG_LINEBREAKS;
2786 help('convertbreaks');
2789 $this->input_yesno('convertbreaks',$blog->convertBreaks(),55);
2794 echo '<td>' . _EBLOG_ALLOWPASTPOSTING;
2795 help('allowpastposting');
2798 $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57);
2802 echo '<td>' . _EBLOG_DISABLECOMMENTS;
2805 $this->input_yesno('comments', $blog->commentsEnabled(), 60);
2809 echo '<td>' . _EBLOG_ANONYMOUS . "</td>\n";
2811 $this->input_yesno('public',$blog->isPublic(),70);
2815 echo '<td>' . _EBLOG_REQUIREDEMAIL . "</td>\n";
2817 $this->input_yesno('reqemail', $blog->emailRequired(),72);
2821 echo '<td>' . _EBLOG_NOTIFY;
2824 echo '<td><input name="notify" tabindex="80" maxlength="128" size="40" value="' . Entity::hsc($blog->getNotifyAddress()) . '" />' . "</td>\n";
2828 echo '<td>' . _EBLOG_NOTIFY_ON . "</td>\n";
2831 if ( !$blog->notifyOnComment() )
2833 echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" />\n";
2837 echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" checked=\"checked\"/>\n";
2839 echo '<label for="notifyComment">' . _EBLOG_NOTIFY_COMMENT . "</label><br />\n";
2841 if ( !$blog->notifyOnVote() )
2843 echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" />\n";
2847 echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" checked=\"checked\" />\n";
2850 echo '<label for="notifyVote">' . _EBLOG_NOTIFY_KARMA . "</label><br />\n";
2852 if ( !$blog->notifyOnNewItem() )
2854 echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" />\n";
2859 echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" checked=\"checked\" />\n";
2862 echo '<label for="notifyNewItem">' . _EBLOG_NOTIFY_ITEM . "</label>\n";
2867 echo '<td>' . _EBLOG_MAXCOMMENTS;
2868 help('blogmaxcomments');
2870 echo '<td><input name="maxcomments" tabindex="90" size="3" value="' . Entity::hsc($blog->getMaxComments()) . '" />' . "</td>\n";
2873 echo '<td>' . _EBLOG_UPDATE;
2874 help('blogupdatefile');
2876 echo '<td><input name="update" tabindex="100" size="40" maxlength="60" value="' . Entity::hsc($blog->getUpdateFile()) .'" />' . "</td>\n";
2879 echo '<td>' . _EBLOG_DEFCAT . "</td>\n";
2881 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2882 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2883 $template['name'] = 'defcat';
2884 $template['selected'] = $blog->getDefaultCategory();
2885 $template['tabindex'] = 110;
2886 showlist($query, 'select', $template);
2890 echo '<td>' . _EBLOG_OFFSET;
2891 help('blogtimeoffset');
2894 echo ' <b>' . i18n::formatted_datetime('%H:%M', time()) . '</b><br />';
2896 echo '<b>' . i18n::formatted_datetime('%H:%M', $blog->getCorrectTime()) . '</b>';
2898 echo '<td><input name="timeoffset" tabindex="120" size="3" value="' . Entity::hsc($blog->getTimeOffset()) .'" />' . "</td>\n";
2901 echo '<td>' . _EBLOG_SEARCH;
2902 help('blogsearchable');
2905 $this->input_yesno('searchable', $blog->getSearchable(), 122);
2910 $this->_insertPluginOptions('blog', $blogid);
2918 echo '<h3>' . _EBLOG_CAT_TITLE . "</h3>\n";
2920 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2921 $template['content'] = 'categorylist';
2922 $template['tabindex'] = 200;
2924 $manager->loadClass("ENCAPSULATE");
2925 $batch = new Batch('category');
2926 $batch->showlist($query,'table',$template);
2928 echo "<form action=\"index.php\" method=\"post\">\n";
2930 echo "<input name=\"action\" value=\"categorynew\" type=\"hidden\" />\n";
2931 $manager->addTicketHidden() . "\n";
2932 echo "<input name=\"blogid\" value=\"{$blog->getID()}\" type=\"hidden\" />\n";
2934 echo '<table frame="box" rules="all" summary="' . _EBLOG_CAT_CREATE . '">' . "\n";
2937 echo '<th colspan="2">' . _EBLOG_CAT_CREATE . "</th>\n";
2942 echo '<td>' . _EBLOG_CAT_NAME . "</td>\n";
2943 echo "<td><input name=\"cname\" size=\"40\" maxlength=\"40\" tabindex=\"300\" /></td>\n";
2946 echo '<td>' . _EBLOG_CAT_DESC . "</td>\n";
2947 echo "<td><input name=\"cdesc\" size=\"40\" maxlength=\"200\" tabindex=\"310\" /></td>\n";
2950 echo '<td>' . _EBLOG_CAT_CREATE . "</td>\n";
2951 echo '<td><input type="submit" value="' . _EBLOG_CAT_CREATE . '" tabindex="320" />' . "</td>\n";
2958 echo '<h3>' . _PLUGINS_EXTRA . "</h3>\n";
2959 $manager->notify('BlogSettingsFormExtras', array('blog' => &$blog));
2966 * @todo document this
2968 function action_categorynew() {
2969 global $member, $manager;
2971 $blogid = intRequestVar('blogid');
2973 $member->blogAdminRights($blogid) or $this->disallow();
2975 $cname = postVar('cname');
2976 $cdesc = postVar('cdesc');
2978 if (!isValidCategoryName($cname))
2979 $this->error(_ERROR_BADCATEGORYNAME);
2981 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=' . DB::quoteValue($cname).' and cblog=' . intval($blogid);
2982 $res = DB::getResult($query);
2983 if ($res->rowCount() > 0)
2984 $this->error(_ERROR_DUPCATEGORYNAME);
2986 $blog =& $manager->getBlog($blogid);
2987 $newCatID = $blog->createNewCategory($cname, $cdesc);
2989 $this->action_blogsettings();
2993 * @todo document this
2995 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2996 global $member, $manager;
2999 $blogid = intGetVar('blogid');
3001 $blogid = intval($blogid);
3003 $catid = intGetVar('catid');
3005 $catid = intval($catid);
3007 $member->blogAdminRights($blogid) or $this->disallow();
3009 $res = DB::getRow('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
3011 $cname = $res['cname'];
3012 $cdesc = $res['cdesc'];
3014 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
3015 $this->pagehead($extrahead);
3017 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
3020 <h2><?php echo _EBLOG_CAT_UPDATE ?> '<?php echo Entity::hsc($cname) ?>'</h2>
3021 <form method='post' action='index.php'><div>
3022 <input name="blogid" type="hidden" value="<?php echo $blogid ?>" />
3023 <input name="catid" type="hidden" value="<?php echo $catid ?>" />
3024 <input name="desturl" type="hidden" value="<?php echo Entity::hsc($desturl) ?>" />
3025 <input name="action" type="hidden" value="categoryupdate" />
3026 <?php $manager->addTicketHidden(); ?>
3029 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
3031 <td><?php echo _EBLOG_CAT_NAME ?></td>
3032 <td><input type="text" name="cname" value="<?php echo Entity::hsc($cname) ?>" size="40" maxlength="40" /></td>
3034 <td><?php echo _EBLOG_CAT_DESC ?></td>
3035 <td><input type="text" name="cdesc" value="<?php echo Entity::hsc($cdesc) ?>" size="40" maxlength="200" /></td>
3038 // insert plugin options
3039 $this->_insertPluginOptions('category',$catid);
3042 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
3044 <td><?php echo _EBLOG_CAT_UPDATE ?></td>
3045 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN ?>" /></td>
3054 * @todo document this
3056 function action_categoryupdate() {
3057 global $member, $manager;
3059 $blogid = intPostVar('blogid');
3060 $catid = intPostVar('catid');
3061 $cname = postVar('cname');
3062 $cdesc = postVar('cdesc');
3063 $desturl = postVar('desturl');
3065 $member->blogAdminRights($blogid) or $this->disallow();
3067 if (!isValidCategoryName($cname))
3068 $this->error(_ERROR_BADCATEGORYNAME);
3070 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=' . DB::quoteValue($cname).' and cblog=' . intval($blogid) . " and not(catid=$catid)";
3071 $res = DB::getResult($query);
3072 if ($res->rowCount() > 0)
3073 $this->error(_ERROR_DUPCATEGORYNAME);
3075 $query = 'UPDATE '.sql_table('category').' SET'
3076 . ' cname=' . DB::quoteValue($cname) . ','
3077 . ' cdesc=' . DB::quoteValue($cdesc)
3078 . ' WHERE catid=' . $catid;
3080 DB::execute($query);
3082 // store plugin options
3083 $aOptions = requestArray('plugoption');
3084 NucleusPlugin::apply_plugin_options($aOptions);
3085 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
3092 $this->action_blogsettings();
3097 * @todo document this
3099 function action_categorydelete() {
3100 global $member, $manager;
3102 $blogid = intRequestVar('blogid');
3103 $catid = intRequestVar('catid');
3105 $member->blogAdminRights($blogid) or $this->disallow();
3107 $blog =& $manager->getBlog($blogid);
3109 // check if the category is valid
3110 if (!$blog->isValidCategory($catid))
3111 $this->error(_ERROR_NOSUCHCATEGORY);
3113 // don't allow deletion of default category
3114 if ($blog->getDefaultCategory() == $catid)
3115 $this->error(_ERROR_DELETEDEFCATEGORY);
3117 // check if catid is the only category left for blogid
3118 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
3119 $res = DB::getResult($query);
3120 if ($res->rowCount() == 1)
3121 $this->error(_ERROR_DELETELASTCATEGORY);
3126 <h2><?php echo _DELETE_CONFIRM ?></h2>
3129 <?php echo _CONFIRMTXT_CATEGORY ?><b><?php echo Entity::hsc($blog->getCategoryName($catid)) ?></b>
3132 <form method="post" action="index.php"><div>
3133 <input type="hidden" name="action" value="categorydeleteconfirm" />
3134 <?php $manager->addTicketHidden() ?>
3135 <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
3136 <input type="hidden" name="catid" value="<?php echo $catid ?>" />
3137 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
3144 * @todo document this
3146 function action_categorydeleteconfirm() {
3147 global $member, $manager;
3149 $blogid = intRequestVar('blogid');
3150 $catid = intRequestVar('catid');
3152 $member->blogAdminRights($blogid) or $this->disallow();
3154 $error = $this->deleteOneCategory($catid);
3156 $this->error($error);
3158 $this->action_blogsettings();
3162 * Admin::deleteOneCategory()
3163 * Delete a category by its id
3165 * @param String $catid category id for deleting
3168 function deleteOneCategory($catid)
3170 global $manager, $member;
3172 $catid = intval($catid);
3173 $blogid = getBlogIDFromCatID($catid);
3175 if ( !$member->blogAdminRights($blogid) )
3177 return ERROR_DISALLOWED;
3181 $blog =& $manager->getBlog($blogid);
3183 // check if the category is valid
3184 if ( !$blog || !$blog->isValidCategory($catid) )
3186 return _ERROR_NOSUCHCATEGORY;
3189 $destcatid = $blog->getDefaultCategory();
3191 // don't allow deletion of default category
3192 if ( $blog->getDefaultCategory() == $catid )
3194 return _ERROR_DELETEDEFCATEGORY;
3197 // check if catid is the only category left for blogid
3198 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
3199 $res = DB::getResult($query);
3200 if ( $res->rowCount() == 1 )
3202 return _ERROR_DELETELASTCATEGORY;
3205 $manager->notify('PreDeleteCategory', array('catid' => $catid));
3207 // change category for all items to the default category
3208 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
3209 DB::execute($query);
3211 // delete all associated plugin options
3212 NucleusPlugin::delete_option_values('category', $catid);
3215 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
3216 DB::execute($query);
3218 $manager->notify('PostDeleteCategory', array('catid' => $catid));
3223 * Admin::action_blogsettingsupdate
3224 * Updating blog settings
3229 function action_blogsettingsupdate()
3231 global $member, $manager;
3233 $blogid = intRequestVar('blogid');
3235 $member->blogAdminRights($blogid) or $this->disallow();
3237 $blog =& $manager->getBlog($blogid);
3239 $notify_address = trim(postVar('notify'));
3240 $shortname = trim(postVar('shortname'));
3241 $updatefile = trim(postVar('update'));
3243 $notifyComment = intPostVar('notifyComment');
3244 $notifyVote = intPostVar('notifyVote');
3245 $notifyNewItem = intPostVar('notifyNewItem');
3247 if ( $notifyComment == 0 )
3251 if ( $notifyVote == 0 )
3255 if ( $notifyNewItem == 0 )
3259 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3261 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
3263 $this->error(_ERROR_BADNOTIFY);
3266 if ( !isValidShortName($shortname) )
3268 $this->error(_ERROR_BADSHORTBLOGNAME);
3271 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
3273 $this->error(_ERROR_DUPSHORTBLOGNAME);
3275 // check if update file is writable
3276 if ( $updatefile && !is_writeable($updatefile) )
3278 $this->error(_ERROR_UPDATEFILE);
3281 $blog->setName(trim(postVar('name')));
3282 $blog->setShortName($shortname);
3283 $blog->setNotifyAddress($notify_address);
3284 $blog->setNotifyType($notifyType);
3285 $blog->setMaxComments(postVar('maxcomments'));
3286 $blog->setCommentsEnabled(postVar('comments'));
3287 $blog->setTimeOffset(postVar('timeoffset'));
3288 $blog->setUpdateFile($updatefile);
3289 $blog->setURL(trim(postVar('url')));
3290 $blog->setDefaultSkin(intPostVar('defskin'));
3291 $blog->setDescription(trim(postVar('desc')));
3292 $blog->setPublic(postVar('public'));
3293 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3294 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3295 $blog->setDefaultCategory(intPostVar('defcat'));
3296 $blog->setSearchable(intPostVar('searchable'));
3297 $blog->setEmailRequired(intPostVar('reqemail'));
3298 $blog->writeSettings();
3300 // store plugin options
3301 $aOptions = requestArray('plugoption');
3302 NucleusPlugin::apply_plugin_options($aOptions);
3303 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3305 $this->action_overview(_MSG_SETTINGSCHANGED);
3310 * @todo document this
3312 function action_deleteblog() {
3313 global $member, $CONF, $manager;
3315 $blogid = intRequestVar('blogid');
3317 $member->blogAdminRights($blogid) or $this->disallow();
3319 // check if blog is default blog
3320 if ($CONF['DefaultBlog'] == $blogid)
3321 $this->error(_ERROR_DELDEFBLOG);
3323 $blog =& $manager->getBlog($blogid);
3327 <h2><?php echo _DELETE_CONFIRM ?></h2>
3329 <p><?php echo _WARNINGTXT_BLOGDEL ?>
3333 <?php echo _CONFIRMTXT_BLOG ?><b><?php echo Entity::hsc($blog->getName()) ?></b>
3336 <form method="post" action="index.php"><div>
3337 <input type="hidden" name="action" value="deleteblogconfirm" />
3338 <?php $manager->addTicketHidden() ?>
3339 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3340 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
3347 * Admin::action_deleteblogconfirm()
3353 function action_deleteblogconfirm()
3355 global $member, $CONF, $manager;
3357 $blogid = intRequestVar('blogid');
3358 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3359 $member->blogAdminRights($blogid) or $this->disallow();
3361 // check if blog is default blog
3362 if ( $CONF['DefaultBlog'] == $blogid )
3364 $this->error(_ERROR_DELDEFBLOG);
3367 // delete all comments
3368 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3369 DB::execute($query);
3372 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3373 DB::execute($query);
3375 // delete all team members
3376 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3377 DB::execute($query);
3380 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3381 DB::execute($query);
3383 // delete all categories
3384 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3385 DB::execute($query);
3387 // delete all associated plugin options
3388 NucleusPlugin::delete_option_values('blog', $blogid);
3390 // delete the blog itself
3391 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3392 DB::execute($query);
3394 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3396 $this->action_overview(_DELETED_BLOG);
3401 * @todo document this
3403 function action_memberdelete() {
3404 global $member, $manager;
3406 $memberid = intRequestVar('memberid');
3408 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3410 $mem = Member::createFromID($memberid);
3414 <h2><?php echo _DELETE_CONFIRM ?></h2>
3416 <p><?php echo _CONFIRMTXT_MEMBER ?><b><?php echo Entity::hsc($mem->getDisplayName()) ?></b>
3420 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3423 <form method="post" action="index.php"><div>
3424 <input type="hidden" name="action" value="memberdeleteconfirm" />
3425 <?php $manager->addTicketHidden() ?>
3426 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3427 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
3434 * @todo document this
3436 function action_memberdeleteconfirm() {
3439 $memberid = intRequestVar('memberid');
3441 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3443 $error = $this->deleteOneMember($memberid);
3445 $this->error($error);
3447 if ($member->isAdmin())
3448 $this->action_usermanagement();
3450 $this->action_overview(_DELETED_MEMBER);
3454 * Admin::deleteOneMember()
3455 * Delete a member by id
3458 * @params Integer $memberid member id
3459 * @return String null string or error messages
3461 function deleteOneMember($memberid)
3465 $memberid = intval($memberid);
3466 $mem = Member::createFromID($memberid);
3468 if ( !$mem->canBeDeleted() )
3470 return _ERROR_DELETEMEMBER;
3473 $manager->notify('PreDeleteMember', array('member' => &$mem));
3475 /* unlink comments from memberid */
3478 $query = "UPDATE %s SET cmember=0, cuser=%s WHERE cmember=%d";
3479 $query = sprintf($query, sql_table('comment'), DB::quoteValue($mem->getDisplayName()), $memberid);
3480 DB::execute($query);
3483 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3484 DB::execute($query);
3486 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3487 DB::execute($query);
3489 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3490 DB::execute($query);
3492 // delete all associated plugin options
3493 NucleusPlugin::delete_option_values('member', $memberid);
3495 $manager->notify('PostDeleteMember', array('member' => &$mem));
3501 * @todo document this
3503 function action_createnewlog() {
3504 global $member, $CONF, $manager;
3506 // Only Super-Admins can do this
3507 $member->isAdmin() or $this->disallow();
3511 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3513 <h2><?php echo _EBLOG_CREATE_TITLE ?></h2>
3515 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3517 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3519 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3522 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3523 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3526 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3529 <?php echo _EBLOG_CREATE_TEXT ?>
3532 <form method="post" action="index.php"><div>
3534 <input type="hidden" name="action" value="addnewlog" />
3535 <?php $manager->addTicketHidden() ?>
3539 <td><?php echo _EBLOG_NAME ?></td>
3540 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3542 <td><?php echo _EBLOG_SHORTNAME ?>
3543 <?php help('shortblogname'); ?>
3545 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3547 <td><?php echo _EBLOG_DESC ?></td>
3548 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3550 <td><?php echo _EBLOG_DEFSKIN ?>
3551 <?php help('blogdefaultskin'); ?>
3555 $query = 'SELECT sdname as text, sdnumber as value'
3556 . ' FROM '.sql_table('skin_desc');
3557 $template['name'] = 'defskin';
3558 $template['tabindex'] = 50;
3559 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3560 showlist($query,'select',$template);
3564 <td><?php echo _EBLOG_OFFSET ?>
3565 <?php help('blogtimeoffset'); ?>
3566 <br /><?php echo _EBLOG_STIME ?> <b><?php echo i18n::formatted_datetime('%H:%M',time()); ?></b>
3568 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3570 <td><?php echo _EBLOG_ADMIN ?>
3571 <?php help('teamadmin'); ?>
3573 <td><?php echo _EBLOG_ADMIN_MSG ?></td>
3575 <td><?php echo _EBLOG_CREATE ?></td>
3576 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
3585 * @todo document this
3587 function action_addnewlog() {
3588 global $member, $manager, $CONF;
3590 // Only Super-Admins can do this
3591 $member->isAdmin() or $this->disallow();
3593 $bname = trim(postVar('name'));
3594 $bshortname = trim(postVar('shortname'));
3595 $btimeoffset = postVar('timeoffset');
3596 $bdesc = trim(postVar('desc'));
3597 $bdefskin = postVar('defskin');
3599 if (!isValidShortName($bshortname))
3600 $this->error(_ERROR_BADSHORTBLOGNAME);
3602 if ($manager->existsBlog($bshortname))
3603 $this->error(_ERROR_DUPSHORTBLOGNAME);
3609 'shortname' => &$bshortname,
3610 'timeoffset' => &$btimeoffset,
3611 'description' => &$bdesc,
3612 'defaultskin' => &$bdefskin
3618 $query = sprintf('INSERT INTO %s (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES (%s, %s, %s, %s, %s)',
3620 DB::quoteValue($bname),
3621 DB::quoteValue($bshortname),
3622 DB::quoteValue($bdesc),
3623 DB::quoteValue($btimeoffset),
3624 DB::quoteValue($bdefskin)
3626 DB::execute($query);
3627 $blogid = DB::getInsertId();
3628 $blog =& $manager->getBlog($blogid);
3630 // create new category
3631 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3632 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3633 $query = sprintf('INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, %s, %s)',
3634 sql_table('category'),
3636 DB::quoteValue($catdefname),
3637 DB::quoteValue($catdefdesc)
3639 DB::execute($query);
3640 $catid = DB::getInsertId();
3642 // set as default category
3643 $blog->setDefaultCategory($catid);
3644 $blog->writeSettings();
3646 // create team member
3647 $memberid = $member->getID();
3648 $query = sprintf('INSERT INTO %s (tmember, tblog, tadmin) VALUES (%d, %d, 1)', sql_table('team'), $memberid, $blogid);
3649 DB::execute($query);
3651 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3652 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3654 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3668 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3669 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3676 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3678 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, Entity::hsc($bname)) ?></p>
3681 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, Entity::hsc($bshortname)) ?></a></li>
3682 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3685 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, Entity::hsc($bshortname)) ?></a></h3>
3687 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, Entity::hsc($bshortname)) ?></p>
3690 $CONF['Self'] = '<b><?php echo Entity::hsc($bshortname) ?>.php</b>';
3692 include('<i>./config.php</i>');
3694 selectBlog('<b><?php echo Entity::hsc($bshortname) ?></b>');
3699 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3701 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3703 <form action="index.php" method="post"><div>
3704 <input type="hidden" name="action" value="addnewlog2" />
3705 <?php $manager->addTicketHidden() ?>
3706 <input type="hidden" name="blogid" value="<?php echo intval($blogid) ?>" />
3708 <td><?php echo _EBLOG_URL ?></td>
3709 <td><input name="url" maxlength="100" size="40" value="<?php echo Entity::hsc($CONF['IndexURL'].$bshortname.'.php') ?>" /></td>
3711 <td><?php echo _EBLOG_CREATE ?></td>
3712 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
3716 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3718 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3720 <form action="index.php" method="post"><div>
3721 <input type="hidden" name="action" value="addnewlog2" />
3722 <?php $manager->addTicketHidden() ?>
3723 <input type="hidden" name="blogid" value="<?php echo intval($blogid) ?>" />
3725 <td><?php echo _EBLOG_URL ?></td>
3726 <td><input name="url" maxlength="100" size="40" /></td>
3728 <td><?php echo _EBLOG_CREATE ?></td>
3729 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
3733 <?php $this->pagefoot();
3738 * @todo document this
3740 function action_addnewlog2() {
3741 global $member, $manager;
3743 $member->blogAdminRights($blogid) or $this->disallow();
3745 $burl = requestVar('url');
3746 $blogid = intRequestVar('blogid');
3748 $blog =& $manager->getBlog($blogid);
3749 $blog->setURL(trim($burl));
3750 $blog->writeSettings();
3752 $this->action_overview(_MSG_NEWBLOG);
3756 * @todo document this
3758 function action_skinieoverview() {
3759 global $member, $DIR_LIBS, $manager;
3761 $member->isAdmin() or $this->disallow();
3763 // load skinie class
3764 include_once($DIR_LIBS . 'skinie.php');
3768 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3771 <h2><?php echo _SKINIE_TITLE_IMPORT ?></h2>
3773 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL ?></label>
3774 <?php global $DIR_SKINS;
3776 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
3778 if (sizeof($candidates) > 0) {
3780 <form method="post" action="index.php"><div>
3781 <input type="hidden" name="action" value="skinieimport" />
3782 <?php $manager->addTicketHidden() ?>
3783 <input type="hidden" name="mode" value="file" />
3784 <select name="skinfile" id="skinie_import_local">
3785 <?php foreach ($candidates as $skinname => $skinfile) {
3786 $html = Entity::hsc($skinfile);
3787 echo '<option value="',$html,'">',$skinname,'</option>';
3791 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT ?>" />
3794 echo _SKINIE_NOCANDIDATES;
3799 <p><em><?php echo _OR ?></em></p>
3801 <form method="post" action="index.php"><p>
3802 <?php $manager->addTicketHidden() ?>
3803 <input type="hidden" name="action" value="skinieimport" />
3804 <input type="hidden" name="mode" value="url" />
3805 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL ?></label>
3806 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3807 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT ?>" />
3811 <h2><?php echo _SKINIE_TITLE_EXPORT ?></h2>
3812 <form method="post" action="index.php"><div>
3813 <input type="hidden" name="action" value="skinieexport" />
3814 <?php $manager->addTicketHidden() ?>
3816 <p><?php echo _SKINIE_EXPORT_INTRO ?></p>
3819 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS ?></th>
3821 <?php // show list of skins
3822 $res = DB::getResult('SELECT * FROM '.sql_table('skin_desc'));
3823 foreach ( $res as $row) {
3824 $id = 'skinexp' . $row['sdnumber'];
3825 echo '<td><input type="checkbox" name="skin[',$row['sdnumber'],']" id="',$id,'" />';
3826 echo '<label for="',$id,'">',Entity::hsc($row['sdname']),'</label></td>';
3827 echo '<td>',Entity::hsc($row['sddesc']),'</td>';
3831 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3833 // show list of templates
3834 $res = DB::getResult('SELECT * FROM '.sql_table('template_desc'));
3835 foreach ( $res as $row ) {
3836 $id = 'templateexp' . $row['tdnumber'];
3837 echo '<td><input type="checkbox" name="template[',$row['tdnumber'],']" id="',$id,'" />';
3838 echo '<label for="',$id,'">',Entity::hsc($row['tdname']),'</label></td>';
3839 echo '<td>',Entity::hsc($row['tddesc']),'</td>';
3844 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA ?></th>
3846 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3848 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT ?></th>
3850 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT ?>" /></td>
3860 * @todo document this
3862 function action_skinieimport() {
3863 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3865 $member->isAdmin() or $this->disallow();
3867 // load skinie class
3868 include_once($DIR_LIBS . 'skinie.php');
3870 $skinFileRaw= postVar('skinfile');
3871 $mode = postVar('mode');
3873 $importer = new SkinImport();
3875 // get full filename
3876 if ($mode == 'file')
3878 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3880 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3881 if (!file_exists($skinFile))
3882 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3884 $skinFile = $skinFileRaw;
3887 // read only metadata
3888 $error = $importer->readFile($skinFile, 1);
3891 $skinNameClashes = $importer->checkSkinNameClashes();
3892 $templateNameClashes = $importer->checkTemplateNameClashes();
3893 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3895 if ($error) $this->error($error);
3899 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3901 <h2><?php echo _SKINIE_CONFIRM_TITLE ?></h2>
3904 <li><p><strong><?php echo _SKINIE_INFO_GENERAL ?></strong> <?php echo Entity::hsc($importer->getInfo()) ?></p></li>
3905 <li><p><strong><?php echo _SKINIE_INFO_SKINS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames()) ?></p></li>
3906 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames()) ?></p></li>
3908 if ($hasNameClashes)
3911 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes) ?></p></li>
3912 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes) ?></p></li>
3914 } // if (hasNameClashes)
3918 <form method="post" action="index.php"><div>
3919 <input type="hidden" name="action" value="skiniedoimport" />
3920 <?php $manager->addTicketHidden() ?>
3921 <input type="hidden" name="skinfile" value="<?php echo Entity::hsc(postVar('skinfile')) ?>" />
3922 <input type="hidden" name="mode" value="<?php echo Entity::hsc($mode) ?>" />
3923 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT ?>" />
3925 if ($hasNameClashes)
3929 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE ?></label>
3931 } // if (hasNameClashes)
3941 * @todo document this
3943 function action_skiniedoimport() {
3944 global $member, $DIR_LIBS, $DIR_SKINS;
3946 $member->isAdmin() or $this->disallow();
3948 // load skinie class
3949 include_once($DIR_LIBS . 'skinie.php');
3951 $skinFileRaw= postVar('skinfile');
3952 $mode = postVar('mode');
3954 $allowOverwrite = intPostVar('overwrite');
3956 // get full filename
3957 if ($mode == 'file')
3959 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3961 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3962 if (!file_exists($skinFile))
3963 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3966 $skinFile = $skinFileRaw;
3969 $importer = new SkinImport();
3971 $error = $importer->readFile($skinFile);
3974 $this->error($error);
3976 $error = $importer->writeToDatabase($allowOverwrite);
3979 $this->error($error);
3983 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3985 <h2><?php echo _SKINIE_DONE ?></h2>
3988 <li><p><strong><?php echo _SKINIE_INFO_GENERAL ?></strong> <?php echo Entity::hsc($importer->getInfo()) ?></p></li>
3989 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames()) ?></p></li>
3990 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS ?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames()) ?></p></li>
3993 <?php $this->pagefoot();
3998 * @todo document this
4000 function action_skinieexport() {
4001 global $member, $DIR_LIBS;
4003 $member->isAdmin() or $this->disallow();
4005 // load skinie class
4006 include_once($DIR_LIBS . 'skinie.php');
4008 $aSkins = requestIntArray('skin');
4009 $aTemplates = requestIntArray('template');
4011 if (!is_array($aTemplates)) $aTemplates = array();
4012 if (!is_array($aSkins)) $aSkins = array();
4014 $skinList = array_keys($aSkins);
4015 $templateList = array_keys($aTemplates);
4017 $info = postVar('info');
4019 $exporter = new SkinExport();
4020 foreach ($skinList as $skinId) {
4021 $exporter->addSkin($skinId);
4023 foreach ($templateList as $templateId) {
4024 $exporter->addTemplate($templateId);
4026 $exporter->setInfo($info);
4028 $exporter->export();
4032 * @todo document this
4034 function action_templateoverview() {
4035 global $member, $manager;
4037 $member->isAdmin() or $this->disallow();
4041 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4043 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
4044 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
4046 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
4047 $template['content'] = 'templatelist';
4048 $template['tabindex'] = 10;
4049 showlist($query,'table',$template);
4051 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
4054 <form method="post" action="index.php"><div>
4056 <input name="action" value="templatenew" type="hidden" />
4057 <?php $manager->addTicketHidden() ?>
4059 <td><?php echo _TEMPLATE_NAME ?> <?php help('shortnames'); ?></td>
4060 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4062 <td><?php echo _TEMPLATE_DESC ?></td>
4063 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4065 <td><?php echo _TEMPLATE_CREATE ?></td>
4066 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN ?>" onclick="return checkSubmit();" /></td>
4076 * @todo document this
4078 function action_templateedit($msg = '') {
4079 global $member, $manager;
4081 $templateid = intRequestVar('templateid');
4083 $member->isAdmin() or $this->disallow();
4085 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
4086 $extrahead .= '<script type="text/javascript">setTemplateEditText('.DB::quoteValue(_EDITTEMPLATE_EMPTY).');</script>';
4088 $this->pagehead($extrahead);
4090 $templatename = Template::getNameFromId($templateid);
4091 $templatedescription = Template::getDesc($templateid);
4092 $template =& $manager->getTemplate($templatename);
4096 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK ?>)</a>
4099 <h2><?php echo _TEMPLATE_EDIT_TITLE ?> '<?php echo Entity::hsc($templatename); ?>'</h2>
4101 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4104 <p><?php echo _TEMPLATE_EDIT_MSG ?></p>
4106 <form method="post" action="index.php">
4109 <input type="hidden" name="action" value="templateupdate" />
4110 <?php $manager->addTicketHidden() ?>
4111 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
4114 <th colspan="2"><?php echo _TEMPLATE_SETTINGS ?></th>
4116 <td><?php echo _TEMPLATE_NAME ?> <?php help('shortnames'); ?></td>
4117 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo Entity::hsc($templatename) ?>" /></td>
4119 <td><?php echo _TEMPLATE_DESC ?></td>
4120 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo Entity::hsc($templatedescription) ?>" /></td>
4122 <th colspan="2"><?php echo _TEMPLATE_UPDATE ?></th>
4124 <td><?php echo _TEMPLATE_UPDATE ?></td>
4126 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN ?>" onclick="return checkSubmit();" />
4127 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN ?>" />
4130 <th colspan="2"><?php echo _TEMPLATE_ITEMS ?> <?php help('templateitems'); ?></th>
4131 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
4132 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
4133 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
4134 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
4135 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
4136 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
4139 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY ?> <?php help('templatecomments'); ?></th>
4140 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
4141 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
4142 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
4143 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
4144 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
4145 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
4146 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
4149 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE ?> <?php help('templatecomments'); ?></th>
4151 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
4154 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH ?> <?php help('templatecomments'); ?></th>
4155 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
4158 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST ?> <?php help('templatearchivelists'); ?></th>
4159 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
4160 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
4161 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
4164 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST ?> <?php help('templatebloglists'); ?></th>
4165 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
4166 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
4167 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
4170 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST ?> <?php help('templatecategorylists'); ?></th>
4171 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
4172 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
4173 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
4176 <th colspan="2"><?php echo _TEMPLATE_DATETIME ?></th>
4177 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
4178 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
4179 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
4180 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
4181 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
4184 <th colspan="2"><?php echo _TEMPLATE_IMAGE ?> <?php help('templatepopups'); ?></th>
4185 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
4186 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
4187 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
4190 <th colspan="2"><?php echo _TEMPLATE_SEARCH ?></th>
4191 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
4192 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
4195 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS ?></th>
4198 $pluginfields = array();
4199 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4201 foreach ($pluginfields as $pfkey=>$pfvalue) {
4203 echo '<th colspan="2">' . Entity::hen($pfkey) . "</th>\n";
4204 foreach ($pfvalue as $pffield=>$pfdesc) {
4205 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
4210 <th colspan="2"><?php echo _TEMPLATE_UPDATE ?></th>
4212 <td><?php echo _TEMPLATE_UPDATE ?></td>
4214 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN ?>" onclick="return checkSubmit();" />
4215 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN ?>" />
4226 * @todo document this
4228 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
4230 if (!isset($template[$name])) $template[$name] = '';
4233 <td><?php echo $description ?> <?php if ($help) help('template'.$help); ?></td>
4234 <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>
4239 * @todo document this
4241 function action_templateupdate() {
4242 global $member,$manager;
4244 $templateid = intRequestVar('templateid');
4246 $member->isAdmin() or $this->disallow();
4248 $name = postVar('tname');
4249 $desc = postVar('tdesc');
4251 if (!isValidTemplateName($name))
4252 $this->error(_ERROR_BADTEMPLATENAME);
4254 if ((Template::getNameFromId($templateid) != $name) && Template::exists($name))
4255 $this->error(_ERROR_DUPTEMPLATENAME);
4258 $name = DB::quoteValue($name);
4259 $desc = DB::quoteValue($desc);
4261 // 1. Remove all template parts
4262 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4263 DB::execute($query);
4265 // 2. Update description
4266 $query = 'UPDATE '.sql_table('template_desc').' SET'
4267 . ' tdname=' . $name . ','
4268 . ' tddesc=' . $desc
4269 . ' WHERE tdnumber=' . $templateid;
4270 DB::execute($query);
4272 // 3. Add non-empty template parts
4273 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4274 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4275 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4276 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4277 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4278 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4279 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4280 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4281 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4282 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4283 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4284 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4285 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4286 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4287 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4288 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4289 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4290 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4291 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4292 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4293 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4294 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4295 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4296 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4297 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4298 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4299 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4300 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4301 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4302 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4303 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4304 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4305 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4306 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4308 $pluginfields = array();
4309 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4310 foreach ($pluginfields as $pfkey=>$pfvalue) {
4311 foreach ($pfvalue as $pffield=>$pfdesc) {
4312 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4316 // jump back to template edit
4317 $this->action_templateedit(_TEMPLATE_UPDATED);
4322 * Admin::addToTemplate()
4324 * @param Integer $id ID for template
4325 * @param String $partname parts name
4326 * @param String $content template contents
4327 * @return Integer record index
4330 function addToTemplate($id, $partname, $content)
4332 // don't add empty parts:
4333 if ( !trim($content) )
4338 $partname = DB::quoteValue($partname);
4339 $content = DB::quoteValue($content);
4341 $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, %s, %s)";
4342 $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
4343 if ( DB::execute($query) === FALSE )
4345 $err = DB::getError();
4346 exit(_ADMIN_SQLDIE_QUERYERROR . $err[2]);
4348 return DB::getInsertId();
4352 * @todo document this
4354 function action_templatedelete() {
4355 global $member, $manager;
4357 $member->isAdmin() or $this->disallow();
4359 $templateid = intRequestVar('templateid');
4360 // TODO: check if template can be deleted
4364 $name = Template::getNameFromId($templateid);
4365 $desc = Template::getDesc($templateid);
4368 <h2><?php echo _DELETE_CONFIRM ?></h2>
4371 <?php echo _CONFIRMTXT_TEMPLATE ?><b><?php echo Entity::hsc($name) ?></b> (<?php echo Entity::hsc($desc) ?>)
4374 <form method="post" action="index.php"><div>
4375 <input type="hidden" name="action" value="templatedeleteconfirm" />
4376 <?php $manager->addTicketHidden() ?>
4377 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4378 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
4385 * @todo document this
4387 function action_templatedeleteconfirm() {
4388 global $member, $manager;
4390 $templateid = intRequestVar('templateid');
4392 $member->isAdmin() or $this->disallow();
4394 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4396 // 1. delete description
4397 DB::execute('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4400 DB::execute('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4402 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4404 $this->action_templateoverview();
4408 * @todo document this
4410 function action_templatenew() {
4413 $member->isAdmin() or $this->disallow();
4415 $name = postVar('name');
4416 $desc = postVar('desc');
4418 if (!isValidTemplateName($name))
4419 $this->error(_ERROR_BADTEMPLATENAME);
4421 if (Template::exists($name))
4422 $this->error(_ERROR_DUPTEMPLATENAME);
4424 $newTemplateId = Template::createNew($name, $desc);
4426 $this->action_templateoverview();
4430 * @todo document this
4432 function action_templateclone() {
4435 $templateid = intRequestVar('templateid');
4437 $member->isAdmin() or $this->disallow();
4439 // 1. read old template
4440 $name = Template::getNameFromId($templateid);
4441 $desc = Template::getDesc($templateid);
4443 // 2. create desc thing
4444 $name = "cloned" . $name;
4446 // if a template with that name already exists:
4447 if (Template::exists($name)) {
4449 while (Template::exists($name . $i))
4454 $newid = Template::createNew($name, $desc);
4457 // go through parts of old template and add them to the new one
4458 $res = DB::getResult('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4459 foreach ( $res as $row ) {
4460 $this->addToTemplate($newid, $row['tpartname'], $row['tcontent']);
4463 $this->action_templateoverview();
4467 * Admin::action_skinoverview()
4472 public function action_skinoverview()
4474 global $member, $manager;
4476 $member->isAdmin() or $this->disallow();
4480 echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
4481 echo '<h2>' . _SKIN_EDIT_TITLE . "</h2>\n";
4482 echo '<h3>' . _SKIN_AVAILABLE_TITLE . "</h3>\n";
4484 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;';
4485 $template['content'] = 'skinlist';
4486 $template['tabindex'] = 10;
4488 showlist($query,'table',$template);
4490 echo '<h3>' . _SKIN_NEW_TITLE . "</h3>\n";
4491 echo "<form method=\"post\" action=\"index.php\">\n";
4493 echo "<input name=\"action\" value=\"skinnew\" type=\"hidden\" />\n";
4495 $manager->addTicketHidden() . "\n";
4497 echo "<table frame=\"box\" rules=\"all\" summary=\"skinoverview\">\n";
4499 echo "<td>" . _SKIN_NAME;
4500 echo help('shortnames');
4502 echo "<td><input name=\"name\" tabindex=\"10010\" maxlength=\"20\" size=\"20\" /></td>\n";
4505 echo "<td>" . _SKIN_DESC . "</td>\n";
4506 echo "<td><input name=\"desc\" tabindex=\"10020\" maxlength=\"200\" size=\"50\" /></td>\n";
4509 echo '<td>' . _SKIN_CREATE . "</td>\n";
4510 echo '<td><input type="submit" tabindex="10030" value="' . _SKIN_CREATE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
4522 * @todo document this
4524 function action_skinnew() {
4527 $member->isAdmin() or $this->disallow();
4529 $name = trim(postVar('name'));
4530 $desc = trim(postVar('desc'));
4532 if (!isValidSkinName($name))
4533 $this->error(_ERROR_BADSKINNAME);
4535 if (Skin::exists($name))
4536 $this->error(_ERROR_DUPSKINNAME);
4538 $newId = Skin::createNew($name, $desc);
4540 $this->action_skinoverview();
4544 * Admin::action_skinedit()
4548 public function action_skinedit()
4550 global $member, $manager;
4552 $skinid = intRequestVar('skinid');
4554 $member->isAdmin() or $this->disallow();
4556 $skin = new SKIN($skinid);
4557 $default_skin_types = $skin->getDefaultTypes();
4558 $available_skin_types = $skin->getAvailableTypes();
4563 echo '( <a href="index.php?action=skinoverview">' . _SKIN_BACK . "</a> )";
4565 echo '<h2>' . _SKIN_EDITONE_TITLE . $skin->getName() . "</h2>\n";
4567 echo '<h3>' . _SKIN_PARTS_TITLE . "</h3>\n";
4568 echo _SKIN_PARTS_MSG . "\n";
4572 foreach ( $default_skin_types as $type => $friendly_name )
4575 echo "<a tabindex=\"{$tabindex}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type={$type}\">";
4576 echo $friendly_name;
4578 help("skinpart{$type}");
4584 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4585 echo "<form method=\"get\" action=\"index.php\">\n";
4586 echo "<input type=\"hidden\" name=\"action\" value=\"skinedittype\" />\n";
4587 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4588 echo "<input type=\"text\" name=\"type\" tabindex=\"89\" size=\"20\" maxlength=\"20\" />\n";
4589 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . "\" onclick=\"return checkSubmit();\" />\n";
4592 /* NOTE: special skin parts has FALSE in its value */
4593 if ( in_array(FALSE, array_values($available_skin_types)) )
4598 foreach ( $available_skin_types as $type => $friendly_name )
4600 if ( !$friendly_name )
4604 echo "<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
4605 echo Entity::hsc(ucfirst($type));
4608 echo "(<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinremovetype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
4617 echo '<h3>' . _SKIN_GENSETTINGS_TITLE . "</h3>\n";
4618 echo "<form method=\"post\" action=\"index.php\">\n";
4620 echo "<input type=\"hidden\" name=\"action\" value=\"skineditgeneral\" />\n";
4621 $manager->addTicketHidden() . "\n";
4622 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4624 echo '<table frame="box" rules="all" summary="' . _SKIN_GENSETTINGS_TITLE . '">' . "\n";
4630 echo '<td><input type="text" name="name" tabindex="90" value="' . Entity::hsc($skin->getName()) . '" maxlength="20" size="20" />' . "</td>\n";
4633 echo '<td>' . _SKIN_DESC . "</td>\n";
4634 echo '<td><input type="text" name="desc" tabindex="100" value="' . Entity::hsc($skin->getDescription()) . '" maxlength="200" size="50" />' . "</td>\n";
4637 echo '<td>' . _SKIN_TYPE . "</td>\n";
4638 echo '<td><input type="text" name="type" tabindex="110" value="' . Entity::hsc($skin->getContentType()) . '" maxlength="40" size="20" />' . "</td>\n";
4642 echo _SKIN_INCLUDE_MODE;
4643 help('includemode');
4646 $this->input_yesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
4651 echo _SKIN_INCLUDE_PREFIX;
4652 help('includeprefix');
4654 echo '<td><input type="text" name="inc_prefix" tabindex="130" value="' . Entity::hsc($skin->getIncludePrefix()) . '" maxlength="40" size="20" />' . "</td>\n";
4657 echo '<td>' . _SKIN_CHANGE . "</td>\n";
4658 echo '<td><input type="submit" tabindex="140" value="' . _SKIN_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
4669 * @todo document this
4671 function action_skineditgeneral() {
4674 $skinid = intRequestVar('skinid');
4676 $member->isAdmin() or $this->disallow();
4678 $name = postVar('name');
4679 $desc = postVar('desc');
4680 $type = postVar('type');
4681 $inc_mode = postVar('inc_mode');
4682 $inc_prefix = postVar('inc_prefix');
4684 $skin = new SKIN($skinid);
4687 if (!isValidSkinName($name))
4688 $this->error(_ERROR_BADSKINNAME);
4690 if (($skin->getName() != $name) && Skin::exists($name))
4691 $this->error(_ERROR_DUPSKINNAME);
4693 if (!$type) $type = 'text/html';
4694 if (!$inc_mode) $inc_mode = 'normal';
4696 // 2. Update description
4697 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4699 $this->action_skinedit();
4704 * Admin::action_skinedittype()
4706 * @param string $msg message for pageheader
4709 public function action_skinedittype($msg = '')
4711 global $member, $manager;
4713 $skinid = intRequestVar('skinid');
4714 $type = requestVar('type');
4716 $member->isAdmin() or $this->disallow();
4718 $type = trim($type);
4719 $type = strtolower($type);
4721 if ( !isValidShortName($type) )
4723 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4726 $skin = new SKIN($skinid);
4727 $skin_types = $skin->getAvailableTypes();
4728 if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
4730 $friendlyName = ucfirst($type);
4734 $friendlyName = $skin_types[$type];
4739 echo '<p>(<a href="index.php?action=skinoverview">' . _SKIN_GOBACK . "</a>)</p>\n";
4741 echo '<h2>' . _SKIN_EDITPART_TITLE . " '" . Entity::hsc($skin->getName()) . "': " . Entity::hsc($friendlyName) . "</h2>\n";
4745 echo "<p>" . _MESSAGE . ": $msg</p>\n";
4748 echo "<form method=\"post\" action=\"index.php\">\n";
4751 echo "<input type=\"hidden\" name=\"action\" value=\"skinupdate\" />\n";
4752 $manager->addTicketHidden() . "\n";
4753 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4754 echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\" />\n";
4756 echo '<input type="submit" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
4757 echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
4758 echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
4760 if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
4762 help('skinpartspecial');
4766 help('skinpart' . $type);
4770 echo "<textarea class=\"skinedit\" tabindex=\"10\" rows=\"20\" cols=\"80\" name=\"content\">\n";
4771 echo Entity::hsc($skin->getContent($type)) . "\n";
4772 echo "</textarea>\n";
4775 echo '<input type="submit" tabindex="20" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
4776 echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
4777 echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
4781 echo _SKIN_ALLOWEDVARS;
4783 $actions = $skin->getAllowedActionsForType($type);
4787 while ( $current = array_shift($actions) )
4789 // skip deprecated vars
4790 if ( in_array($current, array('ifcat', 'imagetext', 'vars')) )
4795 echo helplink("skinvar-{$current}") . "{$current}</a>\n";
4797 if ( count($actions) != 0 )
4805 echo _SKINEDIT_ALLOWEDBLOGS;
4807 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4808 showlist($query, 'table', array('content'=>'shortblognames'));
4811 echo _SKINEDIT_ALLOWEDTEMPLATESS;
4813 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4814 showlist($query, 'table', array('content'=>'shortnames'));
4825 * @todo document this
4827 function action_skinupdate() {
4830 $skinid = intRequestVar('skinid');
4831 $content = trim(postVar('content'));
4832 $type = postVar('type');
4834 $member->isAdmin() or $this->disallow();
4836 $skin = new SKIN($skinid);
4837 $skin->update($type, $content);
4839 $this->action_skinedittype(_SKIN_UPDATED);
4843 * @todo document this
4845 function action_skindelete() {
4846 global $member, $manager, $CONF;
4848 $skinid = intRequestVar('skinid');
4850 $member->isAdmin() or $this->disallow();
4852 // don't allow default skin to be deleted
4853 if ($skinid == $CONF['BaseSkin'])
4854 $this->error(_ERROR_DEFAULTSKIN);
4856 // don't allow deletion of default skins for blogs
4857 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4858 $r = DB::getValue($query);
4860 $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($r));
4864 $skin = new SKIN($skinid);
4865 $name = $skin->getName();
4866 $desc = $skin->getDescription();
4869 <h2><?php echo _DELETE_CONFIRM ?></h2>
4872 <?php echo _CONFIRMTXT_SKIN ?><b><?php echo Entity::hsc($name) ?></b> (<?php echo Entity::hsc($desc) ?>)
4875 <form method="post" action="index.php"><div>
4876 <input type="hidden" name="action" value="skindeleteconfirm" />
4877 <?php $manager->addTicketHidden() ?>
4878 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4879 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
4886 * @todo document this
4888 function action_skindeleteconfirm() {
4889 global $member, $CONF, $manager;
4891 $skinid = intRequestVar('skinid');
4893 $member->isAdmin() or $this->disallow();
4895 // don't allow default skin to be deleted
4896 if ($skinid == $CONF['BaseSkin'])
4897 $this->error(_ERROR_DEFAULTSKIN);
4899 // don't allow deletion of default skins for blogs
4900 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4901 $r = DB::getValue($query);
4903 $this->error(_ERROR_SKINDEFDELETE .$r);
4905 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4907 // 1. delete description
4908 DB::execute('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4911 DB::execute('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4913 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4915 $this->action_skinoverview();
4919 * Admin::action_skinremovetype()
4924 public function action_skinremovetype()
4926 global $member, $manager, $CONF;
4928 $skinid = intRequestVar('skinid');
4929 $skintype = requestVar('type');
4931 if ( !isValidShortName($skintype) )
4933 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4936 $member->isAdmin() or $this->disallow();
4938 // don't allow default skinparts to be deleted
4939 $skin = new Skin($skinid);
4940 $default_skin_types = $skin->getDefaultTypes();
4941 if ( array_key_exists($skintype, $default_skin_types) )
4943 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4946 $name = $skin->getName();
4947 $desc = $skin->getDescription();
4951 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
4953 echo _CONFIRMTXT_SKIN_PARTS_SPECIAL;
4954 echo Entity::hsc($skintype);
4955 echo '(' . Entity::hsc($name) . ')</b>';
4956 echo ' (' . Entity::hsc($desc) . ')';
4959 echo "<form method=\"post\" action=\"index.php\">\n";
4961 echo "<input type=\"hidden\" name=\"action\" value=\"skinremovetypeconfirm\" />\n";
4962 $manager->addTicketHidden();
4963 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4964 echo '<input type="hidden" name="type" value="' . Entity::hsc($skintype) . '" />' . "\n";
4965 echo '<input type="submit" tabindex="10" value="' . _DELETE_CONFIRM_BTN . '" />' . "\n";
4973 * Admin::action_skinremovetypeconfirm()
4978 public function action_skinremovetypeconfirm()
4980 global $member, $CONF, $manager;
4982 $skinid = intRequestVar('skinid');
4983 $skintype = requestVar('type');
4985 if ( !isValidShortName($skintype) )
4987 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4990 $member->isAdmin() or $this->disallow();
4992 // don't allow default skinparts to be deleted
4993 $skin = new Skin($skinid);
4994 $default_skin_types = $skin->getDefaultTypes();
4995 if ( array_key_exists($skintype, $default_skin_types) )
4997 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
5001 'skinid' => $skinid,
5002 'skintype' => $skintype
5004 $manager->notify('PreDeleteSkinPart', $data);
5007 $query = "DELETE FROM %s WHERE sdesc=%d AND stype='%s';";
5008 $query = sprintf($query, sql_table('skin'), (integer) $skinid, $skintype);
5009 DB::execute($query);
5012 'skinid' => $skinid,
5013 'skintype' => $skintype
5015 $manager->notify('PostDeleteSkinPart', $data);
5017 $this->action_skinedit();
5022 * @todo document this
5024 function action_skinclone() {
5027 $skinid = intRequestVar('skinid');
5029 $member->isAdmin() or $this->disallow();
5031 // 1. read skin to clone
5032 $skin = new SKIN($skinid);
5034 $name = "clone_" . $skin->getName();
5036 // if a skin with that name already exists:
5037 if (Skin::exists($name)) {
5039 while (Skin::exists($name . $i))
5044 // 2. create skin desc
5045 $newid = Skin::createNew(
5047 $skin->getDescription(),
5048 $skin->getContentType(),
5049 $skin->getIncludeMode(),
5050 $skin->getIncludePrefix()
5053 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
5054 $res = DB::getResult($query);
5055 foreach ( $res as $row) {
5056 $this->skinclonetype($skin, $newid, $row['stype']);
5059 $this->action_skinoverview();
5064 * Admin::skinclonetype()
5066 * @param String $skin Skin object
5067 * @param Integer $newid ID for this clone
5068 * @param String $type type of skin
5071 function skinclonetype($skin, $newid, $type)
5073 $newid = intval($newid);
5074 $content = $skin->getContent($type);
5078 $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
5079 $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
5080 DB::execute($query);
5086 * Admin::action_settingsedit()
5091 function action_settingsedit() {
5092 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
5094 $member->isAdmin() or $this->disallow();
5098 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5101 <h2><?php echo _SETTINGS_TITLE ?></h2>
5103 <form action="index.php" method="post">
5106 <input type="hidden" name="action" value="settingsupdate" />
5107 <?php $manager->addTicketHidden() ?>
5110 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL ?></th>
5112 <td><?php echo _SETTINGS_DEFBLOG ?> <?php help('defaultblog'); ?></td>
5115 $query = 'SELECT bname as text, bnumber as value'
5116 . ' FROM '.sql_table('blog');
5117 $template['name'] = 'DefaultBlog';
5118 $template['selected'] = $CONF['DefaultBlog'];
5119 $template['tabindex'] = 10;
5120 showlist($query,'select',$template);
5124 <td><?php echo _SETTINGS_BASESKIN ?> <?php help('baseskin'); ?></td>
5127 $query = 'SELECT sdname as text, sdnumber as value'
5128 . ' FROM '.sql_table('skin_desc');
5129 $template['name'] = 'BaseSkin';
5130 $template['selected'] = $CONF['BaseSkin'];
5131 $template['tabindex'] = 1;
5132 showlist($query,'select',$template);
5136 <td><?php echo _SETTINGS_ADMINMAIL ?></td>
5137 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo Entity::hsc($CONF['AdminEmail']) ?>" /></td>
5139 <td><?php echo _SETTINGS_SITENAME ?></td>
5140 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo Entity::hsc($CONF['SiteName']) ?>" /></td>
5142 <td><?php echo _SETTINGS_SITEURL ?></td>
5143 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo Entity::hsc($CONF['IndexURL']) ?>" /></td>
5145 <td><?php echo _SETTINGS_ADMINURL ?></td>
5146 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo Entity::hsc($CONF['AdminURL']) ?>" /></td>
5148 <td><?php echo _SETTINGS_PLUGINURL ?> <?php help('pluginurl'); ?></td>
5149 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo Entity::hsc($CONF['PluginURL']) ?>" /></td>
5151 <td><?php echo _SETTINGS_SKINSURL ?> <?php help('skinsurl'); ?></td>
5152 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo Entity::hsc($CONF['SkinsURL']) ?>" /></td>
5154 <td><?php echo _SETTINGS_ACTIONSURL ?> <?php help('actionurl'); ?></td>
5155 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo Entity::hsc($CONF['ActionURL']) ?>" /></td>
5157 <td><?php echo _SETTINGS_LOCALE ?> <?php help('locale'); ?>
5160 <select name="Locale" tabindex="10050">
5162 $locales = i18n::get_available_locale_list();
5163 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
5165 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
5169 echo "<option value=\"\">en_Latn_US</option>\n";
5172 foreach ( $locales as $locale )
5174 if ( $locale == 'en_Latn_US' )
5178 if ( $locale == i18n::get_current_locale() )
5180 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
5184 echo "<option value=\"{$locale}\">{$locale}</option>\n";
5192 <td><?php echo _SETTINGS_DISABLESITE ?> <?php help('disablesite'); ?>
5194 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
5196 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo Entity::hsc($CONF['DisableSiteURL']) ?>" />
5199 <td><?php echo _SETTINGS_DIRS ?></td>
5200 <td><?php echo Entity::hsc($DIR_NUCLEUS) ?>
5201 <i><?php echo _SETTINGS_SEECONFIGPHP ?></i></td>
5203 <td><?php echo _SETTINGS_DBLOGIN ?></td>
5204 <td><i><?php echo _SETTINGS_SEECONFIGPHP ?></i></td>
5208 echo _SETTINGS_JSTOOLBAR
5209 /* =_SETTINGS_DISABLEJS
5211 I temporary changed the meaning of DisableJsTools, until I can find a good
5212 way to select the javascript version to use
5216 1 : all javascript disabled
5217 2 : 'simpler' javascript (for mozilla/opera/mac)
5221 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */ ?>
5222 <select name="DisableJsTools" tabindex="10075">
5223 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
5224 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
5225 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
5226 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
5227 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
5228 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
5233 <td><?php echo _SETTINGS_URLMODE ?> <?php help('urlmode'); ?></td>
5236 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
5237 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
5239 echo ' ', _SETTINGS_URLMODE_HELP;
5245 <td><?php echo _SETTINGS_DEBUGVARS ?> <?php help('debugvars'); ?></td>
5248 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
5254 <td><?php echo _SETTINGS_DEFAULTLISTSIZE ?> <?php help('defaultlistsize'); ?></td>
5257 if (!array_key_exists('DefaultListSize',$CONF)) {
5258 DB::execute("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
5259 $CONF['DefaultListSize'] = 10;
5262 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo Entity::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
5265 <td><?php echo _SETTINGS_ADMINCSS ?>
5269 <select name="AdminCSS" tabindex="10080">
5270 <?php // show a dropdown list of all available admin css files
5271 global $DIR_NUCLEUS;
5273 $dirhandle = opendir($DIR_NUCLEUS."styles/");
5275 while ($filename = readdir($dirhandle) )
5278 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
5279 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
5281 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
5284 $name = $matches[1];
5285 echo "<option value=\"$name\"";
5287 if ($name == $CONF['AdminCSS'])
5289 echo " selected=\"selected\"";
5292 echo ">$name</option>";
5298 closedir($dirhandle);
5305 <th colspan="2"><?php echo _SETTINGS_MEDIA ?> <?php help('media'); ?></th>
5307 <td><?php echo _SETTINGS_MEDIADIR ?></td>
5308 <td><?php echo Entity::hsc($DIR_MEDIA) ?>
5309 <i><?php echo _SETTINGS_SEECONFIGPHP ?></i>
5310 <?php if (!is_dir($DIR_MEDIA))
5311 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
5312 if (!is_readable($DIR_MEDIA))
5313 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
5314 if (!is_writeable($DIR_MEDIA))
5315 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
5319 <td><?php echo _SETTINGS_MEDIAURL ?></td>
5321 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo Entity::hsc($CONF['MediaURL']) ?>" />
5324 <td><?php echo _SETTINGS_ALLOWUPLOAD ?></td>
5325 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
5327 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES ?></td>
5329 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo Entity::hsc($CONF['AllowedTypes']) ?>" />
5332 <td><?php echo _SETTINGS_MAXUPLOADSIZE ?></td>
5334 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo Entity::hsc($CONF['MaxUploadSize']) ?>" />
5337 <td><?php echo _SETTINGS_MEDIAPREFIX ?></td>
5338 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
5341 <th colspan="2"><?php echo _SETTINGS_MEMBERS ?></th>
5343 <td><?php echo _SETTINGS_CHANGELOGIN ?></td>
5344 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
5346 <td><?php echo _SETTINGS_ALLOWCREATE ?>
5347 <?php help('allowaccountcreation'); ?>
5349 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
5352 <td><?php echo _SETTINGS_NEWLOGIN ?> <?php help('allownewmemberlogin'); ?>
5353 <br /><?php echo _SETTINGS_NEWLOGIN2 ?>
5355 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
5358 <td><?php echo _SETTINGS_MEMBERMSGS ?>
5359 <?php help('messageservice'); ?>
5361 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
5364 <td><?php echo _SETTINGS_NONMEMBERMSGS ?>
5365 <?php help('messageservice'); ?>
5367 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5370 <td><?php echo _SETTINGS_PROTECTMEMNAMES ?>
5371 <?php help('protectmemnames'); ?>
5373 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5379 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE ?> <?php help('cookies'); ?></th>
5381 <td><?php echo _SETTINGS_COOKIEPREFIX ?></td>
5382 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo Entity::hsc($CONF['CookiePrefix']) ?>" /></td>
5384 <td><?php echo _SETTINGS_COOKIEDOMAIN ?></td>
5385 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo Entity::hsc($CONF['CookieDomain']) ?>" /></td>
5387 <td><?php echo _SETTINGS_COOKIEPATH ?></td>
5388 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo Entity::hsc($CONF['CookiePath']) ?>" /></td>
5390 <td><?php echo _SETTINGS_COOKIESECURE ?></td>
5391 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5393 <td><?php echo _SETTINGS_COOKIELIFE ?></td>
5394 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5395 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5398 <td><?php echo _SETTINGS_LASTVISIT ?></td>
5399 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5404 <th colspan="2"><?php echo _SETTINGS_UPDATE ?></th>
5406 <td><?php echo _SETTINGS_UPDATE ?></td>
5407 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN ?>" onclick="return checkSubmit();" /></td>
5414 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5417 'GeneralSettingsFormExtras',
5425 * Admin::action_settingsupdate()
5426 * Update $CONFIG and redirect
5431 function action_settingsupdate() {
5432 global $member, $CONF;
5434 $member->isAdmin() or $this->disallow();
5436 // check if email address for admin is valid
5437 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5439 $this->error(_ERROR_BADMAILADDRESS);
5443 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5444 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5445 $this->updateConfig('IndexURL', postVar('IndexURL'));
5446 $this->updateConfig('AdminURL', postVar('AdminURL'));
5447 $this->updateConfig('PluginURL', postVar('PluginURL'));
5448 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5449 $this->updateConfig('ActionURL', postVar('ActionURL'));
5450 $this->updateConfig('Locale', postVar('Locale'));
5451 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5452 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5453 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5454 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5455 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5456 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5457 $this->updateConfig('SiteName', postVar('SiteName'));
5458 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5459 $this->updateConfig('DisableSite', postVar('DisableSite'));
5460 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5461 $this->updateConfig('LastVisit', postVar('LastVisit'));
5462 $this->updateConfig('MediaURL', postVar('MediaURL'));
5463 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5464 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5465 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5466 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5467 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5468 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5469 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5470 $this->updateConfig('CookiePath', postVar('CookiePath'));
5471 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5472 $this->updateConfig('URLMode', postVar('URLMode'));
5473 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5474 $this->updateConfig('DebugVars', postVar('DebugVars'));
5475 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5476 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5478 // load new config and redirect (this way, the new locale will be used is necessary)
5479 // note that when changing cookie settings, this redirect might cause the user
5480 // to have to log in again.
5482 redirect($CONF['AdminURL'] . '?action=manage');
5487 * Admin::action_systemoverview()
5488 * Output system overview
5493 function action_systemoverview()
5495 global $member, $nucleus, $CONF;
5499 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5501 if ( $member->isLoggedIn() && $member->isAdmin() )
5503 // Information about the used PHP and MySQL installation
5504 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5506 // Version of PHP MySQL
5507 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5510 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5515 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5516 echo '<td>' . phpversion() . "</td>\n";
5519 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5520 echo '<td>' . DB::getAttribute(PDO::ATTR_SERVER_VERSION) . ' (' . DB::getAttribute(PDO::ATTR_CLIENT_VERSION) . ')' . "</td>\n";
5523 echo "</table>\n\n";
5525 // Important PHP settings
5526 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5529 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5534 echo '<td>magic_quotes_gpc' . "</td>\n";
5535 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5536 echo '<td>' . $mqg . "</td>\n";
5539 echo '<td>magic_quotes_runtime' . "</td>\n";
5540 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5541 echo '<td>' . $mqr . "</td>\n";
5544 echo '<td>register_globals' . "</td>\n";
5545 $rg = ini_get('register_globals') ? 'On' : 'Off';
5546 echo '<td>' . $rg . "</td>\n";
5549 echo "</table>\n\n";
5551 // Information about GD library
5552 $gdinfo = gd_info();
5553 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5556 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5560 foreach ( $gdinfo as $key=>$value )
5562 if ( is_bool($value) )
5564 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5568 $value = Entity::hsc($value);
5571 echo '<td>' . $key . "</td>\n";
5572 echo '<td>' . $value . "</td>\n";
5576 echo "</table>\n\n";
5578 // Check if special modules are loaded
5580 phpinfo(INFO_MODULES);
5581 $im = ob_get_contents();
5583 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5586 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5590 echo '<td>mod_rewrite' . "</td>\n";
5591 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5592 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5593 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5594 echo '<td>' . $modrewrite . "</td>\n";
5597 echo "</table>\n\n";
5599 // Information about the used Nucleus CMS
5600 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5602 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5603 $np = getNucleusPatchLevel();
5604 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5607 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5612 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5613 echo '<td>' . $nv . "</td>\n";
5616 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5617 echo '<td>' . $np . "</td>\n";
5620 echo "</table>\n\n";
5622 // Important settings of the installation
5623 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5626 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5631 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5632 echo '<td>' . $CONF['Self'] . "</td>\n";
5635 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5636 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5639 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5640 $ohs = $CONF['alertOnHeadersSent'] ?
5641 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5642 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5643 echo '<td>' . $ohs . "</td>\n";
5646 echo "<td>i18n::get_current_charset()</td>\n";
5647 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5650 echo "</table>\n\n";
5652 // Link to the online version test at the Nucleus CMS website
5653 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5654 if ( $nucleus['codename'] != '')
5656 $codenamestring = ' "' . $nucleus['codename'] . '"';
5660 $codenamestring = '';
5662 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5663 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5664 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5665 echo 'Nucleus CMS ' . $nv . $codenamestring;
5670 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5676 * Admin::updateConfig()
5678 * @param string $name
5679 * @param string $val
5680 * @return integer return the ID in which the latest query posted
5682 function updateConfig($name, $val)
5684 $name = DB::quoteValue($name);
5685 $val = DB::quoteValue(trim($val));
5687 $query = "UPDATE %s SET value=%s WHERE name=%s";
5688 $query = sprintf($query, sql_table('config'), $val, $name);
5689 if ( DB::execute($query) === FALSE )
5691 $err = DB::getError();
5692 die("Query error: " . $err[2]);
5694 return DB::getInsertId();
5699 * @param string $msg message that will be shown
5701 function error($msg)
5705 echo "<h2>Error!</h2>\n";
5708 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5715 * add error log and show error page
5722 ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5723 $this->error(_ERROR_DISALLOWED);
5728 * Output admin page head
5733 function pagehead($extrahead = '')
5735 global $member, $nucleus, $CONF, $manager;
5740 'extrahead' => &$extrahead,
5741 'action' => $this->action));
5743 $baseUrl = Entity::hsc($CONF['AdminURL']);
5744 if ( !array_key_exists('AdminCSS',$CONF) )
5746 DB::execute("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5747 $CONF['AdminCSS'] = 'original';
5750 /* HTTP 1.1 application for no caching */
5751 header("Cache-Control: no-cache, must-revalidate");
5752 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5754 $root_element = 'html';
5755 $charset = i18n::get_current_charset();
5756 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5758 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5759 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5760 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5762 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5763 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5764 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5765 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5766 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5767 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5768 echo "{$extrahead}\n";
5771 echo "<div id=\"adminwrapper\">\n";
5772 echo "<div class=\"header\">\n";
5773 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5775 echo "<div id=\"container\">\n";
5776 echo "<div id=\"content\">\n";
5777 echo "<div class=\"loginname\">\n";
5778 if ( $member->isLoggedIn() )
5780 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5781 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5785 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5787 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5790 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5792 $codenamestring = ' "' . $nucleus['codename'].'"';
5796 $codenamestring = '';
5799 if ( $member->isLoggedIn() && $member->isAdmin() )
5801 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5802 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5804 $newestVersion = getLatestVersion();
5805 $newestCompare = str_replace('/','.',$newestVersion);
5806 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5807 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5810 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5811 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5817 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5826 * Output admin page foot include quickmenu
5833 global $action, $member, $manager;
5837 array('action' => $this->action)
5840 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5842 echo '<h2>' . _LOGOUT . "</h2>\n";
5844 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5845 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5849 echo "<div class=\"foot\">\n";
5850 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5852 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5855 echo "<!-- content -->\n";
5856 echo "<div id=\"quickmenu\">\n";
5858 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5861 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5864 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5865 echo "<form method=\"get\" action=\"index.php\">\n";
5867 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5869 $showAll = requestVar('showall');
5871 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5873 // Super-Admins have access to all blogs! (no add item support though)
5874 $query = 'SELECT bnumber as value, bname as text'
5875 . ' FROM ' . sql_table('blog')
5876 . ' ORDER BY bname';
5880 $query = 'SELECT bnumber as value, bname as text'
5881 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5882 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5883 . ' ORDER BY bname';
5885 $template['name'] = 'blogid';
5886 $template['tabindex'] = 15000;
5887 $template['extra'] = _QMENU_ADD_SELECT;
5888 $template['selected'] = -1;
5889 $template['shorten'] = 10;
5890 $template['shortenel'] = '';
5891 $template['javascript'] = 'onchange="return form.submit()"';
5892 showlist($query,'select',$template);
5897 echo "<h2>{$member->getDisplayName()}</h2>\n";
5899 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5900 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5901 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5904 // ---- general settings ----
5905 if ( $member->isAdmin() )
5907 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5909 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5910 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5911 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5912 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5913 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5914 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5915 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5918 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5920 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5921 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5922 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5926 $aPluginExtras = array();
5930 'options' => &$aPluginExtras));
5932 if ( count($aPluginExtras) > 0 )
5934 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5936 foreach ( $aPluginExtras as $aInfo )
5938 echo '<li><a href="' . Entity::hsc($aInfo['url']) . '" title="' . Entity::hsc($aInfo['tooltip']) . '">' . Entity::hsc($aInfo['title']) . "</a></li>\n";
5943 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5946 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5950 // introduction text on login screen
5951 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5954 echo "<!-- quickmenu -->\n";
5957 echo "<!-- content -->\n";
5960 echo "<!-- container -->\n";
5963 echo "<!-- adminwrapper -->\n";
5972 * @todo document this
5974 function action_regfile() {
5975 global $member, $CONF;
5977 $blogid = intRequestVar('blogid');
5979 $member->teamRights($blogid) or $this->disallow();
5981 // header-code stolen from phpMyAdmin
5982 // REGEDIT and bookmarklet code stolen from GreyMatter
5984 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5987 header('Content-Type: application/octetstream');
5988 header('Content-Disposition: filename="nucleus.reg"');
5989 header('Pragma: no-cache');
5990 header('Expires: 0');
5993 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5994 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5995 echo '"contexts"=hex:31';
5999 * @todo document this
6001 function action_bookmarklet() {
6002 global $member, $manager;
6004 $blogid = intRequestVar('blogid');
6006 $member->teamRights($blogid) or $this->disallow();
6008 $blog =& $manager->getBlog($blogid);
6009 $bm = getBookmarklet($blogid);
6013 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
6017 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
6020 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
6023 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
6025 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
6028 <?php echo '<a href="' . Entity::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, Entity::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
6031 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
6034 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
6035 $url = $manager->addTicketToUrl($url);
6037 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . Entity::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
6041 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
6044 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
6046 <?php echo _BOOKMARKLET_DELETEBAR ?>
6050 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
6054 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
6055 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
6056 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
6057 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
6058 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
6067 * @todo document this
6069 function action_actionlog() {
6070 global $member, $manager;
6072 $member->isAdmin() or $this->disallow();
6076 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6078 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
6081 <h2><?php echo _ACTIONLOG_CLEAR_TITLE ?></h2>
6082 <p><a href="<?php echo Entity::hsc($url) ?>"><?php echo _ACTIONLOG_CLEAR_TEXT ?></a></p>
6084 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
6086 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
6087 $template['content'] = 'actionlist';
6088 $amount = showlist($query,'table',$template);
6095 * @todo document this
6097 function action_banlist() {
6098 global $member, $manager;
6100 $blogid = intRequestVar('blogid');
6102 $member->blogAdminRights($blogid) or $this->disallow();
6104 $blog =& $manager->getBlog($blogid);
6108 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
6110 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
6112 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
6113 $template['content'] = 'banlist';
6114 $amount = showlist($query,'table',$template);
6119 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
6120 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
6128 * @todo document this
6130 function action_banlistdelete() {
6131 global $member, $manager;
6133 $blogid = intRequestVar('blogid');
6134 $iprange = requestVar('iprange');
6136 $member->blogAdminRights($blogid) or $this->disallow();
6138 $blog =& $manager->getBlog($blogid);
6139 $banBlogName = Entity::hsc($blog->getName());
6143 <h2><?php echo _BAN_REMOVE_TITLE ?></h2>
6145 <form method="post" action="index.php">
6147 <h3><?php echo _BAN_IPRANGE ?></h3>
6150 <?php echo _CONFIRMTXT_BAN ?> <?php echo Entity::hsc($iprange) ?>
6151 <input name="iprange" type="hidden" value="<?php echo Entity::hsc($iprange) ?>" />
6154 <h3><?php echo _BAN_BLOGS ?></h3>
6157 <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
6158 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
6159 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
6161 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS ?></label>
6164 <h3><?php echo _BAN_DELETE_TITLE ?></h3>
6167 <?php $manager->addTicketHidden() ?>
6168 <input type="hidden" name="action" value="banlistdeleteconfirm" />
6169 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
6178 * @todo document this
6180 function action_banlistdeleteconfirm() {
6181 global $member, $manager;
6183 $blogid = intPostVar('blogid');
6184 $allblogs = postVar('allblogs');
6185 $iprange = postVar('iprange');
6187 $member->blogAdminRights($blogid) or $this->disallow();
6192 if (Ban::removeBan($blogid, $iprange))
6193 array_push($deleted, $blogid);
6195 // get blogs fot which member has admin rights
6196 $adminblogs = $member->getAdminBlogs();
6197 foreach ($adminblogs as $blogje) {
6198 if (Ban::removeBan($blogje, $iprange))
6199 array_push($deleted, $blogje);
6203 if (sizeof($deleted) == 0)
6204 $this->error(_ERROR_DELETEBAN);
6208 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
6209 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
6210 echo "<p>"._BAN_REMOVED_TEXT."</p>";
6213 foreach ($deleted as $delblog) {
6214 $b =& $manager->getBlog($delblog);
6215 echo "<li>" . Entity::hsc($b->getName()). "</li>";
6224 * @todo document this
6226 function action_banlistnewfromitem() {
6227 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
6231 * @todo document this
6233 function action_banlistnew($blogid = '') {
6234 global $member, $manager;
6237 $blogid = intRequestVar('blogid');
6239 $ip = requestVar('ip');
6241 $member->blogAdminRights($blogid) or $this->disallow();
6243 $blog =& $manager->getBlog($blogid);
6247 <h2><?php echo _BAN_ADD_TITLE ?></h2>
6250 <form method="post" action="index.php">
6252 <h3><?php echo _BAN_IPRANGE ?></h3>
6254 <p><?php echo _BAN_IPRANGE_TEXT ?></p>
6257 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
6258 <?php echo _BAN_EXAMPLE_TEXT ?>
6264 $iprangeVal = Entity::hsc($ip);
6266 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
6267 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
6269 <input name="iprange" type="radio" value="custom" id="ip_custom" />
6270 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
6271 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
6274 echo "<input name='iprange' value='custom' type='hidden' />";
6275 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
6280 <h3><?php echo _BAN_BLOGS ?></h3>
6282 <p><?php echo _BAN_BLOGS_TEXT ?></p>
6285 <input type="hidden" name="blogid" value="<?php echo $blogid ?>" />
6286 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo Entity::hsc($blog->getName()) ?>'</label>
6288 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS ?></label>
6291 <h3><?php echo _BAN_REASON_TITLE ?></h3>
6293 <p><?php echo _BAN_REASON_TEXT ?></p>
6295 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
6297 <h3><?php echo _BAN_ADD_TITLE ?></h3>
6300 <input name="action" type="hidden" value="banlistadd" />
6301 <?php $manager->addTicketHidden() ?>
6302 <input type="submit" value="<?php echo _BAN_ADD_BTN ?>" />
6307 <?php $this->pagefoot();
6311 * @todo document this
6313 function action_banlistadd() {
6316 $blogid = intPostVar('blogid');
6317 $allblogs = postVar('allblogs');
6318 $iprange = postVar('iprange');
6319 if ($iprange == "custom")
6320 $iprange = postVar('customiprange');
6321 $reason = postVar('reason');
6323 $member->blogAdminRights($blogid) or $this->disallow();
6325 // TODO: check IP range validity
6328 if (!Ban::addBan($blogid, $iprange, $reason))
6329 $this->error(_ERROR_ADDBAN);
6331 // get blogs fot which member has admin rights
6332 $adminblogs = $member->getAdminBlogs();
6334 foreach ($adminblogs as $blogje) {
6335 if (!Ban::addBan($blogje, $iprange, $reason))
6339 $this->error(_ERROR_ADDBAN);
6342 $this->action_banlist();
6347 * @todo document this
6349 function action_clearactionlog() {
6352 $member->isAdmin() or $this->disallow();
6356 $this->action_manage(_MSG_ACTIONLOGCLEARED);
6360 * @todo document this
6362 function action_backupoverview() {
6363 global $member, $manager;
6365 $member->isAdmin() or $this->disallow();
6369 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6371 <h2><?php echo _BACKUPS_TITLE ?></h2>
6373 <h3><?php echo _BACKUP_TITLE ?></h3>
6375 <p><?php echo _BACKUP_INTRO ?></p>
6377 <form method="post" action="index.php"><p>
6378 <input type="hidden" name="action" value="backupcreate" />
6379 <?php $manager->addTicketHidden() ?>
6381 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES ?></label>
6383 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO ?></label>
6385 <input type="submit" value="<?php echo _BACKUP_BTN ?>" tabindex="20" />
6389 <div class="note"><?php echo _BACKUP_NOTE ?></div>
6392 <h3><?php echo _RESTORE_TITLE ?></h3>
6394 <div class="note"><?php echo _RESTORE_NOTE ?></div>
6396 <p><?php echo _RESTORE_INTRO ?></p>
6398 <form method="post" action="index.php" enctype="multipart/form-data"><p>
6399 <input type="hidden" name="action" value="backuprestore" />
6400 <?php $manager->addTicketHidden() ?>
6401 <input name="backup_file" type="file" tabindex="30" />
6403 <input type="submit" value="<?php echo _RESTORE_BTN ?>" tabindex="40" />
6404 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE ?></label>
6405 <br /><?php echo _RESTORE_WARNING ?>
6408 <?php $this->pagefoot();
6412 * Admin::action_backupcreate()
6413 * create file for backup
6419 function action_backupcreate()
6421 global $member, $DIR_LIBS;
6423 $member->isAdmin() or $this->disallow();
6425 // use compression ?
6426 $useGzip = (integer) postVar('gzip');
6428 include($DIR_LIBS . 'backup.php');
6430 // try to extend time limit
6431 // (creating/restoring dumps might take a while)
6432 @set_time_limit(1200);
6434 Backup::do_backup($useGzip);
6439 * Admin::action_backuprestore()
6440 * restoring from uploaded file
6445 function action_backuprestore()
6447 global $member, $DIR_LIBS;
6449 $member->isAdmin() or $this->disallow();
6451 if ( intPostVar('letsgo') != 1 )
6453 $this->error(_ERROR_BACKUP_NOTSURE);
6456 include($DIR_LIBS . 'backup.php');
6458 // try to extend time limit
6459 // (creating/restoring dumps might take a while)
6460 @set_time_limit(1200);
6462 $message = Backup::do_restore();
6463 if ( $message != '' )
6465 $this->error($message);
6468 echo '<h2>' . _RESTORE_COMPLETE . "</h2>\n";
6474 * Admin::action_pluginlist()
6475 * output the list of installed plugins
6481 function action_pluginlist()
6483 global $DIR_PLUGINS, $member, $manager;
6486 $member->isAdmin() or $this->disallow();
6490 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6492 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6494 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6496 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6498 $template['content'] = 'pluginlist';
6499 $template['tabindex'] = 10;
6500 showlist($query, 'table', $template);
6502 echo '<h3>' . _PLUGS_TITLE_UPDATE . "</h3>\n";
6503 echo '<p>' . _PLUGS_TEXT_UPDATE . "</p>\n";
6504 echo '<form method="post" action="index.php">' . "\n";
6506 echo '<input type="hidden" name="action" value="pluginupdate" />' . "\n";
6507 $manager->addTicketHidden();
6508 echo '<input type="submit" value="' . _PLUGS_BTN_UPDATE . '" tabindex="20" />' . "\n";
6512 echo '<h3>' . _PLUGS_TITLE_NEW . "</h3>\n";
6514 // find a list of possibly non-installed plugins
6515 $candidates = array();
6516 $dirhandle = opendir($DIR_PLUGINS);
6518 while ( $filename = readdir($dirhandle) )
6520 if ( preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6522 $name = $matches[1];
6524 // only show in list when not yet installed
6525 $query = 'SELECT * FROM %s WHERE pfile = %s';
6526 $query = sprintf($query, sql_table('plugin'), DB::quoteValue('NP_'.$name));
6527 $res = DB::getResult($query);
6529 if ( $res->rowCount() == 0 )
6531 array_push($candidates, $name);
6536 closedir($dirhandle);
6538 if ( sizeof($candidates) > 0 )
6540 echo '<p>' . _PLUGS_ADD_TEXT . "</p>\n";
6542 echo '<form method="post" action="index.php">' . "\n";
6544 echo '<input type="hidden" name="action" value="pluginadd" />' . "\n";
6545 $manager->addTicketHidden();
6546 echo '<select name="filename" tabindex="30">' . "\n";
6548 foreach ( $candidates as $name )
6550 echo '<option value="NP_',$name,'">',Entity::hsc($name),'</option>';
6554 echo '<input type="submit" tabindex="40" value="' . _PLUGS_BTN_INSTALL ."\" />\n";
6560 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6568 * @todo document this
6570 function action_pluginhelp() {
6571 global $member, $manager, $DIR_PLUGINS, $CONF;
6574 $member->isAdmin() or $this->disallow();
6576 $plugid = intGetVar('plugid');
6578 if (!$manager->pidInstalled($plugid))
6579 $this->error(_ERROR_NOSUCHPLUGIN);
6581 $plugName = getPluginNameFromPid($plugid);
6585 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6587 echo '<h2>',_PLUGS_HELP_TITLE,': ',Entity::hsc($plugName),'</h2>';
6589 $plug =& $manager->getPlugin($plugName);
6590 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6592 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6593 @readfile($helpFile);
6595 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6596 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6604 * Admin::action_pluginadd()
6610 function action_pluginadd()
6612 global $member, $manager, $DIR_PLUGINS;
6615 $member->isAdmin() or $this->disallow();
6617 $name = postVar('filename');
6619 if ( $manager->pluginInstalled($name) )
6621 $this->error(_ERROR_DUPPLUGIN);
6624 if ( !checkPlugin($name) )
6626 $this->error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');
6629 // get number of currently installed plugins
6630 $res = DB::getResult('SELECT * FROM '.sql_table('plugin'));
6631 $numCurrent = $res->rowCount();
6633 // plugin will be added as last one in the list
6634 $newOrder = $numCurrent + 1;
6643 // do this before calling getPlugin (in case the plugin id is used there)
6644 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.','.DB::quoteValue($name).')';
6645 DB::execute($query);
6646 $iPid = DB::getInsertId();
6648 $manager->clearCachedInfo('installedPlugins');
6650 // Load the plugin for condition checking and instalation
6651 $plugin =& $manager->getPlugin($name);
6653 // check if it got loaded (could have failed)
6656 DB::execute('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6657 $manager->clearCachedInfo('installedPlugins');
6658 $this->error(_ERROR_PLUGIN_LOAD);
6661 // check if plugin needs a newer Nucleus version
6662 if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
6664 // uninstall plugin again...
6665 $this->deleteOnePlugin($plugin->getID());
6667 // ...and show error
6668 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));
6671 // check if plugin needs a newer Nucleus version
6672 if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
6674 // uninstall plugin again...
6675 $this->deleteOnePlugin($plugin->getID());
6677 // ...and show error
6678 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6681 $pluginList = $plugin->getPluginDep();
6682 foreach ( $pluginList as $pluginName )
6684 $res = DB::getResult('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile=' . DB::quoteValue($pluginName));
6685 if ($res->rowCount() == 0)
6687 // uninstall plugin again...
6688 $this->deleteOnePlugin($plugin->getID());
6689 $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
6693 // call the install method of the plugin
6699 'plugin' => &$plugin
6703 // update all events
6704 $this->action_pluginupdate();
6709 * ADMIN:action_pluginupdate():
6715 function action_pluginupdate()
6717 global $member, $manager, $CONF;
6720 $member->isAdmin() or $this->disallow();
6722 // delete everything from plugin_events
6723 DB::execute('DELETE FROM '.sql_table('plugin_event'));
6725 // loop over all installed plugins
6726 $res = DB::getResult('SELECT pid, pfile FROM '.sql_table('plugin'));
6727 foreach ( $res as $row )
6730 $plug =& $manager->getPlugin($row['pfile']);
6733 $eventList = $plug->getEventList();
6734 foreach ( $eventList as $eventName )
6736 $query = "INSERT INTO %s (pid, event) VALUES (%d, %s)";
6737 $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, DB::quoteValue($eventName));
6738 DB::execute($query);
6742 redirect($CONF['AdminURL'] . '?action=pluginlist');
6747 * @todo document this
6749 function action_plugindelete() {
6750 global $member, $manager;
6753 $member->isAdmin() or $this->disallow();
6755 $pid = intGetVar('plugid');
6757 if (!$manager->pidInstalled($pid))
6758 $this->error(_ERROR_NOSUCHPLUGIN);
6762 <h2><?php echo _DELETE_CONFIRM ?></h2>
6764 <p><?php echo _CONFIRMTXT_PLUGIN ?> <strong><?php echo getPluginNameFromPid($pid) ?></strong>?</p>
6766 <form method="post" action="index.php"><div>
6767 <?php $manager->addTicketHidden() ?>
6768 <input type="hidden" name="action" value="plugindeleteconfirm" />
6769 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6770 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN ?>" />
6777 * @todo document this
6779 function action_plugindeleteconfirm() {
6780 global $member, $manager, $CONF;
6783 $member->isAdmin() or $this->disallow();
6785 $pid = intPostVar('plugid');
6787 $error = $this->deleteOnePlugin($pid, 1);
6789 $this->error($error);
6792 redirect($CONF['AdminURL'] . '?action=pluginlist');
6793 // $this->action_pluginlist();
6797 * @todo document this
6799 function deleteOnePlugin($pid, $callUninstall = 0) {
6802 $pid = intval($pid);
6804 if (!$manager->pidInstalled($pid))
6805 return _ERROR_NOSUCHPLUGIN;
6807 $name = DB::getValue('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6809 /* // call the unInstall method of the plugin
6810 if ($callUninstall) {
6811 $plugin =& $manager->getPlugin($name);
6812 if ($plugin) $plugin->unInstall();
6815 // check dependency before delete
6816 $res = DB::getResult('SELECT pfile FROM '.sql_table('plugin'));
6817 foreach ( $res as $row ) {
6818 $plug =& $manager->getPlugin($row['pfile']);
6821 $depList = $plug->getPluginDep();
6822 foreach ($depList as $depName)
6824 if ($name == $depName)
6826 return sprintf(_ERROR_DELREQPLUGIN, $row['pfile']);
6832 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6834 // call the unInstall method of the plugin
6835 if ($callUninstall) {
6836 $plugin =& $manager->getPlugin($name);
6837 if ($plugin) $plugin->unInstall();
6840 // delete all subscriptions
6841 DB::execute('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6843 // delete all options
6844 // get OIDs from plugin_option_desc
6845 $res = DB::getResult('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6847 foreach ( $res as $row ) {
6848 array_push($aOIDs, $row['oid']);
6851 // delete from plugin_option and plugin_option_desc
6852 DB::execute('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6853 if (count($aOIDs) > 0)
6854 DB::execute('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6856 // update order numbers
6857 $res = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6858 DB::execute('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$res);
6861 DB::execute('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6863 $manager->clearCachedInfo('installedPlugins');
6864 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6870 * @todo document this
6872 function action_pluginup() {
6873 global $member, $manager, $CONF;
6876 $member->isAdmin() or $this->disallow();
6878 $plugid = intGetVar('plugid');
6880 if (!$manager->pidInstalled($plugid))
6881 $this->error(_ERROR_NOSUCHPLUGIN);
6883 // 1. get old order number
6884 $oldOrder = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6886 // 2. calculate new order number
6887 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6889 // 3. update plug numbers
6890 DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6891 DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6893 //$this->action_pluginlist();
6894 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6895 redirect($CONF['AdminURL'] . '?action=pluginlist');
6899 * @todo document this
6901 function action_plugindown() {
6902 global $member, $manager, $CONF;
6905 $member->isAdmin() or $this->disallow();
6907 $plugid = intGetVar('plugid');
6908 if (!$manager->pidInstalled($plugid))
6909 $this->error(_ERROR_NOSUCHPLUGIN);
6911 // 1. get old order number
6912 $oldOrder = DB::getValue('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6914 $res = DB::getResult('SELECT * FROM '.sql_table('plugin'));
6915 $maxOrder = $res->rowCount();
6917 // 2. calculate new order number
6918 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6920 // 3. update plug numbers
6921 DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6922 DB::execute('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6924 //$this->action_pluginlist();
6925 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6926 redirect($CONF['AdminURL'] . '?action=pluginlist');
6930 * Admin::action_pluginoptions()
6932 * Output Plugin option page
6935 * @param string $message message when fallbacked
6939 public function action_pluginoptions($message = '')
6941 global $member, $manager;
6944 $member->isAdmin() or $this->disallow();
6946 $pid = (integer) requestVar('plugid');
6947 if ( !$manager->pidInstalled($pid) )
6949 $this->error(_ERROR_NOSUCHPLUGIN);
6952 $pname = getPluginNameFromPid($pid);
6954 /* just for including translation */
6955 $manager->getPlugin($pname);
6957 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6958 $this->pagehead($extrahead);
6959 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6960 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($pname)) . "</h2>\n";
6962 if ( isset($message) )
6967 echo "<form action=\"index.php\" method=\"post\">\n";
6969 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6970 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6971 $manager->addTicketHidden();
6973 $aOptions = array();
6975 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6976 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6977 $result = DB::getResult($query);
6978 foreach ( $result as $row )
6980 array_push($aOIDs, $row['oid']);
6981 $aOptions[$row['oid']] = array(
6982 'oid' => $row['oid'],
6983 'value' => $row['odef'],
6984 'name' => $row['oname'],
6985 'description' => $row['odesc'],
6986 'type' => $row['otype'],
6987 'typeinfo' => $row['oextra'],
6991 // fill out actual values
6992 if ( count($aOIDs) > 0 )
6994 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6995 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6996 $result = DB::getResult($query);
6997 foreach ( $result as $row )
6999 $aOptions[$row['oid']]['value'] = $row['ovalue'];
7004 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
7005 $manager->notify('PrePluginOptionsEdit',$data);
7007 $template['content'] = 'plugoptionlist';
7008 $amount = showlist($aOptions,'table',$template);
7011 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
7021 * Admin::action_pluginoptionsupdate()
7023 * Update plugin options and fallback to plugin option page
7029 public function action_pluginoptionsupdate()
7031 global $member, $manager;
7034 $member->isAdmin() or $this->disallow();
7036 $pid = (integer) requestVar('plugid');
7037 if ( !$manager->pidInstalled($pid) )
7039 $this->error(_ERROR_NOSUCHPLUGIN);
7042 $aOptions = requestArray('plugoption');
7043 NucleusPlugin::apply_plugin_options($aOptions);
7045 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
7047 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
7052 * Admin::_insertPluginOptions()
7054 * Output plugin option field
7057 * @param string $context plugin option context
7058 * @param integer $contextid plugin option context id
7061 public function _insertPluginOptions($context, $contextid = 0)
7063 // get all current values for this contextid
7064 // (note: this might contain doubles for overlapping contextids)
7065 $aIdToValue = array();
7066 $res = DB::getResult('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
7067 foreach ( $res as $row )
7069 $aIdToValue[$row['oid']] = $row['ovalue'];
7072 // get list of oids per pid
7073 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
7074 . ' WHERE opid=pid and ocontext='.DB::quoteValue($context).' ORDER BY porder, oid ASC';
7075 $res = DB::getResult($query);
7076 $aOptions = array();
7077 foreach ( $res as $row )
7079 if (in_array($row['oid'], array_keys($aIdToValue)))
7081 $value = $aIdToValue[$row['oid']];
7085 $value = $row['odef'];
7088 array_push($aOptions, array(
7089 'pid' => $row['pid'],
7090 'pfile' => $row['pfile'],
7091 'oid' => $row['oid'],
7093 'name' => $row['oname'],
7094 'description' => $row['odesc'],
7095 'type' => $row['otype'],
7096 'typeinfo' => $row['oextra'],
7097 'contextid' => $contextid,
7102 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
7105 foreach ($aOptions as $aOption)
7108 if ( $iPrevPid != $aOption['pid'] )
7110 $iPrevPid = $aOption['pid'];
7111 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
7113 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
7115 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($aOption['pfile'])).'</th></tr>';
7118 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
7119 if ( @$meta['access'] != 'hidden' )
7122 listplug_plugOptionRow($aOption);
7130 * Admin::input_yesno()
7131 * Output input elements with radio attribute for yes/no options
7133 * @param string $name name attribute
7134 * @param string $value_current current value attribute
7135 * @param integer $tabindex tab index
7136 * @param string $value_yes value attribute for yes option
7137 * @param string $value_no value attribute for no option
7138 * @param string $text_yes child text element for yes option
7139 * @param string $text_no child text element for no option
7140 * @param boolean $isAdmin have admin right or not
7143 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
7145 $id = preg_replace('#\[|\]#', '-', $name);
7146 $id_yes = $id . $value_yes;
7147 $id_no = $id . $value_no;
7150 echo '<input type="radio" id="' . Entity::hsc($id_yes) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_yes) . '"';
7151 if ( $name=="admin" )
7153 echo ' onclick="selectCanLogin(true);"';
7155 if ( $value_current == $value_yes )
7157 echo " tabindex='$tabindex' checked='checked'";
7160 echo '<label for="' . Entity::hsc($id_yes) . '">' . Entity::hsc($text_yes) . "</label>\n";
7163 echo '<input type="radio" id="' . Entity::hsc($id_no) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_no) . '"';
7164 if ( $name=="admin" )
7166 echo ' onclick="selectCanLogin(false);"';
7168 if ( $value_current != $value_yes )
7170 echo " tabindex='$tabindex' checked='checked'";
7172 if ($isAdmin && $name=="canlogin")
7174 echo ' disabled="disabled"';
7177 echo '<label for="' . Entity::hsc($id_no) . '">' . Entity::hsc($text_no) . "</label>\n";