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', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
125 if (!in_array($this->action, $aActionsNotToCheck))
127 if (!$manager->checkTicket())
128 $this->error(_ERROR_BADTICKET);
131 if (method_exists($this, $methodName))
132 call_user_func(array(&$this, $methodName));
134 $this->error(_BADACTION . Entity::hsc(" ($action)"));
139 * @todo document this
141 function action_showlogin() {
143 $this->action_login($error);
147 * @todo document this
149 function action_login($msg = '', $passvars = 1) {
152 // skip to overview when allowed
153 if ($member->isLoggedIn() && $member->canLogin()) {
154 $this->action_overview();
160 echo '<h2>', _LOGIN ,'</h2>';
161 if ($msg) echo _MESSAGE , ': ', Entity::hsc($msg);
164 <form action="index.php" method="post"><p>
165 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
167 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
169 <input name="action" value="login" type="hidden" />
171 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
174 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
175 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
177 <?php // pass through vars
179 $oldaction = postVar('oldaction');
180 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
187 <?php $this->pagefoot();
192 * provides a screen with the overview of the actions available
193 * @todo document parameter
195 function action_overview($msg = '') {
201 echo _MESSAGE , ': ', $msg;
203 /* ---- add items ---- */
204 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
206 $showAll = requestVar('showall');
208 if (($member->isAdmin()) && ($showAll == 'yes')) {
209 // Super-Admins have access to all blogs! (no add item support though)
210 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
211 . ' FROM ' . sql_table('blog')
214 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
215 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
216 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
219 $template['content'] = 'bloglist';
220 $template['superadmin'] = $member->isAdmin();
221 $amount = showlist($query,'table',$template);
223 if (($showAll != 'yes') && ($member->isAdmin())) {
224 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
225 if ($total > $amount)
226 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
230 echo _OVERVIEW_NOBLOGS;
233 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
234 $query = 'SELECT ititle, inumber, bshortname'
235 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
236 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
237 $template['content'] = 'draftlist';
238 $amountdrafts = showlist($query, 'table', $template);
239 if ($amountdrafts == 0)
240 echo _OVERVIEW_NODRAFTS;
244 $yrBlogs = $member->getAdminBlogs();
245 if ($showAll != 'yes') {
247 foreach ($yrBlogs as $value) {
248 if ($member->isBlogAdmin(intval($value))) {
249 $admBlogs[] = intval($value);
252 $yrBlogs = $admBlogs;
255 if (count($yrBlogs) > 0) {
256 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
257 $query = 'SELECT ititle, inumber, bshortname, mname'
258 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
259 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
260 . ' ORDER BY iblog ASC';
261 $template['content'] = 'otherdraftlist';
262 $amountdrafts = showlist($query, 'table', $template);
263 if ($amountdrafts == 0)
264 echo _OVERVIEW_NODRAFTS;
268 /* ---- user settings ---- */
269 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
271 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
272 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
273 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
276 /* ---- general settings ---- */
277 if ($member->isAdmin()) {
278 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
280 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
289 * Returns a link to a weblog
292 function bloglink(&$blog) {
293 return '<a href="'.Entity::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. Entity::hsc( $blog->getName() ) .'</a>';
297 * @todo document this
299 function action_manage($msg = '') {
302 $member->isAdmin() or $this->disallow();
306 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
309 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
312 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
315 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
316 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
317 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
318 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
321 echo '<h2>' . _MANAGE_SKINS . '</h2>';
323 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
324 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
325 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
328 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
330 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
331 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
338 * 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 '%" . sql_real_escape_string($search) . "%') OR (ibody LIKE '%" . sql_real_escape_string($search) . "%') OR (imore LIKE '%" . sql_real_escape_string($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 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
585 // there should always remain at least one super-admin
586 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
587 if (sql_num_rows($r) < 2)
588 $error = _ERROR_ATLEASTONEADMIN;
590 sql_query('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 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
655 // there should always remain at least one admin
656 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
657 if (sql_num_rows($r) < 2)
658 $error = _ERROR_ATLEASTONEBLOGADMIN;
660 sql_query('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 = sql_query($query);
894 while ( $o = sql_fetch_object($rblogids) )
896 if ( $o->bnumber != $iForcedBlogInclude )
898 $aBlogIds[] = (integer) $o->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 = sql_query($query);
914 if ( $mode == 'category' )
916 if ( sql_num_rows($blogs) > 1 )
921 while ( $oBlog = sql_fetch_object($blogs) )
923 if ( $multipleBlogs )
925 echo '<optgroup label="' . Entity::hsc($oBlog->bname) . '">' . "\n";
928 // show selection to create new category when allowed/wanted
931 // check if allowed to do so
932 if ( $member->blogAdminRights($oBlog->bnumber) )
934 echo "<option value=\"newcat-{$oBlog->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) $oBlog->bnumber);
941 $categories = sql_query($query);
942 while ( $oCat = sql_fetch_object($categories) )
944 if ( $oCat->catid != $selected )
946 echo "<option value=\"{$oCat->catid}\" {$selectText} >" . Entity::hsc($oCat->cname) . "</option>\n";
950 echo "<option value=\"{$oCat->catid}\" selected=\"selected\" >" . Entity::hsc($oCat->cname) . "</option>\n";
954 if ( $multipleBlogs )
956 echo "</optgroup>\n";
963 while ( $oBlog = sql_fetch_object($blogs) )
965 if ( $oBlog->bnumber != $selected )
967 echo "<option value=\"{$oBlog->bnumber}\">" . Entity::hsc($oBlog->bname) . "</option>\n";
971 echo "<option value=\"{$oBlog->bnumber}\" selected=\"selected\">" . Entity::hsc($oBlog->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 '%" . sql_real_escape_string($search) . "%') or (ibody LIKE '%" . sql_real_escape_string($search) . "%') or (imore LIKE '%" . sql_real_escape_string($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 '%" . sql_real_escape_string($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 '%" . sql_real_escape_string($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 '%" . sql_real_escape_string($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);
1275 // generate the add-item form
1276 $handler = new PageFactory($blog);
1278 $contents = $handler->getTemplateFor('admin', 'add');
1279 $manager->notify('PreAddItemForm', array('contents' => &$contents, 'blog' => &$blog));
1281 $parser = new Parser($handler->getDefinedActions(), $handler);
1284 $parser->parse($contents);
1291 * Admin::action_itemedit()
1296 public function action_itemedit()
1298 global $member, $manager;
1300 $itemid = intRequestVar('itemid');
1302 // only allow if user is allowed to alter item
1303 $member->canAlterItem($itemid) or $this->disallow();
1305 $variables =& $manager->getItem($itemid, 1, 1);
1306 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1308 $manager->notify('PrepareItemForEdit', array('item' => &$variables));
1310 if ( $blog->convertBreaks() )
1312 $variables['body'] = removeBreaks($variables['body']);
1313 $variables['more'] = removeBreaks($variables['more']);
1316 // form to edit blog items
1317 $handler = new PageFactory($blog);
1318 $handler->setVariables($variables);
1320 $content = $handler->getTemplateFor('admin', 'edit');
1322 $parser = new Parser($handler->getDefinedActions(), $handler);
1325 $parser->parse($content);
1331 * @todo document this
1333 function action_itemupdate() {
1334 global $member, $manager, $CONF;
1336 $itemid = intRequestVar('itemid');
1337 $catid = postVar('catid');
1339 // only allow if user is allowed to alter item
1340 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1342 $actiontype = postVar('actiontype');
1344 // delete actions are handled by itemdelete (which has confirmation)
1345 if ($actiontype == 'delete') {
1346 $this->action_itemdelete();
1350 $body = postVar('body');
1351 $title = postVar('title');
1352 $more = postVar('more');
1353 $closed = intPostVar('closed');
1354 $draftid = intPostVar('draftid');
1356 // default action = add now
1358 $actiontype='addnow';
1360 // create new category if needed
1361 if ( i18n::strpos($catid,'newcat') === 0 ) {
1363 list($blogid) = sscanf($catid,"newcat-%d");
1366 $blog =& $manager->getBlog($blogid);
1367 $catid = $blog->createNewCategory();
1369 // show error when sth goes wrong
1371 $this->doError(_ERROR_CATCREATEFAIL);
1375 set some variables based on actiontype
1378 draft items -> addnow, addfuture, adddraft, delete
1379 non-draft items -> edit, changedate, delete
1382 $timestamp: set to a nonzero value for future dates or date changes
1383 $wasdraft: set to 1 when the item used to be a draft item
1384 $publish: set to 1 when the edited item is not a draft
1386 $blogid = getBlogIDFromItemID($itemid);
1387 $blog =& $manager->getBlog($blogid);
1389 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1390 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1391 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1392 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1393 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1398 // edit the item for real
1399 Item::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1401 $this->updateFuturePosted($blogid);
1404 // delete permission is checked inside Item::delete()
1405 Item::delete($draftid);
1408 // show category edit window when we created a new category
1409 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1410 if ($catid != intPostVar('catid')) {
1411 $this->action_categoryedit(
1414 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1417 // TODO: set start item correctly for itemlist
1418 $this->action_itemlist(getBlogIDFromItemID($itemid));
1423 * Admin::action_itemdelete()
1429 function action_itemdelete()
1431 global $member, $manager;
1433 $itemid = intRequestVar('itemid');
1435 // only allow if user is allowed to alter item
1436 $member->canAlterItem($itemid) or $this->disallow();
1438 if ( !$manager->existsItem($itemid,1,1) )
1440 $this->error(_ERROR_NOSUCHITEM);
1443 $item =& $manager->getItem($itemid,1,1);
1444 $title = Entity::hsc(strip_tags($item['title']));
1445 $body = strip_tags($item['body']);
1446 $body = Entity::hsc(Entity::shorten($body,300,'...'));
1449 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1450 echo '<p>' . _CONFIRMTXT_ITEM . "</p>\n";
1451 echo "<div class=\"note\">\n";
1452 echo "<b>{$title}</b>\n";
1456 echo "<form method=\"post\" action=\"index.php\">\n";
1458 echo "<input type=\"hidden\" name=\"action\" value=\"itemdeleteconfirm\" />\n";
1459 echo $manager->addTicketHidden() . "\n";
1460 echo "<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\" />\n";
1461 echo '<input type="submit" value="' . _DELETE_CONFIRM_BTN . "\" tabindex=\"10\" />\n";
1469 * @todo document this
1471 function action_itemdeleteconfirm() {
1474 $itemid = intRequestVar('itemid');
1476 // only allow if user is allowed to alter item
1477 $member->canAlterItem($itemid) or $this->disallow();
1480 $blogid = getBlogIdFromItemId($itemid);
1482 // delete item (note: some checks will be performed twice)
1483 $this->deleteOneItem($itemid);
1485 $this->action_itemlist($blogid);
1489 * Deletes one item and returns error if something goes wrong
1490 * @param int $itemid
1492 function deleteOneItem($itemid) {
1493 global $member, $manager;
1495 // only allow if user is allowed to alter item (also checks if itemid exists)
1496 if (!$member->canAlterItem($itemid))
1497 return _ERROR_DISALLOWED;
1499 // need to get blogid before the item is deleted
1500 $blogid = getBlogIDFromItemId($itemid);
1502 $manager->loadClass('ITEM');
1503 Item::delete($itemid);
1505 // update blog's futureposted
1506 $this->updateFuturePosted($blogid);
1510 * Admin::updateFuturePosted()
1511 * Update a blog's future posted flag
1513 * @param integer $blogid
1517 function updateFuturePosted($blogid)
1521 $blog =& $manager->getBlog($blogid);
1522 $currenttime = $blog->getCorrectTime(time());
1524 $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
1525 $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));
1526 $result = sql_query($query);
1528 if ( sql_num_rows($result) > 0 )
1530 $blog->setFuturePost();
1534 $blog->clearFuturePost();
1540 * @todo document this
1542 function action_itemmove() {
1543 global $member, $manager;
1545 $itemid = intRequestVar('itemid');
1547 // only allow if user is allowed to alter item
1548 $member->canAlterItem($itemid) or $this->disallow();
1550 $item =& $manager->getItem($itemid,1,1);
1554 <h2><?php echo _MOVE_TITLE?></h2>
1555 <form method="post" action="index.php"><div>
1556 <input type="hidden" name="action" value="itemmoveto" />
1557 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1561 $manager->addTicketHidden();
1562 $this->selectBlogCategory('catid',$item['catid'],10,1);
1565 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1572 * @todo document this
1574 function action_itemmoveto() {
1575 global $member, $manager;
1577 $itemid = intRequestVar('itemid');
1578 $catid = requestVar('catid');
1580 // create new category if needed
1581 if ( i18n::strpos($catid,'newcat') === 0 ) {
1583 list($blogid) = sscanf($catid,'newcat-%d');
1586 $blog =& $manager->getBlog($blogid);
1587 $catid = $blog->createNewCategory();
1589 // show error when sth goes wrong
1591 $this->doError(_ERROR_CATCREATEFAIL);
1594 // only allow if user is allowed to alter item
1595 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1597 $old_blogid = getBlogIDFromItemId($itemid);
1599 Item::move($itemid, $catid);
1601 // set the futurePosted flag on the blog
1602 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1604 // reset the futurePosted in case the item is moved from one blog to another
1605 $this->updateFuturePosted($old_blogid);
1607 if ($catid != intRequestVar('catid'))
1608 $this->action_categoryedit($catid, $blog->getID());
1610 $this->action_itemlist(getBlogIDFromCatID($catid));
1614 * Moves one item to a given category (category existance should be checked by caller)
1615 * errors are returned
1616 * @param int $itemid
1617 * @param int $destCatid category ID to which the item will be moved
1619 function moveOneItem($itemid, $destCatid) {
1622 // only allow if user is allowed to move item
1623 if (!$member->canUpdateItem($itemid, $destCatid))
1624 return _ERROR_DISALLOWED;
1626 Item::move($itemid, $destCatid);
1630 * Adds a item to the chosen blog
1632 function action_additem() {
1633 global $manager, $CONF;
1635 $manager->loadClass('ITEM');
1637 $result = Item::createFromRequest();
1639 if ($result['status'] == 'error')
1640 $this->error($result['message']);
1642 $blogid = getBlogIDFromItemID($result['itemid']);
1643 $blog =& $manager->getBlog($blogid);
1644 $btimestamp = $blog->getCorrectTime();
1645 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1647 if ($result['status'] == 'newcategory') {
1648 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1649 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1651 $methodName = 'action_itemList';
1652 call_user_func(array(&$this, $methodName), $blogid);
1657 * Allows to edit previously made comments
1659 function action_commentedit() {
1661 global $member, $manager;
1663 $commentid = intRequestVar('commentid');
1665 $member->canAlterComment($commentid) or $this->disallow();
1667 $comment = Comment::getComment($commentid);
1669 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1671 // change <br /> to \n
1672 $comment['body'] = str_replace('<br />', '', $comment['body']);
1674 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1675 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1677 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1682 <h2><?php echo _EDITC_TITLE?></h2>
1684 <form action="index.php" method="post"><div>
1686 <input type="hidden" name="action" value="commentupdate" />
1687 <?php $manager->addTicketHidden(); ?>
1688 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1690 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1692 <td><?php echo _EDITC_WHO?></td>
1694 <?php if ($comment['member'])
1695 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1697 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1701 <td><?php echo _EDITC_WHEN?></td>
1702 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1704 <td><?php echo _EDITC_HOST?></td>
1705 <td><?php echo $comment['host']; ?></td>
1708 <td><?php echo _EDITC_URL; ?></td>
1709 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1712 <td><?php echo _EDITC_EMAIL; ?></td>
1713 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1716 <td><?php echo _EDITC_TEXT?></td>
1718 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1719 echo $comment['body'];
1723 <td><?php echo _EDITC_EDIT?></td>
1724 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1733 * @todo document this
1735 function action_commentupdate() {
1736 global $member, $manager;
1738 $commentid = intRequestVar('commentid');
1740 $member->canAlterComment($commentid) or $this->disallow();
1742 $url = postVar('url');
1743 $email = postVar('email');
1744 $body = postVar('body');
1746 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1747 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1748 # important note that '\' must be matched with '\\\\' in preg* expressions
1750 // intercept words that are too long
1751 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1753 $this->error(_ERROR_COMMENT_LONGWORD);
1757 if (i18n::strlen($body) < 3)
1759 $this->error(_ERROR_COMMENT_NOCOMMENT);
1762 if (i18n::strlen($body) > 5000)
1764 $this->error(_ERROR_COMMENT_TOOLONG);
1768 $body = Comment::prepareBody($body);
1771 $manager->notify('PreUpdateComment',array('body' => &$body));
1773 $query = 'UPDATE ' . sql_table('comment')
1774 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1775 . " WHERE cnumber = " . $commentid;
1779 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1780 $o = sql_fetch_object($res);
1781 $itemid = $o->citem;
1783 if ($member->canAlterItem($itemid))
1784 $this->action_itemcommentlist($itemid);
1786 $this->action_browseowncomments();
1791 * Admin::action_commentdelete()
1797 function action_commentdelete()
1799 global $member, $manager;
1801 $commentid = intRequestVar('commentid');
1802 $member->canAlterComment($commentid) or $this->disallow();
1803 $comment = Comment::getComment($commentid);
1805 $body = strip_tags($comment['body']);
1806 $body = Entity::hsc(Entity::shorten($body, 300, '...'));
1808 if ( $comment['member'] )
1810 $author = $comment['member'];
1814 $author = $comment['user'];
1819 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1820 echo '<p>' . _CONFIRMTXT_COMMENT . "</p>\n";
1821 echo "<div class=\"note\">\n";
1822 echo '<b>' . _EDITC_WHO . ":</b>{$author}<br />\n";
1823 echo '<b>' . _EDITC_TEXT . ":</b>{$body}\n";
1825 echo "<form method=\"post\" action=\"index.php\">\n";
1827 echo "<input type=\"hidden\" name=\"action\" value=\"commentdeleteconfirm\" />\n";
1828 echo $manager->addTicketHidden() . "\n";
1829 echo "<input type=\"hidden\" name=\"commentid\" value=\"{$commentid}\" />\n";
1830 echo '<input type="submit" tabindex="10" value="'. _DELETE_CONFIRM_BTN . "\" />\n";
1838 * @todo document this
1840 function action_commentdeleteconfirm() {
1843 $commentid = intRequestVar('commentid');
1845 // get item id first
1846 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1847 $o = sql_fetch_object($res);
1848 $itemid = $o->citem;
1850 $error = $this->deleteOneComment($commentid);
1852 $this->doError($error);
1854 if ($member->canAlterItem($itemid))
1855 $this->action_itemcommentlist($itemid);
1857 $this->action_browseowncomments();
1861 * @todo document this
1863 function deleteOneComment($commentid) {
1864 global $member, $manager;
1866 $commentid = intval($commentid);
1868 if (!$member->canAlterComment($commentid))
1869 return _ERROR_DISALLOWED;
1871 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1873 // delete the comments associated with the item
1874 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1877 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1883 * Admin::action_usermanagement()
1885 * Usermanagement main
1889 public function action_usermanagement()
1891 global $member, $manager;
1894 $member->isAdmin() or $this->disallow();
1898 echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
1900 echo '<h2>' . _MEMBERS_TITLE . "</h2>\n";
1902 echo '<h3>' . _MEMBERS_CURRENT . "</h3>\n";
1904 // show list of members with actions
1905 $query = 'SELECT * FROM '.sql_table('member');
1906 $template['content'] = 'memberlist';
1907 $template['tabindex'] = 10;
1909 $manager->loadClass("ENCAPSULATE");
1910 $batch = new Batch('member');
1911 $batch->showlist($query,'table',$template);
1913 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1914 echo "<form method=\"post\" action=\"index.php\" name=\"memberedit\">\n";
1916 echo "<input type=\"hidden\" name=\"action\" value=\"memberadd\" />\n";
1917 $manager->addTicketHidden();
1919 echo '<table frame="box" rules="rules" summary="' . _MEMBERS_NEW . '">' ."\n";
1921 echo '<th colspan="2">' . _MEMBERS_NEW . "</th>\n";
1924 echo '<td>' . _MEMBERS_DISPLAY;
1927 echo '<small>' . _MEMBERS_DISPLAY_INFO . '</small>';
1929 echo "<td><input tabindex=\"10010\" name=\"name\" size=\"32\" maxlength=\"32\" /></td>\n";
1932 echo '<td>' . _MEMBERS_REALNAME . "</td>\n";
1933 echo "<td><input name=\"realname\" tabindex=\"10020\" size=\"40\" maxlength=\"60\" /></td>\n";
1936 echo '<td>' . _MEMBERS_PWD . "</td>\n";
1937 echo "<td><input name=\"password\" tabindex=\"10030\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
1940 echo '<td>' . _MEMBERS_REPPWD . "</td>\n";
1941 echo "<td><input name=\"repeatpassword\" tabindex=\"10035\" size=\"16\" maxlength=\"40\" type=\"password\" /></td>\n";
1944 echo '<td>' . _MEMBERS_EMAIL . "</td>\n";
1945 echo "<td><input name=\"email\" tabindex=\"10040\" size=\"40\" maxlength=\"60\" /></td>\n";
1948 echo '<td>' . _MEMBERS_URL . "</td>\n";
1949 echo "<td><input name=\"url\" tabindex=\"10050\" size=\"40\" maxlength=\"100\" /></td>\n";
1952 echo '<td>' . _MEMBERS_SUPERADMIN;
1956 $this->input_yesno('admin',0,10060);
1960 echo '<td>' . _MEMBERS_CANLOGIN;
1964 $this->input_yesno('canlogin',1,10070);
1968 echo '<td>' . _MEMBERS_NOTES . "</td>\n";
1969 echo "<td><input name=\"notes\" maxlength=\"100\" size=\"40\" tabindex=\"10080\" /></td>\n";
1972 echo '<td>' . _MEMBERS_NEW . "</td>\n";
1973 echo '<td><input type="submit" value="' . _MEMBERS_NEW_BTN . '" tabindex="10090" onclick="return checkSubmit();" />' . "</td>\n";
1983 * Edit member settings
1985 function action_memberedit() {
1986 $this->action_editmembersettings(intRequestVar('memberid'));
1990 * @todo document this
1992 function action_editmembersettings($memberid = '') {
1993 global $member, $manager, $CONF;
1995 if ($memberid == '')
1997 $memberid = $member->getID();
2001 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
2003 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2004 $this->pagehead($extrahead);
2006 // show message to go back to member overview (only for admins)
2007 if ($member->isAdmin())
2009 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
2013 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
2015 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
2017 $mem = Member::createFromID($memberid);
2019 <form method="post" action="index.php" name="memberedit"><div>
2021 <input type="hidden" name="action" value="changemembersettings" />
2022 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2023 <?php $manager->addTicketHidden() ?>
2026 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
2028 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
2029 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
2032 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
2033 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo Entity::hsc($mem->getDisplayName()); ?>" />
2035 echo Entity::hsc($member->getDisplayName());
2040 <td><?php echo _MEMBERS_REALNAME?></td>
2041 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo Entity::hsc($mem->getRealName()); ?>" /></td>
2043 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
2044 <td><?php echo _MEMBERS_PWD?></td>
2045 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
2047 <td><?php echo _MEMBERS_REPPWD?></td>
2048 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
2051 <td><?php echo _MEMBERS_EMAIL?>
2052 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
2054 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo Entity::hsc($mem->getEmail()); ?>" /></td>
2056 <td><?php echo _MEMBERS_URL?></td>
2057 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getURL()); ?>" /></td>
2058 <?php // only allow to change this by super-admins
2059 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
2060 if ($member->isAdmin()) {
2063 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
2064 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
2066 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
2067 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
2070 <td><?php echo _MEMBERS_NOTES?></td>
2071 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo Entity::hsc($mem->getNotes()); ?>" /></td>
2073 <td><?php echo _MEMBERS_LOCALE?> <?php help('locale'); ?>
2077 <select name="locale" tabindex="85">
2079 $locales = i18n::get_available_locale_list();
2080 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
2082 echo "<option value=\"\" selected=\"selected\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2086 echo "<option value=\"\">" . Entity::hsc(_MEMBERS_USESITELANG) . "</option>\n";
2089 foreach( $locales as $locale )
2091 if( $locale == $mem->getLocale() )
2093 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
2097 echo "<option value=\"{$locale}\">{$locale}</option>\n";
2106 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
2107 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
2111 $this->_insertPluginOptions('member',$memberid);
2114 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
2116 <td><?php echo _MEMBERS_EDIT?></td>
2117 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
2123 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2126 'MemberSettingsFormExtras',
2135 * @todo document this
2137 function action_changemembersettings() {
2138 global $member, $CONF, $manager;
2140 $memberid = intRequestVar('memberid');
2143 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
2145 $name = trim(strip_tags(postVar('name')));
2146 $realname = trim(strip_tags(postVar('realname')));
2147 $password = postVar('password');
2148 $repeatpassword = postVar('repeatpassword');
2149 $email = strip_tags(postVar('email'));
2150 $url = strip_tags(postVar('url'));
2152 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
2153 # original eregi: !eregi("^https?://", $url)
2155 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
2156 if (!preg_match('#^https?://#', $url) )
2158 $url = 'http://' . $url;
2161 $admin = postVar('admin');
2162 $canlogin = postVar('canlogin');
2163 $notes = strip_tags(postVar('notes'));
2164 $locale = postVar('locale');
2166 $mem = Member::createFromID($memberid);
2168 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2170 if (!isValidDisplayName($name))
2171 $this->error(_ERROR_BADNAME);
2173 if (($name != $mem->getDisplayName()) && Member::exists($name))
2174 $this->error(_ERROR_NICKNAMEINUSE);
2176 if ($password != $repeatpassword)
2177 $this->error(_ERROR_PASSWORDMISMATCH);
2179 if ($password && (i18n::strlen($password) < 6))
2180 $this->error(_ERROR_PASSWORDTOOSHORT);
2185 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2187 $this->error($pwderror);
2192 if ( !NOTIFICATION::address_validation($email) )
2194 $this->error(_ERROR_BADMAILADDRESS);
2198 $this->error(_ERROR_REALNAMEMISSING);
2200 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2201 $this->error(_ERROR_NOSUCHTRANSLATION);
2203 // check if there will remain at least one site member with both the logon and admin rights
2204 // (check occurs when taking away one of these rights from such a member)
2205 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2206 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2209 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2210 if (sql_num_rows($r) < 2)
2211 $this->error(_ERROR_ATLEASTONEADMIN);
2214 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2215 $mem->setDisplayName($name);
2217 $mem->setPassword($password);
2220 $oldEmail = $mem->getEmail();
2222 $mem->setRealName($realname);
2223 $mem->setEmail($email);
2225 $mem->setNotes($notes);
2226 $mem->setLocale($locale);
2229 // only allow super-admins to make changes to the admin status
2230 if ($member->isAdmin()) {
2231 $mem->setAdmin($admin);
2232 $mem->setCanLogin($canlogin);
2235 $autosave = postVar ('autosave');
2236 $mem->setAutosave($autosave);
2240 // store plugin options
2241 $aOptions = requestArray('plugoption');
2242 NucleusPlugin::apply_plugin_options($aOptions);
2243 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2245 // if email changed, generate new password
2246 if ($oldEmail != $mem->getEmail())
2248 $mem->sendActivationLink('addresschange', $oldEmail);
2250 $mem->newCookieKey();
2252 // only log out if the member being edited is the current member.
2253 if ($member->getID() == $memberid)
2255 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2260 if ( ( $mem->getID() == $member->getID() )
2261 && ( $mem->getDisplayName() != $member->getDisplayName() )
2263 $mem->newCookieKey();
2265 $this->action_login(_MSG_LOGINAGAIN, 0);
2267 $this->action_overview(_MSG_SETTINGSCHANGED);
2272 * Admin::action_memberadd()
2278 function action_memberadd()
2280 global $member, $manager;
2283 $member->isAdmin() or $this->disallow();
2285 if ( postVar('password') != postVar('repeatpassword') )
2287 $this->error(_ERROR_PASSWORDMISMATCH);
2290 if ( i18n::strlen(postVar('password')) < 6 )
2292 $this->error(_ERROR_PASSWORDTOOSHORT);
2295 $res = Member::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2301 // fire PostRegister event
2302 $newmem = new Member();
2303 $newmem->readFromName(postVar('name'));
2304 $manager->notify('PostRegister',array('member' => &$newmem));
2306 $this->action_usermanagement();
2311 * Account activation
2315 function action_activate() {
2317 $key = getVar('key');
2318 $this->_showActivationPage($key);
2322 * @todo document this
2324 function _showActivationPage($key, $message = '')
2328 // clean up old activation keys
2329 Member::cleanupActivationTable();
2331 // get activation info
2332 $info = Member::getActivationInfo($key);
2335 $this->error(_ERROR_ACTIVATE);
2337 $mem = Member::createFromId($info->vmember);
2340 $this->error(_ERROR_ACTIVATE);
2344 $bNeedsPasswordChange = true;
2346 switch ($info->vtype)
2349 $title = _ACTIVATE_FORGOT_TITLE;
2350 $text = _ACTIVATE_FORGOT_TEXT;
2353 $title = _ACTIVATE_REGISTER_TITLE;
2354 $text = _ACTIVATE_REGISTER_TEXT;
2356 case 'addresschange':
2357 $title = _ACTIVATE_CHANGE_TITLE;
2358 $text = _ACTIVATE_CHANGE_TEXT;
2359 $bNeedsPasswordChange = false;
2360 Member::activate($key);
2365 'memberName' => Entity::hsc($mem->getDisplayName())
2367 $title = Template::fill($title, $aVars);
2368 $text = Template::fill($text, $aVars);
2372 echo '<h2>' , $title, '</h2>';
2373 echo '<p>' , $text, '</p>';
2377 echo '<p class="error">',$message,'</p>';
2380 if ($bNeedsPasswordChange)
2383 <div><form action="index.php" method="post">
2385 <input type="hidden" name="action" value="activatesetpwd" />
2386 <?php $manager->addTicketHidden() ?>
2387 <input type="hidden" name="key" value="<?php echo Entity::hsc($key) ?>" />
2390 <td><?php echo _MEMBERS_PWD?></td>
2391 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2393 <td><?php echo _MEMBERS_REPPWD?></td>
2394 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2398 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2402 <td><?php echo _MEMBERS_SETPWD ?></td>
2403 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2418 * Account activation - set password part
2422 function action_activatesetpwd() {
2424 $key = postVar('key');
2426 // clean up old activation keys
2427 Member::cleanupActivationTable();
2429 // get activation info
2430 $info = Member::getActivationInfo($key);
2432 if (!$info || ($info->type == 'addresschange'))
2433 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2435 $mem = Member::createFromId($info->vmember);
2438 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2440 $password = postVar('password');
2441 $repeatpassword = postVar('repeatpassword');
2443 if ($password != $repeatpassword)
2444 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2446 if ($password && (i18n::strlen($password) < 6))
2447 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2453 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2455 return $this->_showActivationPage($key,$pwderror);
2461 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2463 return $this->_showActivationPage($key, $error);
2467 $mem->setPassword($password);
2470 // do the activation
2471 Member::activate($key);
2474 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2475 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2480 * Admin::action_manageteam()
2486 public function action_manageteam()
2488 global $member, $manager;
2490 $blogid = intRequestVar('blogid');
2493 $member->blogAdminRights($blogid) or $this->disallow();
2497 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(" . _BACK_TO_BLOGSETTINGS . ")</a></p>\n";
2499 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . "</h2>\n";
2501 echo '<h3>' . _TEAM_CURRENT . "</h3>\n";
2503 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2504 . ' FROM '.sql_table('member').', '.sql_table('team')
2505 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2507 $template['content'] = 'teamlist';
2508 $template['tabindex'] = 10;
2510 $manager->loadClass("ENCAPSULATE");
2511 $batch = new Batch('team');
2512 $batch->showlist($query, 'table', $template);
2514 echo '<h3>' . _TEAM_ADDNEW . "</h3>\n";
2516 echo "<form method=\"post\" action=\"index.php\">\n";
2519 echo "<input type=\"hidden\" name=\"action\" value=\"teamaddmember\" />\n";
2520 echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
2521 $manager->addTicketHidden();
2523 echo '<table frame="box" rules="all" summary="' . _TEAM_ADDNEW . '">' . "\n";
2525 echo '<td>' . _TEAM_CHOOSEMEMBER . "</td>\n";
2527 // TODO: try to make it so only non-team-members are listed
2530 $query = 'SELECT mname as text, mnumber as value FROM '.sql_table('member');
2531 $template['name'] = 'memberid';
2532 $template['tabindex'] = 10000;
2533 showlist($query,'select',$template);
2538 echo '<td>' . _TEAM_ADMIN;
2542 $this->input_yesno('admin',0,10020);
2546 echo '<td>' . _TEAM_ADD . "</td>\n";
2547 echo '<td><input type="submit" value="' . _TEAM_ADD_BTN . '" tabindex="10030" />' . "</td>\n";
2559 * Add member to team
2561 function action_teamaddmember() {
2562 global $member, $manager;
2564 $memberid = intPostVar('memberid');
2565 $blogid = intPostVar('blogid');
2566 $admin = intPostVar('admin');
2569 $member->blogAdminRights($blogid) or $this->disallow();
2571 $blog =& $manager->getBlog($blogid);
2572 if (!$blog->addTeamMember($memberid, $admin))
2573 $this->error(_ERROR_ALREADYONTEAM);
2575 $this->action_manageteam();
2580 * @todo document this
2582 function action_teamdelete() {
2583 global $member, $manager;
2585 $memberid = intRequestVar('memberid');
2586 $blogid = intRequestVar('blogid');
2589 $member->blogAdminRights($blogid) or $this->disallow();
2591 $teammem = Member::createFromID($memberid);
2592 $blog =& $manager->getBlog($blogid);
2596 <h2><?php echo _DELETE_CONFIRM?></h2>
2598 <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>
2602 <form method="post" action="index.php"><div>
2603 <input type="hidden" name="action" value="teamdeleteconfirm" />
2604 <?php $manager->addTicketHidden() ?>
2605 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2606 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2607 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2614 * @todo document this
2616 function action_teamdeleteconfirm() {
2619 $memberid = intRequestVar('memberid');
2620 $blogid = intRequestVar('blogid');
2622 $error = $this->deleteOneTeamMember($blogid, $memberid);
2624 $this->error($error);
2627 $this->action_manageteam();
2631 * @todo document this
2633 function deleteOneTeamMember($blogid, $memberid) {
2634 global $member, $manager;
2636 $blogid = intval($blogid);
2637 $memberid = intval($memberid);
2640 if (!$member->blogAdminRights($blogid))
2641 return _ERROR_DISALLOWED;
2643 // check if: - there remains at least one blog admin
2644 // - (there remains at least one team member)
2645 $tmem = Member::createFromID($memberid);
2647 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2649 if ($tmem->isBlogAdmin($blogid)) {
2650 // check if there are more blog members left and at least one admin
2651 // (check for at least two admins before deletion)
2652 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2653 $r = sql_query($query);
2654 if (sql_num_rows($r) < 2)
2655 return _ERROR_ATLEASTONEBLOGADMIN;
2658 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2661 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2667 * @todo document this
2669 function action_teamchangeadmin() {
2672 $blogid = intRequestVar('blogid');
2673 $memberid = intRequestVar('memberid');
2676 $member->blogAdminRights($blogid) or $this->disallow();
2678 $mem = Member::createFromID($memberid);
2680 // don't allow when there is only one admin at this moment
2681 if ($mem->isBlogAdmin($blogid)) {
2682 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2683 if (sql_num_rows($r) == 1)
2684 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2687 if ($mem->isBlogAdmin($blogid))
2692 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2695 // only show manageteam if member did not change its own admin privileges
2696 if ($member->isBlogAdmin($blogid))
2697 $this->action_manageteam();
2699 $this->action_overview(_MSG_ADMINCHANGED);
2703 * Admin::action_blogsettings()
2708 public function action_blogsettings()
2710 global $member, $manager;
2712 $blogid = intRequestVar('blogid');
2715 $member->blogAdminRights($blogid) or $this->disallow();
2717 $blog =& $manager->getBlog($blogid);
2719 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
2720 $this->pagehead($extrahead);
2722 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
2723 echo '<h2>' . _EBLOG_TITLE . ": '{$this->bloglink($blog)}'</h2>\n";
2725 echo '<h3>' . _EBLOG_TEAM_TITLE . "</h3>\n";
2727 echo '<p>' . _EBLOG_CURRENT_TEAM_MEMBER;
2729 $query = "SELECT mname, mrealname FROM %s, %s WHERE mnumber=tmember AND tblog=%d;";
2730 $query = sprintf($query, sql_table('member'), sql_table('team'), (integer) $blogid);
2731 $res = sql_query($query);
2732 $aMemberNames = array();
2733 while ( $o = sql_fetch_object($res) )
2735 $aMemberNames[] = Entity::hsc($o->mname) . ' (' . Entity::hsc($o->mrealname). ')';
2737 echo implode(',', $aMemberNames);
2741 echo '<a href="index.php?action=manageteam&blogid=' . $blogid . '">' . _EBLOG_TEAM_TEXT . '</a>';
2744 echo '<h3>' . _EBLOG_SETTINGS_TITLE . "</h3>\n";
2746 echo "<form method=\"post\" action=\"index.php\">\n";
2749 echo "<input type=\"hidden\" name=\"action\" value=\"blogsettingsupdate\" />\n";
2750 $manager->addTicketHidden() . "\n";
2751 echo "<input type=\"hidden\" name=\"blogid\" value=\"{$blogid}\" />\n";
2753 echo '<table frame="box" rules="all" summary="' . _EBLOG_SETTINGS_TITLE . '">' . "\n";
2756 echo '<th colspan="2">' . _EBLOG_CHANGE . "</th>\n";
2759 echo '<td>' . _EBLOG_CHANGE . "</td>\n";
2760 echo '<td><input type="submit" tabindex="130" value="' . _EBLOG_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
2765 echo '<td>' . _EBLOG_NAME . "</td>\n";
2766 echo '<td><input name="name" tabindex="10" size="40" maxlength="60" value="' . Entity::hsc($blog->getName()) . '" />' . "</td>\n";
2769 echo '<td>' . _EBLOG_SHORTNAME;
2770 help('shortblogname');
2771 echo _EBLOG_SHORTNAME_EXTRA;
2773 echo '<td><input name="shortname" tabindex="20" maxlength="15" size="15" value="' . Entity::hsc($blog->getShortName()) .'" />' . "</td>\n";
2776 echo '<td>' . _EBLOG_DESC . "</td>\n";
2777 echo '<td><input name="desc" tabindex="30" maxlength="200" size="40" value="' . Entity::hsc($blog->getDescription()) . '" />' . "</td>\n";
2780 echo '<td>' . _EBLOG_URL . "</td>\n";
2781 echo '<td><input name="url" tabindex="40" size="40" maxlength="100" value="' . Entity::hsc($blog->getURL()) . '" />' . "</td>\n";
2784 echo '<td>' . _EBLOG_DEFSKIN;
2785 help('blogdefaultskin');
2789 $query = 'SELECT sdname as text, sdnumber as value FROM ' . sql_table('skin_desc');
2790 $template['name'] = 'defskin';
2791 $template['selected'] = $blog->getDefaultSkin();
2792 $template['tabindex'] = 50;
2793 showlist($query, 'select', $template);
2798 echo '<td>' . _EBLOG_LINEBREAKS;
2799 help('convertbreaks');
2802 $this->input_yesno('convertbreaks',$blog->convertBreaks(),55);
2807 echo '<td>' . _EBLOG_ALLOWPASTPOSTING;
2808 help('allowpastposting');
2811 $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57);
2815 echo '<td>' . _EBLOG_DISABLECOMMENTS;
2818 $this->input_yesno('comments', $blog->commentsEnabled(), 60);
2822 echo '<td>' . _EBLOG_ANONYMOUS . "</td>\n";
2824 $this->input_yesno('public',$blog->isPublic(),70);
2828 echo '<td>' . _EBLOG_REQUIREDEMAIL . "</td>\n";
2830 $this->input_yesno('reqemail', $blog->emailRequired(),72);
2834 echo '<td>' . _EBLOG_NOTIFY;
2837 echo '<td><input name="notify" tabindex="80" maxlength="128" size="40" value="' . Entity::hsc($blog->getNotifyAddress()) . '" />' . "</td>\n";
2841 echo '<td>' . _EBLOG_NOTIFY_ON . "</td>\n";
2844 if ( !$blog->notifyOnComment() )
2846 echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" />\n";
2850 echo "<input name=\"notifyComment\" value=\"3\" type=\"checkbox\" tabindex=\"81\" id=\"notifyComment\" checked=\"checked\"/>\n";
2852 echo '<label for="notifyComment">' . _EBLOG_NOTIFY_COMMENT . "</label><br />\n";
2854 if ( !$blog->notifyOnVote() )
2856 echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" />\n";
2860 echo "<input name=\"notifyVote\" value=\"5\" type=\"checkbox\" tabindex=\"82\" id=\"notifyVote\" checked=\"checked\" />\n";
2863 echo '<label for="notifyVote">' . _EBLOG_NOTIFY_KARMA . "</label><br />\n";
2865 if ( !$blog->notifyOnNewItem() )
2867 echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" />\n";
2872 echo "<input name=\"notifyNewItem\" value=\"7\" type=\"checkbox\" tabindex=\"83\" id=\"notifyNewItem\" checked=\"checked\" />\n";
2875 echo '<label for="notifyNewItem">' . _EBLOG_NOTIFY_ITEM . "</label>\n";
2880 echo '<td>' . _EBLOG_MAXCOMMENTS;
2881 help('blogmaxcomments');
2883 echo '<td><input name="maxcomments" tabindex="90" size="3" value="' . Entity::hsc($blog->getMaxComments()) . '" />' . "</td>\n";
2886 echo '<td>' . _EBLOG_UPDATE;
2887 help('blogupdatefile');
2889 echo '<td><input name="update" tabindex="100" size="40" maxlength="60" value="' . Entity::hsc($blog->getUpdateFile()) .'" />' . "</td>\n";
2892 echo '<td>' . _EBLOG_DEFCAT . "</td>\n";
2894 $query = "SELECT cname as text, catid as value FROM %s WHERE cblog=%d;";
2895 $query = sprintf($query, sql_table('category'), (integer) $blog->getID());
2896 $template['name'] = 'defcat';
2897 $template['selected'] = $blog->getDefaultCategory();
2898 $template['tabindex'] = 110;
2899 showlist($query, 'select', $template);
2903 echo '<td>' . _EBLOG_OFFSET;
2904 help('blogtimeoffset');
2907 echo ' <b>' . i18n::formatted_datetime('%H:%M', time()) . '</b><br />';
2909 echo '<b>' . i18n::formatted_datetime('%H:%M', $blog->getCorrectTime()) . '</b>';
2911 echo '<td><input name="timeoffset" tabindex="120" size="3" value="' . Entity::hsc($blog->getTimeOffset()) .'" />' . "</td>\n";
2914 echo '<td>' . _EBLOG_SEARCH;
2915 help('blogsearchable');
2918 $this->input_yesno('searchable', $blog->getSearchable(), 122);
2923 $this->_insertPluginOptions('blog', $blogid);
2931 echo '<h3>' . _EBLOG_CAT_TITLE . "</h3>\n";
2933 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2934 $template['content'] = 'categorylist';
2935 $template['tabindex'] = 200;
2937 $manager->loadClass("ENCAPSULATE");
2938 $batch = new Batch('category');
2939 $batch->showlist($query,'table',$template);
2941 echo "<form action=\"index.php\" method=\"post\">\n";
2943 echo "<input name=\"action\" value=\"categorynew\" type=\"hidden\" />\n";
2944 $manager->addTicketHidden() . "\n";
2945 echo "<input name=\"blogid\" value=\"{$blog->getID()}\" type=\"hidden\" />\n";
2947 echo '<table frame="box" rules="all" summary="' . _EBLOG_CAT_CREATE . '">' . "\n";
2950 echo '<th colspan="2">' . _EBLOG_CAT_CREATE . "</th>\n";
2955 echo '<td>' . _EBLOG_CAT_NAME . "</td>\n";
2956 echo "<td><input name=\"cname\" size=\"40\" maxlength=\"40\" tabindex=\"300\" /></td>\n";
2959 echo '<td>' . _EBLOG_CAT_DESC . "</td>\n";
2960 echo "<td><input name=\"cdesc\" size=\"40\" maxlength=\"200\" tabindex=\"310\" /></td>\n";
2963 echo '<td>' . _EBLOG_CAT_CREATE . "</td>\n";
2964 echo '<td><input type="submit" value="' . _EBLOG_CAT_CREATE . '" tabindex="320" />' . "</td>\n";
2971 echo '<h3>' . _PLUGINS_EXTRA . "</h3>\n";
2972 $manager->notify('BlogSettingsFormExtras', array('blog' => &$blog));
2979 * @todo document this
2981 function action_categorynew() {
2982 global $member, $manager;
2984 $blogid = intRequestVar('blogid');
2986 $member->blogAdminRights($blogid) or $this->disallow();
2988 $cname = postVar('cname');
2989 $cdesc = postVar('cdesc');
2991 if (!isValidCategoryName($cname))
2992 $this->error(_ERROR_BADCATEGORYNAME);
2994 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2995 $res = sql_query($query);
2996 if (sql_num_rows($res) > 0)
2997 $this->error(_ERROR_DUPCATEGORYNAME);
2999 $blog =& $manager->getBlog($blogid);
3000 $newCatID = $blog->createNewCategory($cname, $cdesc);
3002 $this->action_blogsettings();
3006 * @todo document this
3008 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
3009 global $member, $manager;
3012 $blogid = intGetVar('blogid');
3014 $blogid = intval($blogid);
3016 $catid = intGetVar('catid');
3018 $catid = intval($catid);
3020 $member->blogAdminRights($blogid) or $this->disallow();
3022 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
3023 $obj = sql_fetch_object($res);
3025 $cname = $obj->cname;
3026 $cdesc = $obj->cdesc;
3028 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
3029 $this->pagehead($extrahead);
3031 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
3034 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo Entity::hsc($cname)?>'</h2>
3035 <form method='post' action='index.php'><div>
3036 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
3037 <input name="catid" type="hidden" value="<?php echo $catid?>" />
3038 <input name="desturl" type="hidden" value="<?php echo Entity::hsc($desturl) ?>" />
3039 <input name="action" type="hidden" value="categoryupdate" />
3040 <?php $manager->addTicketHidden(); ?>
3043 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
3045 <td><?php echo _EBLOG_CAT_NAME?></td>
3046 <td><input type="text" name="cname" value="<?php echo Entity::hsc($cname)?>" size="40" maxlength="40" /></td>
3048 <td><?php echo _EBLOG_CAT_DESC?></td>
3049 <td><input type="text" name="cdesc" value="<?php echo Entity::hsc($cdesc)?>" size="40" maxlength="200" /></td>
3052 // insert plugin options
3053 $this->_insertPluginOptions('category',$catid);
3056 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
3058 <td><?php echo _EBLOG_CAT_UPDATE?></td>
3059 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
3068 * @todo document this
3070 function action_categoryupdate() {
3071 global $member, $manager;
3073 $blogid = intPostVar('blogid');
3074 $catid = intPostVar('catid');
3075 $cname = postVar('cname');
3076 $cdesc = postVar('cdesc');
3077 $desturl = postVar('desturl');
3079 $member->blogAdminRights($blogid) or $this->disallow();
3081 if (!isValidCategoryName($cname))
3082 $this->error(_ERROR_BADCATEGORYNAME);
3084 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
3085 $res = sql_query($query);
3086 if (sql_num_rows($res) > 0)
3087 $this->error(_ERROR_DUPCATEGORYNAME);
3089 $query = 'UPDATE '.sql_table('category').' SET'
3090 . " cname='" . sql_real_escape_string($cname) . "',"
3091 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
3092 . " WHERE catid=" . $catid;
3096 // store plugin options
3097 $aOptions = requestArray('plugoption');
3098 NucleusPlugin::apply_plugin_options($aOptions);
3099 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
3106 $this->action_blogsettings();
3111 * @todo document this
3113 function action_categorydelete() {
3114 global $member, $manager;
3116 $blogid = intRequestVar('blogid');
3117 $catid = intRequestVar('catid');
3119 $member->blogAdminRights($blogid) or $this->disallow();
3121 $blog =& $manager->getBlog($blogid);
3123 // check if the category is valid
3124 if (!$blog->isValidCategory($catid))
3125 $this->error(_ERROR_NOSUCHCATEGORY);
3127 // don't allow deletion of default category
3128 if ($blog->getDefaultCategory() == $catid)
3129 $this->error(_ERROR_DELETEDEFCATEGORY);
3131 // check if catid is the only category left for blogid
3132 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
3133 $res = sql_query($query);
3134 if (sql_num_rows($res) == 1)
3135 $this->error(_ERROR_DELETELASTCATEGORY);
3140 <h2><?php echo _DELETE_CONFIRM?></h2>
3143 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo Entity::hsc($blog->getCategoryName($catid))?></b>
3146 <form method="post" action="index.php"><div>
3147 <input type="hidden" name="action" value="categorydeleteconfirm" />
3148 <?php $manager->addTicketHidden() ?>
3149 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
3150 <input type="hidden" name="catid" value="<?php echo $catid?>" />
3151 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3158 * @todo document this
3160 function action_categorydeleteconfirm() {
3161 global $member, $manager;
3163 $blogid = intRequestVar('blogid');
3164 $catid = intRequestVar('catid');
3166 $member->blogAdminRights($blogid) or $this->disallow();
3168 $error = $this->deleteOneCategory($catid);
3170 $this->error($error);
3172 $this->action_blogsettings();
3176 * Admin::deleteOneCategory()
3177 * Delete a category by its id
3179 * @param String $catid category id for deleting
3182 function deleteOneCategory($catid)
3184 global $manager, $member;
3186 $catid = intval($catid);
3187 $blogid = getBlogIDFromCatID($catid);
3189 if ( !$member->blogAdminRights($blogid) )
3191 return ERROR_DISALLOWED;
3195 $blog =& $manager->getBlog($blogid);
3197 // check if the category is valid
3198 if ( !$blog || !$blog->isValidCategory($catid) )
3200 return _ERROR_NOSUCHCATEGORY;
3203 $destcatid = $blog->getDefaultCategory();
3205 // don't allow deletion of default category
3206 if ( $blog->getDefaultCategory() == $catid )
3208 return _ERROR_DELETEDEFCATEGORY;
3211 // check if catid is the only category left for blogid
3212 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
3213 $res = sql_query($query);
3214 if ( sql_num_rows($res) == 1 )
3216 return _ERROR_DELETELASTCATEGORY;
3219 $manager->notify('PreDeleteCategory', array('catid' => $catid));
3221 // change category for all items to the default category
3222 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
3225 // delete all associated plugin options
3226 NucleusPlugin::delete_option_values('category', $catid);
3229 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
3232 $manager->notify('PostDeleteCategory', array('catid' => $catid));
3237 * Admin::action_blogsettingsupdate
3238 * Updating blog settings
3243 function action_blogsettingsupdate()
3245 global $member, $manager;
3247 $blogid = intRequestVar('blogid');
3249 $member->blogAdminRights($blogid) or $this->disallow();
3251 $blog =& $manager->getBlog($blogid);
3253 $notify_address = trim(postVar('notify'));
3254 $shortname = trim(postVar('shortname'));
3255 $updatefile = trim(postVar('update'));
3257 $notifyComment = intPostVar('notifyComment');
3258 $notifyVote = intPostVar('notifyVote');
3259 $notifyNewItem = intPostVar('notifyNewItem');
3261 if ( $notifyComment == 0 )
3265 if ( $notifyVote == 0 )
3269 if ( $notifyNewItem == 0 )
3273 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
3275 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
3277 $this->error(_ERROR_BADNOTIFY);
3280 if ( !isValidShortName($shortname) )
3282 $this->error(_ERROR_BADSHORTBLOGNAME);
3285 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
3287 $this->error(_ERROR_DUPSHORTBLOGNAME);
3289 // check if update file is writable
3290 if ( $updatefile && !is_writeable($updatefile) )
3292 $this->error(_ERROR_UPDATEFILE);
3295 $blog->setName(trim(postVar('name')));
3296 $blog->setShortName($shortname);
3297 $blog->setNotifyAddress($notify_address);
3298 $blog->setNotifyType($notifyType);
3299 $blog->setMaxComments(postVar('maxcomments'));
3300 $blog->setCommentsEnabled(postVar('comments'));
3301 $blog->setTimeOffset(postVar('timeoffset'));
3302 $blog->setUpdateFile($updatefile);
3303 $blog->setURL(trim(postVar('url')));
3304 $blog->setDefaultSkin(intPostVar('defskin'));
3305 $blog->setDescription(trim(postVar('desc')));
3306 $blog->setPublic(postVar('public'));
3307 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3308 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3309 $blog->setDefaultCategory(intPostVar('defcat'));
3310 $blog->setSearchable(intPostVar('searchable'));
3311 $blog->setEmailRequired(intPostVar('reqemail'));
3312 $blog->writeSettings();
3314 // store plugin options
3315 $aOptions = requestArray('plugoption');
3316 NucleusPlugin::apply_plugin_options($aOptions);
3317 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3319 $this->action_overview(_MSG_SETTINGSCHANGED);
3324 * @todo document this
3326 function action_deleteblog() {
3327 global $member, $CONF, $manager;
3329 $blogid = intRequestVar('blogid');
3331 $member->blogAdminRights($blogid) or $this->disallow();
3333 // check if blog is default blog
3334 if ($CONF['DefaultBlog'] == $blogid)
3335 $this->error(_ERROR_DELDEFBLOG);
3337 $blog =& $manager->getBlog($blogid);
3341 <h2><?php echo _DELETE_CONFIRM?></h2>
3343 <p><?php echo _WARNINGTXT_BLOGDEL?>
3347 <?php echo _CONFIRMTXT_BLOG?><b><?php echo Entity::hsc($blog->getName())?></b>
3350 <form method="post" action="index.php"><div>
3351 <input type="hidden" name="action" value="deleteblogconfirm" />
3352 <?php $manager->addTicketHidden() ?>
3353 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3354 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3361 * Admin::action_deleteblogconfirm()
3367 function action_deleteblogconfirm()
3369 global $member, $CONF, $manager;
3371 $blogid = intRequestVar('blogid');
3372 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3373 $member->blogAdminRights($blogid) or $this->disallow();
3375 // check if blog is default blog
3376 if ( $CONF['DefaultBlog'] == $blogid )
3378 $this->error(_ERROR_DELDEFBLOG);
3381 // delete all comments
3382 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3386 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3389 // delete all team members
3390 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3394 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3397 // delete all categories
3398 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3401 // delete all associated plugin options
3402 NucleusPlugin::delete_option_values('blog', $blogid);
3404 // delete the blog itself
3405 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3408 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3410 $this->action_overview(_DELETED_BLOG);
3415 * @todo document this
3417 function action_memberdelete() {
3418 global $member, $manager;
3420 $memberid = intRequestVar('memberid');
3422 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3424 $mem = Member::createFromID($memberid);
3428 <h2><?php echo _DELETE_CONFIRM?></h2>
3430 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo Entity::hsc($mem->getDisplayName()) ?></b>
3434 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3437 <form method="post" action="index.php"><div>
3438 <input type="hidden" name="action" value="memberdeleteconfirm" />
3439 <?php $manager->addTicketHidden() ?>
3440 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3441 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3448 * @todo document this
3450 function action_memberdeleteconfirm() {
3453 $memberid = intRequestVar('memberid');
3455 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3457 $error = $this->deleteOneMember($memberid);
3459 $this->error($error);
3461 if ($member->isAdmin())
3462 $this->action_usermanagement();
3464 $this->action_overview(_DELETED_MEMBER);
3468 * Admin::deleteOneMember()
3469 * Delete a member by id
3472 * @params Integer $memberid member id
3473 * @return String null string or error messages
3475 function deleteOneMember($memberid)
3479 $memberid = intval($memberid);
3480 $mem = Member::createFromID($memberid);
3482 if ( !$mem->canBeDeleted() )
3484 return _ERROR_DELETEMEMBER;
3487 $manager->notify('PreDeleteMember', array('member' => &$mem));
3489 /* unlink comments from memberid */
3492 $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";
3493 $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);
3497 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3500 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3503 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3506 // delete all associated plugin options
3507 NucleusPlugin::delete_option_values('member', $memberid);
3509 $manager->notify('PostDeleteMember', array('member' => &$mem));
3515 * @todo document this
3517 function action_createnewlog() {
3518 global $member, $CONF, $manager;
3520 // Only Super-Admins can do this
3521 $member->isAdmin() or $this->disallow();
3525 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3527 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3529 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3531 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3533 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3536 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3537 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3540 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3543 <?php echo _EBLOG_CREATE_TEXT?>
3546 <form method="post" action="index.php"><div>
3548 <input type="hidden" name="action" value="addnewlog" />
3549 <?php $manager->addTicketHidden() ?>
3553 <td><?php echo _EBLOG_NAME?></td>
3554 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3556 <td><?php echo _EBLOG_SHORTNAME?>
3557 <?php help('shortblogname'); ?>
3559 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3561 <td><?php echo _EBLOG_DESC?></td>
3562 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3564 <td><?php echo _EBLOG_DEFSKIN?>
3565 <?php help('blogdefaultskin'); ?>
3569 $query = 'SELECT sdname as text, sdnumber as value'
3570 . ' FROM '.sql_table('skin_desc');
3571 $template['name'] = 'defskin';
3572 $template['tabindex'] = 50;
3573 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3574 showlist($query,'select',$template);
3578 <td><?php echo _EBLOG_OFFSET?>
3579 <?php help('blogtimeoffset'); ?>
3580 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::formatted_datetime('%H:%M',time()); ?></b>
3582 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3584 <td><?php echo _EBLOG_ADMIN?>
3585 <?php help('teamadmin'); ?>
3587 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3589 <td><?php echo _EBLOG_CREATE?></td>
3590 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3599 * @todo document this
3601 function action_addnewlog() {
3602 global $member, $manager, $CONF;
3604 // Only Super-Admins can do this
3605 $member->isAdmin() or $this->disallow();
3607 $bname = trim(postVar('name'));
3608 $bshortname = trim(postVar('shortname'));
3609 $btimeoffset = postVar('timeoffset');
3610 $bdesc = trim(postVar('desc'));
3611 $bdefskin = postVar('defskin');
3613 if (!isValidShortName($bshortname))
3614 $this->error(_ERROR_BADSHORTBLOGNAME);
3616 if ($manager->existsBlog($bshortname))
3617 $this->error(_ERROR_DUPSHORTBLOGNAME);
3623 'shortname' => &$bshortname,
3624 'timeoffset' => &$btimeoffset,
3625 'description' => &$bdesc,
3626 'defaultskin' => &$bdefskin
3631 // add slashes for sql queries
3632 $bname = sql_real_escape_string($bname);
3633 $bshortname = sql_real_escape_string($bshortname);
3634 $btimeoffset = sql_real_escape_string($btimeoffset);
3635 $bdesc = sql_real_escape_string($bdesc);
3636 $bdefskin = sql_real_escape_string($bdefskin);
3639 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3641 $blogid = sql_insert_id();
3642 $blog =& $manager->getBlog($blogid);
3644 // create new category
3645 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3646 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3647 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3648 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3649 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3650 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3651 $catid = sql_insert_id();
3653 // set as default category
3654 $blog->setDefaultCategory($catid);
3655 $blog->writeSettings();
3657 // create team member
3658 $memberid = $member->getID();
3659 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3662 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3663 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3665 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3666 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3681 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3682 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3689 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3691 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, Entity::hsc($bname)) ?></p>
3694 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, Entity::hsc($bshortname)) ?></a></li>
3695 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3698 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, Entity::hsc($bshortname)) ?></a></h3>
3700 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, Entity::hsc($bshortname)) ?></p>
3703 $CONF['Self'] = '<b><?php echo Entity::hsc($bshortname)?>.php</b>';
3705 include('<i>./config.php</i>');
3707 selectBlog('<b><?php echo Entity::hsc($bshortname)?></b>');
3712 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3714 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3716 <form action="index.php" method="post"><div>
3717 <input type="hidden" name="action" value="addnewlog2" />
3718 <?php $manager->addTicketHidden() ?>
3719 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3721 <td><?php echo _EBLOG_URL?></td>
3722 <td><input name="url" maxlength="100" size="40" value="<?php echo Entity::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3724 <td><?php echo _EBLOG_CREATE?></td>
3725 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3729 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3731 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3733 <form action="index.php" method="post"><div>
3734 <input type="hidden" name="action" value="addnewlog2" />
3735 <?php $manager->addTicketHidden() ?>
3736 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3738 <td><?php echo _EBLOG_URL?></td>
3739 <td><input name="url" maxlength="100" size="40" /></td>
3741 <td><?php echo _EBLOG_CREATE?></td>
3742 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3746 <?php $this->pagefoot();
3751 * @todo document this
3753 function action_addnewlog2() {
3754 global $member, $manager;
3756 $member->blogAdminRights($blogid) or $this->disallow();
3758 $burl = requestVar('url');
3759 $blogid = intRequestVar('blogid');
3761 $blog =& $manager->getBlog($blogid);
3762 $blog->setURL(trim($burl));
3763 $blog->writeSettings();
3765 $this->action_overview(_MSG_NEWBLOG);
3769 * @todo document this
3771 function action_skinieoverview() {
3772 global $member, $DIR_LIBS, $manager;
3774 $member->isAdmin() or $this->disallow();
3776 // load skinie class
3777 include_once($DIR_LIBS . 'skinie.php');
3781 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3784 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3786 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3787 <?php global $DIR_SKINS;
3789 $candidates = SkinImport::searchForCandidates($DIR_SKINS);
3791 if (sizeof($candidates) > 0) {
3793 <form method="post" action="index.php"><div>
3794 <input type="hidden" name="action" value="skinieimport" />
3795 <?php $manager->addTicketHidden() ?>
3796 <input type="hidden" name="mode" value="file" />
3797 <select name="skinfile" id="skinie_import_local">
3798 <?php foreach ($candidates as $skinname => $skinfile) {
3799 $html = Entity::hsc($skinfile);
3800 echo '<option value="',$html,'">',$skinname,'</option>';
3804 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3807 echo _SKINIE_NOCANDIDATES;
3812 <p><em><?php echo _OR?></em></p>
3814 <form method="post" action="index.php"><p>
3815 <?php $manager->addTicketHidden() ?>
3816 <input type="hidden" name="action" value="skinieimport" />
3817 <input type="hidden" name="mode" value="url" />
3818 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3819 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3820 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3824 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3825 <form method="post" action="index.php"><div>
3826 <input type="hidden" name="action" value="skinieexport" />
3827 <?php $manager->addTicketHidden() ?>
3829 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3832 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3834 <?php // show list of skins
3835 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3836 while ($skinObj = sql_fetch_object($res)) {
3837 $id = 'skinexp' . $skinObj->sdnumber;
3838 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3839 echo '<label for="',$id,'">',Entity::hsc($skinObj->sdname),'</label></td>';
3840 echo '<td>',Entity::hsc($skinObj->sddesc),'</td>';
3844 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3846 // show list of templates
3847 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3848 while ($templateObj = sql_fetch_object($res)) {
3849 $id = 'templateexp' . $templateObj->tdnumber;
3850 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3851 echo '<label for="',$id,'">',Entity::hsc($templateObj->tdname),'</label></td>';
3852 echo '<td>',Entity::hsc($templateObj->tddesc),'</td>';
3857 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3859 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3861 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3863 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3873 * @todo document this
3875 function action_skinieimport() {
3876 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3878 $member->isAdmin() or $this->disallow();
3880 // load skinie class
3881 include_once($DIR_LIBS . 'skinie.php');
3883 $skinFileRaw= postVar('skinfile');
3884 $mode = postVar('mode');
3886 $importer = new SkinImport();
3888 // get full filename
3889 if ($mode == 'file')
3891 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3893 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3894 if (!file_exists($skinFile))
3895 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3897 $skinFile = $skinFileRaw;
3900 // read only metadata
3901 $error = $importer->readFile($skinFile, 1);
3904 $skinNameClashes = $importer->checkSkinNameClashes();
3905 $templateNameClashes = $importer->checkTemplateNameClashes();
3906 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3908 if ($error) $this->error($error);
3912 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3914 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3917 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
3918 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3919 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3921 if ($hasNameClashes)
3924 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3925 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3927 } // if (hasNameClashes)
3931 <form method="post" action="index.php"><div>
3932 <input type="hidden" name="action" value="skiniedoimport" />
3933 <?php $manager->addTicketHidden() ?>
3934 <input type="hidden" name="skinfile" value="<?php echo Entity::hsc(postVar('skinfile'))?>" />
3935 <input type="hidden" name="mode" value="<?php echo Entity::hsc($mode)?>" />
3936 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3938 if ($hasNameClashes)
3942 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3944 } // if (hasNameClashes)
3954 * @todo document this
3956 function action_skiniedoimport() {
3957 global $member, $DIR_LIBS, $DIR_SKINS;
3959 $member->isAdmin() or $this->disallow();
3961 // load skinie class
3962 include_once($DIR_LIBS . 'skinie.php');
3964 $skinFileRaw= postVar('skinfile');
3965 $mode = postVar('mode');
3967 $allowOverwrite = intPostVar('overwrite');
3969 // get full filename
3970 if ($mode == 'file')
3972 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3974 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3975 if (!file_exists($skinFile))
3976 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3979 $skinFile = $skinFileRaw;
3982 $importer = new SkinImport();
3984 $error = $importer->readFile($skinFile);
3987 $this->error($error);
3989 $error = $importer->writeToDatabase($allowOverwrite);
3992 $this->error($error);
3996 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3998 <h2><?php echo _SKINIE_DONE?></h2>
4001 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo Entity::hsc($importer->getInfo())?></p></li>
4002 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
4003 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
4006 <?php $this->pagefoot();
4011 * @todo document this
4013 function action_skinieexport() {
4014 global $member, $DIR_LIBS;
4016 $member->isAdmin() or $this->disallow();
4018 // load skinie class
4019 include_once($DIR_LIBS . 'skinie.php');
4021 $aSkins = requestIntArray('skin');
4022 $aTemplates = requestIntArray('template');
4024 if (!is_array($aTemplates)) $aTemplates = array();
4025 if (!is_array($aSkins)) $aSkins = array();
4027 $skinList = array_keys($aSkins);
4028 $templateList = array_keys($aTemplates);
4030 $info = postVar('info');
4032 $exporter = new SkinExport();
4033 foreach ($skinList as $skinId) {
4034 $exporter->addSkin($skinId);
4036 foreach ($templateList as $templateId) {
4037 $exporter->addTemplate($templateId);
4039 $exporter->setInfo($info);
4041 $exporter->export();
4045 * @todo document this
4047 function action_templateoverview() {
4048 global $member, $manager;
4050 $member->isAdmin() or $this->disallow();
4054 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4056 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
4057 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
4059 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
4060 $template['content'] = 'templatelist';
4061 $template['tabindex'] = 10;
4062 showlist($query,'table',$template);
4064 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
4067 <form method="post" action="index.php"><div>
4069 <input name="action" value="templatenew" type="hidden" />
4070 <?php $manager->addTicketHidden() ?>
4072 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
4073 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4075 <td><?php echo _TEMPLATE_DESC?></td>
4076 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4078 <td><?php echo _TEMPLATE_CREATE?></td>
4079 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4089 * @todo document this
4091 function action_templateedit($msg = '') {
4092 global $member, $manager;
4094 $templateid = intRequestVar('templateid');
4096 $member->isAdmin() or $this->disallow();
4098 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
4099 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
4101 $this->pagehead($extrahead);
4103 $templatename = Template::getNameFromId($templateid);
4104 $templatedescription = Template::getDesc($templateid);
4105 $template =& $manager->getTemplate($templatename);
4109 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
4112 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo Entity::hsc($templatename); ?>'</h2>
4114 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4117 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
4119 <form method="post" action="index.php">
4122 <input type="hidden" name="action" value="templateupdate" />
4123 <?php $manager->addTicketHidden() ?>
4124 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
4127 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
4129 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
4130 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo Entity::hsc($templatename) ?>" /></td>
4132 <td><?php echo _TEMPLATE_DESC?></td>
4133 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo Entity::hsc($templatedescription) ?>" /></td>
4135 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
4137 <td><?php echo _TEMPLATE_UPDATE?></td>
4139 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
4140 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
4143 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
4144 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
4145 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
4146 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
4147 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
4148 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
4149 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
4152 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
4153 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
4154 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
4155 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
4156 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
4157 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
4158 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
4159 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
4162 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
4164 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
4167 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
4168 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
4171 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
4172 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
4173 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
4174 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
4177 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
4178 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
4179 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
4180 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
4183 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
4184 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
4185 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
4186 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
4189 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
4190 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
4191 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
4192 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
4193 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
4194 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
4197 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
4198 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
4199 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
4200 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
4203 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
4204 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
4205 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
4208 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
4211 $pluginfields = array();
4212 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4214 foreach ($pluginfields as $pfkey=>$pfvalue) {
4216 echo '<th colspan="2">' . Entity::hen($pfkey) . "</th>\n";
4217 foreach ($pfvalue as $pffield=>$pfdesc) {
4218 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
4223 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
4225 <td><?php echo _TEMPLATE_UPDATE?></td>
4227 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
4228 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
4239 * @todo document this
4241 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
4243 if (!isset($template[$name])) $template[$name] = '';
4246 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
4247 <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>
4252 * @todo document this
4254 function action_templateupdate() {
4255 global $member,$manager;
4257 $templateid = intRequestVar('templateid');
4259 $member->isAdmin() or $this->disallow();
4261 $name = postVar('tname');
4262 $desc = postVar('tdesc');
4264 if (!isValidTemplateName($name))
4265 $this->error(_ERROR_BADTEMPLATENAME);
4267 if ((Template::getNameFromId($templateid) != $name) && Template::exists($name))
4268 $this->error(_ERROR_DUPTEMPLATENAME);
4271 $name = sql_real_escape_string($name);
4272 $desc = sql_real_escape_string($desc);
4274 // 1. Remove all template parts
4275 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4278 // 2. Update description
4279 $query = 'UPDATE '.sql_table('template_desc').' SET'
4280 . " tdname='" . $name . "',"
4281 . " tddesc='" . $desc . "'"
4282 . " WHERE tdnumber=" . $templateid;
4285 // 3. Add non-empty template parts
4286 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4287 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4288 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4289 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4290 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4291 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4292 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4293 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4294 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4295 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4296 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4297 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4298 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4299 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4300 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4301 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4302 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4303 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4304 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4305 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4306 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4307 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4308 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4309 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4310 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4311 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4312 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4313 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4314 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4315 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4316 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4317 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4318 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4319 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4321 $pluginfields = array();
4322 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4323 foreach ($pluginfields as $pfkey=>$pfvalue) {
4324 foreach ($pfvalue as $pffield=>$pfdesc) {
4325 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4329 // jump back to template edit
4330 $this->action_templateedit(_TEMPLATE_UPDATED);
4335 * Admin::addToTemplate()
4337 * @param Integer $id ID for template
4338 * @param String $partname parts name
4339 * @param String $content template contents
4340 * @return Integer record index
4343 function addToTemplate($id, $partname, $content)
4345 // don't add empty parts:
4346 if ( !trim($content) )
4351 $partname = sql_real_escape_string($partname);
4352 $content = sql_real_escape_string($content);
4354 $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, '%s', '%s')";
4355 $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
4356 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4357 return sql_insert_id();
4361 * @todo document this
4363 function action_templatedelete() {
4364 global $member, $manager;
4366 $member->isAdmin() or $this->disallow();
4368 $templateid = intRequestVar('templateid');
4369 // TODO: check if template can be deleted
4373 $name = Template::getNameFromId($templateid);
4374 $desc = Template::getDesc($templateid);
4377 <h2><?php echo _DELETE_CONFIRM?></h2>
4380 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo Entity::hsc($name)?></b> (<?php echo Entity::hsc($desc) ?>)
4383 <form method="post" action="index.php"><div>
4384 <input type="hidden" name="action" value="templatedeleteconfirm" />
4385 <?php $manager->addTicketHidden() ?>
4386 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4387 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4394 * @todo document this
4396 function action_templatedeleteconfirm() {
4397 global $member, $manager;
4399 $templateid = intRequestVar('templateid');
4401 $member->isAdmin() or $this->disallow();
4403 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4405 // 1. delete description
4406 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4409 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4411 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4413 $this->action_templateoverview();
4417 * @todo document this
4419 function action_templatenew() {
4422 $member->isAdmin() or $this->disallow();
4424 $name = postVar('name');
4425 $desc = postVar('desc');
4427 if (!isValidTemplateName($name))
4428 $this->error(_ERROR_BADTEMPLATENAME);
4430 if (Template::exists($name))
4431 $this->error(_ERROR_DUPTEMPLATENAME);
4433 $newTemplateId = Template::createNew($name, $desc);
4435 $this->action_templateoverview();
4439 * @todo document this
4441 function action_templateclone() {
4444 $templateid = intRequestVar('templateid');
4446 $member->isAdmin() or $this->disallow();
4448 // 1. read old template
4449 $name = Template::getNameFromId($templateid);
4450 $desc = Template::getDesc($templateid);
4452 // 2. create desc thing
4453 $name = "cloned" . $name;
4455 // if a template with that name already exists:
4456 if (Template::exists($name)) {
4458 while (Template::exists($name . $i))
4463 $newid = Template::createNew($name, $desc);
4466 // go through parts of old template and add them to the new one
4467 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4468 while ($o = sql_fetch_object($res)) {
4469 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4472 $this->action_templateoverview();
4476 * Admin::action_skinoverview()
4481 public function action_skinoverview()
4483 global $member, $manager;
4485 $member->isAdmin() or $this->disallow();
4489 echo '<p><a href="index.php?action=manage">(' . _BACKTOMANAGE . ")</a></p>\n";
4490 echo '<h2>' . _SKIN_EDIT_TITLE . "</h2>\n";
4491 echo '<h3>' . _SKIN_AVAILABLE_TITLE . "</h3>\n";
4493 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname;';
4494 $template['content'] = 'skinlist';
4495 $template['tabindex'] = 10;
4497 showlist($query,'table',$template);
4499 echo '<h3>' . _SKIN_NEW_TITLE . "</h3>\n";
4500 echo "<form method=\"post\" action=\"index.php\">\n";
4502 echo "<input name=\"action\" value=\"skinnew\" type=\"hidden\" />\n";
4504 $manager->addTicketHidden() . "\n";
4506 echo "<table frame=\"box\" rules=\"all\" summary=\"skinoverview\">\n";
4508 echo "<td>" . _SKIN_NAME;
4509 echo help('shortnames');
4511 echo "<td><input name=\"name\" tabindex=\"10010\" maxlength=\"20\" size=\"20\" /></td>\n";
4514 echo "<td>" . _SKIN_DESC . "</td>\n";
4515 echo "<td><input name=\"desc\" tabindex=\"10020\" maxlength=\"200\" size=\"50\" /></td>\n";
4518 echo '<td>' . _SKIN_CREATE . "</td>\n";
4519 echo '<td><input type="submit" tabindex="10030" value="' . _SKIN_CREATE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
4531 * @todo document this
4533 function action_skinnew() {
4536 $member->isAdmin() or $this->disallow();
4538 $name = trim(postVar('name'));
4539 $desc = trim(postVar('desc'));
4541 if (!isValidSkinName($name))
4542 $this->error(_ERROR_BADSKINNAME);
4544 if (Skin::exists($name))
4545 $this->error(_ERROR_DUPSKINNAME);
4547 $newId = Skin::createNew($name, $desc);
4549 $this->action_skinoverview();
4553 * Admin::action_skinedit()
4557 public function action_skinedit()
4559 global $member, $manager;
4561 $skinid = intRequestVar('skinid');
4563 $member->isAdmin() or $this->disallow();
4565 $skin = new SKIN($skinid);
4566 $default_skin_types = $skin->getDefaultTypes();
4567 $available_skin_types = $skin->getAvailableTypes();
4572 echo '( <a href="index.php?action=skinoverview">' . _SKIN_BACK . "</a> )";
4574 echo '<h2>' . _SKIN_EDITONE_TITLE . $skin->getName() . "</h2>\n";
4576 echo '<h3>' . _SKIN_PARTS_TITLE . "</h3>\n";
4577 echo _SKIN_PARTS_MSG . "\n";
4581 foreach ( $default_skin_types as $type => $friendly_name )
4584 echo "<a tabindex=\"{$tabindex}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type={$type}\">";
4585 echo $friendly_name;
4587 help("skinpart{$type}");
4593 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4594 echo "<form method=\"get\" action=\"index.php\">\n";
4595 echo "<input type=\"hidden\" name=\"action\" value=\"skinedittype\" />\n";
4596 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4597 echo "<input type=\"text\" name=\"type\" tabindex=\"89\" size=\"20\" maxlength=\"20\" />\n";
4598 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . "\" onclick=\"return checkSubmit();\" />\n";
4601 /* NOTE: special skin parts has FALSE in its value */
4602 if ( in_array(FALSE, array_values($available_skin_types)) )
4607 foreach ( $available_skin_types as $type => $friendly_name )
4609 if ( !$friendly_name )
4613 echo "<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinedittype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
4614 echo Entity::hsc(ucfirst($type));
4617 echo "(<a tabindex=\"{$tabstart}\" href=\"index.php?action=skinremovetype&skinid={$skinid}&type=" . Entity::hsc(strtolower($type)) . '">';
4626 echo '<h3>' . _SKIN_GENSETTINGS_TITLE . "</h3>\n";
4627 echo "<form method=\"post\" action=\"index.php\">\n";
4629 echo "<input type=\"hidden\" name=\"action\" value=\"skineditgeneral\" />\n";
4630 $manager->addTicketHidden() . "\n";
4631 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4633 echo '<table frame="box" rules="all" summary="' . _SKIN_GENSETTINGS_TITLE . '">' . "\n";
4639 echo '<td><input type="text" name="name" tabindex="90" value="' . Entity::hsc($skin->getName()) . '" maxlength="20" size="20" />' . "</td>\n";
4642 echo '<td>' . _SKIN_DESC . "</td>\n";
4643 echo '<td><input type="text" name="desc" tabindex="100" value="' . Entity::hsc($skin->getDescription()) . '" maxlength="200" size="50" />' . "</td>\n";
4646 echo '<td>' . _SKIN_TYPE . "</td>\n";
4647 echo '<td><input type="text" name="type" tabindex="110" value="' . Entity::hsc($skin->getContentType()) . '" maxlength="40" size="20" />' . "</td>\n";
4651 echo _SKIN_INCLUDE_MODE;
4652 help('includemode');
4655 $this->input_yesno('inc_mode', $skin->getIncludeMode(), 120, 'skindir', 'normal', _PARSER_INCMODE_SKINDIR, _PARSER_INCMODE_NORMAL);
4660 echo _SKIN_INCLUDE_PREFIX;
4661 help('includeprefix');
4663 echo '<td><input type="text" name="inc_prefix" tabindex="130" value="' . Entity::hsc($skin->getIncludePrefix()) . '" maxlength="40" size="20" />' . "</td>\n";
4666 echo '<td>' . _SKIN_CHANGE . "</td>\n";
4667 echo '<td><input type="submit" tabindex="140" value="' . _SKIN_CHANGE_BTN . '" onclick="return checkSubmit();" />' . "</td>\n";
4678 * @todo document this
4680 function action_skineditgeneral() {
4683 $skinid = intRequestVar('skinid');
4685 $member->isAdmin() or $this->disallow();
4687 $name = postVar('name');
4688 $desc = postVar('desc');
4689 $type = postVar('type');
4690 $inc_mode = postVar('inc_mode');
4691 $inc_prefix = postVar('inc_prefix');
4693 $skin = new SKIN($skinid);
4696 if (!isValidSkinName($name))
4697 $this->error(_ERROR_BADSKINNAME);
4699 if (($skin->getName() != $name) && Skin::exists($name))
4700 $this->error(_ERROR_DUPSKINNAME);
4702 if (!$type) $type = 'text/html';
4703 if (!$inc_mode) $inc_mode = 'normal';
4705 // 2. Update description
4706 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4708 $this->action_skinedit();
4713 * Admin::action_skinedittype()
4715 * @param string $msg message for pageheader
4718 public function action_skinedittype($msg = '')
4720 global $member, $manager;
4722 $skinid = intRequestVar('skinid');
4723 $type = requestVar('type');
4725 $member->isAdmin() or $this->disallow();
4727 $type = trim($type);
4728 $type = strtolower($type);
4730 if ( !isValidShortName($type) )
4732 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4735 $skin = new SKIN($skinid);
4736 $skin_types = $skin->getAvailableTypes();
4737 if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
4739 $friendlyName = ucfirst($type);
4743 $friendlyName = $skin_types[$type];
4748 echo '<p>(<a href="index.php?action=skinoverview">' . _SKIN_GOBACK . "</a>)</p>\n";
4750 echo '<h2>' . _SKIN_EDITPART_TITLE . " '" . Entity::hsc($skin->getName()) . "': " . Entity::hsc($friendlyName) . "</h2>\n";
4754 echo "<p>" . _MESSAGE . ": $msg</p>\n";
4757 echo "<form method=\"post\" action=\"index.php\">\n";
4760 echo "<input type=\"hidden\" name=\"action\" value=\"skinupdate\" />\n";
4761 $manager->addTicketHidden() . "\n";
4762 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4763 echo "<input type=\"hidden\" name=\"type\" value=\"{$type}\" />\n";
4765 echo '<input type="submit" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
4766 echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
4767 echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
4769 if ( !array_key_exists($type, $skin_types) || !$skin_types[$type] )
4771 help('skinpartspecial');
4775 help('skinpart' . $type);
4779 echo "<textarea class=\"skinedit\" tabindex=\"10\" rows=\"20\" cols=\"80\" name=\"content\">\n";
4780 echo Entity::hsc($skin->getContent($type)) . "\n";
4781 echo "</textarea>\n";
4784 echo '<input type="submit" tabindex="20" value="' . _SKIN_UPDATE_BTN . '" onclick="return checkSubmit();" />' . "\n";
4785 echo '<input type="reset" value="' . _SKIN_RESET_BTN . '" />' . "\n";
4786 echo '(skin type: ' . Entity::hsc($friendlyName) . ")\n";
4790 echo _SKIN_ALLOWEDVARS;
4792 $actions = $skin->getAllowedActionsForType($type);
4796 while ( $current = array_shift($actions) )
4798 // skip deprecated vars
4799 if ( in_array($current, array('ifcat', 'imagetext', 'vars')) )
4804 echo helplink("skinvar-{$current}") . "{$current}</a>\n";
4806 if ( count($actions) != 0 )
4814 echo _SKINEDIT_ALLOWEDBLOGS;
4816 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4817 showlist($query, 'table', array('content'=>'shortblognames'));
4820 echo _SKINEDIT_ALLOWEDTEMPLATESS;
4822 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4823 showlist($query, 'table', array('content'=>'shortnames'));
4834 * @todo document this
4836 function action_skinupdate() {
4839 $skinid = intRequestVar('skinid');
4840 $content = trim(postVar('content'));
4841 $type = postVar('type');
4843 $member->isAdmin() or $this->disallow();
4845 $skin = new SKIN($skinid);
4846 $skin->update($type, $content);
4848 $this->action_skinedittype(_SKIN_UPDATED);
4852 * @todo document this
4854 function action_skindelete() {
4855 global $member, $manager, $CONF;
4857 $skinid = intRequestVar('skinid');
4859 $member->isAdmin() or $this->disallow();
4861 // don't allow default skin to be deleted
4862 if ($skinid == $CONF['BaseSkin'])
4863 $this->error(_ERROR_DEFAULTSKIN);
4865 // don't allow deletion of default skins for blogs
4866 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4867 $r = sql_query($query);
4868 if ($o = sql_fetch_object($r))
4869 $this->error(_ERROR_SKINDEFDELETE . Entity::hsc($o->bname));
4873 $skin = new SKIN($skinid);
4874 $name = $skin->getName();
4875 $desc = $skin->getDescription();
4878 <h2><?php echo _DELETE_CONFIRM?></h2>
4881 <?php echo _CONFIRMTXT_SKIN?><b><?php echo Entity::hsc($name) ?></b> (<?php echo Entity::hsc($desc)?>)
4884 <form method="post" action="index.php"><div>
4885 <input type="hidden" name="action" value="skindeleteconfirm" />
4886 <?php $manager->addTicketHidden() ?>
4887 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4888 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4895 * @todo document this
4897 function action_skindeleteconfirm() {
4898 global $member, $CONF, $manager;
4900 $skinid = intRequestVar('skinid');
4902 $member->isAdmin() or $this->disallow();
4904 // don't allow default skin to be deleted
4905 if ($skinid == $CONF['BaseSkin'])
4906 $this->error(_ERROR_DEFAULTSKIN);
4908 // don't allow deletion of default skins for blogs
4909 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4910 $r = sql_query($query);
4911 if ($o = sql_fetch_object($r))
4912 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4914 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4916 // 1. delete description
4917 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4920 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4922 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4924 $this->action_skinoverview();
4928 * Admin::action_skinremovetype()
4933 public function action_skinremovetype()
4935 global $member, $manager, $CONF;
4937 $skinid = intRequestVar('skinid');
4938 $skintype = requestVar('type');
4940 if ( !isValidShortName($skintype) )
4942 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4945 $member->isAdmin() or $this->disallow();
4947 // don't allow default skinparts to be deleted
4948 $skin = new Skin($skinid);
4949 $default_skin_types = $skin->getDefaultTypes();
4950 if ( array_key_exists($skintype, $default_skin_types) )
4952 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4955 $name = $skin->getName();
4956 $desc = $skin->getDescription();
4960 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
4962 echo _CONFIRMTXT_SKIN_PARTS_SPECIAL;
4963 echo Entity::hsc($skintype);
4964 echo '(' . Entity::hsc($name) . ')</b>';
4965 echo ' (' . Entity::hsc($desc) . ')';
4968 echo "<form method=\"post\" action=\"index.php\">\n";
4970 echo "<input type=\"hidden\" name=\"action\" value=\"skinremovetypeconfirm\" />\n";
4971 $manager->addTicketHidden();
4972 echo "<input type=\"hidden\" name=\"skinid\" value=\"{$skinid}\" />\n";
4973 echo '<input type="hidden" name="type" value="' . Entity::hsc($skintype) . '" />' . "\n";
4974 echo '<input type="submit" tabindex="10" value="' . _DELETE_CONFIRM_BTN . '" />' . "\n";
4982 * Admin::action_skinremovetypeconfirm()
4987 public function action_skinremovetypeconfirm()
4989 global $member, $CONF, $manager;
4991 $skinid = intRequestVar('skinid');
4992 $skintype = requestVar('type');
4994 if ( !isValidShortName($skintype) )
4996 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4999 $member->isAdmin() or $this->disallow();
5001 // don't allow default skinparts to be deleted
5002 $skin = new Skin($skinid);
5003 $default_skin_types = $skin->getDefaultTypes();
5004 if ( array_key_exists($skintype, $default_skin_types) )
5006 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
5010 'skinid' => $skinid,
5011 'skintype' => $skintype
5013 $manager->notify('PreDeleteSkinPart', $data);
5016 $query = "DELETE FROM %s WHERE sdesc=%d AND stype='%s';";
5017 $query = sprintf($query, sql_table('skin'), (integer) $skinid, $skintype);
5021 'skinid' => $skinid,
5022 'skintype' => $skintype
5024 $manager->notify('PostDeleteSkinPart', $data);
5026 $this->action_skinedit();
5031 * @todo document this
5033 function action_skinclone() {
5036 $skinid = intRequestVar('skinid');
5038 $member->isAdmin() or $this->disallow();
5040 // 1. read skin to clone
5041 $skin = new SKIN($skinid);
5043 $name = "clone_" . $skin->getName();
5045 // if a skin with that name already exists:
5046 if (Skin::exists($name)) {
5048 while (Skin::exists($name . $i))
5053 // 2. create skin desc
5054 $newid = Skin::createNew(
5056 $skin->getDescription(),
5057 $skin->getContentType(),
5058 $skin->getIncludeMode(),
5059 $skin->getIncludePrefix()
5062 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
5063 $res = sql_query($query);
5064 while ($row = sql_fetch_assoc($res)) {
5065 $this->skinclonetype($skin, $newid, $row['stype']);
5068 $this->action_skinoverview();
5073 * Admin::skinclonetype()
5075 * @param String $skin Skin object
5076 * @param Integer $newid ID for this clone
5077 * @param String $type type of skin
5080 function skinclonetype($skin, $newid, $type)
5082 $newid = intval($newid);
5083 $content = $skin->getContent($type);
5087 $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
5088 $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
5095 * Admin::action_settingsedit()
5100 function action_settingsedit() {
5101 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
5103 $member->isAdmin() or $this->disallow();
5107 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5110 <h2><?php echo _SETTINGS_TITLE?></h2>
5112 <form action="index.php" method="post">
5115 <input type="hidden" name="action" value="settingsupdate" />
5116 <?php $manager->addTicketHidden() ?>
5119 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
5121 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
5124 $query = 'SELECT bname as text, bnumber as value'
5125 . ' FROM '.sql_table('blog');
5126 $template['name'] = 'DefaultBlog';
5127 $template['selected'] = $CONF['DefaultBlog'];
5128 $template['tabindex'] = 10;
5129 showlist($query,'select',$template);
5133 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
5136 $query = 'SELECT sdname as text, sdnumber as value'
5137 . ' FROM '.sql_table('skin_desc');
5138 $template['name'] = 'BaseSkin';
5139 $template['selected'] = $CONF['BaseSkin'];
5140 $template['tabindex'] = 1;
5141 showlist($query,'select',$template);
5145 <td><?php echo _SETTINGS_ADMINMAIL?></td>
5146 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo Entity::hsc($CONF['AdminEmail']) ?>" /></td>
5148 <td><?php echo _SETTINGS_SITENAME?></td>
5149 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo Entity::hsc($CONF['SiteName']) ?>" /></td>
5151 <td><?php echo _SETTINGS_SITEURL?></td>
5152 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo Entity::hsc($CONF['IndexURL']) ?>" /></td>
5154 <td><?php echo _SETTINGS_ADMINURL?></td>
5155 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo Entity::hsc($CONF['AdminURL']) ?>" /></td>
5157 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
5158 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo Entity::hsc($CONF['PluginURL']) ?>" /></td>
5160 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
5161 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo Entity::hsc($CONF['SkinsURL']) ?>" /></td>
5163 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
5164 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo Entity::hsc($CONF['ActionURL']) ?>" /></td>
5166 <td><?php echo _SETTINGS_LOCALE?> <?php help('locale'); ?>
5169 <select name="Locale" tabindex="10050">
5171 $locales = i18n::get_available_locale_list();
5172 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
5174 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
5178 echo "<option value=\"\">en_Latn_US</option>\n";
5181 foreach ( $locales as $locale )
5183 if ( $locale == 'en_Latn_US' )
5187 if ( $locale == i18n::get_current_locale() )
5189 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
5193 echo "<option value=\"{$locale}\">{$locale}</option>\n";
5201 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
5203 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
5205 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo Entity::hsc($CONF['DisableSiteURL'])?>" />
5208 <td><?php echo _SETTINGS_DIRS?></td>
5209 <td><?php echo Entity::hsc($DIR_NUCLEUS) ?>
5210 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
5212 <td><?php echo _SETTINGS_DBLOGIN?></td>
5213 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
5217 echo _SETTINGS_JSTOOLBAR
5218 /* =_SETTINGS_DISABLEJS
5220 I temporary changed the meaning of DisableJsTools, until I can find a good
5221 way to select the javascript version to use
5225 1 : all javascript disabled
5226 2 : 'simpler' javascript (for mozilla/opera/mac)
5230 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
5231 <select name="DisableJsTools" tabindex="10075">
5232 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
5233 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
5234 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
5235 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
5236 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
5237 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
5242 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
5245 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
5246 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
5248 echo ' ', _SETTINGS_URLMODE_HELP;
5254 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
5257 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
5263 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
5266 if (!array_key_exists('DefaultListSize',$CONF)) {
5267 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
5268 $CONF['DefaultListSize'] = 10;
5271 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo Entity::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
5274 <td><?php echo _SETTINGS_ADMINCSS?>
5278 <select name="AdminCSS" tabindex="10080">
5279 <?php // show a dropdown list of all available admin css files
5280 global $DIR_NUCLEUS;
5282 $dirhandle = opendir($DIR_NUCLEUS."styles/");
5284 while ($filename = readdir($dirhandle) )
5287 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
5288 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
5290 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
5293 $name = $matches[1];
5294 echo "<option value=\"$name\"";
5296 if ($name == $CONF['AdminCSS'])
5298 echo " selected=\"selected\"";
5301 echo ">$name</option>";
5307 closedir($dirhandle);
5314 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
5316 <td><?php echo _SETTINGS_MEDIADIR?></td>
5317 <td><?php echo Entity::hsc($DIR_MEDIA) ?>
5318 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
5319 <?php if (!is_dir($DIR_MEDIA))
5320 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
5321 if (!is_readable($DIR_MEDIA))
5322 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
5323 if (!is_writeable($DIR_MEDIA))
5324 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
5328 <td><?php echo _SETTINGS_MEDIAURL?></td>
5330 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo Entity::hsc($CONF['MediaURL']) ?>" />
5333 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
5334 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
5336 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
5338 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo Entity::hsc($CONF['AllowedTypes']) ?>" />
5341 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
5343 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo Entity::hsc($CONF['MaxUploadSize']) ?>" />
5346 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
5347 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
5350 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
5352 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
5353 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
5355 <td><?php echo _SETTINGS_ALLOWCREATE?>
5356 <?php help('allowaccountcreation'); ?>
5358 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
5361 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
5362 <br /><?php echo _SETTINGS_NEWLOGIN2?>
5364 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
5367 <td><?php echo _SETTINGS_MEMBERMSGS?>
5368 <?php help('messageservice'); ?>
5370 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
5373 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
5374 <?php help('messageservice'); ?>
5376 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5379 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5380 <?php help('protectmemnames'); ?>
5382 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5388 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5390 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5391 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo Entity::hsc($CONF['CookiePrefix'])?>" /></td>
5393 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5394 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo Entity::hsc($CONF['CookieDomain'])?>" /></td>
5396 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5397 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo Entity::hsc($CONF['CookiePath'])?>" /></td>
5399 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5400 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5402 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5403 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5404 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5407 <td><?php echo _SETTINGS_LASTVISIT?></td>
5408 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5413 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5415 <td><?php echo _SETTINGS_UPDATE?></td>
5416 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5423 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5426 'GeneralSettingsFormExtras',
5434 * Admin::action_settingsupdate()
5435 * Update $CONFIG and redirect
5440 function action_settingsupdate() {
5441 global $member, $CONF;
5443 $member->isAdmin() or $this->disallow();
5445 // check if email address for admin is valid
5446 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5448 $this->error(_ERROR_BADMAILADDRESS);
5452 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5453 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5454 $this->updateConfig('IndexURL', postVar('IndexURL'));
5455 $this->updateConfig('AdminURL', postVar('AdminURL'));
5456 $this->updateConfig('PluginURL', postVar('PluginURL'));
5457 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5458 $this->updateConfig('ActionURL', postVar('ActionURL'));
5459 $this->updateConfig('Locale', postVar('Locale'));
5460 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5461 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5462 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5463 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5464 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5465 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5466 $this->updateConfig('SiteName', postVar('SiteName'));
5467 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5468 $this->updateConfig('DisableSite', postVar('DisableSite'));
5469 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5470 $this->updateConfig('LastVisit', postVar('LastVisit'));
5471 $this->updateConfig('MediaURL', postVar('MediaURL'));
5472 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5473 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5474 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5475 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5476 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5477 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5478 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5479 $this->updateConfig('CookiePath', postVar('CookiePath'));
5480 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5481 $this->updateConfig('URLMode', postVar('URLMode'));
5482 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5483 $this->updateConfig('DebugVars', postVar('DebugVars'));
5484 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5485 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5487 // load new config and redirect (this way, the new locale will be used is necessary)
5488 // note that when changing cookie settings, this redirect might cause the user
5489 // to have to log in again.
5491 redirect($CONF['AdminURL'] . '?action=manage');
5496 * Admin::action_systemoverview()
5497 * Output system overview
5502 function action_systemoverview()
5504 global $member, $nucleus, $CONF;
5508 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5510 if ( $member->isLoggedIn() && $member->isAdmin() )
5512 // Information about the used PHP and MySQL installation
5513 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5515 // Version of PHP MySQL
5516 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5519 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5524 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5525 echo '<td>' . phpversion() . "</td>\n";
5528 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5529 echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5532 echo "</table>\n\n";
5534 // Important PHP settings
5535 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5538 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5543 echo '<td>magic_quotes_gpc' . "</td>\n";
5544 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5545 echo '<td>' . $mqg . "</td>\n";
5548 echo '<td>magic_quotes_runtime' . "</td>\n";
5549 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5550 echo '<td>' . $mqr . "</td>\n";
5553 echo '<td>register_globals' . "</td>\n";
5554 $rg = ini_get('register_globals') ? 'On' : 'Off';
5555 echo '<td>' . $rg . "</td>\n";
5558 echo "</table>\n\n";
5560 // Information about GD library
5561 $gdinfo = gd_info();
5562 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5565 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5569 foreach ( $gdinfo as $key=>$value )
5571 if ( is_bool($value) )
5573 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5577 $value = Entity::hsc($value);
5580 echo '<td>' . $key . "</td>\n";
5581 echo '<td>' . $value . "</td>\n";
5585 echo "</table>\n\n";
5587 // Check if special modules are loaded
5589 phpinfo(INFO_MODULES);
5590 $im = ob_get_contents();
5592 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5595 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5599 echo '<td>mod_rewrite' . "</td>\n";
5600 $modrewrite = (i18n::strpos($im, 'mod_rewrite') !== FALSE) ?
5601 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5602 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5603 echo '<td>' . $modrewrite . "</td>\n";
5606 echo "</table>\n\n";
5608 // Information about the used Nucleus CMS
5609 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5611 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5612 $np = getNucleusPatchLevel();
5613 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5616 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5621 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5622 echo '<td>' . $nv . "</td>\n";
5625 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5626 echo '<td>' . $np . "</td>\n";
5629 echo "</table>\n\n";
5631 // Important settings of the installation
5632 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5635 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5640 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5641 echo '<td>' . $CONF['Self'] . "</td>\n";
5644 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5645 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5648 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5649 $ohs = $CONF['alertOnHeadersSent'] ?
5650 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5651 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5652 echo '<td>' . $ohs . "</td>\n";
5655 echo "<td>i18n::get_current_charset()</td>\n";
5656 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5659 echo "</table>\n\n";
5661 // Link to the online version test at the Nucleus CMS website
5662 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5663 if ( $nucleus['codename'] != '')
5665 $codenamestring = ' "' . $nucleus['codename'] . '"';
5669 $codenamestring = '';
5671 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5672 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5673 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5674 echo 'Nucleus CMS ' . $nv . $codenamestring;
5679 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5685 * Admin::updateConfig()
5687 * @param string $name
5688 * @param string $val
5689 * @return integer return the ID in which the latest query posted
5691 function updateConfig($name, $val)
5693 $name = sql_real_escape_string($name);
5694 $val = trim(sql_real_escape_string($val));
5696 $query = "UPDATE %s SET value='%s' WHERE name='%s'";
5697 $query = sprintf($query, sql_table('config'), $val, $name);
5698 sql_query($query) or die("Query error: " . sql_error());
5699 return sql_insert_id();
5704 * @param string $msg message that will be shown
5706 function error($msg)
5710 echo "<h2>Error!</h2>\n";
5713 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5720 * add error log and show error page
5727 ActionLog::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5728 $this->error(_ERROR_DISALLOWED);
5733 * Output admin page head
5738 function pagehead($extrahead = '')
5740 global $member, $nucleus, $CONF, $manager;
5745 'extrahead' => &$extrahead,
5746 'action' => $this->action));
5748 $baseUrl = Entity::hsc($CONF['AdminURL']);
5749 if ( !array_key_exists('AdminCSS',$CONF) )
5751 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5752 $CONF['AdminCSS'] = 'original';
5755 /* HTTP 1.1 application for no caching */
5756 header("Cache-Control: no-cache, must-revalidate");
5757 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5759 $root_element = 'html';
5760 $charset = i18n::get_current_charset();
5761 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5763 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5764 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5765 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5767 echo '<title>' . Entity::hsc($CONF['SiteName']) . " - Admin</title>\n";
5768 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5769 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5770 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5771 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5772 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5773 echo "{$extrahead}\n";
5776 echo "<div id=\"adminwrapper\">\n";
5777 echo "<div class=\"header\">\n";
5778 echo '<h1>' . Entity::hsc($CONF['SiteName']) . "</h1>\n";
5780 echo "<div id=\"container\">\n";
5781 echo "<div id=\"content\">\n";
5782 echo "<div class=\"loginname\">\n";
5783 if ( $member->isLoggedIn() )
5785 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5786 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5790 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5792 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5795 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5797 $codenamestring = ' "' . $nucleus['codename'].'"';
5801 $codenamestring = '';
5804 if ( $member->isLoggedIn() && $member->isAdmin() )
5806 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5807 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5809 $newestVersion = getLatestVersion();
5810 $newestCompare = str_replace('/','.',$newestVersion);
5811 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5812 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5815 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5816 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5822 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5831 * Output admin page foot include quickmenu
5838 global $action, $member, $manager;
5842 array('action' => $this->action)
5845 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5847 echo '<h2>' . _LOGOUT . "</h2>\n";
5849 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5850 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5854 echo "<div class=\"foot\">\n";
5855 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5857 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5860 echo "<!-- content -->\n";
5861 echo "<div id=\"quickmenu\">\n";
5863 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5866 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5869 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5870 echo "<form method=\"get\" action=\"index.php\">\n";
5872 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5874 $showAll = requestVar('showall');
5876 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5878 // Super-Admins have access to all blogs! (no add item support though)
5879 $query = 'SELECT bnumber as value, bname as text'
5880 . ' FROM ' . sql_table('blog')
5881 . ' ORDER BY bname';
5885 $query = 'SELECT bnumber as value, bname as text'
5886 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5887 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5888 . ' ORDER BY bname';
5890 $template['name'] = 'blogid';
5891 $template['tabindex'] = 15000;
5892 $template['extra'] = _QMENU_ADD_SELECT;
5893 $template['selected'] = -1;
5894 $template['shorten'] = 10;
5895 $template['shortenel'] = '';
5896 $template['javascript'] = 'onchange="return form.submit()"';
5897 showlist($query,'select',$template);
5902 echo "<h2>{$member->getDisplayName()}</h2>\n";
5904 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5905 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5906 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5909 // ---- general settings ----
5910 if ( $member->isAdmin() )
5912 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5914 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5915 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5916 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5917 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5918 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5919 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5920 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5923 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5925 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5926 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5927 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5931 $aPluginExtras = array();
5935 'options' => &$aPluginExtras));
5937 if ( count($aPluginExtras) > 0 )
5939 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5941 foreach ( $aPluginExtras as $aInfo )
5943 echo '<li><a href="' . Entity::hsc($aInfo['url']) . '" title="' . Entity::hsc($aInfo['tooltip']) . '">' . Entity::hsc($aInfo['title']) . "</a></li>\n";
5948 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5951 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5955 // introduction text on login screen
5956 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5959 echo "<!-- quickmenu -->\n";
5962 echo "<!-- content -->\n";
5965 echo "<!-- container -->\n";
5968 echo "<!-- adminwrapper -->\n";
5977 * Admin::action_bookmarklet()
5982 public function action_bookmarklet()
5984 global $member, $manager;
5986 $blogid = intRequestVar('blogid');
5987 $member->teamRights($blogid) or $this->disallow();
5988 $blog =& $manager->getBlog($blogid);
5992 echo '<p><a href="index.php?action=overview">(' . _BACKHOME . ")</a></p>\n";
5994 echo '<h2>' . _BOOKMARKLET_TITLE . "</h2>\n";
5996 echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5;
5999 echo '<h3>' . _BOOKMARKLET_BOOKARKLET . "</h3>\n";
6001 echo _BOOKMARKLET_BMARKTEXT . '<small>' . _BOOKMARKLET_BMARKTEST . '</small>';
6004 echo '<a href="javascript:' . rawurlencode(getBookmarklet($blogid)) . '">' . sprintf(_BOOKMARKLET_ANCHOR, Entity::hsc($blog->getName())) . '</a>';
6005 echo _BOOKMARKLET_BMARKFOLLOW;
6013 * @todo document this
6015 function action_actionlog() {
6016 global $member, $manager;
6018 $member->isAdmin() or $this->disallow();
6022 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6024 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
6027 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
6028 <p><a href="<?php echo Entity::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
6030 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
6032 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
6033 $template['content'] = 'actionlist';
6034 $amount = showlist($query,'table',$template);
6041 * @todo document this
6043 function action_banlist() {
6044 global $member, $manager;
6046 $blogid = intRequestVar('blogid');
6048 $member->blogAdminRights($blogid) or $this->disallow();
6050 $blog =& $manager->getBlog($blogid);
6054 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
6056 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
6058 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
6059 $template['content'] = 'banlist';
6060 $amount = showlist($query,'table',$template);
6065 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
6066 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
6074 * @todo document this
6076 function action_banlistdelete() {
6077 global $member, $manager;
6079 $blogid = intRequestVar('blogid');
6080 $iprange = requestVar('iprange');
6082 $member->blogAdminRights($blogid) or $this->disallow();
6084 $blog =& $manager->getBlog($blogid);
6085 $banBlogName = Entity::hsc($blog->getName());
6089 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
6091 <form method="post" action="index.php">
6093 <h3><?php echo _BAN_IPRANGE?></h3>
6096 <?php echo _CONFIRMTXT_BAN?> <?php echo Entity::hsc($iprange) ?>
6097 <input name="iprange" type="hidden" value="<?php echo Entity::hsc($iprange)?>" />
6100 <h3><?php echo _BAN_BLOGS?></h3>
6103 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
6104 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
6105 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
6107 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
6110 <h3><?php echo _BAN_DELETE_TITLE?></h3>
6113 <?php $manager->addTicketHidden() ?>
6114 <input type="hidden" name="action" value="banlistdeleteconfirm" />
6115 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6124 * @todo document this
6126 function action_banlistdeleteconfirm() {
6127 global $member, $manager;
6129 $blogid = intPostVar('blogid');
6130 $allblogs = postVar('allblogs');
6131 $iprange = postVar('iprange');
6133 $member->blogAdminRights($blogid) or $this->disallow();
6138 if (Ban::removeBan($blogid, $iprange))
6139 array_push($deleted, $blogid);
6141 // get blogs fot which member has admin rights
6142 $adminblogs = $member->getAdminBlogs();
6143 foreach ($adminblogs as $blogje) {
6144 if (Ban::removeBan($blogje, $iprange))
6145 array_push($deleted, $blogje);
6149 if (sizeof($deleted) == 0)
6150 $this->error(_ERROR_DELETEBAN);
6154 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
6155 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
6156 echo "<p>"._BAN_REMOVED_TEXT."</p>";
6159 foreach ($deleted as $delblog) {
6160 $b =& $manager->getBlog($delblog);
6161 echo "<li>" . Entity::hsc($b->getName()). "</li>";
6170 * @todo document this
6172 function action_banlistnewfromitem() {
6173 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
6177 * @todo document this
6179 function action_banlistnew($blogid = '') {
6180 global $member, $manager;
6183 $blogid = intRequestVar('blogid');
6185 $ip = requestVar('ip');
6187 $member->blogAdminRights($blogid) or $this->disallow();
6189 $blog =& $manager->getBlog($blogid);
6193 <h2><?php echo _BAN_ADD_TITLE?></h2>
6196 <form method="post" action="index.php">
6198 <h3><?php echo _BAN_IPRANGE?></h3>
6200 <p><?php echo _BAN_IPRANGE_TEXT?></p>
6203 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
6204 <?php echo _BAN_EXAMPLE_TEXT ?>
6210 $iprangeVal = Entity::hsc($ip);
6212 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
6213 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
6215 <input name="iprange" type="radio" value="custom" id="ip_custom" />
6216 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
6217 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
6220 echo "<input name='iprange' value='custom' type='hidden' />";
6221 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
6226 <h3><?php echo _BAN_BLOGS?></h3>
6228 <p><?php echo _BAN_BLOGS_TEXT?></p>
6231 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
6232 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo Entity::hsc($blog->getName())?>'</label>
6234 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
6237 <h3><?php echo _BAN_REASON_TITLE?></h3>
6239 <p><?php echo _BAN_REASON_TEXT?></p>
6241 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
6243 <h3><?php echo _BAN_ADD_TITLE?></h3>
6246 <input name="action" type="hidden" value="banlistadd" />
6247 <?php $manager->addTicketHidden() ?>
6248 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
6253 <?php $this->pagefoot();
6257 * @todo document this
6259 function action_banlistadd() {
6262 $blogid = intPostVar('blogid');
6263 $allblogs = postVar('allblogs');
6264 $iprange = postVar('iprange');
6265 if ($iprange == "custom")
6266 $iprange = postVar('customiprange');
6267 $reason = postVar('reason');
6269 $member->blogAdminRights($blogid) or $this->disallow();
6271 // TODO: check IP range validity
6274 if (!Ban::addBan($blogid, $iprange, $reason))
6275 $this->error(_ERROR_ADDBAN);
6277 // get blogs fot which member has admin rights
6278 $adminblogs = $member->getAdminBlogs();
6280 foreach ($adminblogs as $blogje) {
6281 if (!Ban::addBan($blogje, $iprange, $reason))
6285 $this->error(_ERROR_ADDBAN);
6288 $this->action_banlist();
6293 * @todo document this
6295 function action_clearactionlog() {
6298 $member->isAdmin() or $this->disallow();
6302 $this->action_manage(_MSG_ACTIONLOGCLEARED);
6306 * @todo document this
6308 function action_backupoverview() {
6309 global $member, $manager;
6311 $member->isAdmin() or $this->disallow();
6315 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6317 <h2><?php echo _BACKUPS_TITLE?></h2>
6319 <h3><?php echo _BACKUP_TITLE?></h3>
6321 <p><?php echo _BACKUP_INTRO?></p>
6323 <form method="post" action="index.php"><p>
6324 <input type="hidden" name="action" value="backupcreate" />
6325 <?php $manager->addTicketHidden() ?>
6327 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
6329 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
6331 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
6335 <div class="note"><?php echo _BACKUP_NOTE?></div>
6338 <h3><?php echo _RESTORE_TITLE?></h3>
6340 <div class="note"><?php echo _RESTORE_NOTE?></div>
6342 <p><?php echo _RESTORE_INTRO?></p>
6344 <form method="post" action="index.php" enctype="multipart/form-data"><p>
6345 <input type="hidden" name="action" value="backuprestore" />
6346 <?php $manager->addTicketHidden() ?>
6347 <input name="backup_file" type="file" tabindex="30" />
6349 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
6350 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
6351 <br /><?php echo _RESTORE_WARNING?>
6354 <?php $this->pagefoot();
6358 * Admin::action_backupcreate()
6359 * create file for backup
6365 function action_backupcreate()
6367 global $member, $DIR_LIBS;
6369 $member->isAdmin() or $this->disallow();
6371 // use compression ?
6372 $useGzip = (integer) postVar('gzip');
6374 include($DIR_LIBS . 'backup.php');
6376 // try to extend time limit
6377 // (creating/restoring dumps might take a while)
6378 @set_time_limit(1200);
6380 Backup::do_backup($useGzip);
6385 * Admin::action_backuprestore()
6386 * restoring from uploaded file
6391 function action_backuprestore()
6393 global $member, $DIR_LIBS;
6395 $member->isAdmin() or $this->disallow();
6397 if ( intPostVar('letsgo') != 1 )
6399 $this->error(_ERROR_BACKUP_NOTSURE);
6402 include($DIR_LIBS . 'backup.php');
6404 // try to extend time limit
6405 // (creating/restoring dumps might take a while)
6406 @set_time_limit(1200);
6408 $message = Backup::do_restore();
6409 if ( $message != '' )
6411 $this->error($message);
6414 echo '<h2>' . _RESTORE_COMPLETE . "</h2>\n";
6420 * Admin::action_pluginlist()
6421 * output the list of installed plugins
6427 function action_pluginlist()
6429 global $DIR_PLUGINS, $member, $manager;
6432 $member->isAdmin() or $this->disallow();
6436 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6438 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6440 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6442 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6444 $template['content'] = 'pluginlist';
6445 $template['tabindex'] = 10;
6446 showlist($query, 'table', $template);
6448 echo '<h3>' . _PLUGS_TITLE_UPDATE . "</h3>\n";
6449 echo '<p>' . _PLUGS_TEXT_UPDATE . "</p>\n";
6450 echo '<form method="post" action="index.php">' . "\n";
6452 echo '<input type="hidden" name="action" value="pluginupdate" />' . "\n";
6453 $manager->addTicketHidden();
6454 echo '<input type="submit" value="' . _PLUGS_BTN_UPDATE . '" tabindex="20" />' . "\n";
6458 echo '<h3>' . _PLUGS_TITLE_NEW . "</h3>\n";
6460 // find a list of possibly non-installed plugins
6461 $candidates = array();
6462 $dirhandle = opendir($DIR_PLUGINS);
6464 while ( $filename = readdir($dirhandle) )
6466 if ( preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6468 $name = $matches[1];
6470 // only show in list when not yet installed
6471 $query = 'SELECT * FROM %s WHERE pfile = "NP_%s"';
6472 $query = sprintf($query, sql_table('plugin'), sql_real_escape_string($name));
6473 $res = sql_query($query);
6475 if ( sql_num_rows($res) == 0 )
6477 array_push($candidates, $name);
6482 closedir($dirhandle);
6484 if ( sizeof($candidates) > 0 )
6486 echo '<p>' . _PLUGS_ADD_TEXT . "</p>\n";
6488 echo '<form method="post" action="index.php">' . "\n";
6490 echo '<input type="hidden" name="action" value="pluginadd" />' . "\n";
6491 $manager->addTicketHidden();
6492 echo '<select name="filename" tabindex="30">' . "\n";
6494 foreach ( $candidates as $name )
6496 echo '<option value="NP_',$name,'">',Entity::hsc($name),'</option>';
6500 echo '<input type="submit" tabindex="40" value="' . _PLUGS_BTN_INSTALL ."\" />\n";
6506 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6514 * @todo document this
6516 function action_pluginhelp() {
6517 global $member, $manager, $DIR_PLUGINS, $CONF;
6520 $member->isAdmin() or $this->disallow();
6522 $plugid = intGetVar('plugid');
6524 if (!$manager->pidInstalled($plugid))
6525 $this->error(_ERROR_NOSUCHPLUGIN);
6527 $plugName = getPluginNameFromPid($plugid);
6531 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6533 echo '<h2>',_PLUGS_HELP_TITLE,': ',Entity::hsc($plugName),'</h2>';
6535 $plug =& $manager->getPlugin($plugName);
6536 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6538 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6539 @readfile($helpFile);
6541 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6542 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6550 * Admin::action_pluginadd()
6556 function action_pluginadd()
6558 global $member, $manager, $DIR_PLUGINS;
6561 $member->isAdmin() or $this->disallow();
6563 $name = postVar('filename');
6565 if ( $manager->pluginInstalled($name) )
6567 $this->error(_ERROR_DUPPLUGIN);
6570 if ( !checkPlugin($name) )
6572 $this->error(_ERROR_PLUGFILEERROR . ' (' . Entity::hsc($name) . ')');
6575 // get number of currently installed plugins
6576 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6577 $numCurrent = sql_num_rows($res);
6579 // plugin will be added as last one in the list
6580 $newOrder = $numCurrent + 1;
6589 // do this before calling getPlugin (in case the plugin id is used there)
6590 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6592 $iPid = sql_insert_id();
6594 $manager->clearCachedInfo('installedPlugins');
6596 // Load the plugin for condition checking and instalation
6597 $plugin =& $manager->getPlugin($name);
6599 // check if it got loaded (could have failed)
6602 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6603 $manager->clearCachedInfo('installedPlugins');
6604 $this->error(_ERROR_PLUGIN_LOAD);
6607 // check if plugin needs a newer Nucleus version
6608 if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
6610 // uninstall plugin again...
6611 $this->deleteOnePlugin($plugin->getID());
6613 // ...and show error
6614 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc($plugin->getMinNucleusVersion()));
6617 // check if plugin needs a newer Nucleus version
6618 if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
6620 // uninstall plugin again...
6621 $this->deleteOnePlugin($plugin->getID());
6623 // ...and show error
6624 $this->error(_ERROR_NUCLEUSVERSIONREQ . Entity::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6627 $pluginList = $plugin->getPluginDep();
6628 foreach ( $pluginList as $pluginName )
6630 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6631 if (sql_num_rows($res) == 0)
6633 // uninstall plugin again...
6634 $this->deleteOnePlugin($plugin->getID());
6635 $this->error(sprintf(_ERROR_INSREQPLUGIN, Entity::hsc($pluginName)));
6639 // call the install method of the plugin
6645 'plugin' => &$plugin
6649 // update all events
6650 $this->action_pluginupdate();
6655 * ADMIN:action_pluginupdate():
6661 function action_pluginupdate()
6663 global $member, $manager, $CONF;
6666 $member->isAdmin() or $this->disallow();
6668 // delete everything from plugin_events
6669 sql_query('DELETE FROM '.sql_table('plugin_event'));
6671 // loop over all installed plugins
6672 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6673 while ( $o = sql_fetch_object($res) )
6676 $plug =& $manager->getPlugin($o->pfile);
6679 $eventList = $plug->getEventList();
6680 foreach ( $eventList as $eventName )
6682 $query = "INSERT INTO %s (pid, event) VALUES (%d, '%s')";
6683 $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, sql_real_escape_string($eventName));
6688 redirect($CONF['AdminURL'] . '?action=pluginlist');
6693 * @todo document this
6695 function action_plugindelete() {
6696 global $member, $manager;
6699 $member->isAdmin() or $this->disallow();
6701 $pid = intGetVar('plugid');
6703 if (!$manager->pidInstalled($pid))
6704 $this->error(_ERROR_NOSUCHPLUGIN);
6708 <h2><?php echo _DELETE_CONFIRM?></h2>
6710 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6712 <form method="post" action="index.php"><div>
6713 <?php $manager->addTicketHidden() ?>
6714 <input type="hidden" name="action" value="plugindeleteconfirm" />
6715 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6716 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6723 * @todo document this
6725 function action_plugindeleteconfirm() {
6726 global $member, $manager, $CONF;
6729 $member->isAdmin() or $this->disallow();
6731 $pid = intPostVar('plugid');
6733 $error = $this->deleteOnePlugin($pid, 1);
6735 $this->error($error);
6738 redirect($CONF['AdminURL'] . '?action=pluginlist');
6739 // $this->action_pluginlist();
6743 * @todo document this
6745 function deleteOnePlugin($pid, $callUninstall = 0) {
6748 $pid = intval($pid);
6750 if (!$manager->pidInstalled($pid))
6751 return _ERROR_NOSUCHPLUGIN;
6753 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6755 /* // call the unInstall method of the plugin
6756 if ($callUninstall) {
6757 $plugin =& $manager->getPlugin($name);
6758 if ($plugin) $plugin->unInstall();
6761 // check dependency before delete
6762 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6763 while($o = sql_fetch_object($res)) {
6764 $plug =& $manager->getPlugin($o->pfile);
6767 $depList = $plug->getPluginDep();
6768 foreach ($depList as $depName)
6770 if ($name == $depName)
6772 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6778 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6780 // call the unInstall method of the plugin
6781 if ($callUninstall) {
6782 $plugin =& $manager->getPlugin($name);
6783 if ($plugin) $plugin->unInstall();
6786 // delete all subscriptions
6787 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6789 // delete all options
6790 // get OIDs from plugin_option_desc
6791 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6793 while ($o = sql_fetch_object($res)) {
6794 array_push($aOIDs, $o->oid);
6797 // delete from plugin_option and plugin_option_desc
6798 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6799 if (count($aOIDs) > 0)
6800 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6802 // update order numbers
6803 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6804 $o = sql_fetch_object($res);
6805 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6808 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6810 $manager->clearCachedInfo('installedPlugins');
6811 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6817 * @todo document this
6819 function action_pluginup() {
6820 global $member, $manager, $CONF;
6823 $member->isAdmin() or $this->disallow();
6825 $plugid = intGetVar('plugid');
6827 if (!$manager->pidInstalled($plugid))
6828 $this->error(_ERROR_NOSUCHPLUGIN);
6830 // 1. get old order number
6831 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6832 $o = sql_fetch_object($res);
6833 $oldOrder = $o->porder;
6835 // 2. calculate new order number
6836 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6838 // 3. update plug numbers
6839 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6840 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6842 //$this->action_pluginlist();
6843 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6844 redirect($CONF['AdminURL'] . '?action=pluginlist');
6848 * @todo document this
6850 function action_plugindown() {
6851 global $member, $manager, $CONF;
6854 $member->isAdmin() or $this->disallow();
6856 $plugid = intGetVar('plugid');
6857 if (!$manager->pidInstalled($plugid))
6858 $this->error(_ERROR_NOSUCHPLUGIN);
6860 // 1. get old order number
6861 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6862 $o = sql_fetch_object($res);
6863 $oldOrder = $o->porder;
6865 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6866 $maxOrder = sql_num_rows($res);
6868 // 2. calculate new order number
6869 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6871 // 3. update plug numbers
6872 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6873 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6875 //$this->action_pluginlist();
6876 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6877 redirect($CONF['AdminURL'] . '?action=pluginlist');
6881 * Admin::action_pluginoptions()
6883 * Output Plugin option page
6886 * @param string $message message when fallbacked
6890 public function action_pluginoptions($message = '')
6892 global $member, $manager;
6895 $member->isAdmin() or $this->disallow();
6897 $pid = (integer) requestVar('plugid');
6898 if ( !$manager->pidInstalled($pid) )
6900 $this->error(_ERROR_NOSUCHPLUGIN);
6903 $pname = getPluginNameFromPid($pid);
6905 /* just for including translation */
6906 $manager->getPlugin($pname);
6908 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6909 $this->pagehead($extrahead);
6910 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6911 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($pname)) . "</h2>\n";
6913 if ( isset($message) )
6918 echo "<form action=\"index.php\" method=\"post\">\n";
6920 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6921 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6922 $manager->addTicketHidden();
6924 $aOptions = array();
6926 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6927 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6928 $result = sql_query($query);
6929 while ( $object = sql_fetch_object($result) )
6931 array_push($aOIDs, $object->oid);
6932 $aOptions[$object->oid] = array(
6933 'oid' => $object->oid,
6934 'value' => $object->odef,
6935 'name' => $object->oname,
6936 'description' => $object->odesc,
6937 'type' => $object->otype,
6938 'typeinfo' => $object->oextra,
6942 // fill out actual values
6943 if ( count($aOIDs) > 0 )
6945 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6946 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6947 $result = sql_query($query);
6948 while ( $object = sql_fetch_object($result) )
6950 $aOptions[$object->oid]['value'] = $object->ovalue;
6955 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
6956 $manager->notify('PrePluginOptionsEdit',$data);
6958 $template['content'] = 'plugoptionlist';
6959 $amount = showlist($aOptions,'table',$template);
6962 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6972 * Admin::action_pluginoptionsupdate()
6974 * Update plugin options and fallback to plugin option page
6980 public function action_pluginoptionsupdate()
6982 global $member, $manager;
6985 $member->isAdmin() or $this->disallow();
6987 $pid = (integer) requestVar('plugid');
6988 if ( !$manager->pidInstalled($pid) )
6990 $this->error(_ERROR_NOSUCHPLUGIN);
6993 $aOptions = requestArray('plugoption');
6994 NucleusPlugin::apply_plugin_options($aOptions);
6996 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6998 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
7003 * Admin::_insertPluginOptions()
7005 * Output plugin option field
7008 * @param string $context plugin option context
7009 * @param integer $contextid plugin option context id
7012 public function _insertPluginOptions($context, $contextid = 0)
7014 // get all current values for this contextid
7015 // (note: this might contain doubles for overlapping contextids)
7016 $aIdToValue = array();
7017 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
7018 while ( $object = sql_fetch_object($res) )
7020 $aIdToValue[$object->oid] = $object->ovalue;
7023 // get list of oids per pid
7024 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
7025 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
7026 $res = sql_query($query);
7027 $aOptions = array();
7028 while ( $object = sql_fetch_object($res) )
7030 if (in_array($object->oid, array_keys($aIdToValue)))
7032 $value = $aIdToValue[$object->oid];
7036 $value = $object->odef;
7039 array_push($aOptions, array(
7040 'pid' => $object->pid,
7041 'pfile' => $object->pfile,
7042 'oid' => $object->oid,
7044 'name' => $object->oname,
7045 'description' => $object->odesc,
7046 'type' => $object->otype,
7047 'typeinfo' => $object->oextra,
7048 'contextid' => $contextid,
7053 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
7056 foreach ($aOptions as $aOption)
7059 if ( $iPrevPid != $aOption['pid'] )
7061 $iPrevPid = $aOption['pid'];
7062 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
7064 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
7066 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, Entity::hsc($aOption['pfile'])).'</th></tr>';
7069 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
7070 if ( @$meta['access'] != 'hidden' )
7073 listplug_plugOptionRow($aOption);
7081 * Admin::input_yesno()
7082 * Output input elements with radio attribute for yes/no options
7084 * @param string $name name attribute
7085 * @param string $value_current current value attribute
7086 * @param integer $tabindex tab index
7087 * @param string $value_yes value attribute for yes option
7088 * @param string $value_no value attribute for no option
7089 * @param string $text_yes child text element for yes option
7090 * @param string $text_no child text element for no option
7091 * @param boolean $isAdmin have admin right or not
7094 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
7096 $id = preg_replace('#\[|\]#', '-', $name);
7097 $id_yes = $id . $value_yes;
7098 $id_no = $id . $value_no;
7101 echo '<input type="radio" id="' . Entity::hsc($id_yes) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_yes) . '"';
7102 if ( $name=="admin" )
7104 echo ' onclick="selectCanLogin(true);"';
7106 if ( $value_current == $value_yes )
7108 echo " tabindex='$tabindex' checked='checked'";
7111 echo '<label for="' . Entity::hsc($id_yes) . '">' . Entity::hsc($text_yes) . "</label>\n";
7114 echo '<input type="radio" id="' . Entity::hsc($id_no) . '" name="' . Entity::hsc($name) . '" value="' . Entity::hsc($value_no) . '"';
7115 if ( $name=="admin" )
7117 echo ' onclick="selectCanLogin(false);"';
7119 if ( $value_current != $value_yes )
7121 echo " tabindex='$tabindex' checked='checked'";
7123 if ($isAdmin && $name=="canlogin")
7125 echo ' disabled="disabled"';
7128 echo '<label for="' . Entity::hsc($id_no) . '">' . Entity::hsc($text_no) . "</label>\n";