3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2009 The Nucleus Group
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 * (see nucleus/documentation/index.html#license for more info)
13 * The code for the Nucleus admin area
15 * @license http://nucleuscms.org/license.txt GNU General Public License
16 * @copyright Copyright (C) 2002-2009 The Nucleus Group
17 * @version $Id: ADMIN.php 1661 2012-02-12 11:55:39Z sakamocchi $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
29 private $xml_version_info = '1.0';
30 private $formal_public_identifier = '-//W3C//DTD XHTML 1.0 Strict//EN';
31 private $system_identifier = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd';
32 private $xhtml_namespace = 'http://www.w3.org/1999/xhtml';
35 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
49 * @param string $action action to be performed
51 function action($action) {
52 global $CONF, $manager;
54 // list of action aliases
56 'login' => 'overview',
60 if (isset($alias[$action]))
61 $action = $alias[$action];
63 $methodName = 'action_' . $action;
65 $this->action = strtolower($action);
67 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
68 // is an action that requires user interaction before something is actually done)
69 // all safe actions are in this array:
70 $aActionsNotToCheck = array(
101 'banlistnewfromitem',
122 // the rest of the actions needs to be checked
123 $aActionsToCheck = array('additem', 'itemupdate', 'itemmoveto', 'categoryupdate', 'categorydeleteconfirm', 'itemdeleteconfirm', 'commentdeleteconfirm', 'teamdeleteconfirm', 'memberdeleteconfirm', 'templatedeleteconfirm', 'skindeleteconfirm', 'banlistdeleteconfirm', 'plugindeleteconfirm', 'batchitem', 'batchcomment', 'batchmember', 'batchcategory', 'batchteam', 'regfile', 'commentupdate', 'banlistadd', 'changemembersettings', 'clearactionlog', 'settingsupdate', 'blogsettingsupdate', 'categorynew', 'teamchangeadmin', 'teamaddmember', 'memberadd', 'addnewlog', 'addnewlog2', 'backupcreate', 'backuprestore', 'pluginup', 'plugindown', 'pluginupdate', 'pluginadd', 'pluginoptionsupdate', 'skinupdate', 'skinclone', 'skineditgeneral', 'templateclone', 'templatenew', 'templateupdate', 'skinieimport', 'skinieexport', 'skiniedoimport', 'skinnew', 'deleteblogconfirm', 'activatesetpwd');
125 if (!in_array($this->action, $aActionsNotToCheck))
127 if (!$manager->checkTicket())
128 $this->error(_ERROR_BADTICKET);
131 if (method_exists($this, $methodName))
132 call_user_func(array(&$this, $methodName));
134 $this->error(_BADACTION . ENTITY::hsc(" ($action)"));
139 * @todo document this
141 function action_showlogin() {
143 $this->action_login($error);
147 * @todo document this
149 function action_login($msg = '', $passvars = 1) {
152 // skip to overview when allowed
153 if ($member->isLoggedIn() && $member->canLogin()) {
154 $this->action_overview();
160 echo '<h2>', _LOGIN ,'</h2>';
161 if ($msg) echo _MESSAGE , ': ', ENTITY::hsc($msg);
164 <form action="index.php" method="post"><p>
165 <?php echo _LOGIN_NAME; ?> <br /><input name="login" tabindex="10" />
167 <?php echo _LOGIN_PASSWORD; ?> <br /><input name="password" tabindex="20" type="password" />
169 <input name="action" value="login" type="hidden" />
171 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
174 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
175 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
177 <?php // pass through vars
179 $oldaction = postVar('oldaction');
180 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
187 <?php $this->pagefoot();
192 * provides a screen with the overview of the actions available
193 * @todo document parameter
195 function action_overview($msg = '') {
201 echo _MESSAGE , ': ', $msg;
203 /* ---- add items ---- */
204 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
206 $showAll = requestVar('showall');
208 if (($member->isAdmin()) && ($showAll == 'yes')) {
209 // Super-Admins have access to all blogs! (no add item support though)
210 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
211 . ' FROM ' . sql_table('blog')
214 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
215 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
216 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
219 $template['content'] = 'bloglist';
220 $template['superadmin'] = $member->isAdmin();
221 $amount = showlist($query,'table',$template);
223 if (($showAll != 'yes') && ($member->isAdmin())) {
224 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
225 if ($total > $amount)
226 echo '<p><a href="index.php?action=overview&showall=yes">' . _OVERVIEW_SHOWALL . '</a></p>';
230 echo _OVERVIEW_NOBLOGS;
233 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
234 $query = 'SELECT ititle, inumber, bshortname'
235 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
236 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
237 $template['content'] = 'draftlist';
238 $amountdrafts = showlist($query, 'table', $template);
239 if ($amountdrafts == 0)
240 echo _OVERVIEW_NODRAFTS;
244 $yrBlogs = $member->getAdminBlogs();
245 if ($showAll != 'yes') {
247 foreach ($yrBlogs as $value) {
248 if ($member->isBlogAdmin(intval($value))) {
249 $admBlogs[] = intval($value);
252 $yrBlogs = $admBlogs;
255 if (count($yrBlogs) > 0) {
256 echo '<h2>' . _OVERVIEW_OTHER_DRAFTS . '</h2>';
257 $query = 'SELECT ititle, inumber, bshortname, mname'
258 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog'). ', ' . sql_table('member')
259 . ' WHERE iauthor<>'.$member->getID().' and iblog IN ('.implode(",",$yrBlogs).') and iblog=bnumber and iauthor=mnumber and idraft=1'
260 . ' ORDER BY iblog ASC';
261 $template['content'] = 'otherdraftlist';
262 $amountdrafts = showlist($query, 'table', $template);
263 if ($amountdrafts == 0)
264 echo _OVERVIEW_NODRAFTS;
268 /* ---- user settings ---- */
269 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
271 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
272 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
273 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
276 /* ---- general settings ---- */
277 if ($member->isAdmin()) {
278 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
280 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
289 * Returns a link to a weblog
292 function bloglink(&$blog) {
293 return '<a href="'.ENTITY::hsc($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. ENTITY::hsc( $blog->getName() ) .'</a>';
297 * @todo document this
299 function action_manage($msg = '') {
302 $member->isAdmin() or $this->disallow();
306 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
309 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
312 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
315 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
316 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
317 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
318 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
321 echo '<h2>' . _MANAGE_SKINS . '</h2>';
323 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
324 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
325 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
328 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
330 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
331 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
338 * @todo document this
340 function action_itemlist($blogid = '') {
341 global $member, $manager, $CONF;
344 $blogid = intRequestVar('blogid');
346 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
349 $blog =& $manager->getBlog($blogid);
351 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
352 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
355 if (postVar('start'))
356 $start = intPostVar('start');
361 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
363 // amount of items to show
364 if (postVar('amount'))
365 $amount = intPostVar('amount');
367 $amount = intval($CONF['DefaultListSize']);
372 $search = postVar('search'); // search through items
374 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
375 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
376 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
379 $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
381 // non-blog-admins can only edit/delete their own items
382 if (!$member->blogAdminRights($blogid))
383 $query .= ' and iauthor=' . $member->getID();
386 $query .= ' ORDER BY itime DESC'
387 . " LIMIT $start,$amount";
389 $template['content'] = 'itemlist';
390 $template['now'] = $blog->getCorrectTime(time());
392 $manager->loadClass("ENCAPSULATE");
393 $navList = new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
394 $navList->showBatchList('item',$query,'table',$template);
401 * @todo document this
403 function action_batchitem() {
404 global $member, $manager;
406 // check if logged in
407 $member->isLoggedIn() or $this->disallow();
409 // more precise check will be done for each performed operation
411 // get array of itemids from request
412 $selected = requestIntArray('batch');
413 $action = requestVar('batchaction');
415 // Show error when no items were selected
416 if (!is_array($selected) || sizeof($selected) == 0)
417 $this->error(_BATCH_NOSELECTION);
419 // On move: when no destination blog/category chosen, show choice now
420 $destCatid = intRequestVar('destcatid');
421 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
422 $this->batchMoveSelectDestination('item',$selected);
424 // On delete: check if confirmation has been given
425 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
426 $this->batchAskDeleteConfirmation('item',$selected);
430 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
431 echo '<h2>',_BATCH_ITEMS,'</h2>';
432 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
436 // walk over all itemids and perform action
437 foreach ($selected as $itemid) {
438 $itemid = intval($itemid);
439 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
441 // perform action, display errors if needed
444 $error = $this->deleteOneItem($itemid);
447 $error = $this->moveOneItem($itemid, $destCatid);
450 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
453 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
458 echo '<b>',_BATCH_DONE,'</b>';
466 * @todo document this
468 function action_batchcomment() {
471 // check if logged in
472 $member->isLoggedIn() or $this->disallow();
474 // more precise check will be done for each performed operation
476 // get array of itemids from request
477 $selected = requestIntArray('batch');
478 $action = requestVar('batchaction');
480 // Show error when no items were selected
481 if (!is_array($selected) || sizeof($selected) == 0)
482 $this->error(_BATCH_NOSELECTION);
484 // On delete: check if confirmation has been given
485 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
486 $this->batchAskDeleteConfirmation('comment',$selected);
490 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
491 echo '<h2>',_BATCH_COMMENTS,'</h2>';
492 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
495 // walk over all itemids and perform action
496 foreach ($selected as $commentid) {
497 $commentid = intval($commentid);
498 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
500 // perform action, display errors if needed
503 $error = $this->deleteOneComment($commentid);
506 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
509 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
514 echo '<b>',_BATCH_DONE,'</b>';
522 * @todo document this
524 function action_batchmember() {
527 // check if logged in and admin
528 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
530 // get array of itemids from request
531 $selected = requestIntArray('batch');
532 $action = requestVar('batchaction');
534 // Show error when no members selected
535 if (!is_array($selected) || sizeof($selected) == 0)
536 $this->error(_BATCH_NOSELECTION);
538 // On delete: check if confirmation has been given
539 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
540 $this->batchAskDeleteConfirmation('member',$selected);
544 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
545 echo '<h2>',_BATCH_MEMBERS,'</h2>';
546 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
549 // walk over all itemids and perform action
550 foreach ($selected as $memberid) {
551 $memberid = intval($memberid);
552 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
554 // perform action, display errors if needed
557 $error = $this->deleteOneMember($memberid);
561 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
565 // there should always remain at least one super-admin
566 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
567 if (sql_num_rows($r) < 2)
568 $error = _ERROR_ATLEASTONEADMIN;
570 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
573 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
576 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
581 echo '<b>',_BATCH_DONE,'</b>';
589 * @todo document this
591 function action_batchteam() {
594 $blogid = intRequestVar('blogid');
596 // check if logged in and admin
597 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
599 // get array of itemids from request
600 $selected = requestIntArray('batch');
601 $action = requestVar('batchaction');
603 // Show error when no members selected
604 if (!is_array($selected) || sizeof($selected) == 0)
605 $this->error(_BATCH_NOSELECTION);
607 // On delete: check if confirmation has been given
608 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
609 $this->batchAskDeleteConfirmation('team',$selected);
613 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
615 echo '<h2>',_BATCH_TEAM,'</h2>';
616 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
619 // walk over all itemids and perform action
620 foreach ($selected as $memberid) {
621 $memberid = intval($memberid);
622 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
624 // perform action, display errors if needed
627 $error = $this->deleteOneTeamMember($blogid, $memberid);
631 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
635 // there should always remain at least one admin
636 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
637 if (sql_num_rows($r) < 2)
638 $error = _ERROR_ATLEASTONEBLOGADMIN;
640 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
643 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
646 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
651 echo '<b>',_BATCH_DONE,'</b>';
659 * @todo document this
661 function action_batchcategory() {
662 global $member, $manager;
664 // check if logged in
665 $member->isLoggedIn() or $this->disallow();
667 // more precise check will be done for each performed operation
669 // get array of itemids from request
670 $selected = requestIntArray('batch');
671 $action = requestVar('batchaction');
673 // Show error when no items were selected
674 if (!is_array($selected) || sizeof($selected) == 0)
675 $this->error(_BATCH_NOSELECTION);
677 // On move: when no destination blog chosen, show choice now
678 $destBlogId = intRequestVar('destblogid');
679 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
680 $this->batchMoveCategorySelectDestination('category',$selected);
682 // On delete: check if confirmation has been given
683 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
684 $this->batchAskDeleteConfirmation('category',$selected);
688 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
689 echo '<h2>',BATCH_CATEGORIES,'</h2>';
690 echo '<p>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b></p>';
693 // walk over all itemids and perform action
694 foreach ($selected as $catid) {
695 $catid = intval($catid);
696 echo '<li>',_BATCH_EXECUTING,' <b>',ENTITY::hsc($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
698 // perform action, display errors if needed
701 $error = $this->deleteOneCategory($catid);
704 $error = $this->moveOneCategory($catid, $destBlogId);
707 $error = _BATCH_UNKNOWN . ENTITY::hsc($action);
710 echo '<b>',($error ? _ERROR . ': '.$error : _BATCH_SUCCESS),'</b>';
715 echo '<b>',_BATCH_DONE,'</b>';
722 * @todo document this
724 function batchMoveSelectDestination($type, $ids) {
728 <h2><?php echo _MOVE_TITLE?></h2>
729 <form method="post" action="index.php"><div>
731 <input type="hidden" name="action" value="batch<?php echo $type?>" />
732 <input type="hidden" name="batchaction" value="move" />
734 $manager->addTicketHidden();
736 // insert selected item numbers
738 foreach ($ids as $id)
739 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
741 // show blog/category selection list
742 $this->selectBlogCategory('destcatid');
747 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
750 <?php $this->pagefoot();
755 * @todo document this
757 function batchMoveCategorySelectDestination($type, $ids) {
761 <h2><?php echo _MOVECAT_TITLE?></h2>
762 <form method="post" action="index.php"><div>
764 <input type="hidden" name="action" value="batch<?php echo $type?>" />
765 <input type="hidden" name="batchaction" value="move" />
767 $manager->addTicketHidden();
769 // insert selected item numbers
771 foreach ($ids as $id)
772 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
774 // show blog/category selection list
775 $this->selectBlog('destblogid');
780 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
783 <?php $this->pagefoot();
788 * @todo document this
790 function batchAskDeleteConfirmation($type, $ids) {
795 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
796 <form method="post" action="index.php"><div>
798 <input type="hidden" name="action" value="batch<?php echo $type?>" />
799 <?php $manager->addTicketHidden() ?>
800 <input type="hidden" name="batchaction" value="delete" />
801 <input type="hidden" name="confirmation" value="yes" />
802 <?php // insert selected item numbers
804 foreach ($ids as $id)
805 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
807 // add hidden vars for team & comment
810 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
812 if ($type == 'comment')
814 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
819 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
822 <?php $this->pagefoot();
828 * Inserts a HTML select element with choices for all categories to which the current
830 * @see function selectBlog
832 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
833 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
837 * Inserts a HTML select element with choices for all blogs to which the user has access
838 * mode = 'blog' => shows blognames and values are blogids
839 * mode = 'category' => show category names and values are catids
841 * @param $iForcedBlogInclude
842 * ID of a blog that always needs to be included, without checking if the
843 * member is on the blog team (-1 = none)
844 * @todo document parameters
846 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
847 global $member, $CONF;
849 // 0. get IDs of blogs to which member can post items (+ forced blog)
851 if ($iForcedBlogInclude != -1)
852 $aBlogIds[] = intval($iForcedBlogInclude);
854 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
855 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
857 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
858 $rblogids = sql_query($queryBlogs);
859 while ($o = sql_fetch_object($rblogids))
860 if ($o->bnumber != $iForcedBlogInclude)
861 $aBlogIds[] = intval($o->bnumber);
863 if (count($aBlogIds) == 0)
866 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
868 // 1. select blogs (we'll create optiongroups)
869 // (only select those blogs that have the user on the team)
870 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
871 $blogs = sql_query($queryBlogs);
872 if ($mode == 'category') {
873 if (sql_num_rows($blogs) > 1)
876 while ($oBlog = sql_fetch_object($blogs)) {
878 echo '<optgroup label="',ENTITY::hsc($oBlog->bname),'">';
880 // show selection to create new category when allowed/wanted
882 // check if allowed to do so
883 if ($member->blogAdminRights($oBlog->bnumber))
884 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
887 // 2. for each category in that blog
888 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
889 while ($oCat = sql_fetch_object($categories)) {
890 if ($oCat->catid == $selected)
891 $selectText = ' selected="selected" ';
894 echo '<option value="',$oCat->catid,'" ', $selectText,'>',ENTITY::hsc($oCat->cname),'</option>';
902 while ($oBlog = sql_fetch_object($blogs)) {
903 echo '<option value="',$oBlog->bnumber,'"';
904 if ($oBlog->bnumber == $selected)
905 echo ' selected="selected"';
906 echo'>',ENTITY::hsc($oBlog->bname),'</option>';
914 * @todo document this
916 function action_browseownitems() {
917 global $member, $manager, $CONF;
921 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
922 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
925 if (postVar('start'))
926 $start = intPostVar('start');
930 // amount of items to show
931 if (postVar('amount'))
932 $amount = intPostVar('amount');
934 $amount = intval($CONF['DefaultListSize']);
939 $search = postVar('search'); // search through items
941 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
942 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
943 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
946 $query .= ' and ((ititle LIKE "%' . sql_real_escape_string($search) . '%") or (ibody LIKE "%' . sql_real_escape_string($search) . '%") or (imore LIKE "%' . sql_real_escape_string($search) . '%"))';
948 $query .= ' ORDER BY itime DESC'
949 . " LIMIT $start,$amount";
951 $template['content'] = 'itemlist';
952 $template['now'] = time();
954 $manager->loadClass("ENCAPSULATE");
955 $navList = new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
956 $navList->showBatchList('item',$query,'table',$template);
963 * Show all the comments for a given item
966 function action_itemcommentlist($itemid = '') {
967 global $member, $manager, $CONF;
970 $itemid = intRequestVar('itemid');
972 // only allow if user is allowed to alter item
973 $member->canAlterItem($itemid) or $this->disallow();
975 $blogid = getBlogIdFromItemId($itemid);
980 if (postVar('start'))
981 $start = intPostVar('start');
985 // amount of items to show
986 if (postVar('amount'))
987 $amount = intPostVar('amount');
989 $amount = intval($CONF['DefaultListSize']);
994 $search = postVar('search');
996 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
997 echo '<h2>',_COMMENTS,'</h2>';
999 $query = 'SELECT cbody, cuser, cmail, cemail, mname, ctime, chost, cnumber, cip, citem FROM ' . sql_table('comment') . ' LEFT OUTER JOIN ' . sql_table('member') . ' ON mnumber = cmember WHERE citem = ' . $itemid;
1002 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1004 $query .= ' ORDER BY ctime ASC'
1005 . " LIMIT $start,$amount";
1007 $template['content'] = 'commentlist';
1008 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
1010 $manager->loadClass("ENCAPSULATE");
1011 $navList = new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
1012 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
1018 * Browse own comments
1020 function action_browseowncomments() {
1021 global $member, $manager, $CONF;
1024 if (postVar('start'))
1025 $start = intPostVar('start');
1029 // amount of items to show
1030 if (postVar('amount'))
1031 $amount = intPostVar('amount');
1033 $amount = intval($CONF['DefaultListSize']);
1038 $search = postVar('search');
1041 $query = 'SELECT cbody, cuser, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cmember=' . $member->getID();
1044 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1046 $query .= ' ORDER BY ctime DESC'
1047 . " LIMIT $start,$amount";
1051 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1052 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
1054 $template['content'] = 'commentlist';
1055 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
1057 $manager->loadClass("ENCAPSULATE");
1058 $navList = new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
1059 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
1065 * Browse all comments for a weblog
1066 * @param int $blogid
1068 function action_blogcommentlist($blogid = '')
1070 global $member, $manager, $CONF;
1073 $blogid = intRequestVar('blogid');
1075 $blogid = intval($blogid);
1077 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
1080 if (postVar('start'))
1081 $start = intPostVar('start');
1085 // amount of items to show
1086 if (postVar('amount'))
1087 $amount = intPostVar('amount');
1089 $amount = intval($CONF['DefaultListSize']);
1094 $search = postVar('search'); // search through comments
1097 $query = 'SELECT cbody, cuser, cemail, cmail, mname, ctime, chost, cnumber, cip, citem FROM '.sql_table('comment').' LEFT OUTER JOIN '.sql_table('member').' ON mnumber=cmember WHERE cblog=' . intval($blogid);
1100 $query .= ' and cbody LIKE "%' . sql_real_escape_string($search) . '%"';
1103 $query .= ' ORDER BY ctime DESC'
1104 . " LIMIT $start,$amount";
1107 $blog =& $manager->getBlog($blogid);
1111 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1112 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1114 $template['content'] = 'commentlist';
1115 $template['canAddBan'] = $member->blogAdminRights($blogid);
1117 $manager->loadClass("ENCAPSULATE");
1118 $navList = new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1119 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1125 * Provide a page to item a new item to the given blog
1127 function action_createitem() {
1128 global $member, $manager;
1130 $blogid = intRequestVar('blogid');
1133 $member->teamRights($blogid) or $this->disallow();
1135 $memberid = $member->getID();
1137 $blog =& $manager->getBlog($blogid);
1141 // generate the add-item form
1142 $formfactory = new PAGEFACTORY($blogid);
1143 $formfactory->createAddForm('admin');
1149 * @todo document this
1151 function action_itemedit()
1153 global $member, $manager;
1155 $itemid = intRequestVar('itemid');
1157 // only allow if user is allowed to alter item
1158 $member->canAlterItem($itemid) or $this->disallow();
1160 $item =& $manager->getItem($itemid, 1, 1);
1161 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1163 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1165 if ($blog->convertBreaks())
1167 $item['body'] = removeBreaks($item['body']);
1168 $item['more'] = removeBreaks($item['more']);
1171 // form to edit blog items
1173 $formfactory = new PAGEFACTORY($blog->getID());
1174 $formfactory->createEditForm('admin', $item);
1179 * @todo document this
1181 function action_itemupdate() {
1182 global $member, $manager, $CONF;
1184 $itemid = intRequestVar('itemid');
1185 $catid = postVar('catid');
1187 // only allow if user is allowed to alter item
1188 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1190 $actiontype = postVar('actiontype');
1192 // delete actions are handled by itemdelete (which has confirmation)
1193 if ($actiontype == 'delete') {
1194 $this->action_itemdelete();
1198 $body = postVar('body');
1199 $title = postVar('title');
1200 $more = postVar('more');
1201 $closed = intPostVar('closed');
1202 $draftid = intPostVar('draftid');
1204 // default action = add now
1206 $actiontype='addnow';
1208 // create new category if needed
1209 if (strstr($catid,'newcat')) {
1211 list($blogid) = sscanf($catid,"newcat-%d");
1214 $blog =& $manager->getBlog($blogid);
1215 $catid = $blog->createNewCategory();
1217 // show error when sth goes wrong
1219 $this->doError(_ERROR_CATCREATEFAIL);
1223 set some variables based on actiontype
1226 draft items -> addnow, addfuture, adddraft, delete
1227 non-draft items -> edit, changedate, delete
1230 $timestamp: set to a nonzero value for future dates or date changes
1231 $wasdraft: set to 1 when the item used to be a draft item
1232 $publish: set to 1 when the edited item is not a draft
1234 $blogid = getBlogIDFromItemID($itemid);
1235 $blog =& $manager->getBlog($blogid);
1237 $wasdrafts = array('adddraft', 'addfuture', 'addnow');
1238 $wasdraft = in_array($actiontype, $wasdrafts) ? 1 : 0;
1239 $publish = ($actiontype != 'adddraft' && $actiontype != 'backtodrafts') ? 1 : 0;
1240 if ($actiontype == 'addfuture' || $actiontype == 'changedate') {
1241 $timestamp = mktime(intPostVar('hour'), intPostVar('minutes'), 0, intPostVar('month'), intPostVar('day'), intPostVar('year'));
1246 // edit the item for real
1247 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1249 $this->updateFuturePosted($blogid);
1252 // delete permission is checked inside ITEM::delete()
1253 ITEM::delete($draftid);
1256 // show category edit window when we created a new category
1257 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1258 if ($catid != intPostVar('catid')) {
1259 $this->action_categoryedit(
1262 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1265 // TODO: set start item correctly for itemlist
1266 $this->action_itemlist(getBlogIDFromItemID($itemid));
1271 * ADMIN::action_itemdelete()
1277 function action_itemdelete()
1279 global $member, $manager;
1281 $itemid = intRequestVar('itemid');
1283 // only allow if user is allowed to alter item
1284 $member->canAlterItem($itemid) or $this->disallow();
1286 if ( !$manager->existsItem($itemid,1,1) )
1288 $this->error(_ERROR_NOSUCHITEM);
1291 $item =& $manager->getItem($itemid,1,1);
1292 $title = ENTITY::hsc(strip_tags($item['title']));
1293 $body = strip_tags($item['body']);
1294 $body = ENTITY::hsc(ENTITY::shorten($body,300,'...'));
1297 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1298 echo '<p>' . _CONFIRMTXT_ITEM . "</p>\n";
1299 echo "<div class=\"note\">\n";
1300 echo "<b>{$title}</b>\n";
1304 echo "<form method=\"post\" action=\"index.php\">\n";
1306 echo "<input type=\"hidden\" name=\"action\" value=\"itemdeleteconfirm\" />\n";
1307 echo $manager->addTicketHidden() . "\n";
1308 echo "<input type=\"hidden\" name=\"itemid\" value=\"{$itemid}\" />\n";
1309 echo '<input type="submit" value="' . _DELETE_CONFIRM_BTN . "\" tabindex=\"10\" />\n";
1317 * @todo document this
1319 function action_itemdeleteconfirm() {
1322 $itemid = intRequestVar('itemid');
1324 // only allow if user is allowed to alter item
1325 $member->canAlterItem($itemid) or $this->disallow();
1328 $blogid = getBlogIdFromItemId($itemid);
1330 // delete item (note: some checks will be performed twice)
1331 $this->deleteOneItem($itemid);
1333 $this->action_itemlist($blogid);
1337 * Deletes one item and returns error if something goes wrong
1338 * @param int $itemid
1340 function deleteOneItem($itemid) {
1341 global $member, $manager;
1343 // only allow if user is allowed to alter item (also checks if itemid exists)
1344 if (!$member->canAlterItem($itemid))
1345 return _ERROR_DISALLOWED;
1347 // need to get blogid before the item is deleted
1348 $blogid = getBlogIDFromItemId($itemid);
1350 $manager->loadClass('ITEM');
1351 ITEM::delete($itemid);
1353 // update blog's futureposted
1354 $this->updateFuturePosted($blogid);
1358 * ADMIN::updateFuturePosted()
1359 * Update a blog's future posted flag
1361 * @param integer $blogid
1365 function updateFuturePosted($blogid)
1369 $blog =& $manager->getBlog($blogid);
1370 $currenttime = $blog->getCorrectTime(time());
1372 $query = "SELECT * FROM %s WHERE iblog=%d AND iposted=0 AND itime>'%s'";
1373 $query = sprintf($query, sql_table('item'), (integer) $blogid, i18n::formatted_datetime('mysql', $currenttime));
1374 $result = sql_query($query);
1376 if ( sql_num_rows($result) > 0 )
1378 $blog->setFuturePost();
1382 $blog->clearFuturePost();
1388 * @todo document this
1390 function action_itemmove() {
1391 global $member, $manager;
1393 $itemid = intRequestVar('itemid');
1395 // only allow if user is allowed to alter item
1396 $member->canAlterItem($itemid) or $this->disallow();
1398 $item =& $manager->getItem($itemid,1,1);
1402 <h2><?php echo _MOVE_TITLE?></h2>
1403 <form method="post" action="index.php"><div>
1404 <input type="hidden" name="action" value="itemmoveto" />
1405 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1409 $manager->addTicketHidden();
1410 $this->selectBlogCategory('catid',$item['catid'],10,1);
1413 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1420 * @todo document this
1422 function action_itemmoveto() {
1423 global $member, $manager;
1425 $itemid = intRequestVar('itemid');
1426 $catid = requestVar('catid');
1428 // create new category if needed
1429 if (strstr($catid,'newcat')) {
1431 list($blogid) = sscanf($catid,'newcat-%d');
1434 $blog =& $manager->getBlog($blogid);
1435 $catid = $blog->createNewCategory();
1437 // show error when sth goes wrong
1439 $this->doError(_ERROR_CATCREATEFAIL);
1442 // only allow if user is allowed to alter item
1443 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1445 $old_blogid = getBlogIDFromItemId($itemid);
1447 ITEM::move($itemid, $catid);
1449 // set the futurePosted flag on the blog
1450 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1452 // reset the futurePosted in case the item is moved from one blog to another
1453 $this->updateFuturePosted($old_blogid);
1455 if ($catid != intRequestVar('catid'))
1456 $this->action_categoryedit($catid, $blog->getID());
1458 $this->action_itemlist(getBlogIDFromCatID($catid));
1462 * Moves one item to a given category (category existance should be checked by caller)
1463 * errors are returned
1464 * @param int $itemid
1465 * @param int $destCatid category ID to which the item will be moved
1467 function moveOneItem($itemid, $destCatid) {
1470 // only allow if user is allowed to move item
1471 if (!$member->canUpdateItem($itemid, $destCatid))
1472 return _ERROR_DISALLOWED;
1474 ITEM::move($itemid, $destCatid);
1478 * Adds a item to the chosen blog
1480 function action_additem() {
1481 global $manager, $CONF;
1483 $manager->loadClass('ITEM');
1485 $result = ITEM::createFromRequest();
1487 if ($result['status'] == 'error')
1488 $this->error($result['message']);
1490 $blogid = getBlogIDFromItemID($result['itemid']);
1491 $blog =& $manager->getBlog($blogid);
1492 $btimestamp = $blog->getCorrectTime();
1493 $item = $manager->getItem(intval($result['itemid']), 1, 1);
1495 if ($result['status'] == 'newcategory') {
1496 $distURI = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=itemList&blogid=' . intval($blogid));
1497 $this->action_categoryedit($result['catid'], $blogid, $distURI);
1499 $methodName = 'action_itemList';
1500 call_user_func(array(&$this, $methodName), $blogid);
1505 * Allows to edit previously made comments
1507 function action_commentedit() {
1509 global $member, $manager;
1511 $commentid = intRequestVar('commentid');
1513 $member->canAlterComment($commentid) or $this->disallow();
1515 $comment = COMMENT::getComment($commentid);
1517 $manager->notify('PrepareCommentForEdit', array('comment' => &$comment) );
1519 // change <br /> to \n
1520 $comment['body'] = str_replace('<br />', '', $comment['body']);
1522 // replaced eregi_replace() below with preg_replace(). ereg* functions are deprecated in PHP 5.3.0
1523 /* original eregi_replace: eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>", "\\1", $comment['body']) */
1525 $comment['body'] = preg_replace("#<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>#i", "\\1", $comment['body']);
1530 <h2><?php echo _EDITC_TITLE?></h2>
1532 <form action="index.php" method="post"><div>
1534 <input type="hidden" name="action" value="commentupdate" />
1535 <?php $manager->addTicketHidden(); ?>
1536 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1538 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1540 <td><?php echo _EDITC_WHO?></td>
1542 <?php if ($comment['member'])
1543 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1545 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1549 <td><?php echo _EDITC_WHEN?></td>
1550 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1552 <td><?php echo _EDITC_HOST?></td>
1553 <td><?php echo $comment['host']; ?></td>
1556 <td><?php echo _EDITC_URL; ?></td>
1557 <td><input type="text" name="url" size="30" tabindex="6" value="<?php echo $comment['userid']; ?>" /></td>
1560 <td><?php echo _EDITC_EMAIL; ?></td>
1561 <td><input type="text" name="email" size="30" tabindex="8" value="<?php echo $comment['email']; ?>" /></td>
1564 <td><?php echo _EDITC_TEXT?></td>
1566 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1567 echo $comment['body'];
1571 <td><?php echo _EDITC_EDIT?></td>
1572 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1581 * @todo document this
1583 function action_commentupdate() {
1584 global $member, $manager;
1586 $commentid = intRequestVar('commentid');
1588 $member->canAlterComment($commentid) or $this->disallow();
1590 $url = postVar('url');
1591 $email = postVar('email');
1592 $body = postVar('body');
1594 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1595 # original eregi: eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}", $body) != FALSE
1596 # important note that '\' must be matched with '\\\\' in preg* expressions
1598 // intercept words that are too long
1599 if (preg_match('#[a-zA-Z0-9|\.,;:!\?=\/\\\\]{90,90}#', $body) != FALSE)
1601 $this->error(_ERROR_COMMENT_LONGWORD);
1605 if (i18n::strlen($body) < 3)
1607 $this->error(_ERROR_COMMENT_NOCOMMENT);
1610 if (i18n::strlen($body) > 5000)
1612 $this->error(_ERROR_COMMENT_TOOLONG);
1616 $body = COMMENT::prepareBody($body);
1619 $manager->notify('PreUpdateComment',array('body' => &$body));
1621 $query = 'UPDATE ' . sql_table('comment')
1622 . " SET cmail = '" . sql_real_escape_string($url) . "', cemail = '" . sql_real_escape_string($email) . "', cbody = '" . sql_real_escape_string($body) . "'"
1623 . " WHERE cnumber = " . $commentid;
1627 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1628 $o = sql_fetch_object($res);
1629 $itemid = $o->citem;
1631 if ($member->canAlterItem($itemid))
1632 $this->action_itemcommentlist($itemid);
1634 $this->action_browseowncomments();
1639 * ADMIN::action_commentdelete()
1645 function action_commentdelete()
1647 global $member, $manager;
1649 $commentid = intRequestVar('commentid');
1650 $member->canAlterComment($commentid) or $this->disallow();
1651 $comment = COMMENT::getComment($commentid);
1653 $body = strip_tags($comment['body']);
1654 $body = ENTITY::hsc(ENTITY::shorten($body, 300, '...'));
1656 if ( $comment['member'] )
1658 $author = $comment['member'];
1662 $author = $comment['user'];
1667 echo '<h2>' . _DELETE_CONFIRM . "</h2>\n";
1668 echo '<p>' . _CONFIRMTXT_COMMENT . "</p>\n";
1669 echo "<div class=\"note\">\n";
1670 echo '<b>' . _EDITC_WHO . ":</b>{$author}<br />\n";
1671 echo '<b>' . _EDITC_TEXT . ":</b>{$body}\n";
1673 echo "<form method=\"post\" action=\"index.php\">\n";
1675 echo "<input type=\"hidden\" name=\"action\" value=\"commentdeleteconfirm\" />\n";
1676 echo $manager->addTicketHidden() . "\n";
1677 echo "<input type=\"hidden\" name=\"commentid\" value=\"{$commentid}\" />\n";
1678 echo '<input type="submit" tabindex="10" value="'. _DELETE_CONFIRM_BTN . "\" />\n";
1686 * @todo document this
1688 function action_commentdeleteconfirm() {
1691 $commentid = intRequestVar('commentid');
1693 // get item id first
1694 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1695 $o = sql_fetch_object($res);
1696 $itemid = $o->citem;
1698 $error = $this->deleteOneComment($commentid);
1700 $this->doError($error);
1702 if ($member->canAlterItem($itemid))
1703 $this->action_itemcommentlist($itemid);
1705 $this->action_browseowncomments();
1709 * @todo document this
1711 function deleteOneComment($commentid) {
1712 global $member, $manager;
1714 $commentid = intval($commentid);
1716 if (!$member->canAlterComment($commentid))
1717 return _ERROR_DISALLOWED;
1719 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1721 // delete the comments associated with the item
1722 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1725 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1731 * Usermanagement main
1733 function action_usermanagement() {
1734 global $member, $manager;
1737 $member->isAdmin() or $this->disallow();
1741 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1743 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1745 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1747 // show list of members with actions
1749 . ' FROM '.sql_table('member');
1750 $template['content'] = 'memberlist';
1751 $template['tabindex'] = 10;
1753 $manager->loadClass("ENCAPSULATE");
1754 $batch = new BATCH('member');
1755 $batch->showlist($query,'table',$template);
1757 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1759 <form method="post" action="index.php" name="memberedit"><div>
1761 <input type="hidden" name="action" value="memberadd" />
1762 <?php $manager->addTicketHidden() ?>
1766 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1768 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1769 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1771 <td><input tabindex="10010" name="name" size="32" maxlength="32" /></td>
1773 <td><?php echo _MEMBERS_REALNAME?></td>
1774 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1776 <td><?php echo _MEMBERS_PWD?></td>
1777 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1779 <td><?php echo _MEMBERS_REPPWD?></td>
1780 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1782 <td><?php echo _MEMBERS_EMAIL?></td>
1783 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1785 <td><?php echo _MEMBERS_URL?></td>
1786 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1788 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1789 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1791 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1792 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1794 <td><?php echo _MEMBERS_NOTES?></td>
1795 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1797 <td><?php echo _MEMBERS_NEW?></td>
1798 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1807 * Edit member settings
1809 function action_memberedit() {
1810 $this->action_editmembersettings(intRequestVar('memberid'));
1814 * @todo document this
1816 function action_editmembersettings($memberid = '') {
1817 global $member, $manager, $CONF;
1819 if ($memberid == '')
1821 $memberid = $member->getID();
1825 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1827 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1828 $this->pagehead($extrahead);
1830 // show message to go back to member overview (only for admins)
1831 if ($member->isAdmin())
1833 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1837 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1839 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1841 $mem = MEMBER::createFromID($memberid);
1843 <form method="post" action="index.php" name="memberedit"><div>
1845 <input type="hidden" name="action" value="changemembersettings" />
1846 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1847 <?php $manager->addTicketHidden() ?>
1850 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1852 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1853 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1856 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1857 <input name="name" tabindex="10" maxlength="32" size="32" value="<?php echo ENTITY::hsc($mem->getDisplayName()); ?>" />
1859 echo ENTITY::hsc($member->getDisplayName());
1864 <td><?php echo _MEMBERS_REALNAME?></td>
1865 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo ENTITY::hsc($mem->getRealName()); ?>" /></td>
1867 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1868 <td><?php echo _MEMBERS_PWD?></td>
1869 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1871 <td><?php echo _MEMBERS_REPPWD?></td>
1872 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1875 <td><?php echo _MEMBERS_EMAIL?>
1876 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1878 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo ENTITY::hsc($mem->getEmail()); ?>" /></td>
1880 <td><?php echo _MEMBERS_URL?></td>
1881 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getURL()); ?>" /></td>
1882 <?php // only allow to change this by super-admins
1883 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1884 if ($member->isAdmin()) {
1887 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1888 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1890 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1891 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1894 <td><?php echo _MEMBERS_NOTES?></td>
1895 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo ENTITY::hsc($mem->getNotes()); ?>" /></td>
1897 <td><?php echo _MEMBERS_LOCALE?> <?php help('locale'); ?>
1901 <select name="locale" tabindex="85">
1903 $locales = i18n::get_available_locale_list();
1904 if ( !$mem->getLocale() || !in_array($mem->getLocale(), $locales) )
1906 echo "<option value=\"\" selected=\"selected\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1910 echo "<option value=\"\">" . ENTITY::hsc(_MEMBERS_USESITELANG) . "</option>\n";
1913 foreach( $locales as $locale )
1915 if( $locale == $mem->getLocale() )
1917 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
1921 echo "<option value=\"{$locale}\">{$locale}</option>\n";
1930 <td><?php echo _MEMBERS_USEAUTOSAVE?> <?php help('autosave'); ?></td>
1931 <td><?php $this->input_yesno('autosave', $mem->getAutosave(), 87); ?></td>
1935 $this->_insertPluginOptions('member',$memberid);
1938 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1940 <td><?php echo _MEMBERS_EDIT?></td>
1941 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1947 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1950 'MemberSettingsFormExtras',
1959 * @todo document this
1961 function action_changemembersettings() {
1962 global $member, $CONF, $manager;
1964 $memberid = intRequestVar('memberid');
1967 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1969 $name = trim(strip_tags(postVar('name')));
1970 $realname = trim(strip_tags(postVar('realname')));
1971 $password = postVar('password');
1972 $repeatpassword = postVar('repeatpassword');
1973 $email = strip_tags(postVar('email'));
1974 $url = strip_tags(postVar('url'));
1976 # replaced eregi() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
1977 # original eregi: !eregi("^https?://", $url)
1979 // begin if: sometimes user didn't prefix the URL with http:// or https://, this cause a malformed URL. Let's fix it.
1980 if (!preg_match('#^https?://#', $url) )
1982 $url = 'http://' . $url;
1985 $admin = postVar('admin');
1986 $canlogin = postVar('canlogin');
1987 $notes = strip_tags(postVar('notes'));
1988 $locale = postVar('locale');
1990 $mem = MEMBER::createFromID($memberid);
1992 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1994 if (!isValidDisplayName($name))
1995 $this->error(_ERROR_BADNAME);
1997 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1998 $this->error(_ERROR_NICKNAMEINUSE);
2000 if ($password != $repeatpassword)
2001 $this->error(_ERROR_PASSWORDMISMATCH);
2003 if ($password && (i18n::strlen($password) < 6))
2004 $this->error(_ERROR_PASSWORDTOOSHORT);
2009 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2011 $this->error($pwderror);
2016 if ( !NOTIFICATION::address_validation($email) )
2018 $this->error(_ERROR_BADMAILADDRESS);
2022 $this->error(_ERROR_REALNAMEMISSING);
2024 if ( ($locale != '') && (!in_array($locale, i18n::get_available_locale_list())) )
2025 $this->error(_ERROR_NOSUCHTRANSLATION);
2027 // check if there will remain at least one site member with both the logon and admin rights
2028 // (check occurs when taking away one of these rights from such a member)
2029 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
2030 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
2033 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
2034 if (sql_num_rows($r) < 2)
2035 $this->error(_ERROR_ATLEASTONEADMIN);
2038 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
2039 $mem->setDisplayName($name);
2041 $mem->setPassword($password);
2044 $oldEmail = $mem->getEmail();
2046 $mem->setRealName($realname);
2047 $mem->setEmail($email);
2049 $mem->setNotes($notes);
2050 $mem->setLocale($locale);
2053 // only allow super-admins to make changes to the admin status
2054 if ($member->isAdmin()) {
2055 $mem->setAdmin($admin);
2056 $mem->setCanLogin($canlogin);
2059 $autosave = postVar ('autosave');
2060 $mem->setAutosave($autosave);
2064 // store plugin options
2065 $aOptions = requestArray('plugoption');
2066 NucleusPlugin::apply_plugin_options($aOptions);
2067 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
2069 // if email changed, generate new password
2070 if ($oldEmail != $mem->getEmail())
2072 $mem->sendActivationLink('addresschange', $oldEmail);
2074 $mem->newCookieKey();
2076 // only log out if the member being edited is the current member.
2077 if ($member->getID() == $memberid)
2079 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2084 if ( ( $mem->getID() == $member->getID() )
2085 && ( $mem->getDisplayName() != $member->getDisplayName() )
2087 $mem->newCookieKey();
2089 $this->action_login(_MSG_LOGINAGAIN, 0);
2091 $this->action_overview(_MSG_SETTINGSCHANGED);
2096 * @todo document this
2098 function action_memberadd() {
2099 global $member, $manager;
2102 $member->isAdmin() or $this->disallow();
2104 if (postVar('password') != postVar('repeatpassword'))
2105 $this->error(_ERROR_PASSWORDMISMATCH);
2106 if (i18n::strlen(postVar('password')) < 6)
2107 $this->error(_ERROR_PASSWORDTOOSHORT);
2109 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2113 // fire PostRegister event
2114 $newmem = new MEMBER();
2115 $newmem->readFromName(postVar('name'));
2116 $manager->notify('PostRegister',array('member' => &$newmem));
2118 $this->action_usermanagement();
2122 * Account activation
2126 function action_activate() {
2128 $key = getVar('key');
2129 $this->_showActivationPage($key);
2133 * @todo document this
2135 function _showActivationPage($key, $message = '')
2139 // clean up old activation keys
2140 MEMBER::cleanupActivationTable();
2142 // get activation info
2143 $info = MEMBER::getActivationInfo($key);
2146 $this->error(_ERROR_ACTIVATE);
2148 $mem = MEMBER::createFromId($info->vmember);
2151 $this->error(_ERROR_ACTIVATE);
2155 $bNeedsPasswordChange = true;
2157 switch ($info->vtype)
2160 $title = _ACTIVATE_FORGOT_TITLE;
2161 $text = _ACTIVATE_FORGOT_TEXT;
2164 $title = _ACTIVATE_REGISTER_TITLE;
2165 $text = _ACTIVATE_REGISTER_TEXT;
2167 case 'addresschange':
2168 $title = _ACTIVATE_CHANGE_TITLE;
2169 $text = _ACTIVATE_CHANGE_TEXT;
2170 $bNeedsPasswordChange = false;
2171 MEMBER::activate($key);
2176 'memberName' => ENTITY::hsc($mem->getDisplayName())
2178 $title = TEMPLATE::fill($title, $aVars);
2179 $text = TEMPLATE::fill($text, $aVars);
2183 echo '<h2>' , $title, '</h2>';
2184 echo '<p>' , $text, '</p>';
2188 echo '<p class="error">',$message,'</p>';
2191 if ($bNeedsPasswordChange)
2194 <div><form action="index.php" method="post">
2196 <input type="hidden" name="action" value="activatesetpwd" />
2197 <?php $manager->addTicketHidden() ?>
2198 <input type="hidden" name="key" value="<?php echo ENTITY::hsc($key) ?>" />
2201 <td><?php echo _MEMBERS_PWD?></td>
2202 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2204 <td><?php echo _MEMBERS_REPPWD?></td>
2205 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2209 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2213 <td><?php echo _MEMBERS_SETPWD ?></td>
2214 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2229 * Account activation - set password part
2233 function action_activatesetpwd() {
2235 $key = postVar('key');
2237 // clean up old activation keys
2238 MEMBER::cleanupActivationTable();
2240 // get activation info
2241 $info = MEMBER::getActivationInfo($key);
2243 if (!$info || ($info->type == 'addresschange'))
2244 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2246 $mem = MEMBER::createFromId($info->vmember);
2249 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2251 $password = postVar('password');
2252 $repeatpassword = postVar('repeatpassword');
2254 if ($password != $repeatpassword)
2255 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2257 if ($password && (i18n::strlen($password) < 6))
2258 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2264 $manager->notify('PrePasswordSet',array('password' => $password, 'errormessage' => &$pwderror, 'valid' => &$pwdvalid));
2266 return $this->_showActivationPage($key,$pwderror);
2272 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2274 return $this->_showActivationPage($key, $error);
2278 $mem->setPassword($password);
2281 // do the activation
2282 MEMBER::activate($key);
2285 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2286 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2293 function action_manageteam() {
2294 global $member, $manager;
2296 $blogid = intRequestVar('blogid');
2299 $member->blogAdminRights($blogid) or $this->disallow();
2303 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2305 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2307 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2311 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2312 . ' FROM '.sql_table('member').', '.sql_table('team')
2313 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2315 $template['content'] = 'teamlist';
2316 $template['tabindex'] = 10;
2318 $manager->loadClass("ENCAPSULATE");
2319 $batch = new BATCH('team');
2320 $batch->showlist($query, 'table', $template);
2323 <h3><?php echo _TEAM_ADDNEW?></h3>
2325 <form method='post' action='index.php'><div>
2327 <input type='hidden' name='action' value='teamaddmember' />
2328 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2329 <?php $manager->addTicketHidden() ?>
2332 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2333 <td><?php // TODO: try to make it so only non-team-members are listed
2334 $query = 'SELECT mname as text, mnumber as value'
2335 . ' FROM '.sql_table('member');
2337 $template['name'] = 'memberid';
2338 $template['tabindex'] = 10000;
2339 showlist($query,'select',$template);
2342 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2343 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2345 <td><?php echo _TEAM_ADD?></td>
2346 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2355 * Add member to team
2357 function action_teamaddmember() {
2358 global $member, $manager;
2360 $memberid = intPostVar('memberid');
2361 $blogid = intPostVar('blogid');
2362 $admin = intPostVar('admin');
2365 $member->blogAdminRights($blogid) or $this->disallow();
2367 $blog =& $manager->getBlog($blogid);
2368 if (!$blog->addTeamMember($memberid, $admin))
2369 $this->error(_ERROR_ALREADYONTEAM);
2371 $this->action_manageteam();
2376 * @todo document this
2378 function action_teamdelete() {
2379 global $member, $manager;
2381 $memberid = intRequestVar('memberid');
2382 $blogid = intRequestVar('blogid');
2385 $member->blogAdminRights($blogid) or $this->disallow();
2387 $teammem = MEMBER::createFromID($memberid);
2388 $blog =& $manager->getBlog($blogid);
2392 <h2><?php echo _DELETE_CONFIRM?></h2>
2394 <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>
2398 <form method="post" action="index.php"><div>
2399 <input type="hidden" name="action" value="teamdeleteconfirm" />
2400 <?php $manager->addTicketHidden() ?>
2401 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2402 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2403 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2410 * @todo document this
2412 function action_teamdeleteconfirm() {
2415 $memberid = intRequestVar('memberid');
2416 $blogid = intRequestVar('blogid');
2418 $error = $this->deleteOneTeamMember($blogid, $memberid);
2420 $this->error($error);
2423 $this->action_manageteam();
2427 * @todo document this
2429 function deleteOneTeamMember($blogid, $memberid) {
2430 global $member, $manager;
2432 $blogid = intval($blogid);
2433 $memberid = intval($memberid);
2436 if (!$member->blogAdminRights($blogid))
2437 return _ERROR_DISALLOWED;
2439 // check if: - there remains at least one blog admin
2440 // - (there remains at least one team member)
2441 $tmem = MEMBER::createFromID($memberid);
2443 $manager->notify('PreDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2445 if ($tmem->isBlogAdmin($blogid)) {
2446 // check if there are more blog members left and at least one admin
2447 // (check for at least two admins before deletion)
2448 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2449 $r = sql_query($query);
2450 if (sql_num_rows($r) < 2)
2451 return _ERROR_ATLEASTONEBLOGADMIN;
2454 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2457 $manager->notify('PostDeleteTeamMember', array('member' => &$tmem, 'blogid' => $blogid));
2463 * @todo document this
2465 function action_teamchangeadmin() {
2468 $blogid = intRequestVar('blogid');
2469 $memberid = intRequestVar('memberid');
2472 $member->blogAdminRights($blogid) or $this->disallow();
2474 $mem = MEMBER::createFromID($memberid);
2476 // don't allow when there is only one admin at this moment
2477 if ($mem->isBlogAdmin($blogid)) {
2478 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2479 if (sql_num_rows($r) == 1)
2480 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2483 if ($mem->isBlogAdmin($blogid))
2488 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2491 // only show manageteam if member did not change its own admin privileges
2492 if ($member->isBlogAdmin($blogid))
2493 $this->action_manageteam();
2495 $this->action_overview(_MSG_ADMINCHANGED);
2499 * @todo document this
2501 function action_blogsettings() {
2502 global $member, $manager;
2504 $blogid = intRequestVar('blogid');
2507 $member->blogAdminRights($blogid) or $this->disallow();
2509 $blog =& $manager->getBlog($blogid);
2511 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2512 $this->pagehead($extrahead);
2514 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2516 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2518 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2520 <p><?php echo _EBLOG_CURRENT_TEAM_MEMBER; ?>
2522 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2523 $aMemberNames = array();
2524 while ($o = sql_fetch_object($res))
2525 array_push($aMemberNames, ENTITY::hsc($o->mname) . ' (' . ENTITY::hsc($o->mrealname). ')');
2526 echo implode(',', $aMemberNames);
2533 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2536 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2538 <form method="post" action="index.php"><div>
2540 <input type="hidden" name="action" value="blogsettingsupdate" />
2541 <?php $manager->addTicketHidden() ?>
2542 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2544 <td><?php echo _EBLOG_NAME?></td>
2545 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getName()) ?>" /></td>
2547 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2548 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2550 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo ENTITY::hsc($blog->getShortName()) ?>" /></td>
2552 <td><?php echo _EBLOG_DESC?></td>
2553 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo ENTITY::hsc($blog->getDescription()) ?>" /></td>
2555 <td><?php echo _EBLOG_URL?></td>
2556 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo ENTITY::hsc($blog->getURL()) ?>" /></td>
2558 <td><?php echo _EBLOG_DEFSKIN?>
2559 <?php help('blogdefaultskin'); ?>
2563 $query = 'SELECT sdname as text, sdnumber as value'
2564 . ' FROM '.sql_table('skin_desc');
2565 $template['name'] = 'defskin';
2566 $template['selected'] = $blog->getDefaultSkin();
2567 $template['tabindex'] = 50;
2568 showlist($query,'select',$template);
2573 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2575 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2577 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2579 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2581 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2583 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2585 <td><?php echo _EBLOG_ANONYMOUS?>
2587 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2589 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2591 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2593 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2594 <td><input name="notify" tabindex="80" maxlength="128" size="40" value="<?php echo ENTITY::hsc($blog->getNotifyAddress()); ?>" /></td>
2596 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2598 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2599 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2600 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2602 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2603 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2604 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2606 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2607 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2608 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2611 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2612 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo ENTITY::hsc($blog->getMaxComments()); ?>" /></td>
2614 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2615 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo ENTITY::hsc($blog->getUpdateFile()) ?>" /></td>
2617 <td><?php echo _EBLOG_DEFCAT?></td>
2620 $query = 'SELECT cname as text, catid as value'
2621 . ' FROM '.sql_table('category')
2622 . ' WHERE cblog=' . $blog->getID();
2623 $template['name'] = 'defcat';
2624 $template['selected'] = $blog->getDefaultCategory();
2625 $template['tabindex'] = 110;
2626 showlist($query,'select',$template);
2630 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2631 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
2632 <br /><?php echo _EBLOG_BTIME?> <b><?php echo i18n::strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2634 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo ENTITY::hsc($blog->getTimeOffset()); ?>" /></td>
2636 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2637 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2641 $this->_insertPluginOptions('blog',$blogid);
2644 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2646 <td><?php echo _EBLOG_CHANGE?></td>
2647 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2652 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2656 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2657 $template['content'] = 'categorylist';
2658 $template['tabindex'] = 200;
2660 $manager->loadClass("ENCAPSULATE");
2661 $batch = new BATCH('category');
2662 $batch->showlist($query,'table',$template);
2667 <form action="index.php" method="post"><div>
2668 <input name="action" value="categorynew" type="hidden" />
2669 <?php $manager->addTicketHidden() ?>
2670 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2673 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2675 <td><?php echo _EBLOG_CAT_NAME?></td>
2676 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2678 <td><?php echo _EBLOG_CAT_DESC?></td>
2679 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2681 <td><?php echo _EBLOG_CAT_CREATE?></td>
2682 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2689 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2692 'BlogSettingsFormExtras',
2702 * @todo document this
2704 function action_categorynew() {
2705 global $member, $manager;
2707 $blogid = intRequestVar('blogid');
2709 $member->blogAdminRights($blogid) or $this->disallow();
2711 $cname = postVar('cname');
2712 $cdesc = postVar('cdesc');
2714 if (!isValidCategoryName($cname))
2715 $this->error(_ERROR_BADCATEGORYNAME);
2717 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid);
2718 $res = sql_query($query);
2719 if (sql_num_rows($res) > 0)
2720 $this->error(_ERROR_DUPCATEGORYNAME);
2722 $blog =& $manager->getBlog($blogid);
2723 $newCatID = $blog->createNewCategory($cname, $cdesc);
2725 $this->action_blogsettings();
2729 * @todo document this
2731 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2732 global $member, $manager;
2735 $blogid = intGetVar('blogid');
2737 $blogid = intval($blogid);
2739 $catid = intGetVar('catid');
2741 $catid = intval($catid);
2743 $member->blogAdminRights($blogid) or $this->disallow();
2745 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2746 $obj = sql_fetch_object($res);
2748 $cname = $obj->cname;
2749 $cdesc = $obj->cdesc;
2751 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2752 $this->pagehead($extrahead);
2754 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2757 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo ENTITY::hsc($cname)?>'</h2>
2758 <form method='post' action='index.php'><div>
2759 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2760 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2761 <input name="desturl" type="hidden" value="<?php echo ENTITY::hsc($desturl) ?>" />
2762 <input name="action" type="hidden" value="categoryupdate" />
2763 <?php $manager->addTicketHidden(); ?>
2766 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2768 <td><?php echo _EBLOG_CAT_NAME?></td>
2769 <td><input type="text" name="cname" value="<?php echo ENTITY::hsc($cname)?>" size="40" maxlength="40" /></td>
2771 <td><?php echo _EBLOG_CAT_DESC?></td>
2772 <td><input type="text" name="cdesc" value="<?php echo ENTITY::hsc($cdesc)?>" size="40" maxlength="200" /></td>
2775 // insert plugin options
2776 $this->_insertPluginOptions('category',$catid);
2779 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2781 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2782 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2791 * @todo document this
2793 function action_categoryupdate() {
2794 global $member, $manager;
2796 $blogid = intPostVar('blogid');
2797 $catid = intPostVar('catid');
2798 $cname = postVar('cname');
2799 $cdesc = postVar('cdesc');
2800 $desturl = postVar('desturl');
2802 $member->blogAdminRights($blogid) or $this->disallow();
2804 if (!isValidCategoryName($cname))
2805 $this->error(_ERROR_BADCATEGORYNAME);
2807 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . sql_real_escape_string($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2808 $res = sql_query($query);
2809 if (sql_num_rows($res) > 0)
2810 $this->error(_ERROR_DUPCATEGORYNAME);
2812 $query = 'UPDATE '.sql_table('category').' SET'
2813 . " cname='" . sql_real_escape_string($cname) . "',"
2814 . " cdesc='" . sql_real_escape_string($cdesc) . "'"
2815 . " WHERE catid=" . $catid;
2819 // store plugin options
2820 $aOptions = requestArray('plugoption');
2821 NucleusPlugin::apply_plugin_options($aOptions);
2822 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2829 $this->action_blogsettings();
2834 * @todo document this
2836 function action_categorydelete() {
2837 global $member, $manager;
2839 $blogid = intRequestVar('blogid');
2840 $catid = intRequestVar('catid');
2842 $member->blogAdminRights($blogid) or $this->disallow();
2844 $blog =& $manager->getBlog($blogid);
2846 // check if the category is valid
2847 if (!$blog->isValidCategory($catid))
2848 $this->error(_ERROR_NOSUCHCATEGORY);
2850 // don't allow deletion of default category
2851 if ($blog->getDefaultCategory() == $catid)
2852 $this->error(_ERROR_DELETEDEFCATEGORY);
2854 // check if catid is the only category left for blogid
2855 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2856 $res = sql_query($query);
2857 if (sql_num_rows($res) == 1)
2858 $this->error(_ERROR_DELETELASTCATEGORY);
2863 <h2><?php echo _DELETE_CONFIRM?></h2>
2866 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo ENTITY::hsc($blog->getCategoryName($catid))?></b>
2869 <form method="post" action="index.php"><div>
2870 <input type="hidden" name="action" value="categorydeleteconfirm" />
2871 <?php $manager->addTicketHidden() ?>
2872 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2873 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2874 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2881 * @todo document this
2883 function action_categorydeleteconfirm() {
2884 global $member, $manager;
2886 $blogid = intRequestVar('blogid');
2887 $catid = intRequestVar('catid');
2889 $member->blogAdminRights($blogid) or $this->disallow();
2891 $error = $this->deleteOneCategory($catid);
2893 $this->error($error);
2895 $this->action_blogsettings();
2899 * ADMIN::deleteOneCategory()
2900 * Delete a category by its id
2902 * @param String $catid category id for deleting
2905 function deleteOneCategory($catid)
2907 global $manager, $member;
2909 $catid = intval($catid);
2910 $blogid = getBlogIDFromCatID($catid);
2912 if ( !$member->blogAdminRights($blogid) )
2914 return ERROR_DISALLOWED;
2918 $blog =& $manager->getBlog($blogid);
2920 // check if the category is valid
2921 if ( !$blog || !$blog->isValidCategory($catid) )
2923 return _ERROR_NOSUCHCATEGORY;
2926 $destcatid = $blog->getDefaultCategory();
2928 // don't allow deletion of default category
2929 if ( $blog->getDefaultCategory() == $catid )
2931 return _ERROR_DELETEDEFCATEGORY;
2934 // check if catid is the only category left for blogid
2935 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2936 $res = sql_query($query);
2937 if ( sql_num_rows($res) == 1 )
2939 return _ERROR_DELETELASTCATEGORY;
2942 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2944 // change category for all items to the default category
2945 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2948 // delete all associated plugin options
2949 NucleusPlugin::delete_option_values('category', $catid);
2952 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2955 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2960 * ADMIN::action_blogsettingsupdate
2961 * Updating blog settings
2966 function action_blogsettingsupdate()
2968 global $member, $manager;
2970 $blogid = intRequestVar('blogid');
2972 $member->blogAdminRights($blogid) or $this->disallow();
2974 $blog =& $manager->getBlog($blogid);
2976 $notify_address = trim(postVar('notify'));
2977 $shortname = trim(postVar('shortname'));
2978 $updatefile = trim(postVar('update'));
2980 $notifyComment = intPostVar('notifyComment');
2981 $notifyVote = intPostVar('notifyVote');
2982 $notifyNewItem = intPostVar('notifyNewItem');
2984 if ( $notifyComment == 0 )
2988 if ( $notifyVote == 0 )
2992 if ( $notifyNewItem == 0 )
2996 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
2998 if ( $notify_address && !NOTIFICATION::address_validation($notify_address) )
3000 $this->error(_ERROR_BADNOTIFY);
3003 if ( !isValidShortName($shortname) )
3005 $this->error(_ERROR_BADSHORTBLOGNAME);
3008 if ( ($blog->getShortName() != $shortname) && $manager->existsBlog($shortname) )
3010 $this->error(_ERROR_DUPSHORTBLOGNAME);
3012 // check if update file is writable
3013 if ( $updatefile && !is_writeable($updatefile) )
3015 $this->error(_ERROR_UPDATEFILE);
3018 $blog->setName(trim(postVar('name')));
3019 $blog->setShortName($shortname);
3020 $blog->setNotifyAddress($notify_address);
3021 $blog->setNotifyType($notifyType);
3022 $blog->setMaxComments(postVar('maxcomments'));
3023 $blog->setCommentsEnabled(postVar('comments'));
3024 $blog->setTimeOffset(postVar('timeoffset'));
3025 $blog->setUpdateFile($updatefile);
3026 $blog->setURL(trim(postVar('url')));
3027 $blog->setDefaultSkin(intPostVar('defskin'));
3028 $blog->setDescription(trim(postVar('desc')));
3029 $blog->setPublic(postVar('public'));
3030 $blog->setConvertBreaks(intPostVar('convertbreaks'));
3031 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
3032 $blog->setDefaultCategory(intPostVar('defcat'));
3033 $blog->setSearchable(intPostVar('searchable'));
3034 $blog->setEmailRequired(intPostVar('reqemail'));
3035 $blog->writeSettings();
3037 // store plugin options
3038 $aOptions = requestArray('plugoption');
3039 NucleusPlugin::apply_plugin_options($aOptions);
3040 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3042 $this->action_overview(_MSG_SETTINGSCHANGED);
3047 * @todo document this
3049 function action_deleteblog() {
3050 global $member, $CONF, $manager;
3052 $blogid = intRequestVar('blogid');
3054 $member->blogAdminRights($blogid) or $this->disallow();
3056 // check if blog is default blog
3057 if ($CONF['DefaultBlog'] == $blogid)
3058 $this->error(_ERROR_DELDEFBLOG);
3060 $blog =& $manager->getBlog($blogid);
3064 <h2><?php echo _DELETE_CONFIRM?></h2>
3066 <p><?php echo _WARNINGTXT_BLOGDEL?>
3070 <?php echo _CONFIRMTXT_BLOG?><b><?php echo ENTITY::hsc($blog->getName())?></b>
3073 <form method="post" action="index.php"><div>
3074 <input type="hidden" name="action" value="deleteblogconfirm" />
3075 <?php $manager->addTicketHidden() ?>
3076 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3077 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3084 * ADMIN::action_deleteblogconfirm()
3090 function action_deleteblogconfirm()
3092 global $member, $CONF, $manager;
3094 $blogid = intRequestVar('blogid');
3095 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3096 $member->blogAdminRights($blogid) or $this->disallow();
3098 // check if blog is default blog
3099 if ( $CONF['DefaultBlog'] == $blogid )
3101 $this->error(_ERROR_DELDEFBLOG);
3104 // delete all comments
3105 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3109 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3112 // delete all team members
3113 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3117 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3120 // delete all categories
3121 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3124 // delete all associated plugin options
3125 NucleusPlugin::delete_option_values('blog', $blogid);
3127 // delete the blog itself
3128 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3131 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3133 $this->action_overview(_DELETED_BLOG);
3138 * @todo document this
3140 function action_memberdelete() {
3141 global $member, $manager;
3143 $memberid = intRequestVar('memberid');
3145 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3147 $mem = MEMBER::createFromID($memberid);
3151 <h2><?php echo _DELETE_CONFIRM?></h2>
3153 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo ENTITY::hsc($mem->getDisplayName()) ?></b>
3157 <?php echo _WARNINGTXT_NOTDELMEDIAFILES ?>
3160 <form method="post" action="index.php"><div>
3161 <input type="hidden" name="action" value="memberdeleteconfirm" />
3162 <?php $manager->addTicketHidden() ?>
3163 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3164 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3171 * @todo document this
3173 function action_memberdeleteconfirm() {
3176 $memberid = intRequestVar('memberid');
3178 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3180 $error = $this->deleteOneMember($memberid);
3182 $this->error($error);
3184 if ($member->isAdmin())
3185 $this->action_usermanagement();
3187 $this->action_overview(_DELETED_MEMBER);
3191 * ADMIN::deleteOneMember()
3192 * Delete a member by id
3195 * @params Integer $memberid member id
3196 * @return String null string or error messages
3198 function deleteOneMember($memberid)
3202 $memberid = intval($memberid);
3203 $mem = MEMBER::createFromID($memberid);
3205 if ( !$mem->canBeDeleted() )
3207 return _ERROR_DELETEMEMBER;
3210 $manager->notify('PreDeleteMember', array('member' => &$mem));
3212 /* unlink comments from memberid */
3215 $query = "UPDATE %s SET cmember=0, cuser='%s' WHERE cmember=%d";
3216 $query = sprintf($query, sql_table('comment'), sql_real_escape_string($mem->getDisplayName()), $memberid);
3220 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3223 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3226 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3229 // delete all associated plugin options
3230 NucleusPlugin::delete_option_values('member', $memberid);
3232 $manager->notify('PostDeleteMember', array('member' => &$mem));
3238 * @todo document this
3240 function action_createnewlog() {
3241 global $member, $CONF, $manager;
3243 // Only Super-Admins can do this
3244 $member->isAdmin() or $this->disallow();
3248 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3250 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3252 <h3><?php echo _ADMIN_NOTABILIA ?></h3>
3254 <p><?php echo _ADMIN_PLEASE_READ ?></p>
3256 <p><?php echo _ADMIN_HOW_TO_ACCESS ?></p>
3259 <li><?php echo _ADMIN_SIMPLE_WAY ?></li>
3260 <li><?php echo _ADMIN_ADVANCED_WAY ?></li>
3263 <h3><?php echo _ADMIN_HOW_TO_CREATE ?></h3>
3266 <?php echo _EBLOG_CREATE_TEXT?>
3269 <form method="post" action="index.php"><div>
3271 <input type="hidden" name="action" value="addnewlog" />
3272 <?php $manager->addTicketHidden() ?>
3276 <td><?php echo _EBLOG_NAME?></td>
3277 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3279 <td><?php echo _EBLOG_SHORTNAME?>
3280 <?php help('shortblogname'); ?>
3282 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3284 <td><?php echo _EBLOG_DESC?></td>
3285 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3287 <td><?php echo _EBLOG_DEFSKIN?>
3288 <?php help('blogdefaultskin'); ?>
3292 $query = 'SELECT sdname as text, sdnumber as value'
3293 . ' FROM '.sql_table('skin_desc');
3294 $template['name'] = 'defskin';
3295 $template['tabindex'] = 50;
3296 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3297 showlist($query,'select',$template);
3301 <td><?php echo _EBLOG_OFFSET?>
3302 <?php help('blogtimeoffset'); ?>
3303 <br /><?php echo _EBLOG_STIME?> <b><?php echo i18n::strftime("%H:%M",time()); ?></b>
3305 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3307 <td><?php echo _EBLOG_ADMIN?>
3308 <?php help('teamadmin'); ?>
3310 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3312 <td><?php echo _EBLOG_CREATE?></td>
3313 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3322 * @todo document this
3324 function action_addnewlog() {
3325 global $member, $manager, $CONF;
3327 // Only Super-Admins can do this
3328 $member->isAdmin() or $this->disallow();
3330 $bname = trim(postVar('name'));
3331 $bshortname = trim(postVar('shortname'));
3332 $btimeoffset = postVar('timeoffset');
3333 $bdesc = trim(postVar('desc'));
3334 $bdefskin = postVar('defskin');
3336 if (!isValidShortName($bshortname))
3337 $this->error(_ERROR_BADSHORTBLOGNAME);
3339 if ($manager->existsBlog($bshortname))
3340 $this->error(_ERROR_DUPSHORTBLOGNAME);
3346 'shortname' => &$bshortname,
3347 'timeoffset' => &$btimeoffset,
3348 'description' => &$bdesc,
3349 'defaultskin' => &$bdefskin
3354 // add slashes for sql queries
3355 $bname = sql_real_escape_string($bname);
3356 $bshortname = sql_real_escape_string($bshortname);
3357 $btimeoffset = sql_real_escape_string($btimeoffset);
3358 $bdesc = sql_real_escape_string($bdesc);
3359 $bdefskin = sql_real_escape_string($bdefskin);
3362 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3364 $blogid = sql_insert_id();
3365 $blog =& $manager->getBlog($blogid);
3367 // create new category
3368 $catdefname = (defined('_EBLOGDEFAULTCATEGORY_NAME') ? _EBLOGDEFAULTCATEGORY_NAME : 'General');
3369 $catdefdesc = (defined('_EBLOGDEFAULTCATEGORY_DESC') ? _EBLOGDEFAULTCATEGORY_DESC : 'Items that do not fit in other categories');
3370 $sql = 'INSERT INTO %s (cblog, cname, cdesc) VALUES (%d, "%s", "%s")';
3371 sql_query(sprintf($sql, sql_table('category'), $blogid, $catdefname, $catdefdesc));
3372 // sql_query(sprintf($sql, sql_table('category'), $blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC));
3373 // sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, _EBLOGDEFAULTCATEGORY_NAME, _EBLOGDEFAULTCATEGORY_DESC)");
3374 $catid = sql_insert_id();
3376 // set as default category
3377 $blog->setDefaultCategory($catid);
3378 $blog->writeSettings();
3380 // create team member
3381 $memberid = $member->getID();
3382 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3385 $itemdeftitle = (defined('_EBLOG_FIRSTITEM_TITLE') ? _EBLOG_FIRSTITEM_TITLE : 'First Item');
3386 $itemdefbody = (defined('_EBLOG_FIRSTITEM_BODY') ? _EBLOG_FIRSTITEM_BODY : 'This is the first item in your weblog. Feel free to delete it.');
3388 $blog->additem($blog->getDefaultCategory(),$itemdeftitle,$itemdefbody,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3389 //$blog->additem($blog->getDefaultCategory(),_EBLOG_FIRSTITEM_TITLE,_EBLOG_FIRSTITEM_BODY,'',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3404 'name' => _EBLOGDEFAULTCATEGORY_NAME,
3405 'description' => _EBLOGDEFAULTCATEGORY_DESC,
3412 <h2><?php echo _BLOGCREATED_TITLE ?></h2>
3414 <p><?php echo sprintf(_BLOGCREATED_ADDEDTXT, ENTITY::hsc($bname)) ?></p>
3417 <li><a href="#index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEWAY, ENTITY::hsc($bshortname)) ?></a></li>
3418 <li><a href="#skins"><?php echo _BLOGCREATED_ADVANCEDWAY ?></a></li>
3421 <h3><a id="index_php"><?php echo sprintf(_BLOGCREATED_SIMPLEDESC1, ENTITY::hsc($bshortname)) ?></a></h3>
3423 <p><?php echo sprintf(_BLOGCREATED_SIMPLEDESC2, ENTITY::hsc($bshortname)) ?></p>
3426 $CONF['Self'] = '<b><?php echo ENTITY::hsc($bshortname)?>.php</b>';
3428 include('<i>./config.php</i>');
3430 selectBlog('<b><?php echo ENTITY::hsc($bshortname)?></b>');
3435 <p><?php echo _BLOGCREATED_SIMPLEDESC3 ?></p>
3437 <p><?php echo _BLOGCREATED_SIMPLEDESC4 ?></p>
3439 <form action="index.php" method="post"><div>
3440 <input type="hidden" name="action" value="addnewlog2" />
3441 <?php $manager->addTicketHidden() ?>
3442 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3444 <td><?php echo _EBLOG_URL?></td>
3445 <td><input name="url" maxlength="100" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3447 <td><?php echo _EBLOG_CREATE?></td>
3448 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3452 <h3><a id="skins"><?php echo _BLOGCREATED_ADVANCEDWAY2 ?></a></h3>
3454 <p><?php echo _BLOGCREATED_ADVANCEDWAY3 ?></p>
3456 <form action="index.php" method="post"><div>
3457 <input type="hidden" name="action" value="addnewlog2" />
3458 <?php $manager->addTicketHidden() ?>
3459 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3461 <td><?php echo _EBLOG_URL?></td>
3462 <td><input name="url" maxlength="100" size="40" /></td>
3464 <td><?php echo _EBLOG_CREATE?></td>
3465 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3469 <?php $this->pagefoot();
3474 * @todo document this
3476 function action_addnewlog2() {
3477 global $member, $manager;
3479 $member->blogAdminRights($blogid) or $this->disallow();
3481 $burl = requestVar('url');
3482 $blogid = intRequestVar('blogid');
3484 $blog =& $manager->getBlog($blogid);
3485 $blog->setURL(trim($burl));
3486 $blog->writeSettings();
3488 $this->action_overview(_MSG_NEWBLOG);
3492 * @todo document this
3494 function action_skinieoverview() {
3495 global $member, $DIR_LIBS, $manager;
3497 $member->isAdmin() or $this->disallow();
3499 // load skinie class
3500 include_once($DIR_LIBS . 'skinie.php');
3504 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3507 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3509 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3510 <?php global $DIR_SKINS;
3512 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3514 if (sizeof($candidates) > 0) {
3516 <form method="post" action="index.php"><div>
3517 <input type="hidden" name="action" value="skinieimport" />
3518 <?php $manager->addTicketHidden() ?>
3519 <input type="hidden" name="mode" value="file" />
3520 <select name="skinfile" id="skinie_import_local">
3521 <?php foreach ($candidates as $skinname => $skinfile) {
3522 $html = ENTITY::hsc($skinfile);
3523 echo '<option value="',$html,'">',$skinname,'</option>';
3527 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3530 echo _SKINIE_NOCANDIDATES;
3535 <p><em><?php echo _OR?></em></p>
3537 <form method="post" action="index.php"><p>
3538 <?php $manager->addTicketHidden() ?>
3539 <input type="hidden" name="action" value="skinieimport" />
3540 <input type="hidden" name="mode" value="url" />
3541 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3542 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3543 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3547 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3548 <form method="post" action="index.php"><div>
3549 <input type="hidden" name="action" value="skinieexport" />
3550 <?php $manager->addTicketHidden() ?>
3552 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3555 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3557 <?php // show list of skins
3558 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3559 while ($skinObj = sql_fetch_object($res)) {
3560 $id = 'skinexp' . $skinObj->sdnumber;
3561 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3562 echo '<label for="',$id,'">',ENTITY::hsc($skinObj->sdname),'</label></td>';
3563 echo '<td>',ENTITY::hsc($skinObj->sddesc),'</td>';
3567 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3569 // show list of templates
3570 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3571 while ($templateObj = sql_fetch_object($res)) {
3572 $id = 'templateexp' . $templateObj->tdnumber;
3573 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3574 echo '<label for="',$id,'">',ENTITY::hsc($templateObj->tdname),'</label></td>';
3575 echo '<td>',ENTITY::hsc($templateObj->tddesc),'</td>';
3580 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3582 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3584 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3586 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3596 * @todo document this
3598 function action_skinieimport() {
3599 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3601 $member->isAdmin() or $this->disallow();
3603 // load skinie class
3604 include_once($DIR_LIBS . 'skinie.php');
3606 $skinFileRaw= postVar('skinfile');
3607 $mode = postVar('mode');
3609 $importer = new SKINIMPORT();
3611 // get full filename
3612 if ($mode == 'file')
3614 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3616 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3617 if (!file_exists($skinFile))
3618 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3620 $skinFile = $skinFileRaw;
3623 // read only metadata
3624 $error = $importer->readFile($skinFile, 1);
3627 $skinNameClashes = $importer->checkSkinNameClashes();
3628 $templateNameClashes = $importer->checkTemplateNameClashes();
3629 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3631 if ($error) $this->error($error);
3635 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3637 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3640 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3641 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3642 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3644 if ($hasNameClashes)
3647 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3648 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3650 } // if (hasNameClashes)
3654 <form method="post" action="index.php"><div>
3655 <input type="hidden" name="action" value="skiniedoimport" />
3656 <?php $manager->addTicketHidden() ?>
3657 <input type="hidden" name="skinfile" value="<?php echo ENTITY::hsc(postVar('skinfile'))?>" />
3658 <input type="hidden" name="mode" value="<?php echo ENTITY::hsc($mode)?>" />
3659 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3661 if ($hasNameClashes)
3665 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3667 } // if (hasNameClashes)
3677 * @todo document this
3679 function action_skiniedoimport() {
3680 global $member, $DIR_LIBS, $DIR_SKINS;
3682 $member->isAdmin() or $this->disallow();
3684 // load skinie class
3685 include_once($DIR_LIBS . 'skinie.php');
3687 $skinFileRaw= postVar('skinfile');
3688 $mode = postVar('mode');
3690 $allowOverwrite = intPostVar('overwrite');
3692 // get full filename
3693 if ($mode == 'file')
3695 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3697 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3698 if (!file_exists($skinFile))
3699 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3702 $skinFile = $skinFileRaw;
3705 $importer = new SKINIMPORT();
3707 $error = $importer->readFile($skinFile);
3710 $this->error($error);
3712 $error = $importer->writeToDatabase($allowOverwrite);
3715 $this->error($error);
3719 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3721 <h2><?php echo _SKINIE_DONE?></h2>
3724 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo ENTITY::hsc($importer->getInfo())?></p></li>
3725 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3726 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3729 <?php $this->pagefoot();
3734 * @todo document this
3736 function action_skinieexport() {
3737 global $member, $DIR_LIBS;
3739 $member->isAdmin() or $this->disallow();
3741 // load skinie class
3742 include_once($DIR_LIBS . 'skinie.php');
3744 $aSkins = requestIntArray('skin');
3745 $aTemplates = requestIntArray('template');
3747 if (!is_array($aTemplates)) $aTemplates = array();
3748 if (!is_array($aSkins)) $aSkins = array();
3750 $skinList = array_keys($aSkins);
3751 $templateList = array_keys($aTemplates);
3753 $info = postVar('info');
3755 $exporter = new SKINEXPORT();
3756 foreach ($skinList as $skinId) {
3757 $exporter->addSkin($skinId);
3759 foreach ($templateList as $templateId) {
3760 $exporter->addTemplate($templateId);
3762 $exporter->setInfo($info);
3764 $exporter->export();
3768 * @todo document this
3770 function action_templateoverview() {
3771 global $member, $manager;
3773 $member->isAdmin() or $this->disallow();
3777 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3779 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3780 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3782 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3783 $template['content'] = 'templatelist';
3784 $template['tabindex'] = 10;
3785 showlist($query,'table',$template);
3787 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3790 <form method="post" action="index.php"><div>
3792 <input name="action" value="templatenew" type="hidden" />
3793 <?php $manager->addTicketHidden() ?>
3795 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3796 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3798 <td><?php echo _TEMPLATE_DESC?></td>
3799 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3801 <td><?php echo _TEMPLATE_CREATE?></td>
3802 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3812 * @todo document this
3814 function action_templateedit($msg = '') {
3815 global $member, $manager;
3817 $templateid = intRequestVar('templateid');
3819 $member->isAdmin() or $this->disallow();
3821 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3822 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.sql_real_escape_string(_EDITTEMPLATE_EMPTY).'");</script>';
3824 $this->pagehead($extrahead);
3826 $templatename = TEMPLATE::getNameFromId($templateid);
3827 $templatedescription = TEMPLATE::getDesc($templateid);
3828 $template =& $manager->getTemplate($templatename);
3832 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3835 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo ENTITY::hsc($templatename); ?>'</h2>
3837 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3840 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3842 <form method="post" action="index.php">
3845 <input type="hidden" name="action" value="templateupdate" />
3846 <?php $manager->addTicketHidden() ?>
3847 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3850 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3852 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3853 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo ENTITY::hsc($templatename) ?>" /></td>
3855 <td><?php echo _TEMPLATE_DESC?></td>
3856 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo ENTITY::hsc($templatedescription) ?>" /></td>
3858 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3860 <td><?php echo _TEMPLATE_UPDATE?></td>
3862 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3863 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3866 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3867 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3868 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3869 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3870 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3871 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3872 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3875 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3876 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3877 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3878 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3879 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3880 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3881 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3882 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3885 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3887 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3890 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3891 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3894 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3895 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3896 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3897 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3900 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3901 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3902 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3903 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3906 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3907 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 190);
3908 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 200);
3909 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 210);
3912 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3913 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 220);
3914 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 230);
3915 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 240);
3916 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 250);
3917 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 260);
3920 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3921 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 270);
3922 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 280);
3923 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 290);
3926 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3927 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',300);
3928 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',310);
3931 <th colspan="2"><?php echo _TEMPLATE_PLUGIN_FIELDS?></th>
3934 $pluginfields = array();
3935 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
3937 foreach ($pluginfields as $pfkey=>$pfvalue) {
3939 echo '<th colspan="2">' . ENTITY::hen($pfkey) . "</th>\n";
3940 foreach ($pfvalue as $pffield=>$pfdesc) {
3941 $this->_templateEditRow($template, $pfdesc, $pffield, '',++$tab,0);
3946 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3948 <td><?php echo _TEMPLATE_UPDATE?></td>
3950 <input type="submit" tabindex="800" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3951 <input type="reset" tabindex="810" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3962 * @todo document this
3964 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3966 if (!isset($template[$name])) $template[$name] = '';
3969 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3970 <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>
3975 * @todo document this
3977 function action_templateupdate() {
3978 global $member,$manager;
3980 $templateid = intRequestVar('templateid');
3982 $member->isAdmin() or $this->disallow();
3984 $name = postVar('tname');
3985 $desc = postVar('tdesc');
3987 if (!isValidTemplateName($name))
3988 $this->error(_ERROR_BADTEMPLATENAME);
3990 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
3991 $this->error(_ERROR_DUPTEMPLATENAME);
3994 $name = sql_real_escape_string($name);
3995 $desc = sql_real_escape_string($desc);
3997 // 1. Remove all template parts
3998 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
4001 // 2. Update description
4002 $query = 'UPDATE '.sql_table('template_desc').' SET'
4003 . " tdname='" . $name . "',"
4004 . " tddesc='" . $desc . "'"
4005 . " WHERE tdnumber=" . $templateid;
4008 // 3. Add non-empty template parts
4009 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
4010 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
4011 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
4012 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
4013 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
4014 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
4015 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
4016 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
4017 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
4018 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
4019 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
4020 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
4021 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
4022 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
4023 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
4024 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
4025 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
4026 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
4027 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
4028 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
4029 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
4030 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
4031 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
4032 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
4033 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
4034 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
4035 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
4036 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
4037 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
4038 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
4039 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
4040 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
4041 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
4042 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
4044 $pluginfields = array();
4045 $manager->notify('TemplateExtraFields',array('fields'=>&$pluginfields));
4046 foreach ($pluginfields as $pfkey=>$pfvalue) {
4047 foreach ($pfvalue as $pffield=>$pfdesc) {
4048 $this->addToTemplate($templateid, $pffield, postVar($pffield));
4052 // jump back to template edit
4053 $this->action_templateedit(_TEMPLATE_UPDATED);
4058 * ADMIN::addToTemplate()
4060 * @param Integer $id ID for template
4061 * @param String $partname parts name
4062 * @param String $content template contents
4063 * @return Integer record index
4066 function addToTemplate($id, $partname, $content)
4068 // don't add empty parts:
4069 if ( !trim($content) )
4074 $partname = sql_real_escape_string($partname);
4075 $content = sql_real_escape_string($content);
4077 $query = "INSERT INTO %s (tdesc, tpartname, tcontent) VALUES (%d, '%s', '%s')";
4078 $query = sprintf($query, sql_table('template'), (integer) $id, $partname, $content);
4079 sql_query($query) or exit(_ADMIN_SQLDIE_QUERYERROR . sql_error());
4080 return sql_insert_id();
4084 * @todo document this
4086 function action_templatedelete() {
4087 global $member, $manager;
4089 $member->isAdmin() or $this->disallow();
4091 $templateid = intRequestVar('templateid');
4092 // TODO: check if template can be deleted
4096 $name = TEMPLATE::getNameFromId($templateid);
4097 $desc = TEMPLATE::getDesc($templateid);
4100 <h2><?php echo _DELETE_CONFIRM?></h2>
4103 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo ENTITY::hsc($name)?></b> (<?php echo ENTITY::hsc($desc) ?>)
4106 <form method="post" action="index.php"><div>
4107 <input type="hidden" name="action" value="templatedeleteconfirm" />
4108 <?php $manager->addTicketHidden() ?>
4109 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4110 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4117 * @todo document this
4119 function action_templatedeleteconfirm() {
4120 global $member, $manager;
4122 $templateid = intRequestVar('templateid');
4124 $member->isAdmin() or $this->disallow();
4126 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4128 // 1. delete description
4129 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4132 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4134 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4136 $this->action_templateoverview();
4140 * @todo document this
4142 function action_templatenew() {
4145 $member->isAdmin() or $this->disallow();
4147 $name = postVar('name');
4148 $desc = postVar('desc');
4150 if (!isValidTemplateName($name))
4151 $this->error(_ERROR_BADTEMPLATENAME);
4153 if (TEMPLATE::exists($name))
4154 $this->error(_ERROR_DUPTEMPLATENAME);
4156 $newTemplateId = TEMPLATE::createNew($name, $desc);
4158 $this->action_templateoverview();
4162 * @todo document this
4164 function action_templateclone() {
4167 $templateid = intRequestVar('templateid');
4169 $member->isAdmin() or $this->disallow();
4171 // 1. read old template
4172 $name = TEMPLATE::getNameFromId($templateid);
4173 $desc = TEMPLATE::getDesc($templateid);
4175 // 2. create desc thing
4176 $name = "cloned" . $name;
4178 // if a template with that name already exists:
4179 if (TEMPLATE::exists($name)) {
4181 while (TEMPLATE::exists($name . $i))
4186 $newid = TEMPLATE::createNew($name, $desc);
4189 // go through parts of old template and add them to the new one
4190 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4191 while ($o = sql_fetch_object($res)) {
4192 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4195 $this->action_templateoverview();
4199 * @todo document this
4201 function action_skinoverview() {
4202 global $member, $manager;
4204 $member->isAdmin() or $this->disallow();
4208 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4210 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4212 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4214 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4215 $template['content'] = 'skinlist';
4216 $template['tabindex'] = 10;
4217 showlist($query,'table',$template);
4219 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4222 <form method="post" action="index.php">
4225 <input name="action" value="skinnew" type="hidden" />
4226 <?php $manager->addTicketHidden() ?>
4228 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4229 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4231 <td><?php echo _SKIN_DESC?></td>
4232 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4234 <td><?php echo _SKIN_CREATE?></td>
4235 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4246 * @todo document this
4248 function action_skinnew() {
4251 $member->isAdmin() or $this->disallow();
4253 $name = trim(postVar('name'));
4254 $desc = trim(postVar('desc'));
4256 if (!isValidSkinName($name))
4257 $this->error(_ERROR_BADSKINNAME);
4259 if (SKIN::exists($name))
4260 $this->error(_ERROR_DUPSKINNAME);
4262 $newId = SKIN::createNew($name, $desc);
4264 $this->action_skinoverview();
4268 * @todo document this
4270 function action_skinedit() {
4271 global $member, $manager;
4273 $skinid = intRequestVar('skinid');
4275 $member->isAdmin() or $this->disallow();
4277 $skin = new SKIN($skinid);
4282 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4284 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4286 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4287 <?php echo _SKIN_PARTS_MSG?>
4289 <li><a tabindex="10" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=index"><?php echo _SKIN_PART_MAIN?></a> <?php help('skinpartindex')?></li>
4290 <li><a tabindex="20" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=item"><?php echo _SKIN_PART_ITEM?></a> <?php help('skinpartitem')?></li>
4291 <li><a tabindex="30" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archivelist"><?php echo _SKIN_PART_ALIST?></a> <?php help('skinpartarchivelist')?></li>
4292 <li><a tabindex="40" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=archive"><?php echo _SKIN_PART_ARCHIVE?></a> <?php help('skinpartarchive')?></li>
4293 <li><a tabindex="50" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=search"><?php echo _SKIN_PART_SEARCH?></a> <?php help('skinpartsearch')?></li>
4294 <li><a tabindex="60" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=error"><?php echo _SKIN_PART_ERROR?></a> <?php help('skinparterror')?></li>
4295 <li><a tabindex="70" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=member"><?php echo _SKIN_PART_MEMBER?></a> <?php help('skinpartmember')?></li>
4296 <li><a tabindex="75" href="index.php?action=skinedittype&skinid=<?php echo $skinid ?>&type=imagepopup"><?php echo _SKIN_PART_POPUP?></a> <?php help('skinpartimagepopup')?></li>
4301 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4302 $res = sql_query($query);
4304 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4305 echo '<form method="get" action="index.php">' . "\r\n";
4306 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4307 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4308 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4309 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4310 echo '</form>' . "\r\n";
4312 if ($res && sql_num_rows($res) > 0) {
4316 while ($row = sql_fetch_assoc($res)) {
4317 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">' . ENTITY::hsc(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . ENTITY::hsc(strtolower($row['stype'])) . '">remove</a>)</li>';
4325 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4326 <form method="post" action="index.php">
4329 <input type="hidden" name="action" value="skineditgeneral" />
4330 <?php $manager->addTicketHidden() ?>
4331 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4333 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4334 <td><input name="name" tabindex="90" value="<?php echo ENTITY::hsc($skin->getName()) ?>" maxlength="20" size="20" /></td>
4336 <td><?php echo _SKIN_DESC?></td>
4337 <td><input name="desc" tabindex="100" value="<?php echo ENTITY::hsc($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4339 <td><?php echo _SKIN_TYPE?></td>
4340 <td><input name="type" tabindex="110" value="<?php echo ENTITY::hsc($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4342 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4343 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4345 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4346 <td><input name="inc_prefix" tabindex="130" value="<?php echo ENTITY::hsc($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4348 <td><?php echo _SKIN_CHANGE?></td>
4349 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4356 <?php $this->pagefoot();
4360 * @todo document this
4362 function action_skineditgeneral() {
4365 $skinid = intRequestVar('skinid');
4367 $member->isAdmin() or $this->disallow();
4369 $name = postVar('name');
4370 $desc = postVar('desc');
4371 $type = postVar('type');
4372 $inc_mode = postVar('inc_mode');
4373 $inc_prefix = postVar('inc_prefix');
4375 $skin = new SKIN($skinid);
4378 if (!isValidSkinName($name))
4379 $this->error(_ERROR_BADSKINNAME);
4381 if (($skin->getName() != $name) && SKIN::exists($name))
4382 $this->error(_ERROR_DUPSKINNAME);
4384 if (!$type) $type = 'text/html';
4385 if (!$inc_mode) $inc_mode = 'normal';
4387 // 2. Update description
4388 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4390 $this->action_skinedit();
4395 * @todo document this
4397 function action_skinedittype($msg = '') {
4398 global $member, $manager;
4400 $skinid = intRequestVar('skinid');
4401 $type = requestVar('type');
4403 $member->isAdmin() or $this->disallow();
4405 $type = trim($type);
4406 $type = strtolower($type);
4408 if (!isValidShortName($type)) {
4409 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4412 $skin = new SKIN($skinid);
4414 $friendlyNames = SKIN::getFriendlyNames();
4418 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4420 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo ENTITY::hsc($skin->getName()) ?>': <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4422 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4426 <form method="post" action="index.php">
4429 <input type="hidden" name="action" value="skinupdate" />
4430 <?php $manager->addTicketHidden() ?>
4431 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4432 <input type="hidden" name="type" value="<?php echo $type ?>" />
4434 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4435 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4436 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4437 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4438 help('skinpart' . $type);
4440 help('skinpartspecial');
4444 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo ENTITY::hsc($skin->getContent($type)) ?></textarea>
4447 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4448 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4449 (skin type: <?php echo ENTITY::hsc(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4452 <?php echo _SKIN_ALLOWEDVARS?>
4453 <?php $actions = SKIN::getAllowedActionsForType($type);
4457 while ($current = array_shift($actions)) {
4458 // skip deprecated vars
4459 if ($current == 'ifcat') continue;
4460 if ($current == 'imagetext') continue;
4461 if ($current == 'vars') continue;
4463 echo helplink('skinvar-' . $current) . "$current</a>";
4464 if (count($actions) != 0) echo ", ";
4466 echo '<br /><br />' . _SKINEDIT_ALLOWEDBLOGS;
4467 $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4468 showlist($query,'table',array('content'=>'shortblognames'));
4469 echo '<br />' . _SKINEDIT_ALLOWEDTEMPLATESS;
4470 $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4471 showlist($query,'table',array('content'=>'shortnames'));
4472 echo '</div></form>';
4477 * @todo document this
4479 function action_skinupdate() {
4482 $skinid = intRequestVar('skinid');
4483 $content = trim(postVar('content'));
4484 $type = postVar('type');
4486 $member->isAdmin() or $this->disallow();
4488 $skin = new SKIN($skinid);
4489 $skin->update($type, $content);
4491 $this->action_skinedittype(_SKIN_UPDATED);
4495 * @todo document this
4497 function action_skindelete() {
4498 global $member, $manager, $CONF;
4500 $skinid = intRequestVar('skinid');
4502 $member->isAdmin() or $this->disallow();
4504 // don't allow default skin to be deleted
4505 if ($skinid == $CONF['BaseSkin'])
4506 $this->error(_ERROR_DEFAULTSKIN);
4508 // don't allow deletion of default skins for blogs
4509 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4510 $r = sql_query($query);
4511 if ($o = sql_fetch_object($r))
4512 $this->error(_ERROR_SKINDEFDELETE . ENTITY::hsc($o->bname));
4516 $skin = new SKIN($skinid);
4517 $name = $skin->getName();
4518 $desc = $skin->getDescription();
4521 <h2><?php echo _DELETE_CONFIRM?></h2>
4524 <?php echo _CONFIRMTXT_SKIN?><b><?php echo ENTITY::hsc($name) ?></b> (<?php echo ENTITY::hsc($desc)?>)
4527 <form method="post" action="index.php"><div>
4528 <input type="hidden" name="action" value="skindeleteconfirm" />
4529 <?php $manager->addTicketHidden() ?>
4530 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4531 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4538 * @todo document this
4540 function action_skindeleteconfirm() {
4541 global $member, $CONF, $manager;
4543 $skinid = intRequestVar('skinid');
4545 $member->isAdmin() or $this->disallow();
4547 // don't allow default skin to be deleted
4548 if ($skinid == $CONF['BaseSkin'])
4549 $this->error(_ERROR_DEFAULTSKIN);
4551 // don't allow deletion of default skins for blogs
4552 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4553 $r = sql_query($query);
4554 if ($o = sql_fetch_object($r))
4555 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4557 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4559 // 1. delete description
4560 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4563 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4565 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4567 $this->action_skinoverview();
4571 * @todo document this
4573 function action_skinremovetype() {
4574 global $member, $manager, $CONF;
4576 $skinid = intRequestVar('skinid');
4577 $skintype = requestVar('type');
4579 if (!isValidShortName($skintype)) {
4580 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4583 $member->isAdmin() or $this->disallow();
4585 // don't allow default skinparts to be deleted
4586 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4587 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4592 $skin = new SKIN($skinid);
4593 $name = $skin->getName();
4594 $desc = $skin->getDescription();
4597 <h2><?php echo _DELETE_CONFIRM?></h2>
4600 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo ENTITY::hsc($skintype); ?> (<?php echo ENTITY::hsc($name); ?>)</b> (<?php echo ENTITY::hsc($desc)?>)
4603 <form method="post" action="index.php"><div>
4604 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4605 <?php $manager->addTicketHidden() ?>
4606 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4607 <input type="hidden" name="type" value="<?php echo ENTITY::hsc($skintype); ?>" />
4608 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4615 * @todo document this
4617 function action_skinremovetypeconfirm() {
4618 global $member, $CONF, $manager;
4620 $skinid = intRequestVar('skinid');
4621 $skintype = requestVar('type');
4623 if (!isValidShortName($skintype)) {
4624 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4627 $member->isAdmin() or $this->disallow();
4629 // don't allow default skinparts to be deleted
4630 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4631 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4634 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4637 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4639 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4641 $this->action_skinedit();
4645 * @todo document this
4647 function action_skinclone() {
4650 $skinid = intRequestVar('skinid');
4652 $member->isAdmin() or $this->disallow();
4654 // 1. read skin to clone
4655 $skin = new SKIN($skinid);
4657 $name = "clone_" . $skin->getName();
4659 // if a skin with that name already exists:
4660 if (SKIN::exists($name)) {
4662 while (SKIN::exists($name . $i))
4667 // 2. create skin desc
4668 $newid = SKIN::createNew(
4670 $skin->getDescription(),
4671 $skin->getContentType(),
4672 $skin->getIncludeMode(),
4673 $skin->getIncludePrefix()
4679 $this->skinclonetype($skin, $newid, 'index');
4680 $this->skinclonetype($skin, $newid, 'item');
4681 $this->skinclonetype($skin, $newid, 'archivelist');
4682 $this->skinclonetype($skin, $newid, 'archive');
4683 $this->skinclonetype($skin, $newid, 'search');
4684 $this->skinclonetype($skin, $newid, 'error');
4685 $this->skinclonetype($skin, $newid, 'member');
4686 $this->skinclonetype($skin, $newid, 'imagepopup');
4689 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4690 $res = sql_query($query);
4691 while ($row = sql_fetch_assoc($res)) {
4692 $this->skinclonetype($skin, $newid, $row['stype']);
4695 $this->action_skinoverview();
4700 * ADMIN::skinclonetype()
4702 * @param String $skin Skin object
4703 * @param Integer $newid ID for this clone
4704 * @param String $type type of skin
4707 function skinclonetype($skin, $newid, $type)
4709 $newid = intval($newid);
4710 $content = $skin->getContent($type);
4714 $query = "INSERT INTO %s (sdesc, scontent, stype) VALUES (%d, '%s', '%s')";
4715 $query = sprintf($query, sql_table('skin'), (integer) $newid, $content, $type);
4722 * ADMIN::action_settingsedit()
4727 function action_settingsedit() {
4728 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4730 $member->isAdmin() or $this->disallow();
4734 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4737 <h2><?php echo _SETTINGS_TITLE?></h2>
4739 <form action="index.php" method="post">
4742 <input type="hidden" name="action" value="settingsupdate" />
4743 <?php $manager->addTicketHidden() ?>
4746 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4748 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4751 $query = 'SELECT bname as text, bnumber as value'
4752 . ' FROM '.sql_table('blog');
4753 $template['name'] = 'DefaultBlog';
4754 $template['selected'] = $CONF['DefaultBlog'];
4755 $template['tabindex'] = 10;
4756 showlist($query,'select',$template);
4760 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4763 $query = 'SELECT sdname as text, sdnumber as value'
4764 . ' FROM '.sql_table('skin_desc');
4765 $template['name'] = 'BaseSkin';
4766 $template['selected'] = $CONF['BaseSkin'];
4767 $template['tabindex'] = 1;
4768 showlist($query,'select',$template);
4772 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4773 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo ENTITY::hsc($CONF['AdminEmail']) ?>" /></td>
4775 <td><?php echo _SETTINGS_SITENAME?></td>
4776 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo ENTITY::hsc($CONF['SiteName']) ?>" /></td>
4778 <td><?php echo _SETTINGS_SITEURL?></td>
4779 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo ENTITY::hsc($CONF['IndexURL']) ?>" /></td>
4781 <td><?php echo _SETTINGS_ADMINURL?></td>
4782 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo ENTITY::hsc($CONF['AdminURL']) ?>" /></td>
4784 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4785 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo ENTITY::hsc($CONF['PluginURL']) ?>" /></td>
4787 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4788 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo ENTITY::hsc($CONF['SkinsURL']) ?>" /></td>
4790 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4791 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo ENTITY::hsc($CONF['ActionURL']) ?>" /></td>
4793 <td><?php echo _SETTINGS_LOCALE?> <?php help('locale'); ?>
4796 <select name="Locale" tabindex="10050">
4798 $locales = i18n::get_available_locale_list();
4799 if ( !i18n::get_current_locale() || !in_array(i18n::get_current_locale(), $locales) )
4801 echo "<option value=\"\" selected=\"selected\">en_Latn_US</option>\n";
4805 echo "<option value=\"\">en_Latn_US</option>\n";
4808 foreach ( $locales as $locale )
4810 if ( $locale == 'en_Latn_US' )
4814 if ( $locale == i18n::get_current_locale() )
4816 echo "<option value=\"{$locale}\" selected=\"selected\">{$locale}</option>\n";
4820 echo "<option value=\"{$locale}\">{$locale}</option>\n";
4828 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4830 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4832 <?php echo _SETTINGS_DISABLESITEURL ?> <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo ENTITY::hsc($CONF['DisableSiteURL'])?>" />
4835 <td><?php echo _SETTINGS_DIRS?></td>
4836 <td><?php echo ENTITY::hsc($DIR_NUCLEUS) ?>
4837 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4839 <td><?php echo _SETTINGS_DBLOGIN?></td>
4840 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4844 echo _SETTINGS_JSTOOLBAR
4845 /* =_SETTINGS_DISABLEJS
4847 I temporary changed the meaning of DisableJsTools, until I can find a good
4848 way to select the javascript version to use
4852 1 : all javascript disabled
4853 2 : 'simpler' javascript (for mozilla/opera/mac)
4857 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4858 <select name="DisableJsTools" tabindex="10075">
4859 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4860 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4861 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4862 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4863 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4864 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4869 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4872 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4873 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4875 echo ' ', _SETTINGS_URLMODE_HELP;
4881 <td><?php echo _SETTINGS_DEBUGVARS?> <?php help('debugvars');?></td>
4884 $this->input_yesno('DebugVars',$CONF['DebugVars'],10078);
4890 <td><?php echo _SETTINGS_DEFAULTLISTSIZE?> <?php help('defaultlistsize');?></td>
4893 if (!array_key_exists('DefaultListSize',$CONF)) {
4894 sql_query("INSERT INTO ".sql_table('config')." VALUES ('DefaultListSize', '10')");
4895 $CONF['DefaultListSize'] = 10;
4898 <input name="DefaultListSize" tabindex="10079" size="40" value="<?php echo ENTITY::hsc((intval($CONF['DefaultListSize']) < 1 ? '10' : $CONF['DefaultListSize'])) ?>" />
4901 <td><?php echo _SETTINGS_ADMINCSS?>
4905 <select name="AdminCSS" tabindex="10080">
4906 <?php // show a dropdown list of all available admin css files
4907 global $DIR_NUCLEUS;
4909 $dirhandle = opendir($DIR_NUCLEUS."styles/");
4911 while ($filename = readdir($dirhandle) )
4914 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
4915 # original ereg: ereg("^(.*)\.php$",$filename,$matches)
4917 if (preg_match('#^admin_(.*)\.css$#', $filename, $matches) )
4920 $name = $matches[1];
4921 echo "<option value=\"$name\"";
4923 if ($name == $CONF['AdminCSS'])
4925 echo " selected=\"selected\"";
4928 echo ">$name</option>";
4934 closedir($dirhandle);
4941 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4943 <td><?php echo _SETTINGS_MEDIADIR?></td>
4944 <td><?php echo ENTITY::hsc($DIR_MEDIA) ?>
4945 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4946 <?php if (!is_dir($DIR_MEDIA))
4947 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4948 if (!is_readable($DIR_MEDIA))
4949 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4950 if (!is_writeable($DIR_MEDIA))
4951 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4955 <td><?php echo _SETTINGS_MEDIAURL?></td>
4957 <input name="MediaURL" tabindex="10090" size="40" value="<?php echo ENTITY::hsc($CONF['MediaURL']) ?>" />
4960 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4961 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4963 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4965 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo ENTITY::hsc($CONF['AllowedTypes']) ?>" />
4968 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4970 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo ENTITY::hsc($CONF['MaxUploadSize']) ?>" />
4973 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4974 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4977 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4979 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4980 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4982 <td><?php echo _SETTINGS_ALLOWCREATE?>
4983 <?php help('allowaccountcreation'); ?>
4985 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4988 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4989 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4991 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4994 <td><?php echo _SETTINGS_MEMBERMSGS?>
4995 <?php help('messageservice'); ?>
4997 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
5000 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
5001 <?php help('messageservice'); ?>
5003 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
5006 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
5007 <?php help('protectmemnames'); ?>
5009 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
5015 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
5017 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
5018 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePrefix'])?>" /></td>
5020 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
5021 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo ENTITY::hsc($CONF['CookieDomain'])?>" /></td>
5023 <td><?php echo _SETTINGS_COOKIEPATH?></td>
5024 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo ENTITY::hsc($CONF['CookiePath'])?>" /></td>
5026 <td><?php echo _SETTINGS_COOKIESECURE?></td>
5027 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
5029 <td><?php echo _SETTINGS_COOKIELIFE?></td>
5030 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
5031 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
5034 <td><?php echo _SETTINGS_LASTVISIT?></td>
5035 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
5040 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
5042 <td><?php echo _SETTINGS_UPDATE?></td>
5043 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
5050 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
5053 'GeneralSettingsFormExtras',
5061 * ADMIN::action_settingsupdate()
5062 * Update $CONFIG and redirect
5067 function action_settingsupdate() {
5068 global $member, $CONF;
5070 $member->isAdmin() or $this->disallow();
5072 // check if email address for admin is valid
5073 if ( !NOTIFICATION::address_validation(postVar('AdminEmail')) )
5075 $this->error(_ERROR_BADMAILADDRESS);
5079 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
5080 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
5081 $this->updateConfig('IndexURL', postVar('IndexURL'));
5082 $this->updateConfig('AdminURL', postVar('AdminURL'));
5083 $this->updateConfig('PluginURL', postVar('PluginURL'));
5084 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
5085 $this->updateConfig('ActionURL', postVar('ActionURL'));
5086 $this->updateConfig('Locale', postVar('Locale'));
5087 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
5088 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
5089 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
5090 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
5091 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
5092 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
5093 $this->updateConfig('SiteName', postVar('SiteName'));
5094 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
5095 $this->updateConfig('DisableSite', postVar('DisableSite'));
5096 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
5097 $this->updateConfig('LastVisit', postVar('LastVisit'));
5098 $this->updateConfig('MediaURL', postVar('MediaURL'));
5099 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
5100 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
5101 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
5102 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
5103 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
5104 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
5105 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
5106 $this->updateConfig('CookiePath', postVar('CookiePath'));
5107 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
5108 $this->updateConfig('URLMode', postVar('URLMode'));
5109 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
5110 $this->updateConfig('DebugVars', postVar('DebugVars'));
5111 $this->updateConfig('DefaultListSize', postVar('DefaultListSize'));
5112 $this->updateConfig('AdminCSS', postVar('AdminCSS'));
5114 // load new config and redirect (this way, the new locale will be used is necessary)
5115 // note that when changing cookie settings, this redirect might cause the user
5116 // to have to log in again.
5118 redirect($CONF['AdminURL'] . '?action=manage');
5123 * ADMIN::action_systemoverview()
5124 * Output system overview
5129 function action_systemoverview()
5131 global $member, $nucleus, $CONF;
5135 echo '<h2>' . _ADMIN_SYSTEMOVERVIEW_HEADING . "</h2>\n";
5137 if ( $member->isLoggedIn() && $member->isAdmin() )
5139 // Information about the used PHP and MySQL installation
5140 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_PHPANDMYSQL . "</h3>\n\n";
5142 // Version of PHP MySQL
5143 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "\" class=\"systemoverview\">\n";
5146 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_VERSIONS . "</th>\n";
5151 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_PHPVERSION . "</td>\n";
5152 echo '<td>' . phpversion() . "</td>\n";
5155 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_MYSQLVERSION . "</td>\n";
5156 echo '<td>' . sql_get_server_info() . ' (' . sql_get_client_info() . ')' . "</td>\n";
5159 echo "</table>\n\n";
5161 // Important PHP settings
5162 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "\" class=\"systemoverview\">\n";
5165 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_SETTINGS . "</th>\n";
5170 echo '<td>magic_quotes_gpc' . "</td>\n";
5171 $mqg = get_magic_quotes_gpc() ? 'On' : 'Off';
5172 echo '<td>' . $mqg . "</td>\n";
5175 echo '<td>magic_quotes_runtime' . "</td>\n";
5176 $mqr = get_magic_quotes_runtime() ? 'On' : 'Off';
5177 echo '<td>' . $mqr . "</td>\n";
5180 echo '<td>register_globals' . "</td>\n";
5181 $rg = ini_get('register_globals') ? 'On' : 'Off';
5182 echo '<td>' . $rg . "</td>\n";
5185 echo "</table>\n\n";
5187 // Information about GD library
5188 $gdinfo = gd_info();
5189 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "\" class=\"systemoverview\">\n";
5192 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_GDLIBRALY . "</th>\n";
5196 foreach ( $gdinfo as $key=>$value )
5198 if ( is_bool($value) )
5200 $value = $value ? _ADMIN_SYSTEMOVERVIEW_ENABLE : _ADMIN_SYSTEMOVERVIEW_DISABLE;
5204 $value = ENTITY::hsc($value);
5207 echo '<td>' . $key . "</td>\n";
5208 echo '<td>' . $value . "</td>\n";
5212 echo "</table>\n\n";
5214 // Check if special modules are loaded
5216 phpinfo(INFO_MODULES);
5217 $im = ob_get_contents();
5219 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_MODULES . "\" class=\"systemoverview\">\n";
5222 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_MODULES . "</th>\n";
5226 echo '<td>mod_rewrite' . "</td>\n";
5227 $modrewrite = (strstr($im, 'mod_rewrite') != '') ?
5228 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5229 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5230 echo '<td>' . $modrewrite . "</td>\n";
5233 echo "</table>\n\n";
5235 // Information about the used Nucleus CMS
5236 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSYSTEM . "</h3>\n";
5238 $nv = getNucleusVersion() / 100 . '(' . $nucleus['version'] . ')';
5239 $np = getNucleusPatchLevel();
5240 echo "<table frame=\"box\" rules=\"all\" summary=\"Nucleus CMS\" class=\"systemoverview\" class=\"systemoverview\">\n";
5243 echo '<th colspan="2">Nucleus CMS' . "</th>\n";
5248 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSVERSION . "</td>\n";
5249 echo '<td>' . $nv . "</td>\n";
5252 echo '<td>' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSPATCHLEVEL . "</td>\n";
5253 echo '<td>' . $np . "</td>\n";
5256 echo "</table>\n\n";
5258 // Important settings of the installation
5259 echo '<table frame="box" rules="all" summary="' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "\" class=\"systemoverview\">\n";
5262 echo '<th colspan="2">' . _ADMIN_SYSTEMOVERVIEW_NUCLEUSSETTINGS . "</th>\n";
5267 echo '<td>' . '$CONF[' . "'Self']</td>\n";
5268 echo '<td>' . $CONF['Self'] . "</td>\n";
5271 echo '<td>' . '$CONF[' . "'ItemURL']</td>\n";
5272 echo '<td>' . $CONF['ItemURL'] . "</td>\n";
5275 echo '<td>' . '$CONF[' . "'alertOnHeadersSent']</td>\n";
5276 $ohs = $CONF['alertOnHeadersSent'] ?
5277 _ADMIN_SYSTEMOVERVIEW_ENABLE :
5278 _ADMIN_SYSTEMOVERVIEW_DISABLE;
5279 echo '<td>' . $ohs . "</td>\n";
5282 echo "<td>i18n::get_current_charset()</td>\n";
5283 echo '<td>' . i18n::get_current_charset() . "</td>\n";
5286 echo "</table>\n\n";
5288 // Link to the online version test at the Nucleus CMS website
5289 echo '<h3>' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK . "</h3>\n";
5290 if ( $nucleus['codename'] != '')
5292 $codenamestring = ' "' . $nucleus['codename'] . '"';
5296 $codenamestring = '';
5298 echo _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TXT;
5299 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5300 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">';
5301 echo 'Nucleus CMS ' . $nv . $codenamestring;
5306 echo _ADMIN_SYSTEMOVERVIEW_NOT_ADMIN;
5312 * ADMIN::updateConfig()
5314 * @param string $name
5315 * @param string $val
5316 * @return integer return the ID in which the latest query posted
5318 function updateConfig($name, $val)
5320 $name = sql_real_escape_string($name);
5321 $val = trim(sql_real_escape_string($val));
5323 $query = "UPDATE %s SET value='%s' WHERE name='%s'";
5324 $query = sprintf($query, sql_table('config'), $val, $name);
5325 sql_query($query) or die("Query error: " . sql_error());
5326 return sql_insert_id();
5331 * @param string $msg message that will be shown
5333 function error($msg)
5337 echo "<h2>Error!</h2>\n";
5340 echo '<a href="index.php" onclick="history.back()">' . _BACK . "</a>\n";
5347 * add error log and show error page
5354 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
5355 $this->error(_ERROR_DISALLOWED);
5360 * Output admin page head
5365 function pagehead($extrahead = '')
5367 global $member, $nucleus, $CONF, $manager;
5372 'extrahead' => &$extrahead,
5373 'action' => $this->action));
5375 $baseUrl = ENTITY::hsc($CONF['AdminURL']);
5376 if ( !array_key_exists('AdminCSS',$CONF) )
5378 sql_query("INSERT INTO ".sql_table('config')." VALUES ('AdminCSS', 'original')");
5379 $CONF['AdminCSS'] = 'original';
5382 /* HTTP 1.1 application for no caching */
5383 header("Cache-Control: no-cache, must-revalidate");
5384 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
5386 $root_element = 'html';
5387 $charset = i18n::get_current_charset();
5388 $locale = preg_replace('#_#', '-', i18n::get_current_locale());
5390 echo "<?xml version=\"{$this->xml_version_info}\" encoding=\"{$charset}\" ?>\n";
5391 echo "<!DOCTYPE {$root_element} PUBLIC \"{$this->formal_public_identifier}\" \"{$this->system_identifier}\">\n";
5392 echo "<{$root_element} xmlns=\"{$this->xhtml_namespace}\" xml:lang=\"{$locale}\" lang=\"{$locale}\">\n";
5394 echo '<title>' . ENTITY::hsc($CONF['SiteName']) . " - Admin</title>\n";
5395 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/admin_{$CONF["AdminCSS"]}.css\" />\n";
5396 echo "<link rel=\"stylesheet\" title=\"Nucleus Admin Default\" type=\"text/css\" href=\"{$baseUrl}styles/addedit.css\" />\n";
5397 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/edit.js\"></script>\n";
5398 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/admin.js\"></script>\n";
5399 echo "<script type=\"text/javascript\" src=\"{$baseUrl}javascript/compatibility.js\"></script>\n";
5400 echo "{$extrahead}\n";
5403 echo "<div id=\"adminwrapper\">\n";
5404 echo "<div class=\"header\">\n";
5405 echo '<h1>' . ENTITY::hsc($CONF['SiteName']) . "</h1>\n";
5407 echo "<div id=\"container\">\n";
5408 echo "<div id=\"content\">\n";
5409 echo "<div class=\"loginname\">\n";
5410 if ( $member->isLoggedIn() )
5412 echo _LOGGEDINAS . ' ' . $member->getDisplayName() ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a><br />\n";
5413 echo "<a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5417 echo '<a href="index.php?action=showlogin" title="Log in">' . _NOTLOGGEDIN . "</a><br />\n";
5419 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a><br />\n";
5422 if (array_key_exists('codename', $nucleus) && $nucleus['codename'] != '' )
5424 $codenamestring = ' "' . $nucleus['codename'].'"';
5428 $codenamestring = '';
5431 if ( $member->isLoggedIn() && $member->isAdmin() )
5433 $checkURL = sprintf(_ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_URL, getNucleusVersion(), getNucleusPatchLevel());
5434 echo '<a href="' . $checkURL . '" title="' . _ADMIN_SYSTEMOVERVIEW_VERSIONCHECK_TITLE . '">Nucleus CMS ' . $nucleus['version'] . $codenamestring . '</a>';
5436 $newestVersion = getLatestVersion();
5437 $newestCompare = str_replace('/','.',$newestVersion);
5438 $currentVersion = str_replace(array('/','v'),array('.',''),$nucleus['version']);
5439 if ( $newestVersion && version_compare($newestCompare, $currentVersion) > 0 )
5442 echo '<a style="color:red" href="http://nucleuscms.org/upgrade.php" title="' . _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE . '">';
5443 echo _ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT . $newestVersion;
5449 echo 'Nucleus CMS ' . $nucleus['version'] . $codenamestring;
5458 * Output admin page foot include quickmenu
5465 global $action, $member, $manager;
5469 array('action' => $this->action)
5472 if ( $member->isLoggedIn() && ($action != 'showlogin') )
5474 echo '<h2>' . _LOGOUT . "</h2>\n";
5476 echo '<li><a href="index.php?action=overview">' . _BACKHOME . "</a></li>\n";
5477 echo '<li><a href="index.php?action=logout">' . _LOGOUT . "</a></li>\n";
5481 echo "<div class=\"foot\">\n";
5482 echo '<a href="' . _ADMINPAGEFOOT_OFFICIALURL . '">Nucleus CMS</a> © 2002-' . date('Y') . ' ' . _ADMINPAGEFOOT_COPYRIGHT;
5484 echo '<a href="' . _ADMINPAGEFOOT_DONATEURL . '">' . _ADMINPAGEFOOT_DONATE . "</a>\n";
5487 echo "<!-- content -->\n";
5488 echo "<div id=\"quickmenu\">\n";
5490 if ( ($action != 'showlogin') && ($member->isLoggedIn()) )
5493 echo '<li><a href="index.php?action=overview">' . _QMENU_HOME . "</a></li>\n";
5496 echo '<h2>' . _QMENU_ADD . "</h2>\n";
5497 echo "<form method=\"get\" action=\"index.php\">\n";
5499 echo "<input type=\"hidden\" name=\"action\" value=\"createitem\" />\n";
5501 $showAll = requestVar('showall');
5503 if ( ($member->isAdmin()) && ($showAll == 'yes') )
5505 // Super-Admins have access to all blogs! (no add item support though)
5506 $query = 'SELECT bnumber as value, bname as text'
5507 . ' FROM ' . sql_table('blog')
5508 . ' ORDER BY bname';
5512 $query = 'SELECT bnumber as value, bname as text'
5513 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5514 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5515 . ' ORDER BY bname';
5517 $template['name'] = 'blogid';
5518 $template['tabindex'] = 15000;
5519 $template['extra'] = _QMENU_ADD_SELECT;
5520 $template['selected'] = -1;
5521 $template['shorten'] = 10;
5522 $template['shortenel'] = '';
5523 $template['javascript'] = 'onchange="return form.submit()"';
5524 showlist($query,'select',$template);
5529 echo "<h2>{$member->getDisplayName()}</h2>\n";
5531 echo '<li><a href="index.php?action=editmembersettings">' . _QMENU_USER_SETTINGS . "</a></li>\n";
5532 echo '<li><a href="index.php?action=browseownitems">' . _QMENU_USER_ITEMS . "</a></li>\n";
5533 echo '<li><a href="index.php?action=browseowncomments">' . _QMENU_USER_COMMENTS . "</a></li>\n";
5536 // ---- general settings ----
5537 if ( $member->isAdmin() )
5539 echo '<h2>' . _QMENU_MANAGE . "</h2>\n";
5541 echo '<li><a href="index.php?action=actionlog">' . _QMENU_MANAGE_LOG . "</a></li>\n";
5542 echo '<li><a href="index.php?action=settingsedit">' . _QMENU_MANAGE_SETTINGS . "</a></li>\n";
5543 echo '<li><a href="index.php?action=systemoverview">' . _QMENU_MANAGE_SYSTEM . "</a></li>\n";
5544 echo '<li><a href="index.php?action=usermanagement">' . _QMENU_MANAGE_MEMBERS . "</a></li>\n";
5545 echo '<li><a href="index.php?action=createnewlog">' . _QMENU_MANAGE_NEWBLOG . "</a></li>\n";
5546 echo '<li><a href="index.php?action=backupoverview">' . _QMENU_MANAGE_BACKUPS . "</a></li>\n";
5547 echo '<li><a href="index.php?action=pluginlist">' . _QMENU_MANAGE_PLUGINS . "</a></li>\n";
5550 echo "<h2>" . _QMENU_LAYOUT . "</h2>\n";
5552 echo '<li><a href="index.php?action=skinoverview">' . _QMENU_LAYOUT_SKINS . "</a></li>\n";
5553 echo '<li><a href="index.php?action=templateoverview">' . _QMENU_LAYOUT_TEMPL . "</a></li>\n";
5554 echo '<li><a href="index.php?action=skinieoverview">' . _QMENU_LAYOUT_IEXPORT . "</a></li>\n";
5558 $aPluginExtras = array();
5562 'options' => &$aPluginExtras));
5564 if ( count($aPluginExtras) > 0 )
5566 echo "<h2>" . _QMENU_PLUGINS . "</h2>\n";
5568 foreach ( $aPluginExtras as $aInfo )
5570 echo '<li><a href="' . ENTITY::hsc($aInfo['url']) . '" title="' . ENTITY::hsc($aInfo['tooltip']) . '">' . ENTITY::hsc($aInfo['title']) . "</a></li>\n";
5575 else if ( ($action == 'activate') || ($action == 'activatesetpwd') )
5578 echo '<h2>' . _QMENU_ACTIVATE . '</h2>' . _QMENU_ACTIVATE_TEXT;
5582 // introduction text on login screen
5583 echo '<h2>' . _QMENU_INTRO . '</h2>' . _QMENU_INTRO_TEXT;
5586 echo "<!-- quickmenu -->\n";
5589 echo "<!-- content -->\n";
5592 echo "<!-- container -->\n";
5595 echo "<!-- adminwrapper -->\n";
5604 * @todo document this
5606 function action_regfile() {
5607 global $member, $CONF;
5609 $blogid = intRequestVar('blogid');
5611 $member->teamRights($blogid) or $this->disallow();
5613 // header-code stolen from phpMyAdmin
5614 // REGEDIT and bookmarklet code stolen from GreyMatter
5616 $sjisBlogName = sprintf(_WINREGFILE_TEXT, getBlogNameFromID($blogid));
5619 header('Content-Type: application/octetstream');
5620 header('Content-Disposition: filename="nucleus.reg"');
5621 header('Pragma: no-cache');
5622 header('Expires: 0');
5625 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\" . $sjisBlogName . "]\n";
5626 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5627 echo '"contexts"=hex:31';
5631 * @todo document this
5633 function action_bookmarklet() {
5634 global $member, $manager;
5636 $blogid = intRequestVar('blogid');
5638 $member->teamRights($blogid) or $this->disallow();
5640 $blog =& $manager->getBlog($blogid);
5641 $bm = getBookmarklet($blogid);
5645 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5649 <h2><?php echo _BOOKMARKLET_TITLE ?></h2>
5652 <?php echo _BOOKMARKLET_DESC1 . _BOOKMARKLET_DESC2 . _BOOKMARKLET_DESC3 . _BOOKMARKLET_DESC4 . _BOOKMARKLET_DESC5 ?>
5655 <h3><?php echo _BOOKMARKLET_BOOKARKLET ?></h3>
5657 <?php echo _BOOKMARKLET_BMARKTEXT ?><small><?php echo _BOOKMARKLET_BMARKTEST ?></small>
5660 <?php echo '<a href="' . ENTITY::hsc($bm) . '">' . sprintf(_BOOKMARKLET_ANCHOR, ENTITY::hsc($blog->getName())) . '</a>' . _BOOKMARKLET_BMARKFOLLOW; ?>
5663 <h3><?php echo _BOOKMARKLET_RIGHTCLICK ?></h3>
5666 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5667 $url = $manager->addTicketToUrl($url);
5669 <?php echo _BOOKMARKLET_RIGHTTEXT1 . '<a href="' . ENTITY::hsc($url, ENT_QUOTES, "SJIS") . '">' . _BOOKMARKLET_RIGHTLABEL . '</a>' . _BOOKMARKLET_RIGHTTEXT2; ?>
5673 <?php echo _BOOKMARKLET_RIGHTTEXT3 ?>
5676 <h3><?php echo _BOOKMARKLET_UNINSTALLTT ?></h3>
5678 <?php echo _BOOKMARKLET_DELETEBAR ?>
5682 <?php echo _BOOKMARKLET_DELETERIGHTT ?>
5686 <li><?php echo _BOOKMARKLET_DELETERIGHT1 ?></li>
5687 <li><?php echo _BOOKMARKLET_DELETERIGHT2 ?></li>
5688 <li><?php echo _BOOKMARKLET_DELETERIGHT3 ?></li>
5689 <li><?php echo _BOOKMARKLET_DELETERIGHT4 ?></li>
5690 <li><?php echo _BOOKMARKLET_DELETERIGHT5 ?></li>
5699 * @todo document this
5701 function action_actionlog() {
5702 global $member, $manager;
5704 $member->isAdmin() or $this->disallow();
5708 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5710 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5713 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5714 <p><a href="<?php echo ENTITY::hsc($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5716 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5718 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5719 $template['content'] = 'actionlist';
5720 $amount = showlist($query,'table',$template);
5727 * @todo document this
5729 function action_banlist() {
5730 global $member, $manager;
5732 $blogid = intRequestVar('blogid');
5734 $member->blogAdminRights($blogid) or $this->disallow();
5736 $blog =& $manager->getBlog($blogid);
5740 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5742 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5744 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5745 $template['content'] = 'banlist';
5746 $amount = showlist($query,'table',$template);
5751 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5752 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5760 * @todo document this
5762 function action_banlistdelete() {
5763 global $member, $manager;
5765 $blogid = intRequestVar('blogid');
5766 $iprange = requestVar('iprange');
5768 $member->blogAdminRights($blogid) or $this->disallow();
5770 $blog =& $manager->getBlog($blogid);
5771 $banBlogName = ENTITY::hsc($blog->getName());
5775 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5777 <form method="post" action="index.php">
5779 <h3><?php echo _BAN_IPRANGE?></h3>
5782 <?php echo _CONFIRMTXT_BAN?> <?php echo ENTITY::hsc($iprange) ?>
5783 <input name="iprange" type="hidden" value="<?php echo ENTITY::hsc($iprange)?>" />
5786 <h3><?php echo _BAN_BLOGS?></h3>
5789 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5790 <input name="allblogs" type="radio" value="0" id="allblogs_one" />
5791 <label for="allblogs_one"><?php echo sprintf(_BAN_BANBLOGNAME, $banBlogName) ?></label>
5793 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5796 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5799 <?php $manager->addTicketHidden() ?>
5800 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5801 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5810 * @todo document this
5812 function action_banlistdeleteconfirm() {
5813 global $member, $manager;
5815 $blogid = intPostVar('blogid');
5816 $allblogs = postVar('allblogs');
5817 $iprange = postVar('iprange');
5819 $member->blogAdminRights($blogid) or $this->disallow();
5824 if (BAN::removeBan($blogid, $iprange))
5825 array_push($deleted, $blogid);
5827 // get blogs fot which member has admin rights
5828 $adminblogs = $member->getAdminBlogs();
5829 foreach ($adminblogs as $blogje) {
5830 if (BAN::removeBan($blogje, $iprange))
5831 array_push($deleted, $blogje);
5835 if (sizeof($deleted) == 0)
5836 $this->error(_ERROR_DELETEBAN);
5840 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5841 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5842 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5845 foreach ($deleted as $delblog) {
5846 $b =& $manager->getBlog($delblog);
5847 echo "<li>" . ENTITY::hsc($b->getName()). "</li>";
5856 * @todo document this
5858 function action_banlistnewfromitem() {
5859 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5863 * @todo document this
5865 function action_banlistnew($blogid = '') {
5866 global $member, $manager;
5869 $blogid = intRequestVar('blogid');
5871 $ip = requestVar('ip');
5873 $member->blogAdminRights($blogid) or $this->disallow();
5875 $blog =& $manager->getBlog($blogid);
5879 <h2><?php echo _BAN_ADD_TITLE?></h2>
5882 <form method="post" action="index.php">
5884 <h3><?php echo _BAN_IPRANGE?></h3>
5886 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5889 <strong><?php echo _BAN_EXAMPLE_TITLE ?></strong>
5890 <?php echo _BAN_EXAMPLE_TEXT ?>
5896 $iprangeVal = ENTITY::hsc($ip);
5898 <input name="iprange" type="radio" value="<?php echo $iprangeVal ?>" checked="checked" id="ip_fixed" />
5899 <label for="ip_fixed"><?php echo $iprangeVal ?></label>
5901 <input name="iprange" type="radio" value="custom" id="ip_custom" />
5902 <label for="ip_custom"><?php echo _BAN_IP_CUSTOM ?></label>
5903 <input name='customiprange' value='<?php echo $iprangeVal ?>' maxlength='15' size='15' />
5906 echo "<input name='iprange' value='custom' type='hidden' />";
5907 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5912 <h3><?php echo _BAN_BLOGS?></h3>
5914 <p><?php echo _BAN_BLOGS_TEXT?></p>
5917 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5918 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo ENTITY::hsc($blog->getName())?>'</label>
5920 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5923 <h3><?php echo _BAN_REASON_TITLE?></h3>
5925 <p><?php echo _BAN_REASON_TEXT?></p>
5927 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5929 <h3><?php echo _BAN_ADD_TITLE?></h3>
5932 <input name="action" type="hidden" value="banlistadd" />
5933 <?php $manager->addTicketHidden() ?>
5934 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5939 <?php $this->pagefoot();
5943 * @todo document this
5945 function action_banlistadd() {
5948 $blogid = intPostVar('blogid');
5949 $allblogs = postVar('allblogs');
5950 $iprange = postVar('iprange');
5951 if ($iprange == "custom")
5952 $iprange = postVar('customiprange');
5953 $reason = postVar('reason');
5955 $member->blogAdminRights($blogid) or $this->disallow();
5957 // TODO: check IP range validity
5960 if (!BAN::addBan($blogid, $iprange, $reason))
5961 $this->error(_ERROR_ADDBAN);
5963 // get blogs fot which member has admin rights
5964 $adminblogs = $member->getAdminBlogs();
5966 foreach ($adminblogs as $blogje) {
5967 if (!BAN::addBan($blogje, $iprange, $reason))
5971 $this->error(_ERROR_ADDBAN);
5974 $this->action_banlist();
5979 * @todo document this
5981 function action_clearactionlog() {
5984 $member->isAdmin() or $this->disallow();
5988 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5992 * @todo document this
5994 function action_backupoverview() {
5995 global $member, $manager;
5997 $member->isAdmin() or $this->disallow();
6001 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6003 <h2><?php echo _BACKUPS_TITLE?></h2>
6005 <h3><?php echo _BACKUP_TITLE?></h3>
6007 <p><?php echo _BACKUP_INTRO?></p>
6009 <form method="post" action="index.php"><p>
6010 <input type="hidden" name="action" value="backupcreate" />
6011 <?php $manager->addTicketHidden() ?>
6013 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
6015 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
6017 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
6021 <div class="note"><?php echo _BACKUP_NOTE?></div>
6024 <h3><?php echo _RESTORE_TITLE?></h3>
6026 <div class="note"><?php echo _RESTORE_NOTE?></div>
6028 <p><?php echo _RESTORE_INTRO?></p>
6030 <form method="post" action="index.php" enctype="multipart/form-data"><p>
6031 <input type="hidden" name="action" value="backuprestore" />
6032 <?php $manager->addTicketHidden() ?>
6033 <input name="backup_file" type="file" tabindex="30" />
6035 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
6036 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
6037 <br /><?php echo _RESTORE_WARNING?>
6040 <?php $this->pagefoot();
6044 * @todo document this
6046 function action_backupcreate() {
6047 global $member, $DIR_LIBS;
6049 $member->isAdmin() or $this->disallow();
6051 // use compression ?
6052 $useGzip = intval(postVar('gzip'));
6054 include($DIR_LIBS . 'backup.php');
6056 // try to extend time limit
6057 // (creating/restoring dumps might take a while)
6058 @set_time_limit(1200);
6061 $bu->do_backup($useGzip);
6066 * @todo document this
6068 function action_backuprestore() {
6069 global $member, $DIR_LIBS;
6071 $member->isAdmin() or $this->disallow();
6073 if (intPostVar('letsgo') != 1)
6074 $this->error(_ERROR_BACKUP_NOTSURE);
6076 include($DIR_LIBS . 'backup.php');
6078 // try to extend time limit
6079 // (creating/restoring dumps might take a while)
6080 @set_time_limit(1200);
6083 $message = $bu->do_restore();
6085 $this->error($message);
6089 <h2><?php echo _RESTORE_COMPLETE?></h2>
6090 <?php $this->pagefoot();
6095 * @todo document this
6097 function action_pluginlist() {
6098 global $member, $manager;
6101 $member->isAdmin() or $this->disallow();
6105 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
6107 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
6109 echo '<h3>' , _PLUGS_TITLE_INSTALLED , ' <span style="font-size:smaller">', helplink('getplugins'), _PLUGS_TITLE_GETPLUGINS, '</a></span></h3>';
6112 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
6114 $template['content'] = 'pluginlist';
6115 $template['tabindex'] = 10;
6116 showlist($query, 'table', $template);
6119 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
6121 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
6123 <form method="post" action="index.php"><div>
6124 <input type="hidden" name="action" value="pluginupdate" />
6125 <?php $manager->addTicketHidden() ?>
6126 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
6129 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
6132 // find a list of possibly non-installed plugins
6133 $candidates = array();
6135 global $DIR_PLUGINS;
6137 $dirhandle = opendir($DIR_PLUGINS);
6139 while ($filename = readdir($dirhandle) )
6142 # replaced ereg() below with preg_match(). ereg* functions are deprecated in PHP 5.3.0
6143 # original ereg: ereg('^NP_(.*)\.php$',$filename,$matches)
6145 if (preg_match('#^NP_(.*)\.php$#', $filename, $matches) )
6148 $name = $matches[1];
6149 // only show in list when not yet installed
6150 $res = sql_query('SELECT * FROM ' . sql_table('plugin') . ' WHERE `pfile` = "NP_' . sql_real_escape_string($name) . '"');
6152 if (sql_num_rows($res) == 0)
6154 array_push($candidates, $name);
6161 closedir($dirhandle);
6163 if (sizeof($candidates) > 0)
6166 <p><?php echo _PLUGS_ADD_TEXT?></p>
6168 <form method='post' action='index.php'><div>
6169 <input type='hidden' name='action' value='pluginadd' />
6170 <?php $manager->addTicketHidden() ?>
6171 <select name="filename" tabindex="30">
6173 foreach($candidates as $name)
6175 echo '<option value="NP_',$name,'">',ENTITY::hsc($name),'</option>';
6179 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
6186 echo '<p>', _PLUGS_NOCANDIDATES, '</p>';
6194 * @todo document this
6196 function action_pluginhelp() {
6197 global $member, $manager, $DIR_PLUGINS, $CONF;
6200 $member->isAdmin() or $this->disallow();
6202 $plugid = intGetVar('plugid');
6204 if (!$manager->pidInstalled($plugid))
6205 $this->error(_ERROR_NOSUCHPLUGIN);
6207 $plugName = getPluginNameFromPid($plugid);
6211 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
6213 echo '<h2>',_PLUGS_HELP_TITLE,': ',ENTITY::hsc($plugName),'</h2>';
6215 $plug =& $manager->getPlugin($plugName);
6216 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
6218 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
6219 @readfile($helpFile);
6221 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
6222 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
6230 * ADMIN::action_pluginadd()
6236 function action_pluginadd()
6238 global $member, $manager, $DIR_PLUGINS;
6241 $member->isAdmin() or $this->disallow();
6243 $name = postVar('filename');
6245 if ( $manager->pluginInstalled($name) )
6247 $this->error(_ERROR_DUPPLUGIN);
6250 if ( !checkPlugin($name) )
6252 $this->error(_ERROR_PLUGFILEERROR . ' (' . ENTITY::hsc($name) . ')');
6255 // get number of currently installed plugins
6256 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6257 $numCurrent = sql_num_rows($res);
6259 // plugin will be added as last one in the list
6260 $newOrder = $numCurrent + 1;
6269 // do this before calling getPlugin (in case the plugin id is used there)
6270 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.sql_real_escape_string($name).'")';
6272 $iPid = sql_insert_id();
6274 $manager->clearCachedInfo('installedPlugins');
6276 // Load the plugin for condition checking and instalation
6277 $plugin =& $manager->getPlugin($name);
6279 // check if it got loaded (could have failed)
6282 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
6283 $manager->clearCachedInfo('installedPlugins');
6284 $this->error(_ERROR_PLUGIN_LOAD);
6287 // check if plugin needs a newer Nucleus version
6288 if ( getNucleusVersion() < $plugin->getMinNucleusVersion() )
6290 // uninstall plugin again...
6291 $this->deleteOnePlugin($plugin->getID());
6293 // ...and show error
6294 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc($plugin->getMinNucleusVersion()));
6297 // check if plugin needs a newer Nucleus version
6298 if ( (getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()) )
6300 // uninstall plugin again...
6301 $this->deleteOnePlugin($plugin->getID());
6303 // ...and show error
6304 $this->error(_ERROR_NUCLEUSVERSIONREQ . ENTITY::hsc( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
6307 $pluginList = $plugin->getPluginDep();
6308 foreach ( $pluginList as $pluginName )
6310 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
6311 if (sql_num_rows($res) == 0)
6313 // uninstall plugin again...
6314 $this->deleteOnePlugin($plugin->getID());
6315 $this->error(sprintf(_ERROR_INSREQPLUGIN, ENTITY::hsc($pluginName)));
6319 // call the install method of the plugin
6325 'plugin' => &$plugin
6329 // update all events
6330 $this->action_pluginupdate();
6335 * ADMIN:action_pluginupdate():
6341 function action_pluginupdate()
6343 global $member, $manager, $CONF;
6346 $member->isAdmin() or $this->disallow();
6348 // delete everything from plugin_events
6349 sql_query('DELETE FROM '.sql_table('plugin_event'));
6351 // loop over all installed plugins
6352 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
6353 while ( $o = sql_fetch_object($res) )
6356 $plug =& $manager->getPlugin($o->pfile);
6359 $eventList = $plug->getEventList();
6360 foreach ( $eventList as $eventName )
6362 $query = "INSERT INTO %s (pid, event) VALUES (%d, '%s')";
6363 $query = sprintf($query, sql_table('plugin_event'), (integer) $pid, sql_real_escape_string($eventName));
6368 redirect($CONF['AdminURL'] . '?action=pluginlist');
6373 * @todo document this
6375 function action_plugindelete() {
6376 global $member, $manager;
6379 $member->isAdmin() or $this->disallow();
6381 $pid = intGetVar('plugid');
6383 if (!$manager->pidInstalled($pid))
6384 $this->error(_ERROR_NOSUCHPLUGIN);
6388 <h2><?php echo _DELETE_CONFIRM?></h2>
6390 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
6392 <form method="post" action="index.php"><div>
6393 <?php $manager->addTicketHidden() ?>
6394 <input type="hidden" name="action" value="plugindeleteconfirm" />
6395 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
6396 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
6403 * @todo document this
6405 function action_plugindeleteconfirm() {
6406 global $member, $manager, $CONF;
6409 $member->isAdmin() or $this->disallow();
6411 $pid = intPostVar('plugid');
6413 $error = $this->deleteOnePlugin($pid, 1);
6415 $this->error($error);
6418 redirect($CONF['AdminURL'] . '?action=pluginlist');
6419 // $this->action_pluginlist();
6423 * @todo document this
6425 function deleteOnePlugin($pid, $callUninstall = 0) {
6428 $pid = intval($pid);
6430 if (!$manager->pidInstalled($pid))
6431 return _ERROR_NOSUCHPLUGIN;
6433 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
6435 /* // call the unInstall method of the plugin
6436 if ($callUninstall) {
6437 $plugin =& $manager->getPlugin($name);
6438 if ($plugin) $plugin->unInstall();
6441 // check dependency before delete
6442 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
6443 while($o = sql_fetch_object($res)) {
6444 $plug =& $manager->getPlugin($o->pfile);
6447 $depList = $plug->getPluginDep();
6448 foreach ($depList as $depName)
6450 if ($name == $depName)
6452 return sprintf(_ERROR_DELREQPLUGIN, $o->pfile);
6458 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
6460 // call the unInstall method of the plugin
6461 if ($callUninstall) {
6462 $plugin =& $manager->getPlugin($name);
6463 if ($plugin) $plugin->unInstall();
6466 // delete all subscriptions
6467 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
6469 // delete all options
6470 // get OIDs from plugin_option_desc
6471 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
6473 while ($o = sql_fetch_object($res)) {
6474 array_push($aOIDs, $o->oid);
6477 // delete from plugin_option and plugin_option_desc
6478 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6479 if (count($aOIDs) > 0)
6480 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6482 // update order numbers
6483 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6484 $o = sql_fetch_object($res);
6485 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6488 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6490 $manager->clearCachedInfo('installedPlugins');
6491 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6497 * @todo document this
6499 function action_pluginup() {
6500 global $member, $manager, $CONF;
6503 $member->isAdmin() or $this->disallow();
6505 $plugid = intGetVar('plugid');
6507 if (!$manager->pidInstalled($plugid))
6508 $this->error(_ERROR_NOSUCHPLUGIN);
6510 // 1. get old order number
6511 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6512 $o = sql_fetch_object($res);
6513 $oldOrder = $o->porder;
6515 // 2. calculate new order number
6516 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6518 // 3. update plug numbers
6519 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6520 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6522 //$this->action_pluginlist();
6523 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6524 redirect($CONF['AdminURL'] . '?action=pluginlist');
6528 * @todo document this
6530 function action_plugindown() {
6531 global $member, $manager, $CONF;
6534 $member->isAdmin() or $this->disallow();
6536 $plugid = intGetVar('plugid');
6537 if (!$manager->pidInstalled($plugid))
6538 $this->error(_ERROR_NOSUCHPLUGIN);
6540 // 1. get old order number
6541 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6542 $o = sql_fetch_object($res);
6543 $oldOrder = $o->porder;
6545 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6546 $maxOrder = sql_num_rows($res);
6548 // 2. calculate new order number
6549 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6551 // 3. update plug numbers
6552 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6553 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6555 //$this->action_pluginlist();
6556 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6557 redirect($CONF['AdminURL'] . '?action=pluginlist');
6561 * ADMIN::action_pluginoptions()
6563 * Output Plugin option page
6566 * @param string $message message when fallbacked
6570 public function action_pluginoptions($message = '')
6572 global $member, $manager;
6575 $member->isAdmin() or $this->disallow();
6577 $pid = (integer) requestVar('plugid');
6578 if ( !$manager->pidInstalled($pid) )
6580 $this->error(_ERROR_NOSUCHPLUGIN);
6583 $pname = getPluginNameFromPid($pid);
6585 /* just for including translation */
6586 $manager->getPlugin($pname);
6588 $extrahead = "<script type=\"text/javascript\" src=\"javascript/numbercheck.js\"></script>\n";
6589 $this->pagehead($extrahead);
6590 echo '<p><a href="index.php?action=pluginlist">(' . _PLUGS_BACK . ")</a></p>\n";
6591 echo '<h2>' . sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($pname)) . "</h2>\n";
6593 if ( isset($message) )
6598 echo "<form action=\"index.php\" method=\"post\">\n";
6600 echo "<input type=\"hidden\" name=\"action\" value=\"pluginoptionsupdate\" />\n";
6601 echo "<input type=\"hidden\" name=\"plugid\" value=\"{$pid}\" />\n";
6602 $manager->addTicketHidden();
6604 $aOptions = array();
6606 $query = "SELECT * FROM %s WHERE ocontext='global' and opid=%d ORDER BY oid ASC";
6607 $query = sprintf($query, sql_table('plugin_option_desc'), $pid);
6608 $result = sql_query($query);
6609 while ( $object = sql_fetch_object($result) )
6611 array_push($aOIDs, $object->oid);
6612 $aOptions[$object->oid] = array(
6613 'oid' => $object->oid,
6614 'value' => $object->odef,
6615 'name' => $object->oname,
6616 'description' => $object->odesc,
6617 'type' => $object->otype,
6618 'typeinfo' => $object->oextra,
6622 // fill out actual values
6623 if ( count($aOIDs) > 0 )
6625 $query = "SELECT oid, ovalue FROM %s WHERE oid in (%s)";
6626 $query = sprintf($query, sql_table('plugin_option'), implode(',',$aOIDs));
6627 $result = sql_query($query);
6628 while ( $object = sql_fetch_object($result) )
6630 $aOptions[$object->oid]['value'] = $object->ovalue;
6635 $data = array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions);
6636 $manager->notify('PrePluginOptionsEdit',$data);
6638 $template['content'] = 'plugoptionlist';
6639 $amount = showlist($aOptions,'table',$template);
6642 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6652 * ADMIN::action_pluginoptionsupdate()
6654 * Update plugin options and fallback to plugin option page
6660 public function action_pluginoptionsupdate()
6662 global $member, $manager;
6665 $member->isAdmin() or $this->disallow();
6667 $pid = (integer) requestVar('plugid');
6668 if ( !$manager->pidInstalled($pid) )
6670 $this->error(_ERROR_NOSUCHPLUGIN);
6673 $aOptions = requestArray('plugoption');
6674 NucleusPlugin::apply_plugin_options($aOptions);
6676 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6678 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6683 * ADMIN::_insertPluginOptions()
6685 * Output plugin option field
6688 * @param string $context plugin option context
6689 * @param integer $contextid plugin option context id
6692 public function _insertPluginOptions($context, $contextid = 0)
6694 // get all current values for this contextid
6695 // (note: this might contain doubles for overlapping contextids)
6696 $aIdToValue = array();
6697 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6698 while ( $object = sql_fetch_object($res) )
6700 $aIdToValue[$object->oid] = $object->ovalue;
6703 // get list of oids per pid
6704 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6705 . ' WHERE opid=pid and ocontext=\''.sql_real_escape_string($context).'\' ORDER BY porder, oid ASC';
6706 $res = sql_query($query);
6707 $aOptions = array();
6708 while ( $object = sql_fetch_object($res) )
6710 if (in_array($object->oid, array_keys($aIdToValue)))
6712 $value = $aIdToValue[$object->oid];
6716 $value = $object->odef;
6719 array_push($aOptions, array(
6720 'pid' => $object->pid,
6721 'pfile' => $object->pfile,
6722 'oid' => $object->oid,
6724 'name' => $object->oname,
6725 'description' => $object->odesc,
6726 'type' => $object->otype,
6727 'typeinfo' => $object->oextra,
6728 'contextid' => $contextid,
6733 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6736 foreach ($aOptions as $aOption)
6739 if ( $iPrevPid != $aOption['pid'] )
6741 $iPrevPid = $aOption['pid'];
6742 if ( !defined('_PLUGIN_OPTIONS_TITLE') )
6744 define('_PLUGIN_OPTIONS_TITLE', 'Options for %s');
6746 echo '<tr><th colspan="2">'.sprintf(_PLUGIN_OPTIONS_TITLE, ENTITY::hsc($aOption['pfile'])).'</th></tr>';
6749 $meta = NucleusPlugin::getOptionMeta($aOption['typeinfo']);
6750 if ( @$meta['access'] != 'hidden' )
6753 listplug_plugOptionRow($aOption);
6761 * ADMIN::input_yesno()
6762 * Output input elements with radio attribute for yes/no options
6764 * @param string $name name attribute
6765 * @param string $value_current current value attribute
6766 * @param integer $tabindex tab index
6767 * @param string $value_yes value attribute for yes option
6768 * @param string $value_no value attribute for no option
6769 * @param string $text_yes child text element for yes option
6770 * @param string $text_no child text element for no option
6771 * @param boolean $isAdmin have admin right or not
6774 function input_yesno($name, $value_current, $tabindex = 0, $value_yes = 1, $value_no = 0, $text_yes = _YES, $text_no = _NO, $isAdmin = 0)
6776 $id = preg_replace('#\[|\]#', '-', $name);
6777 $id_yes = $id . $value_yes;
6778 $id_no = $id . $value_no;
6781 echo '<input type="radio" id="' . ENTITY::hsc($id_yes) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_yes) . '"';
6782 if ( $name=="admin" )
6784 echo ' onclick="selectCanLogin(true);"';
6786 if ( $value_current == $value_yes )
6788 echo " tabindex='$tabindex' checked='checked'";
6791 echo '<label for="' . ENTITY::hsc($id_yes) . '">' . ENTITY::hsc($text_yes) . "</label>\n";
6794 echo '<input type="radio" id="' . ENTITY::hsc($id_no) . '" name="' . ENTITY::hsc($name) . '" value="' . ENTITY::hsc($value_no) . '"';
6795 if ( $name=="admin" )
6797 echo ' onclick="selectCanLogin(false);"';
6799 if ( $value_current != $value_yes )
6801 echo " tabindex='$tabindex' checked='checked'";
6803 if ($isAdmin && $name=="canlogin")
6805 echo ' disabled="disabled"';
6808 echo '<label for="' . ENTITY::hsc($id_no) . '">' . ENTITY::hsc($text_no) . "</label>\n";