3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
4 * Copyright (C) 2002-2007 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-2007 The Nucleus Group
17 * @version $Id: ADMIN.php,v 1.24 2008-02-08 09:31:22 kimitake Exp $
18 * @version $NucleusJP: ADMIN.php,v 1.21.2.4 2007/10/30 19:04:24 kmorimatsu Exp $
21 if ( !function_exists('requestVar') ) exit;
22 require_once dirname(__FILE__) . '/showlist.php';
25 * Builds the admin area and executes admin actions
30 * @var string $action action currently being executed ($action=xxxx -> action_xxxx method)
44 * @param string $action action to be performed
46 function action($action) {
47 global $CONF, $manager;
49 // list of action aliases
51 'login' => 'overview',
55 if (isset($alias[$action]))
56 $action = $alias[$action];
58 $methodName = 'action_' . $action;
60 $this->action = strtolower($action);
62 // check ticket. All actions need a ticket, unless they are considered to be safe (a safe action
63 // is an action that requires user interaction before something is actually done)
64 // all safe actions are in this array:
65 $aActionsNotToCheck = array('showlogin', 'login', 'overview', 'itemlist', 'blogcommentlist', 'bookmarklet', 'blogsettings', 'banlist', 'deleteblog', 'editmembersettings', 'browseownitems', 'browseowncomments', 'createitem', 'itemedit', 'itemmove', 'categoryedit', 'categorydelete', 'manage', 'actionlog', 'settingsedit', 'backupoverview', 'pluginlist', 'createnewlog', 'usermanagement', 'skinoverview', 'templateoverview', 'skinieoverview', 'itemcommentlist', 'commentedit', 'commentdelete', 'banlistnewfromitem', 'banlistdelete', 'itemdelete', 'manageteam', 'teamdelete', 'banlistnew', 'memberedit', 'memberdelete', 'pluginhelp', 'pluginoptions', 'plugindelete', 'skinedittype', 'skinremovetype', 'skindelete', 'skinedit', 'templateedit', 'templatedelete', 'activate');
67 // the rest of the actions needs to be checked
68 $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', 'sendping', 'rawping', 'activatesetpwd');
70 if (!in_array($this->action, $aActionsNotToCheck))
72 if (!$manager->checkTicket())
73 $this->error(_ERROR_BADTICKET);
76 if (method_exists($this, $methodName))
77 call_user_func(array(&$this, $methodName));
79 $this->error(_BADACTION . htmlspecialchars(" ($action)"));
86 function action_showlogin() {
88 $this->action_login($error);
94 function action_login($msg = '', $passvars = 1) {
97 // skip to overview when allowed
98 if ($member->isLoggedIn() && $member->canLogin()) {
99 $this->action_overview();
105 echo '<h2>', _LOGIN ,'</h2>';
106 if ($msg) echo _MESSAGE , ': ', htmlspecialchars($msg);
109 <form action="index.php" method="post"><p>
110 <?php echo _LOGIN_NAME?>: <br /><input name="login" tabindex="10" />
112 <?php echo _LOGIN_PASSWORD?>: <br /><input name="password" tabindex="20" type="password" />
114 <input name="action" value="login" type="hidden" />
116 <input type="submit" value="<?php echo _LOGIN?>" tabindex="30" />
119 <input type="checkbox" value="1" name="shared" tabindex="40" id="shared" /><label for="shared"><?php echo _LOGIN_SHARED?></label>
120 <br /><a href="forgotpassword.html"><?php echo _LOGIN_FORGOT?></a>
122 <?php // pass through vars
124 $oldaction = postVar('oldaction');
125 if ( ($oldaction != 'logout') && ($oldaction != 'login') && $passvars ) {
132 <?php $this->pagefoot();
137 * provides a screen with the overview of the actions available
138 * @todo document parameter
140 function action_overview($msg = '') {
146 echo _MESSAGE , ': ', $msg;
148 /* ---- add items ---- */
149 echo '<h2>' . _OVERVIEW_YRBLOGS . '</h2>';
151 $showAll = requestVar('showall');
153 if (($member->isAdmin()) && ($showAll == 'yes')) {
154 // Super-Admins have access to all blogs! (no add item support though)
155 $query = 'SELECT bnumber, bname, 1 as tadmin, burl, bshortname'
156 . ' FROM ' . sql_table('blog')
159 $query = 'SELECT bnumber, bname, tadmin, burl, bshortname'
160 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
161 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
164 $template['content'] = 'bloglist';
165 $template['superadmin'] = $member->isAdmin();
166 $amount = showlist($query,'table',$template);
168 if (($showAll != 'yes') && ($member->isAdmin())) {
169 $total = quickQuery('SELECT COUNT(*) as result FROM ' . sql_table('blog'));
170 if ($total > $amount)
171 echo '<p><a href="index.php?action=overview&showall=yes">Show all blogs</a></p>';
175 echo _OVERVIEW_NOBLOGS;
178 echo '<h2>' . _OVERVIEW_YRDRAFTS . '</h2>';
179 $query = 'SELECT ititle, inumber, bshortname'
180 . ' FROM ' . sql_table('item'). ', ' . sql_table('blog')
181 . ' WHERE iauthor='.$member->getID().' and iblog=bnumber and idraft=1';
182 $template['content'] = 'draftlist';
183 $amountdrafts = showlist($query, 'table', $template);
184 if ($amountdrafts == 0)
185 echo _OVERVIEW_NODRAFTS;
188 /* ---- user settings ---- */
189 echo '<h2>' . _OVERVIEW_YRSETTINGS . '</h2>';
191 echo '<li><a href="index.php?action=editmembersettings">' . _OVERVIEW_EDITSETTINGS. '</a></li>';
192 echo '<li><a href="index.php?action=browseownitems">' . _OVERVIEW_BROWSEITEMS.'</a></li>';
193 echo '<li><a href="index.php?action=browseowncomments">'._OVERVIEW_BROWSECOMM.'</a></li>';
196 /* ---- general settings ---- */
197 if ($member->isAdmin()) {
198 echo '<h2>' . _OVERVIEW_MANAGEMENT. '</h2>';
200 echo '<li><a href="index.php?action=manage">',_OVERVIEW_MANAGE,'</a></li>';
209 * Returns a link to a weblog
212 function bloglink(&$blog) {
213 return '<a href="'.htmlspecialchars($blog->getURL()).'" title="'._BLOGLIST_TT_VISIT.'">'. htmlspecialchars( $blog->getName() ) .'</a>';
217 * @todo document this
219 function action_manage($msg = '') {
222 $member->isAdmin() or $this->disallow();
226 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
229 echo '<p>' , _MESSAGE , ': ', $msg , '</p>';
232 echo '<h2>' . _MANAGE_GENERAL. '</h2>';
235 echo '<li><a href="index.php?action=createnewlog">'._OVERVIEW_NEWLOG.'</a></li>';
236 echo '<li><a href="index.php?action=settingsedit">'._OVERVIEW_SETTINGS.'</a></li>';
237 echo '<li><a href="index.php?action=usermanagement">'._OVERVIEW_MEMBERS.'</a></li>';
238 echo '<li><a href="index.php?action=actionlog">'._OVERVIEW_VIEWLOG.'</a></li>';
241 echo '<h2>' . _MANAGE_SKINS . '</h2>';
243 echo '<li><a href="index.php?action=skinoverview">'._OVERVIEW_SKINS.'</a></li>';
244 echo '<li><a href="index.php?action=templateoverview">'._OVERVIEW_TEMPLATES.'</a></li>';
245 echo '<li><a href="index.php?action=skinieoverview">'._OVERVIEW_SKINIMPORT.'</a></li>';
248 echo '<h2>' . _MANAGE_EXTRA . '</h2>';
250 echo '<li><a href="index.php?action=backupoverview">'._OVERVIEW_BACKUP.'</a></li>';
251 echo '<li><a href="index.php?action=pluginlist">'._OVERVIEW_PLUGINS.'</a></li>';
258 * @todo document this
260 function action_itemlist($blogid = '') {
261 global $member, $manager;
264 $blogid = intRequestVar('blogid');
266 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
269 $blog =& $manager->getBlog($blogid);
271 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
272 echo '<h2>' . _ITEMLIST_BLOG . ' ' . $this->bloglink($blog) . '</h2>';
275 if (postVar('start'))
276 $start = intPostVar('start');
281 echo '<p><a href="index.php?action=createitem&blogid='.$blogid.'">',_ITEMLIST_ADDNEW,'</a></p>';
283 // amount of items to show
284 if (postVar('amount'))
285 $amount = intPostVar('amount');
289 $search = postVar('search'); // search through items
291 $query = 'SELECT bshortname, cname, mname, ititle, ibody, inumber, idraft, itime'
292 . ' FROM ' . sql_table('item') . ', ' . sql_table('blog') . ', ' . sql_table('member') . ', ' . sql_table('category')
293 . ' WHERE iblog=bnumber and iauthor=mnumber and icat=catid and iblog=' . $blogid;
296 $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
298 // non-blog-admins can only edit/delete their own items
299 if (!$member->blogAdminRights($blogid))
300 $query .= ' and iauthor=' . $member->getID();
303 $query .= ' ORDER BY itime DESC'
304 . " LIMIT $start,$amount";
306 $template['content'] = 'itemlist';
307 $template['now'] = $blog->getCorrectTime(time());
309 $manager->loadClass("ENCAPSULATE");
310 $navList =& new NAVLIST('itemlist', $start, $amount, 0, 1000, $blogid, $search, 0);
311 $navList->showBatchList('item',$query,'table',$template);
318 * @todo document this
320 function action_batchitem() {
321 global $member, $manager;
323 // check if logged in
324 $member->isLoggedIn() or $this->disallow();
326 // more precise check will be done for each performed operation
328 // get array of itemids from request
329 $selected = requestIntArray('batch');
330 $action = requestVar('batchaction');
332 // Show error when no items were selected
333 if (!is_array($selected) || sizeof($selected) == 0)
334 $this->error(_BATCH_NOSELECTION);
336 // On move: when no destination blog/category chosen, show choice now
337 $destCatid = intRequestVar('destcatid');
338 if (($action == 'move') && (!$manager->existsCategory($destCatid)))
339 $this->batchMoveSelectDestination('item',$selected);
341 // On delete: check if confirmation has been given
342 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
343 $this->batchAskDeleteConfirmation('item',$selected);
347 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
348 echo '<h2>',_BATCH_ITEMS,'</h2>';
349 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
353 // walk over all itemids and perform action
354 foreach ($selected as $itemid) {
355 $itemid = intval($itemid);
356 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONITEM,' <b>', $itemid, '</b>...';
358 // perform action, display errors if needed
361 $error = $this->deleteOneItem($itemid);
364 $error = $this->moveOneItem($itemid, $destCatid);
367 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
370 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
375 echo '<b>',_BATCH_DONE,'</b>';
383 * @todo document this
385 function action_batchcomment() {
388 // check if logged in
389 $member->isLoggedIn() or $this->disallow();
391 // more precise check will be done for each performed operation
393 // get array of itemids from request
394 $selected = requestIntArray('batch');
395 $action = requestVar('batchaction');
397 // Show error when no items were selected
398 if (!is_array($selected) || sizeof($selected) == 0)
399 $this->error(_BATCH_NOSELECTION);
401 // On delete: check if confirmation has been given
402 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
403 $this->batchAskDeleteConfirmation('comment',$selected);
407 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
408 echo '<h2>',_BATCH_COMMENTS,'</h2>';
409 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
412 // walk over all itemids and perform action
413 foreach ($selected as $commentid) {
414 $commentid = intval($commentid);
415 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCOMMENT,' <b>', $commentid, '</b>...';
417 // perform action, display errors if needed
420 $error = $this->deleteOneComment($commentid);
423 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
426 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
431 echo '<b>',_BATCH_DONE,'</b>';
439 * @todo document this
441 function action_batchmember() {
444 // check if logged in and admin
445 ($member->isLoggedIn() && $member->isAdmin()) or $this->disallow();
447 // get array of itemids from request
448 $selected = requestIntArray('batch');
449 $action = requestVar('batchaction');
451 // Show error when no members selected
452 if (!is_array($selected) || sizeof($selected) == 0)
453 $this->error(_BATCH_NOSELECTION);
455 // On delete: check if confirmation has been given
456 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
457 $this->batchAskDeleteConfirmation('member',$selected);
461 echo '<a href="index.php?action=usermanagement">(',_MEMBERS_BACKTOOVERVIEW,')</a>';
462 echo '<h2>',_BATCH_MEMBERS,'</h2>';
463 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
466 // walk over all itemids and perform action
467 foreach ($selected as $memberid) {
468 $memberid = intval($memberid);
469 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONMEMBER,' <b>', $memberid, '</b>...';
471 // perform action, display errors if needed
474 $error = $this->deleteOneMember($memberid);
478 sql_query('UPDATE ' . sql_table('member') . ' SET madmin=1 WHERE mnumber='.$memberid);
482 // there should always remain at least one super-admin
483 $r = sql_query('SELECT * FROM '.sql_table('member'). ' WHERE madmin=1 and mcanlogin=1');
484 if (mysql_num_rows($r) < 2)
485 $error = _ERROR_ATLEASTONEADMIN;
487 sql_query('UPDATE ' . sql_table('member') .' SET madmin=0 WHERE mnumber='.$memberid);
490 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
493 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
498 echo '<b>',_BATCH_DONE,'</b>';
506 * @todo document this
508 function action_batchteam() {
511 $blogid = intRequestVar('blogid');
513 // check if logged in and admin
514 ($member->isLoggedIn() && $member->blogAdminRights($blogid)) or $this->disallow();
516 // get array of itemids from request
517 $selected = requestIntArray('batch');
518 $action = requestVar('batchaction');
520 // Show error when no members selected
521 if (!is_array($selected) || sizeof($selected) == 0)
522 $this->error(_BATCH_NOSELECTION);
524 // On delete: check if confirmation has been given
525 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
526 $this->batchAskDeleteConfirmation('team',$selected);
530 echo '<p><a href="index.php?action=manageteam&blogid=',$blogid,'">(',_BACK,')</a></p>';
532 echo '<h2>',_BATCH_TEAM,'</h2>';
533 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
536 // walk over all itemids and perform action
537 foreach ($selected as $memberid) {
538 $memberid = intval($memberid);
539 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONTEAM,' <b>', $memberid, '</b>...';
541 // perform action, display errors if needed
544 $error = $this->deleteOneTeamMember($blogid, $memberid);
548 sql_query('UPDATE '.sql_table('team').' SET tadmin=1 WHERE tblog='.$blogid.' and tmember='.$memberid);
552 // there should always remain at least one admin
553 $r = sql_query('SELECT * FROM '.sql_table('team').' WHERE tadmin=1 and tblog='.$blogid);
554 if (mysql_num_rows($r) < 2)
555 $error = _ERROR_ATLEASTONEBLOGADMIN;
557 sql_query('UPDATE '.sql_table('team').' SET tadmin=0 WHERE tblog='.$blogid.' and tmember='.$memberid);
560 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
563 echo '<b>',($error ? $error : _BATCH_SUCCESS),'</b>';
568 echo '<b>',_BATCH_DONE,'</b>';
576 * @todo document this
578 function action_batchcategory() {
579 global $member, $manager;
581 // check if logged in
582 $member->isLoggedIn() or $this->disallow();
584 // more precise check will be done for each performed operation
586 // get array of itemids from request
587 $selected = requestIntArray('batch');
588 $action = requestVar('batchaction');
590 // Show error when no items were selected
591 if (!is_array($selected) || sizeof($selected) == 0)
592 $this->error(_BATCH_NOSELECTION);
594 // On move: when no destination blog chosen, show choice now
595 $destBlogId = intRequestVar('destblogid');
596 if (($action == 'move') && (!$manager->existsBlogID($destBlogId)))
597 $this->batchMoveCategorySelectDestination('category',$selected);
599 // On delete: check if confirmation has been given
600 if (($action == 'delete') && (requestVar('confirmation') != 'yes'))
601 $this->batchAskDeleteConfirmation('category',$selected);
605 echo '<a href="index.php?action=overview">(',_BACKHOME,')</a>';
606 echo '<h2>',BATCH_CATEGORIES,'</h2>';
607 echo '<p>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b></p>';
610 // walk over all itemids and perform action
611 foreach ($selected as $catid) {
612 $catid = intval($catid);
613 echo '<li>',_BATCH_EXECUTING,' <b>',htmlspecialchars($action),'</b> ',_BATCH_ONCATEGORY,' <b>', $catid, '</b>...';
615 // perform action, display errors if needed
618 $error = $this->deleteOneCategory($catid);
621 $error = $this->moveOneCategory($catid, $destBlogId);
624 $error = _BATCH_UNKNOWN . htmlspecialchars($action);
627 echo '<b>',($error ? 'Error: '.$error : _BATCH_SUCCESS),'</b>';
632 echo '<b>',_BATCH_DONE,'</b>';
639 * @todo document this
641 function batchMoveSelectDestination($type, $ids) {
645 <h2><?php echo _MOVE_TITLE?></h2>
646 <form method="post" action="index.php"><div>
648 <input type="hidden" name="action" value="batch<?php echo $type?>" />
649 <input type="hidden" name="batchaction" value="move" />
651 $manager->addTicketHidden();
653 // insert selected item numbers
655 foreach ($ids as $id)
656 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
658 // show blog/category selection list
659 $this->selectBlogCategory('destcatid');
664 <input type="submit" value="<?php echo _MOVE_BTN?>" onclick="return checkSubmit();" />
667 <?php $this->pagefoot();
672 * @todo document this
674 function batchMoveCategorySelectDestination($type, $ids) {
678 <h2><?php echo _MOVECAT_TITLE?></h2>
679 <form method="post" action="index.php"><div>
681 <input type="hidden" name="action" value="batch<?php echo $type?>" />
682 <input type="hidden" name="batchaction" value="move" />
684 $manager->addTicketHidden();
686 // insert selected item numbers
688 foreach ($ids as $id)
689 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
691 // show blog/category selection list
692 $this->selectBlog('destblogid');
697 <input type="submit" value="<?php echo _MOVECAT_BTN?>" onclick="return checkSubmit();" />
700 <?php $this->pagefoot();
705 * @todo document this
707 function batchAskDeleteConfirmation($type, $ids) {
712 <h2><?php echo _BATCH_DELETE_CONFIRM?></h2>
713 <form method="post" action="index.php"><div>
715 <input type="hidden" name="action" value="batch<?php echo $type?>" />
716 <?php $manager->addTicketHidden() ?>
717 <input type="hidden" name="batchaction" value="delete" />
718 <input type="hidden" name="confirmation" value="yes" />
719 <?php // insert selected item numbers
721 foreach ($ids as $id)
722 echo '<input type="hidden" name="batch[',($idx++),']" value="',intval($id),'" />';
724 // add hidden vars for team & comment
727 echo '<input type="hidden" name="blogid" value="',intRequestVar('blogid'),'" />';
729 if ($type == 'comment')
731 echo '<input type="hidden" name="itemid" value="',intRequestVar('itemid'),'" />';
736 <input type="submit" value="<?php echo _BATCH_DELETE_CONFIRM_BTN?>" onclick="return checkSubmit();" />
739 <?php $this->pagefoot();
745 * Inserts a HTML select element with choices for all categories to which the current
747 * @see function selectBlog
749 function selectBlogCategory($name, $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
750 ADMIN::selectBlog($name, 'category', $selected, $tabindex, $showNewCat, $iForcedBlogInclude);
754 * Inserts a HTML select element with choices for all blogs to which the user has access
755 * mode = 'blog' => shows blognames and values are blogids
756 * mode = 'category' => show category names and values are catids
758 * @param $iForcedBlogInclude
759 * ID of a blog that always needs to be included, without checking if the
760 * member is on the blog team (-1 = none)
761 * @todo document parameters
763 function selectBlog($name, $mode='blog', $selected = 0, $tabindex = 0, $showNewCat = 0, $iForcedBlogInclude = -1) {
764 global $member, $CONF;
766 // 0. get IDs of blogs to which member can post items (+ forced blog)
768 if ($iForcedBlogInclude != -1)
769 $aBlogIds[] = intval($iForcedBlogInclude);
771 if (($member->isAdmin()) && ($CONF['ShowAllBlogs']))
772 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').' ORDER BY bname';
774 $queryBlogs = 'SELECT bnumber FROM '.sql_table('blog').', '.sql_table('team').' WHERE tblog=bnumber and tmember=' . $member->getID();
775 $rblogids = sql_query($queryBlogs);
776 while ($o = mysql_fetch_object($rblogids))
777 if ($o->bnumber != $iForcedBlogInclude)
778 $aBlogIds[] = intval($o->bnumber);
780 if (count($aBlogIds) == 0)
783 echo '<select name="',$name,'" tabindex="',$tabindex,'">';
785 // 1. select blogs (we'll create optiongroups)
786 // (only select those blogs that have the user on the team)
787 $queryBlogs = 'SELECT bnumber, bname FROM '.sql_table('blog').' WHERE bnumber in ('.implode(',',$aBlogIds).') ORDER BY bname';
788 $blogs = sql_query($queryBlogs);
789 if ($mode == 'category') {
790 if (mysql_num_rows($blogs) > 1)
793 while ($oBlog = mysql_fetch_object($blogs)) {
795 echo '<optgroup label="',htmlspecialchars($oBlog->bname),'">';
797 // show selection to create new category when allowed/wanted
799 // check if allowed to do so
800 if ($member->blogAdminRights($oBlog->bnumber))
801 echo '<option value="newcat-',$oBlog->bnumber,'">',_ADD_NEWCAT,'</option>';
804 // 2. for each category in that blog
805 $categories = sql_query('SELECT cname, catid FROM '.sql_table('category').' WHERE cblog=' . $oBlog->bnumber . ' ORDER BY cname ASC');
806 while ($oCat = mysql_fetch_object($categories)) {
807 if ($oCat->catid == $selected)
808 $selectText = ' selected="selected" ';
811 echo '<option value="',$oCat->catid,'" ', $selectText,'>',htmlspecialchars($oCat->cname),'</option>';
819 while ($oBlog = mysql_fetch_object($blogs)) {
820 echo '<option value="',$oBlog->bnumber,'"';
821 if ($oBlog->bnumber == $selected)
822 echo ' selected="selected"';
823 echo'>',htmlspecialchars($oBlog->bname),'</option>';
831 * @todo document this
833 function action_browseownitems() {
834 global $member, $manager;
838 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
839 echo '<h2>' . _ITEMLIST_YOUR. '</h2>';
842 if (postVar('start'))
843 $start = intPostVar('start');
847 // amount of items to show
848 if (postVar('amount'))
849 $amount = intPostVar('amount');
853 $search = postVar('search'); // search through items
855 $query = 'SELECT bshortname, cname, mname, ititle, ibody, idraft, inumber, itime'
856 . ' FROM '.sql_table('item').', '.sql_table('blog') . ', '.sql_table('member') . ', '.sql_table('category')
857 . ' WHERE iauthor='. $member->getID() .' and iauthor=mnumber and iblog=bnumber and icat=catid';
860 $query .= ' and ((ititle LIKE "%' . addslashes($search) . '%") or (ibody LIKE "%' . addslashes($search) . '%") or (imore LIKE "%' . addslashes($search) . '%"))';
862 $query .= ' ORDER BY itime DESC'
863 . " LIMIT $start,$amount";
865 $template['content'] = 'itemlist';
866 $template['now'] = time();
868 $manager->loadClass("ENCAPSULATE");
869 $navList =& new NAVLIST('browseownitems', $start, $amount, 0, 1000, /*$blogid*/ 0, $search, 0);
870 $navList->showBatchList('item',$query,'table',$template);
877 * Show all the comments for a given item
880 function action_itemcommentlist($itemid = '') {
881 global $member, $manager;
884 $itemid = intRequestVar('itemid');
886 // only allow if user is allowed to alter item
887 $member->canAlterItem($itemid) or $this->disallow();
889 $blogid = getBlogIdFromItemId($itemid);
894 if (postVar('start'))
895 $start = intPostVar('start');
899 // amount of items to show
900 if (postVar('amount'))
901 $amount = intPostVar('amount');
905 $search = postVar('search');
907 echo '<p>(<a href="index.php?action=itemlist&blogid=',$blogid,'">',_BACKTOOVERVIEW,'</a>)</p>';
908 echo '<h2>',_COMMENTS,'</h2>';
910 $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 citem=' . $itemid;
913 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
915 $query .= ' ORDER BY ctime ASC'
916 . " LIMIT $start,$amount";
918 $template['content'] = 'commentlist';
919 $template['canAddBan'] = $member->blogAdminRights(getBlogIDFromItemID($itemid));
921 $manager->loadClass("ENCAPSULATE");
922 $navList =& new NAVLIST('itemcommentlist', $start, $amount, 0, 1000, 0, $search, $itemid);
923 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS);
929 * Browse own comments
931 function action_browseowncomments() {
932 global $member, $manager;
935 if (postVar('start'))
936 $start = intPostVar('start');
940 // amount of items to show
941 if (postVar('amount'))
942 $amount = intPostVar('amount');
946 $search = postVar('search');
949 $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();
952 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
954 $query .= ' ORDER BY ctime DESC'
955 . " LIMIT $start,$amount";
959 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
960 echo '<h2>', _COMMENTS_YOUR ,'</h2>';
962 $template['content'] = 'commentlist';
963 $template['canAddBan'] = 0; // doesn't make sense to allow banning yourself
965 $manager->loadClass("ENCAPSULATE");
966 $navList =& new NAVLIST('browseowncomments', $start, $amount, 0, 1000, 0, $search, 0);
967 $navList->showBatchList('comment',$query,'table',$template,_NOCOMMENTS_YOUR);
973 * Browse all comments for a weblog
976 function action_blogcommentlist($blogid = '')
978 global $member, $manager;
981 $blogid = intRequestVar('blogid');
983 $blogid = intval($blogid);
985 $member->teamRights($blogid) or $member->isAdmin() or $this->disallow();
988 if (postVar('start'))
989 $start = intPostVar('start');
993 // amount of items to show
994 if (postVar('amount'))
995 $amount = intPostVar('amount');
999 $search = postVar('search'); // search through comments
1002 $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);
1005 $query .= ' and cbody LIKE "%' . addslashes($search) . '%"';
1008 $query .= ' ORDER BY ctime DESC'
1009 . " LIMIT $start,$amount";
1012 $blog =& $manager->getBlog($blogid);
1016 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
1017 echo '<h2>', _COMMENTS_BLOG , ' ' , $this->bloglink($blog), '</h2>';
1019 $template['content'] = 'commentlist';
1020 $template['canAddBan'] = $member->blogAdminRights($blogid);
1022 $manager->loadClass("ENCAPSULATE");
1023 $navList =& new NAVLIST('blogcommentlist', $start, $amount, 0, 1000, $blogid, $search, 0);
1024 $navList->showBatchList('comment',$query,'table',$template, _NOCOMMENTS_BLOG);
1030 * Provide a page to item a new item to the given blog
1032 function action_createitem() {
1033 global $member, $manager;
1035 $blogid = intRequestVar('blogid');
1038 $member->teamRights($blogid) or $this->disallow();
1040 $memberid = $member->getID();
1042 $blog =& $manager->getBlog($blogid);
1046 // generate the add-item form
1047 $formfactory =& new PAGEFACTORY($blogid);
1048 $formfactory->createAddForm('admin');
1054 * @todo document this
1056 function action_itemedit() {
1057 global $member, $manager;
1059 $itemid = intRequestVar('itemid');
1061 // only allow if user is allowed to alter item
1062 $member->canAlterItem($itemid) or $this->disallow();
1064 $item =& $manager->getItem($itemid,1,1);
1065 $blog =& $manager->getBlog(getBlogIDFromItemID($itemid));
1067 $manager->notify('PrepareItemForEdit', array('item' => &$item));
1069 if ($blog->convertBreaks()) {
1070 $item['body'] = removeBreaks($item['body']);
1071 $item['more'] = removeBreaks($item['more']);
1074 // form to edit blog items
1076 $formfactory =& new PAGEFACTORY($blog->getID());
1077 $formfactory->createEditForm('admin',$item);
1082 * @todo document this
1084 function action_itemupdate() {
1085 global $member, $manager, $CONF;
1087 $itemid = intRequestVar('itemid');
1088 $catid = postVar('catid');
1090 // only allow if user is allowed to alter item
1091 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1093 $actiontype = postVar('actiontype');
1095 // delete actions are handled by itemdelete (which has confirmation)
1096 if ($actiontype == 'delete') {
1097 $this->action_itemdelete();
1101 $body = postVar('body');
1102 $title = postVar('title');
1103 $more = postVar('more');
1104 $closed = intPostVar('closed');
1105 $draftid = intPostVar('draftid');
1107 // default action = add now
1109 $actiontype='addnow';
1111 // create new category if needed
1112 if (strstr($catid,'newcat')) {
1114 list($blogid) = sscanf($catid,"newcat-%d");
1117 $blog =& $manager->getBlog($blogid);
1118 $catid = $blog->createNewCategory();
1120 // show error when sth goes wrong
1122 $this->doError(_ERROR_CATCREATEFAIL);
1126 set some variables based on actiontype
1129 draft items -> addnow, addfuture, adddraft, delete
1130 non-draft items -> edit, changedate, delete
1133 $timestamp: set to a nonzero value for future dates or date changes
1134 $wasdraft: set to 1 when the item used to be a draft item
1135 $publish: set to 1 when the edited item is not a draft
1137 switch ($actiontype) {
1146 $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
1154 $timestamp = mktime(postVar('hour'), postVar('minutes'), 0, postVar('month'), postVar('day'), postVar('year'));
1165 // edit the item for real
1166 ITEM::update($itemid, $catid, $title, $body, $more, $closed, $wasdraft, $publish, $timestamp);
1168 $blogid = getBlogIDFromItemID($itemid);
1169 $blog =& $manager->getBlog($blogid);
1172 if ($timestamp > $blog->getCorrectTime(time())) {
1176 $this->updateFuturePosted($blogid);
1178 if ($draftid > 0 && $member->canAlterItem($draftid)) {
1179 ITEM::delete($draftid);
1182 if (!$closed && $publish && $wasdraft && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 && !$isFuture) {
1183 $this->action_sendping($blogid);
1187 // show category edit window when we created a new category
1188 // ($catid will then be a new category ID, while postVar('catid') will be 'newcat-x')
1189 if ($catid != intPostVar('catid')) {
1190 $this->action_categoryedit(
1193 $CONF['AdminURL'] . 'index.php?action=itemlist&blogid=' . getBlogIDFromItemID($itemid)
1196 // TODO: set start item correctly for itemlist
1197 $this->action_itemlist(getBlogIDFromItemID($itemid));
1202 * @todo document this
1204 function action_itemdelete() {
1205 global $member, $manager;
1207 $itemid = intRequestVar('itemid');
1209 // only allow if user is allowed to alter item
1210 $member->canAlterItem($itemid) or $this->disallow();
1212 if (!$manager->existsItem($itemid,1,1))
1213 $this->error(_ERROR_NOSUCHITEM);
1215 $item =& $manager->getItem($itemid,1,1);
1216 $title = htmlspecialchars(strip_tags($item['title']));
1217 $body = strip_tags($item['body']);
1218 $body = htmlspecialchars(shorten($body,300,'...'));
1222 <h2><?php echo _DELETE_CONFIRM?></h2>
1224 <p><?php echo _CONFIRMTXT_ITEM?></p>
1227 <b>"<?php echo $title ?>"</b>
1232 <form method="post" action="index.php"><div>
1233 <input type="hidden" name="action" value="itemdeleteconfirm" />
1234 <?php $manager->addTicketHidden() ?>
1235 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1236 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" tabindex="10" />
1243 * @todo document this
1245 function action_itemdeleteconfirm() {
1248 $itemid = intRequestVar('itemid');
1250 // only allow if user is allowed to alter item
1251 $member->canAlterItem($itemid) or $this->disallow();
1254 $blogid = getBlogIdFromItemId($itemid);
1256 // delete item (note: some checks will be performed twice)
1257 $this->deleteOneItem($itemid);
1259 $this->action_itemlist($blogid);
1263 * Deletes one item and returns error if something goes wrong
1264 * @param int $itemid
1266 function deleteOneItem($itemid) {
1267 global $member, $manager;
1269 // only allow if user is allowed to alter item (also checks if itemid exists)
1270 if (!$member->canAlterItem($itemid))
1271 return _ERROR_DISALLOWED;
1273 // need to get blogid before the item is deleted
1274 $blogid = getBlogIDFromItemId($itemid);
1276 $manager->loadClass('ITEM');
1277 ITEM::delete($itemid);
1279 // update blog's futureposted
1280 $this->updateFuturePosted($blogid);
1284 * Update a blog's future posted flag
1285 * @param int $blogid
1287 function updateFuturePosted($blogid) {
1290 $blog =& $manager->getBlog($blogid);
1291 $currenttime = $blog->getCorrectTime(time());
1292 $result = sql_query("SELECT * FROM ".sql_table('item').
1293 " WHERE iblog='".$blogid."' AND iposted=0 AND itime>".mysqldate($currenttime));
1294 if (mysql_num_rows($result) > 0) {
1295 $blog->setFuturePost();
1298 $blog->clearFuturePost();
1303 * @todo document this
1305 function action_itemmove() {
1306 global $member, $manager;
1308 $itemid = intRequestVar('itemid');
1310 // only allow if user is allowed to alter item
1311 $member->canAlterItem($itemid) or $this->disallow();
1313 $item =& $manager->getItem($itemid,1,1);
1317 <h2><?php echo _MOVE_TITLE?></h2>
1318 <form method="post" action="index.php"><div>
1319 <input type="hidden" name="action" value="itemmoveto" />
1320 <input type="hidden" name="itemid" value="<?php echo $itemid; ?>" />
1324 $manager->addTicketHidden();
1325 $this->selectBlogCategory('catid',$item['catid'],10,1);
1328 <input type="submit" value="<?php echo _MOVE_BTN?>" tabindex="10000" onclick="return checkSubmit();" />
1335 * @todo document this
1337 function action_itemmoveto() {
1338 global $member, $manager;
1340 $itemid = intRequestVar('itemid');
1341 $catid = requestVar('catid');
1343 // create new category if needed
1344 if (strstr($catid,'newcat')) {
1346 list($blogid) = sscanf($catid,'newcat-%d');
1349 $blog =& $manager->getBlog($blogid);
1350 $catid = $blog->createNewCategory();
1352 // show error when sth goes wrong
1354 $this->doError(_ERROR_CATCREATEFAIL);
1357 // only allow if user is allowed to alter item
1358 $member->canUpdateItem($itemid, $catid) or $this->disallow();
1360 $old_blogid = getBlogIDFromItemId($itemid);
1362 ITEM::move($itemid, $catid);
1364 // set the futurePosted flag on the blog
1365 $this->updateFuturePosted(getBlogIDFromItemId($itemid));
1367 // reset the futurePosted in case the item is moved from one blog to another
1368 $this->updateFuturePosted($old_blogid);
1370 if ($catid != intRequestVar('catid'))
1371 $this->action_categoryedit($catid, $blog->getID());
1373 $this->action_itemlist(getBlogIDFromCatID($catid));
1377 * Moves one item to a given category (category existance should be checked by caller)
1378 * errors are returned
1379 * @param int $itemid
1380 * @param int $destCatid category ID to which the item will be moved
1382 function moveOneItem($itemid, $destCatid) {
1385 // only allow if user is allowed to move item
1386 if (!$member->canUpdateItem($itemid, $destCatid))
1387 return _ERROR_DISALLOWED;
1389 ITEM::move($itemid, $destCatid);
1393 * Adds a item to the chosen blog
1395 function action_additem() {
1396 global $member, $manager, $CONF;
1398 $manager->loadClass('ITEM');
1400 $result = ITEM::createFromRequest();
1402 if ($result['status'] == 'error')
1403 $this->error($result['message']);
1405 $blogid = getBlogIDFromItemID($result['itemid']);
1406 $blog =& $manager->getBlog($blogid);
1408 $pingUrl = $manager->addTicketToUrl($CONF['AdminURL'] . 'index.php?action=sendping&blogid=' . intval($blogid));
1410 if ($result['status'] == 'newcategory')
1411 $this->action_categoryedit(
1414 $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0 ? $pingUrl : ''
1416 elseif ((postVar('actiontype') == 'addnow') && $blog->sendPing() && numberOfEventSubscriber('SendPing') > 0)
1417 $this->action_sendping($blogid);
1419 $this->action_itemlist($blogid);
1423 * Shows a window that says we're about to ping.
1424 * immediately refresh to the real pinging page, which will
1425 * show an error, or redirect to the blog.
1427 * @param int $blogid ID of blog for which ping needs to be sent out
1429 function action_sendping($blogid = -1) {
1430 global $member, $manager;
1433 $blogid = intRequestVar('blogid');
1435 $member->isLoggedIn() or $this->disallow();
1437 $rawPingUrl = $manager->addTicketToUrl('index.php?action=rawping&blogid=' . intval($blogid));
1439 $this->pagehead('<meta http-equiv="refresh" content="1; url='.htmlspecialchars($rawPingUrl).'" />');
1441 <h2>Site Updated, Now pinging various weblog listing services...</h2>
1444 This can take a while...
1448 If you aren't automatically passed through, <a href="index.php?action=rawping&blogid=<?php echo $blogid?>">try again</a>
1450 <?php $this->pagefoot();
1454 * Sends the real ping (can take up to 10 seconds!)
1456 function action_rawping() {
1460 $blogid = intRequestVar('blogid');
1461 $blog =& $manager->getBlog($blogid);
1467 <h2>Pinging services, please wait...</h2>
1471 // send sendPing event
1472 $manager->notify('SendPing', array('blogid' => $blogid));
1478 <li><a href="index.php?action=itemlist&blogid=<?php echo $blog->getID()?>">View list of recent items for <?php echo htmlspecialchars($blog->getName())?></a></li>
1479 <li><a href="<?php echo $blog->getURL()?>">Visit your own site</a></li>
1482 <?php $this->pagefoot();
1486 * Allows to edit previously made comments
1488 function action_commentedit() {
1489 global $member, $manager;
1491 $commentid = intRequestVar('commentid');
1493 $member->canAlterComment($commentid) or $this->disallow();
1495 $comment = COMMENT::getComment($commentid);
1497 $manager->notify('PrepareCommentForEdit',array('comment' => &$comment));
1499 // change <br /> to \n
1500 $comment['body'] = str_replace('<br />','',$comment['body']);
1502 $comment['body'] = eregi_replace("<a href=['\"]([^'\"]+)['\"]( rel=\"nofollow\")?>[^<]*</a>","\\1",$comment['body']);
1507 <h2><?php echo _EDITC_TITLE?></h2>
1509 <form action="index.php" method="post"><div>
1511 <input type="hidden" name="action" value="commentupdate" />
1512 <?php $manager->addTicketHidden(); ?>
1513 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1515 <th colspan="2"><?php echo _EDITC_TITLE?></th>
1517 <td><?php echo _EDITC_WHO?></td>
1519 <?php if ($comment['member'])
1520 echo $comment['member'] . " (" . _EDITC_MEMBER . ")";
1522 echo $comment['user'] . " (" . _EDITC_NONMEMBER . ")";
1526 <td><?php echo _EDITC_WHEN?></td>
1527 <td><?php echo date("Y-m-d @ H:i",$comment['timestamp']); ?></td>
1529 <td><?php echo _EDITC_HOST?></td>
1530 <td><?php echo $comment['host']; ?></td>
1532 <td><?php echo _EDITC_TEXT?></td>
1534 <textarea name="body" tabindex="10" rows="10" cols="50"><?php // htmlspecialchars not needed (things should be escaped already)
1535 echo $comment['body'];
1539 <td><?php echo _EDITC_EDIT?></td>
1540 <td><input type="submit" tabindex="20" value="<?php echo _EDITC_EDIT?>" onclick="return checkSubmit();" /></td>
1549 * @todo document this
1551 function action_commentupdate() {
1552 global $member, $manager;
1554 $commentid = intRequestVar('commentid');
1556 $member->canAlterComment($commentid) or $this->disallow();
1558 $body = postVar('body');
1560 // intercept words that are too long
1561 if (eregi("[a-zA-Z0-9|\.,;:!\?=\/\\]{90,90}",$body) != false)
1562 $this->error(_ERROR_COMMENT_LONGWORD);
1565 if (strlen($body)<3)
1566 $this->error(_ERROR_COMMENT_NOCOMMENT);
1567 if (strlen($body)>5000)
1568 $this->error(_ERROR_COMMENT_TOOLONG);
1572 $body = COMMENT::prepareBody($body);
1575 $manager->notify('PreUpdateComment',array('body' => &$body));
1577 $query = 'UPDATE '.sql_table('comment')
1578 . " SET cbody='" .addslashes($body). "'"
1579 . " WHERE cnumber=" . $commentid;
1583 $res = sql_query('SELECT citem FROM '.sql_table('comment').' WHERE cnumber=' . $commentid);
1584 $o = mysql_fetch_object($res);
1585 $itemid = $o->citem;
1587 if ($member->canAlterItem($itemid))
1588 $this->action_itemcommentlist($itemid);
1590 $this->action_browseowncomments();
1595 * @todo document this
1597 function action_commentdelete() {
1598 global $member, $manager;
1600 $commentid = intRequestVar('commentid');
1602 $member->canAlterComment($commentid) or $this->disallow();
1604 $comment = COMMENT::getComment($commentid);
1606 $body = strip_tags($comment['body']);
1607 $body = htmlspecialchars(shorten($body, 300, '...'));
1609 if ($comment['member'])
1610 $author = $comment['member'];
1612 $author = $comment['user'];
1617 <h2><?php echo _DELETE_CONFIRM?></h2>
1619 <p><?php echo _CONFIRMTXT_COMMENT?></p>
1622 <b><?php echo _EDITC_WHO?>:</b> <?php echo $author ?>
1624 <b><?php echo _EDITC_TEXT?>:</b> <?php echo $body ?>
1627 <form method="post" action="index.php"><div>
1628 <input type="hidden" name="action" value="commentdeleteconfirm" />
1629 <?php $manager->addTicketHidden() ?>
1630 <input type="hidden" name="commentid" value="<?php echo $commentid; ?>" />
1631 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
1638 * @todo document this
1640 function action_commentdeleteconfirm() {
1643 $commentid = intRequestVar('commentid');
1645 // get item id first
1646 $res = sql_query('SELECT citem FROM '.sql_table('comment') .' WHERE cnumber=' . $commentid);
1647 $o = mysql_fetch_object($res);
1648 $itemid = $o->citem;
1650 $error = $this->deleteOneComment($commentid);
1652 $this->doError($error);
1654 if ($member->canAlterItem($itemid))
1655 $this->action_itemcommentlist($itemid);
1657 $this->action_browseowncomments();
1661 * @todo document this
1663 function deleteOneComment($commentid) {
1664 global $member, $manager;
1666 $commentid = intval($commentid);
1668 if (!$member->canAlterComment($commentid))
1669 return _ERROR_DISALLOWED;
1671 $manager->notify('PreDeleteComment', array('commentid' => $commentid));
1673 // delete the comments associated with the item
1674 $query = 'DELETE FROM '.sql_table('comment').' WHERE cnumber=' . $commentid;
1677 $manager->notify('PostDeleteComment', array('commentid' => $commentid));
1683 * Usermanagement main
1685 function action_usermanagement() {
1686 global $member, $manager;
1689 $member->isAdmin() or $this->disallow();
1693 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
1695 echo '<h2>' . _MEMBERS_TITLE .'</h2>';
1697 echo '<h3>' . _MEMBERS_CURRENT .'</h3>';
1699 // show list of members with actions
1701 . ' FROM '.sql_table('member');
1702 $template['content'] = 'memberlist';
1703 $template['tabindex'] = 10;
1705 $manager->loadClass("ENCAPSULATE");
1706 $batch =& new BATCH('member');
1707 $batch->showlist($query,'table',$template);
1709 echo '<h3>' . _MEMBERS_NEW .'</h3>';
1711 <form method="post" action="index.php" name="memberedit"><div>
1713 <input type="hidden" name="action" value="memberadd" />
1714 <?php $manager->addTicketHidden() ?>
1718 <th colspan="2"><?php echo _MEMBERS_NEW?></th>
1720 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1721 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1723 <td><input tabindex="10010" name="name" size="16" maxlength="16" /></td>
1725 <td><?php echo _MEMBERS_REALNAME?></td>
1726 <td><input name="realname" tabindex="10020" size="40" maxlength="60" /></td>
1728 <td><?php echo _MEMBERS_PWD?></td>
1729 <td><input name="password" tabindex="10030" size="16" maxlength="40" type="password" /></td>
1731 <td><?php echo _MEMBERS_REPPWD?></td>
1732 <td><input name="repeatpassword" tabindex="10035" size="16" maxlength="40" type="password" /></td>
1734 <td><?php echo _MEMBERS_EMAIL?></td>
1735 <td><input name="email" tabindex="10040" size="40" maxlength="60" /></td>
1737 <td><?php echo _MEMBERS_URL?></td>
1738 <td><input name="url" tabindex="10050" size="40" maxlength="100" /></td>
1740 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1741 <td><?php $this->input_yesno('admin',0,10060); ?> </td>
1743 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1744 <td><?php $this->input_yesno('canlogin',1,10070); ?></td>
1746 <td><?php echo _MEMBERS_NOTES?></td>
1747 <td><input name="notes" maxlength="100" size="40" tabindex="10080" /></td>
1749 <td><?php echo _MEMBERS_NEW?></td>
1750 <td><input type="submit" value="<?php echo _MEMBERS_NEW_BTN?>" tabindex="10090" onclick="return checkSubmit();" /></td>
1759 * Edit member settings
1761 function action_memberedit() {
1762 $this->action_editmembersettings(intRequestVar('memberid'));
1766 * @todo document this
1768 function action_editmembersettings($memberid = '') {
1769 global $member, $manager, $CONF;
1771 if ($memberid == '')
1772 $memberid = $member->getID();
1775 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1777 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
1778 $this->pagehead($extrahead);
1780 // show message to go back to member overview (only for admins)
1781 if ($member->isAdmin())
1782 echo '<a href="index.php?action=usermanagement">(' ._MEMBERS_BACKTOOVERVIEW. ')</a>';
1784 echo '<a href="index.php?action=overview">(' ._BACKHOME. ')</a>';
1786 echo '<h2>' . _MEMBERS_EDIT . '</h2>';
1788 $mem = MEMBER::createFromID($memberid);
1791 <form method="post" action="index.php" name="memberedit"><div>
1793 <input type="hidden" name="action" value="changemembersettings" />
1794 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
1795 <?php $manager->addTicketHidden() ?>
1798 <th colspan="2"><?php echo _MEMBERS_EDIT?></th>
1800 <td><?php echo _MEMBERS_DISPLAY?> <?php help('shortnames');?>
1801 <br /><small><?php echo _MEMBERS_DISPLAY_INFO?></small>
1804 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1805 <input name="name" tabindex="10" maxlength="16" size="16" value="<?php echo htmlspecialchars($mem->getDisplayName()); ?>" />
1807 echo htmlspecialchars($member->getDisplayName());
1812 <td><?php echo _MEMBERS_REALNAME?></td>
1813 <td><input name="realname" tabindex="20" maxlength="60" size="40" value="<?php echo htmlspecialchars($mem->getRealName()); ?>" /></td>
1815 <?php if ($CONF['AllowLoginEdit'] || $member->isAdmin()) { ?>
1816 <td><?php echo _MEMBERS_PWD?></td>
1817 <td><input type="password" tabindex="30" maxlength="40" size="16" name="password" /></td>
1819 <td><?php echo _MEMBERS_REPPWD?></td>
1820 <td><input type="password" tabindex="35" maxlength="40" size="16" name="repeatpassword" /></td>
1823 <td><?php echo _MEMBERS_EMAIL?>
1824 <br /><small><?php echo _MEMBERS_EMAIL_EDIT?></small>
1826 <td><input name="email" tabindex="40" size="40" maxlength="60" value="<?php echo htmlspecialchars($mem->getEmail()); ?>" /></td>
1828 <td><?php echo _MEMBERS_URL?></td>
1829 <td><input name="url" tabindex="50" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getURL()); ?>" /></td>
1830 <?php // only allow to change this by super-admins
1831 // we don't want normal users to 'upgrade' themselves to super-admins, do we? ;-)
1832 if ($member->isAdmin()) {
1835 <td><?php echo _MEMBERS_SUPERADMIN?> <?php help('superadmin'); ?></td>
1836 <td><?php $this->input_yesno('admin',$mem->isAdmin(),60); ?></td>
1838 <td><?php echo _MEMBERS_CANLOGIN?> <?php help('canlogin'); ?></td>
1839 <td><?php $this->input_yesno('canlogin',$mem->canLogin(),70,1,0,_YES,_NO,$mem->isAdmin()); ?></td>
1842 <td><?php echo _MEMBERS_NOTES?></td>
1843 <td><input name="notes" tabindex="80" size="40" maxlength="100" value="<?php echo htmlspecialchars($mem->getNotes()); ?>" /></td>
1845 <td><?php echo _MEMBERS_DEFLANG?> <?php help('language'); ?>
1849 <select name="deflang" tabindex="85">
1850 <option value=""><?php echo _MEMBERS_USESITELANG?></option>
1851 <?php // show a dropdown list of all available languages
1853 $dirhandle = opendir($DIR_LANG);
1854 while ($filename = readdir($dirhandle)) {
1855 if (ereg("^(.*)\.php$",$filename,$matches)) {
1856 $name = $matches[1];
1857 echo "<option value='$name'";
1858 if ($name == $mem->getLanguage())
1859 echo " selected='selected'";
1860 echo ">$name</option>";
1863 closedir($dirhandle);
1872 $this->_insertPluginOptions('member',$memberid);
1875 <th colspan="2"><?php echo _MEMBERS_EDIT ?></th>
1877 <td><?php echo _MEMBERS_EDIT?></td>
1878 <td><input type="submit" tabindex="90" value="<?php echo _MEMBERS_EDIT_BTN?>" onclick="return checkSubmit();" /></td>
1884 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
1887 'MemberSettingsFormExtras',
1897 * @todo document this
1899 function action_changemembersettings() {
1900 global $member, $CONF, $manager;
1902 $memberid = intRequestVar('memberid');
1905 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
1907 $name = trim(strip_tags(postVar('name')));
1908 $realname = trim(strip_tags(postVar('realname')));
1909 $password = postVar('password');
1910 $repeatpassword = postVar('repeatpassword');
1911 $email = strip_tags(postVar('email'));
1912 $url = strip_tags(postVar('url'));
1914 // Sometimes user didn't prefix the URL with http://, this cause a malformed URL. Let's fix it.
1915 if (!eregi("^https?://", $url))
1916 $url = "http://".$url;
1918 $admin = postVar('admin');
1919 $canlogin = postVar('canlogin');
1920 $notes = strip_tags(postVar('notes'));
1921 $deflang = postVar('deflang');
1923 $mem = MEMBER::createFromID($memberid);
1925 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1927 if (!isValidDisplayName($name))
1928 $this->error(_ERROR_BADNAME);
1930 if (($name != $mem->getDisplayName()) && MEMBER::exists($name))
1931 $this->error(_ERROR_NICKNAMEINUSE);
1933 if ($password != $repeatpassword)
1934 $this->error(_ERROR_PASSWORDMISMATCH);
1936 if ($password && (strlen($password) < 6))
1937 $this->error(_ERROR_PASSWORDTOOSHORT);
1940 if (!isValidMailAddress($email))
1941 $this->error(_ERROR_BADMAILADDRESS);
1945 $this->error(_ERROR_REALNAMEMISSING);
1947 if (($deflang != '') && (!checkLanguage($deflang)))
1948 $this->error(_ERROR_NOSUCHLANGUAGE);
1950 // check if there will remain at least one site member with both the logon and admin rights
1951 // (check occurs when taking away one of these rights from such a member)
1952 if ( (!$admin && $mem->isAdmin() && $mem->canLogin())
1953 || (!$canlogin && $mem->isAdmin() && $mem->canLogin())
1956 $r = sql_query('SELECT * FROM '.sql_table('member').' WHERE madmin=1 and mcanlogin=1');
1957 if (mysql_num_rows($r) < 2)
1958 $this->error(_ERROR_ATLEASTONEADMIN);
1961 if ($CONF['AllowLoginEdit'] || $member->isAdmin()) {
1962 $mem->setDisplayName($name);
1964 $mem->setPassword($password);
1967 $oldEmail = $mem->getEmail();
1969 $mem->setRealName($realname);
1970 $mem->setEmail($email);
1972 $mem->setNotes($notes);
1973 $mem->setLanguage($deflang);
1976 // only allow super-admins to make changes to the admin status
1977 if ($member->isAdmin()) {
1978 $mem->setAdmin($admin);
1979 $mem->setCanLogin($canlogin);
1985 // store plugin options
1986 $aOptions = requestArray('plugoption');
1987 NucleusPlugin::_applyPluginOptions($aOptions);
1988 $manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
1990 // if email changed, generate new password
1991 if ($oldEmail != $mem->getEmail())
1993 $mem->sendActivationLink('addresschange', $oldEmail);
1995 $mem->newCookieKey();
1997 // only log out if the member being edited is the current member.
1998 if ($member->getID() == $memberid)
2000 $this->action_login(_MSG_ACTIVATION_SENT, 0);
2005 if ( ( $mem->getID() == $member->getID() )
2006 && ( $mem->getDisplayName() != $member->getDisplayName() )
2008 $mem->newCookieKey();
2010 $this->action_login(_MSG_LOGINAGAIN, 0);
2012 $this->action_overview(_MSG_SETTINGSCHANGED);
2017 * @todo document this
2019 function action_memberadd() {
2020 global $member, $manager;
2023 $member->isAdmin() or $this->disallow();
2025 if (postVar('password') != postVar('repeatpassword'))
2026 $this->error(_ERROR_PASSWORDMISMATCH);
2027 if (strlen(postVar('password')) < 6)
2028 $this->error(_ERROR_PASSWORDTOOSHORT);
2030 $res = MEMBER::create(postVar('name'), postVar('realname'), postVar('password'), postVar('email'), postVar('url'), postVar('admin'), postVar('canlogin'), postVar('notes'));
2034 // fire PostRegister event
2035 $newmem = new MEMBER();
2036 $newmem->readFromName(postVar('name'));
2037 $manager->notify('PostRegister',array('member' => &$newmem));
2039 $this->action_usermanagement();
2043 * Account activation
2047 function action_activate() {
2049 $key = getVar('key');
2050 $this->_showActivationPage($key);
2054 * @todo document this
2056 function _showActivationPage($key, $message = '')
2060 // clean up old activation keys
2061 MEMBER::cleanupActivationTable();
2063 // get activation info
2064 $info = MEMBER::getActivationInfo($key);
2067 $this->error(_ERROR_ACTIVATE);
2069 $mem = MEMBER::createFromId($info->vmember);
2072 $this->error(_ERROR_ACTIVATE);
2076 $bNeedsPasswordChange = true;
2078 switch ($info->vtype)
2081 $title = _ACTIVATE_FORGOT_TITLE;
2082 $text = _ACTIVATE_FORGOT_TEXT;
2085 $title = _ACTIVATE_REGISTER_TITLE;
2086 $text = _ACTIVATE_REGISTER_TEXT;
2088 case 'addresschange':
2089 $title = _ACTIVATE_CHANGE_TITLE;
2090 $text = _ACTIVATE_CHANGE_TEXT;
2091 $bNeedsPasswordChange = false;
2092 MEMBER::activate($key);
2097 'memberName' => htmlspecialchars($mem->getDisplayName())
2099 $title = TEMPLATE::fill($title, $aVars);
2100 $text = TEMPLATE::fill($text, $aVars);
2104 echo '<h2>' , $title, '</h2>';
2105 echo '<p>' , $text, '</p>';
2109 echo '<p class="error">',$message,'</p>';
2112 if ($bNeedsPasswordChange)
2115 <div><form action="index.php" method="post">
2117 <input type="hidden" name="action" value="activatesetpwd" />
2118 <?php $manager->addTicketHidden() ?>
2119 <input type="hidden" name="key" value="<?php echo htmlspecialchars($key) ?>" />
2122 <td><?php echo _MEMBERS_PWD?></td>
2123 <td><input type="password" maxlength="40" size="16" name="password" /></td>
2125 <td><?php echo _MEMBERS_REPPWD?></td>
2126 <td><input type="password" maxlength="40" size="16" name="repeatpassword" /></td>
2130 $manager->notify('FormExtra', array('type' => 'activation', 'member' => $mem));
2134 <td><?php echo _MEMBERS_SETPWD ?></td>
2135 <td><input type='submit' value='<?php echo _MEMBERS_SETPWD_BTN ?>' /></td>
2150 * Account activation - set password part
2154 function action_activatesetpwd() {
2156 $key = postVar('key');
2158 // clean up old activation keys
2159 MEMBER::cleanupActivationTable();
2161 // get activation info
2162 $info = MEMBER::getActivationInfo($key);
2164 if (!$info || ($info->type == 'addresschange'))
2165 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2167 $mem = MEMBER::createFromId($info->vmember);
2170 return $this->_showActivationPage($key, _ERROR_ACTIVATE);
2172 $password = postVar('password');
2173 $repeatpassword = postVar('repeatpassword');
2175 if ($password != $repeatpassword)
2176 return $this->_showActivationPage($key, _ERROR_PASSWORDMISMATCH);
2178 if ($password && (strlen($password) < 6))
2179 return $this->_showActivationPage($key, _ERROR_PASSWORDTOOSHORT);
2183 $manager->notify('ValidateForm', array('type' => 'activation', 'member' => $mem, 'error' => &$error));
2185 return $this->_showActivationPage($key, $error);
2189 $mem->setPassword($password);
2192 // do the activation
2193 MEMBER::activate($key);
2196 echo '<h2>',_ACTIVATE_SUCCESS_TITLE,'</h2>';
2197 echo '<p>',_ACTIVATE_SUCCESS_TEXT,'</p>';
2204 function action_manageteam() {
2205 global $member, $manager;
2207 $blogid = intRequestVar('blogid');
2210 $member->blogAdminRights($blogid) or $this->disallow();
2214 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2216 echo '<h2>' . _TEAM_TITLE . getBlogNameFromID($blogid) . '</h2>';
2218 echo '<h3>' . _TEAM_CURRENT . '</h3>';
2222 $query = 'SELECT tblog, tmember, mname, mrealname, memail, tadmin'
2223 . ' FROM '.sql_table('member').', '.sql_table('team')
2224 . ' WHERE tmember=mnumber and tblog=' . $blogid;
2226 $template['content'] = 'teamlist';
2227 $template['tabindex'] = 10;
2229 $manager->loadClass("ENCAPSULATE");
2230 $batch =& new BATCH('team');
2231 $batch->showlist($query, 'table', $template);
2234 <h3><?php echo _TEAM_ADDNEW?></h3>
2236 <form method='post' action='index.php'><div>
2238 <input type='hidden' name='action' value='teamaddmember' />
2239 <input type='hidden' name='blogid' value='<?php echo $blogid; ?>' />
2240 <?php $manager->addTicketHidden() ?>
2243 <td><?php echo _TEAM_CHOOSEMEMBER?></td>
2244 <td><?php // TODO: try to make it so only non-team-members are listed
2245 $query = 'SELECT mname as text, mnumber as value'
2246 . ' FROM '.sql_table('member');
2248 $template['name'] = 'memberid';
2249 $template['tabindex'] = 10000;
2250 showlist($query,'select',$template);
2253 <td><?php echo _TEAM_ADMIN?><?php help('teamadmin'); ?></td>
2254 <td><?php $this->input_yesno('admin',0,10020); ?></td>
2256 <td><?php echo _TEAM_ADD?></td>
2257 <td><input type='submit' value='<?php echo _TEAM_ADD_BTN?>' tabindex="10030" /></td>
2266 * Add member to team
2268 function action_teamaddmember() {
2269 global $member, $manager;
2271 $memberid = intPostVar('memberid');
2272 $blogid = intPostVar('blogid');
2273 $admin = intPostVar('admin');
2276 $member->blogAdminRights($blogid) or $this->disallow();
2278 $blog =& $manager->getBlog($blogid);
2279 if (!$blog->addTeamMember($memberid, $admin))
2280 $this->error(_ERROR_ALREADYONTEAM);
2282 $this->action_manageteam();
2287 * @todo document this
2289 function action_teamdelete() {
2290 global $member, $manager;
2292 $memberid = intRequestVar('memberid');
2293 $blogid = intRequestVar('blogid');
2296 $member->blogAdminRights($blogid) or $this->disallow();
2298 $teammem = MEMBER::createFromID($memberid);
2299 $blog =& $manager->getBlog($blogid);
2303 <h2><?php echo _DELETE_CONFIRM?></h2>
2305 <p><?php echo _CONFIRMTXT_TEAM1?><b><?php echo htmlspecialchars($teammem->getDisplayName()) ?></b><?php echo _CONFIRMTXT_TEAM2?><b><?php echo htmlspecialchars(strip_tags($blog->getName())) ?></b>
2309 <form method="post" action="index.php"><div>
2310 <input type="hidden" name="action" value="teamdeleteconfirm" />
2311 <?php $manager->addTicketHidden() ?>
2312 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
2313 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2314 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2321 * @todo document this
2323 function action_teamdeleteconfirm() {
2326 $memberid = intRequestVar('memberid');
2327 $blogid = intRequestVar('blogid');
2329 $error = $this->deleteOneTeamMember($blogid, $memberid);
2331 $this->error($error);
2334 $this->action_manageteam();
2338 * @todo document this
2340 function deleteOneTeamMember($blogid, $memberid) {
2341 global $member, $manager;
2343 $blogid = intval($blogid);
2344 $memberid = intval($memberid);
2347 if (!$member->blogAdminRights($blogid))
2348 return _ERROR_DISALLOWED;
2350 // check if: - there remains at least one blog admin
2351 // - (there remains at least one team member)
2352 $mem = MEMBER::createFromID($memberid);
2354 $manager->notify('PreDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2356 if ($mem->isBlogAdmin($blogid)) {
2357 // check if there are more blog members left and at least one admin
2358 // (check for at least two admins before deletion)
2359 $query = 'SELECT * FROM '.sql_table('team') . ' WHERE tblog='.$blogid.' and tadmin=1';
2360 $r = sql_query($query);
2361 if (mysql_num_rows($r) < 2)
2362 return _ERROR_ATLEASTONEBLOGADMIN;
2365 $query = 'DELETE FROM '.sql_table('team')." WHERE tblog=$blogid and tmember=$memberid";
2368 $manager->notify('PostDeleteTeamMember', array('member' => &$mem, 'blogid' => $blogid));
2374 * @todo document this
2376 function action_teamchangeadmin() {
2379 $blogid = intRequestVar('blogid');
2380 $memberid = intRequestVar('memberid');
2383 $member->blogAdminRights($blogid) or $this->disallow();
2385 $mem = MEMBER::createFromID($memberid);
2387 // don't allow when there is only one admin at this moment
2388 if ($mem->isBlogAdmin($blogid)) {
2389 $r = sql_query('SELECT * FROM '.sql_table('team') . " WHERE tblog=$blogid and tadmin=1");
2390 if (mysql_num_rows($r) == 1)
2391 $this->error(_ERROR_ATLEASTONEBLOGADMIN);
2394 if ($mem->isBlogAdmin($blogid))
2399 $query = 'UPDATE '.sql_table('team') ." SET tadmin=$newval WHERE tblog=$blogid and tmember=$memberid";
2402 // only show manageteam if member did not change its own admin privileges
2403 if ($member->isBlogAdmin($blogid))
2404 $this->action_manageteam();
2406 $this->action_overview(_MSG_ADMINCHANGED);
2410 * @todo document this
2412 function action_blogsettings() {
2413 global $member, $manager;
2415 $blogid = intRequestVar('blogid');
2418 $member->blogAdminRights($blogid) or $this->disallow();
2420 $blog =& $manager->getBlog($blogid);
2422 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2423 $this->pagehead($extrahead);
2425 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
2427 <h2><?php echo _EBLOG_TITLE?>: '<?php echo $this->bloglink($blog)?>'</h2>
2429 <h3><?php echo _EBLOG_TEAM_TITLE?></h3>
2431 <p>Members currently on your team:
2433 $res = sql_query('SELECT mname, mrealname FROM ' . sql_table('member') . ',' . sql_table('team') . ' WHERE mnumber=tmember AND tblog=' . intval($blogid));
2434 $aMemberNames = array();
2435 while ($o = mysql_fetch_object($res))
2436 array_push($aMemberNames, htmlspecialchars($o->mname) . ' (' . htmlspecialchars($o->mrealname). ')');
2437 echo implode(',', $aMemberNames);
2444 <a href="index.php?action=manageteam&blogid=<?php echo $blogid?>"><?php echo _EBLOG_TEAM_TEXT?></a>
2447 <h3><?php echo _EBLOG_SETTINGS_TITLE?></h3>
2449 <form method="post" action="index.php"><div>
2451 <input type="hidden" name="action" value="blogsettingsupdate" />
2452 <?php $manager->addTicketHidden() ?>
2453 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
2455 <td><?php echo _EBLOG_NAME?></td>
2456 <td><input name="name" tabindex="10" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getName()) ?>" /></td>
2458 <td><?php echo _EBLOG_SHORTNAME?> <?php help('shortblogname'); ?>
2459 <?php echo _EBLOG_SHORTNAME_EXTRA?>
2461 <td><input name="shortname" tabindex="20" maxlength="15" size="15" value="<?php echo htmlspecialchars($blog->getShortName()) ?>" /></td>
2463 <td><?php echo _EBLOG_DESC?></td>
2464 <td><input name="desc" tabindex="30" maxlength="200" size="40" value="<?php echo htmlspecialchars($blog->getDescription()) ?>" /></td>
2466 <td><?php echo _EBLOG_URL?></td>
2467 <td><input name="url" tabindex="40" size="40" maxlength="100" value="<?php echo htmlspecialchars($blog->getURL()) ?>" /></td>
2469 <td><?php echo _EBLOG_DEFSKIN?>
2470 <?php help('blogdefaultskin'); ?>
2474 $query = 'SELECT sdname as text, sdnumber as value'
2475 . ' FROM '.sql_table('skin_desc');
2476 $template['name'] = 'defskin';
2477 $template['selected'] = $blog->getDefaultSkin();
2478 $template['tabindex'] = 50;
2479 showlist($query,'select',$template);
2484 <td><?php echo _EBLOG_LINEBREAKS?> <?php help('convertbreaks'); ?>
2486 <td><?php $this->input_yesno('convertbreaks',$blog->convertBreaks(),55); ?></td>
2488 <td><?php echo _EBLOG_ALLOWPASTPOSTING?> <?php help('allowpastposting'); ?>
2490 <td><?php $this->input_yesno('allowpastposting',$blog->allowPastPosting(),57); ?></td>
2492 <td><?php echo _EBLOG_DISABLECOMMENTS?>
2494 <td><?php $this->input_yesno('comments',$blog->commentsEnabled(),60); ?></td>
2496 <td><?php echo _EBLOG_ANONYMOUS?>
2498 <td><?php $this->input_yesno('public',$blog->isPublic(),70); ?></td>
2500 <td><?php echo _EBLOG_REQUIREDEMAIL?>
2502 <td><?php $this->input_yesno('reqemail',$blog->emailRequired(),72); ?></td>
2504 <td><?php echo _EBLOG_NOTIFY?> <?php help('blognotify'); ?></td>
2505 <td><input name="notify" tabindex="80" maxlength="60" size="40" value="<?php echo htmlspecialchars($blog->getNotifyAddress()); ?>" /></td>
2507 <td><?php echo _EBLOG_NOTIFY_ON?></td>
2509 <input name="notifyComment" value="3" type="checkbox" tabindex="81" id="notifyComment"
2510 <?php if ($blog->notifyOnComment()) echo "checked='checked'" ?>
2511 /><label for="notifyComment"><?php echo _EBLOG_NOTIFY_COMMENT?></label>
2513 <input name="notifyVote" value="5" type="checkbox" tabindex="82" id="notifyVote"
2514 <?php if ($blog->notifyOnVote()) echo "checked='checked'" ?>
2515 /><label for="notifyVote"><?php echo _EBLOG_NOTIFY_KARMA?></label>
2517 <input name="notifyNewItem" value="7" type="checkbox" tabindex="83" id="notifyNewItem"
2518 <?php if ($blog->notifyOnNewItem()) echo "checked='checked'" ?>
2519 /><label for="notifyNewItem"><?php echo _EBLOG_NOTIFY_ITEM?></label>
2523 if (numberOfEventSubscriber('SendPing') > 0) {
2525 <td><?php echo _EBLOG_PING?> <?php help('sendping'); ?></td>
2526 <td><?php $this->input_yesno('sendping',$blog->sendPing(),85); ?></td>
2531 <td><?php echo _EBLOG_MAXCOMMENTS?> <?php help('blogmaxcomments'); ?></td>
2532 <td><input name="maxcomments" tabindex="90" size="3" value="<?php echo htmlspecialchars($blog->getMaxComments()); ?>" /></td>
2534 <td><?php echo _EBLOG_UPDATE?> <?php help('blogupdatefile'); ?></td>
2535 <td><input name="update" tabindex="100" size="40" maxlength="60" value="<?php echo htmlspecialchars($blog->getUpdateFile()) ?>" /></td>
2537 <td><?php echo _EBLOG_DEFCAT?></td>
2540 $query = 'SELECT cname as text, catid as value'
2541 . ' FROM '.sql_table('category')
2542 . ' WHERE cblog=' . $blog->getID();
2543 $template['name'] = 'defcat';
2544 $template['selected'] = $blog->getDefaultCategory();
2545 $template['tabindex'] = 110;
2546 showlist($query,'select',$template);
2550 <td><?php echo _EBLOG_OFFSET?> <?php help('blogtimeoffset'); ?>
2551 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
2552 <br /><?php echo _EBLOG_BTIME?> <b><?php echo strftime("%H:%M",$blog->getCorrectTime()); ?></b>
2554 <td><input name="timeoffset" tabindex="120" size="3" value="<?php echo htmlspecialchars($blog->getTimeOffset()); ?>" /></td>
2556 <td><?php echo _EBLOG_SEARCH?> <?php help('blogsearchable'); ?></td>
2557 <td><?php $this->input_yesno('searchable',$blog->getSearchable(),122); ?></td>
2561 $this->_insertPluginOptions('blog',$blogid);
2564 <th colspan="2"><?php echo _EBLOG_CHANGE?></th>
2566 <td><?php echo _EBLOG_CHANGE?></td>
2567 <td><input type="submit" tabindex="130" value="<?php echo _EBLOG_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
2572 <h3><?php echo _EBLOG_CAT_TITLE?></h3>
2576 $query = 'SELECT * FROM '.sql_table('category').' WHERE cblog='.$blog->getID().' ORDER BY cname';
2577 $template['content'] = 'categorylist';
2578 $template['tabindex'] = 200;
2580 $manager->loadClass("ENCAPSULATE");
2581 $batch =& new BATCH('category');
2582 $batch->showlist($query,'table',$template);
2587 <form action="index.php" method="post"><div>
2588 <input name="action" value="categorynew" type="hidden" />
2589 <?php $manager->addTicketHidden() ?>
2590 <input name="blogid" value="<?php echo $blog->getID()?>" type="hidden" />
2593 <th colspan="2"><?php echo _EBLOG_CAT_CREATE?></th>
2595 <td><?php echo _EBLOG_CAT_NAME?></td>
2596 <td><input name="cname" size="40" maxlength="40" tabindex="300" /></td>
2598 <td><?php echo _EBLOG_CAT_DESC?></td>
2599 <td><input name="cdesc" size="40" maxlength="200" tabindex="310" /></td>
2601 <td><?php echo _EBLOG_CAT_CREATE?></td>
2602 <td><input type="submit" value="<?php echo _EBLOG_CAT_CREATE?>" tabindex="320" /></td>
2609 echo '<h3>',_PLUGINS_EXTRA,'</h3>';
2612 'BlogSettingsFormExtras',
2622 * @todo document this
2624 function action_categorynew() {
2625 global $member, $manager;
2627 $blogid = intRequestVar('blogid');
2629 $member->blogAdminRights($blogid) or $this->disallow();
2631 $cname = postVar('cname');
2632 $cdesc = postVar('cdesc');
2634 if (!isValidCategoryName($cname))
2635 $this->error(_ERROR_BADCATEGORYNAME);
2637 $query = 'SELECT * FROM '.sql_table('category') . ' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid);
2638 $res = sql_query($query);
2639 if (mysql_num_rows($res) > 0)
2640 $this->error(_ERROR_DUPCATEGORYNAME);
2642 $blog =& $manager->getBlog($blogid);
2643 $newCatID = $blog->createNewCategory($cname, $cdesc);
2645 $this->action_blogsettings();
2649 * @todo document this
2651 function action_categoryedit($catid = '', $blogid = '', $desturl = '') {
2652 global $member, $manager;
2655 $blogid = intGetVar('blogid');
2657 $blogid = intval($blogid);
2659 $catid = intGetVar('catid');
2661 $catid = intval($catid);
2663 $member->blogAdminRights($blogid) or $this->disallow();
2665 $res = sql_query('SELECT * FROM '.sql_table('category')." WHERE cblog=$blogid AND catid=$catid");
2666 $obj = mysql_fetch_object($res);
2668 $cname = $obj->cname;
2669 $cdesc = $obj->cdesc;
2671 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
2672 $this->pagehead($extrahead);
2674 echo "<p><a href='index.php?action=blogsettings&blogid=$blogid'>(",_BACK_TO_BLOGSETTINGS,")</a></p>";
2677 <h2><?php echo _EBLOG_CAT_UPDATE?> '<?php echo htmlspecialchars($cname)?>'</h2>
2678 <form method='post' action='index.php'><div>
2679 <input name="blogid" type="hidden" value="<?php echo $blogid?>" />
2680 <input name="catid" type="hidden" value="<?php echo $catid?>" />
2681 <input name="desturl" type="hidden" value="<?php echo htmlspecialchars($desturl) ?>" />
2682 <input name="action" type="hidden" value="categoryupdate" />
2683 <?php $manager->addTicketHidden(); ?>
2686 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2688 <td><?php echo _EBLOG_CAT_NAME?></td>
2689 <td><input type="text" name="cname" value="<?php echo htmlspecialchars($cname)?>" size="40" maxlength="40" /></td>
2691 <td><?php echo _EBLOG_CAT_DESC?></td>
2692 <td><input type="text" name="cdesc" value="<?php echo htmlspecialchars($cdesc)?>" size="40" maxlength="200" /></td>
2695 // insert plugin options
2696 $this->_insertPluginOptions('category',$catid);
2699 <th colspan="2"><?php echo _EBLOG_CAT_UPDATE ?></th>
2701 <td><?php echo _EBLOG_CAT_UPDATE?></td>
2702 <td><input type="submit" value="<?php echo _EBLOG_CAT_UPDATE_BTN?>" /></td>
2711 * @todo document this
2713 function action_categoryupdate() {
2714 global $member, $manager;
2716 $blogid = intPostVar('blogid');
2717 $catid = intPostVar('catid');
2718 $cname = postVar('cname');
2719 $cdesc = postVar('cdesc');
2720 $desturl = postVar('desturl');
2722 $member->blogAdminRights($blogid) or $this->disallow();
2724 if (!isValidCategoryName($cname))
2725 $this->error(_ERROR_BADCATEGORYNAME);
2727 $query = 'SELECT * FROM '.sql_table('category').' WHERE cname=\'' . addslashes($cname).'\' and cblog=' . intval($blogid) . " and not(catid=$catid)";
2728 $res = sql_query($query);
2729 if (mysql_num_rows($res) > 0)
2730 $this->error(_ERROR_DUPCATEGORYNAME);
2732 $query = 'UPDATE '.sql_table('category').' SET'
2733 . " cname='" . addslashes($cname) . "',"
2734 . " cdesc='" . addslashes($cdesc) . "'"
2735 . " WHERE catid=" . $catid;
2739 // store plugin options
2740 $aOptions = requestArray('plugoption');
2741 NucleusPlugin::_applyPluginOptions($aOptions);
2742 $manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
2749 $this->action_blogsettings();
2754 * @todo document this
2756 function action_categorydelete() {
2757 global $member, $manager;
2759 $blogid = intRequestVar('blogid');
2760 $catid = intRequestVar('catid');
2762 $member->blogAdminRights($blogid) or $this->disallow();
2764 $blog =& $manager->getBlog($blogid);
2766 // check if the category is valid
2767 if (!$blog->isValidCategory($catid))
2768 $this->error(_ERROR_NOSUCHCATEGORY);
2770 // don't allow deletion of default category
2771 if ($blog->getDefaultCategory() == $catid)
2772 $this->error(_ERROR_DELETEDEFCATEGORY);
2774 // check if catid is the only category left for blogid
2775 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2776 $res = sql_query($query);
2777 if (mysql_num_rows($res) == 1)
2778 $this->error(_ERROR_DELETELASTCATEGORY);
2783 <h2><?php echo _DELETE_CONFIRM?></h2>
2786 <?php echo _CONFIRMTXT_CATEGORY?><b><?php echo htmlspecialchars($blog->getCategoryName($catid))?></b>
2789 <form method="post" action="index.php"><div>
2790 <input type="hidden" name="action" value="categorydeleteconfirm" />
2791 <?php $manager->addTicketHidden() ?>
2792 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
2793 <input type="hidden" name="catid" value="<?php echo $catid?>" />
2794 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
2801 * @todo document this
2803 function action_categorydeleteconfirm() {
2804 global $member, $manager;
2806 $blogid = intRequestVar('blogid');
2807 $catid = intRequestVar('catid');
2809 $member->blogAdminRights($blogid) or $this->disallow();
2811 $error = $this->deleteOneCategory($catid);
2813 $this->error($error);
2815 $this->action_blogsettings();
2819 * @todo document this
2821 function deleteOneCategory($catid) {
2822 global $manager, $member;
2824 $catid = intval($catid);
2826 $manager->notify('PreDeleteCategory', array('catid' => $catid));
2828 $blogid = getBlogIDFromCatID($catid);
2830 if (!$member->blogAdminRights($blogid))
2831 return ERROR_DISALLOWED;
2834 $blog =& $manager->getBlog($blogid);
2836 // check if the category is valid
2837 if (!$blog || !$blog->isValidCategory($catid))
2838 return _ERROR_NOSUCHCATEGORY;
2840 $destcatid = $blog->getDefaultCategory();
2842 // don't allow deletion of default category
2843 if ($blog->getDefaultCategory() == $catid)
2844 return _ERROR_DELETEDEFCATEGORY;
2846 // check if catid is the only category left for blogid
2847 $query = 'SELECT catid FROM '.sql_table('category').' WHERE cblog=' . $blogid;
2848 $res = sql_query($query);
2849 if (mysql_num_rows($res) == 1)
2850 return _ERROR_DELETELASTCATEGORY;
2852 // change category for all items to the default category
2853 $query = 'UPDATE '.sql_table('item')." SET icat=$destcatid WHERE icat=$catid";
2856 // delete all associated plugin options
2857 NucleusPlugin::_deleteOptionValues('category', $catid);
2860 $query = 'DELETE FROM '.sql_table('category').' WHERE catid=' .$catid;
2863 $manager->notify('PostDeleteCategory', array('catid' => $catid));
2868 * @todo document this
2870 function moveOneCategory($catid, $destblogid) {
2871 global $manager, $member;
2873 $catid = intval($catid);
2874 $destblogid = intval($destblogid);
2876 $blogid = getBlogIDFromCatID($catid);
2878 // mover should have admin rights on both blogs
2879 if (!$member->blogAdminRights($blogid))
2880 return _ERROR_DISALLOWED;
2881 if (!$member->blogAdminRights($destblogid))
2882 return _ERROR_DISALLOWED;
2884 // cannot move to self
2885 if ($blogid == $destblogid)
2886 return _ERROR_MOVETOSELF;
2889 $blog =& $manager->getBlog($blogid);
2890 $destblog =& $manager->getBlog($destblogid);
2892 // check if the category is valid
2893 if (!$blog || !$blog->isValidCategory($catid))
2894 return _ERROR_NOSUCHCATEGORY;
2896 // don't allow default category to be moved
2897 if ($blog->getDefaultCategory() == $catid)
2898 return _ERROR_MOVEDEFCATEGORY;
2904 'sourceblog' => &$blog,
2905 'destblog' => &$destblog
2909 // update comments table (cblog)
2910 $query = 'SELECT inumber FROM '.sql_table('item').' WHERE icat='.$catid;
2911 $items = sql_query($query);
2912 while ($oItem = mysql_fetch_object($items)) {
2913 sql_query('UPDATE '.sql_table('comment').' SET cblog='.$destblogid.' WHERE citem='.$oItem->inumber);
2916 // update items (iblog)
2917 $query = 'UPDATE '.sql_table('item').' SET iblog='.$destblogid.' WHERE icat='.$catid;
2921 $query = 'UPDATE '.sql_table('category').' SET cblog='.$destblogid.' WHERE catid='.$catid;
2928 'sourceblog' => &$blog,
2929 'destblog' => $destblog
2936 * @todo document this
2938 function action_blogsettingsupdate() {
2939 global $member, $manager;
2941 $blogid = intRequestVar('blogid');
2943 $member->blogAdminRights($blogid) or $this->disallow();
2945 $blog =& $manager->getBlog($blogid);
2947 $notify = trim(postVar('notify'));
2948 $shortname = trim(postVar('shortname'));
2949 $updatefile = trim(postVar('update'));
2951 $notifyComment = intPostVar('notifyComment');
2952 $notifyVote = intPostVar('notifyVote');
2953 $notifyNewItem = intPostVar('notifyNewItem');
2955 if ($notifyComment == 0) $notifyComment = 1;
2956 if ($notifyVote == 0) $notifyVote = 1;
2957 if ($notifyNewItem == 0) $notifyNewItem = 1;
2959 $notifyType = $notifyComment * $notifyVote * $notifyNewItem;
2963 $not =& new NOTIFICATION($notify);
2964 if (!$not->validAddresses())
2965 $this->error(_ERROR_BADNOTIFY);
2969 if (!isValidShortName($shortname))
2970 $this->error(_ERROR_BADSHORTBLOGNAME);
2972 if (($blog->getShortName() != $shortname) && $manager->existsBlog($shortname))
2973 $this->error(_ERROR_DUPSHORTBLOGNAME);
2975 // check if update file is writable
2976 if ($updatefile && !is_writeable($updatefile))
2977 $this->error(_ERROR_UPDATEFILE);
2979 $blog->setName(trim(postVar('name')));
2980 $blog->setShortName($shortname);
2981 $blog->setNotifyAddress($notify);
2982 $blog->setNotifyType($notifyType);
2983 $blog->setMaxComments(postVar('maxcomments'));
2984 $blog->setCommentsEnabled(postVar('comments'));
2985 $blog->setTimeOffset(postVar('timeoffset'));
2986 $blog->setUpdateFile($updatefile);
2987 $blog->setURL(trim(postVar('url')));
2988 $blog->setDefaultSkin(intPostVar('defskin'));
2989 $blog->setDescription(trim(postVar('desc')));
2990 $blog->setPublic(postVar('public'));
2991 $blog->setPingUserland(postVar('sendping'));
2992 $blog->setConvertBreaks(intPostVar('convertbreaks'));
2993 $blog->setAllowPastPosting(intPostVar('allowpastposting'));
2994 $blog->setDefaultCategory(intPostVar('defcat'));
2995 $blog->setSearchable(intPostVar('searchable'));
2996 $blog->setEmailRequired(intPostVar('reqemail'));
2998 $blog->writeSettings();
3000 // store plugin options
3001 $aOptions = requestArray('plugoption');
3002 NucleusPlugin::_applyPluginOptions($aOptions);
3003 $manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
3006 $this->action_overview(_MSG_SETTINGSCHANGED);
3010 * @todo document this
3012 function action_deleteblog() {
3013 global $member, $CONF, $manager;
3015 $blogid = intRequestVar('blogid');
3017 $member->blogAdminRights($blogid) or $this->disallow();
3019 // check if blog is default blog
3020 if ($CONF['DefaultBlog'] == $blogid)
3021 $this->error(_ERROR_DELDEFBLOG);
3023 $blog =& $manager->getBlog($blogid);
3027 <h2><?php echo _DELETE_CONFIRM?></h2>
3029 <p><?php echo _WARNINGTXT_BLOGDEL?>
3033 <?php echo _CONFIRMTXT_BLOG?><b><?php echo htmlspecialchars($blog->getName())?></b>
3036 <form method="post" action="index.php"><div>
3037 <input type="hidden" name="action" value="deleteblogconfirm" />
3038 <?php $manager->addTicketHidden() ?>
3039 <input type="hidden" name="blogid" value="<?php echo $blogid; ?>" />
3040 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3047 * @todo document this
3049 function action_deleteblogconfirm() {
3050 global $member, $CONF, $manager;
3052 $blogid = intRequestVar('blogid');
3054 $manager->notify('PreDeleteBlog', array('blogid' => $blogid));
3056 $member->blogAdminRights($blogid) or $this->disallow();
3058 // check if blog is default blog
3059 if ($CONF['DefaultBlog'] == $blogid)
3060 $this->error(_ERROR_DELDEFBLOG);
3062 // delete all comments
3063 $query = 'DELETE FROM '.sql_table('comment').' WHERE cblog='.$blogid;
3067 $query = 'DELETE FROM '.sql_table('item').' WHERE iblog='.$blogid;
3070 // delete all team members
3071 $query = 'DELETE FROM '.sql_table('team').' WHERE tblog='.$blogid;
3075 $query = 'DELETE FROM '.sql_table('ban').' WHERE blogid='.$blogid;
3078 // delete all categories
3079 $query = 'DELETE FROM '.sql_table('category').' WHERE cblog='.$blogid;
3082 // delete all associated plugin options
3083 NucleusPlugin::_deleteOptionValues('blog', $blogid);
3085 // delete the blog itself
3086 $query = 'DELETE FROM '.sql_table('blog').' WHERE bnumber='.$blogid;
3089 $manager->notify('PostDeleteBlog', array('blogid' => $blogid));
3091 $this->action_overview(_DELETED_BLOG);
3095 * @todo document this
3097 function action_memberdelete() {
3098 global $member, $manager;
3100 $memberid = intRequestVar('memberid');
3102 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3104 $mem = MEMBER::createFromID($memberid);
3108 <h2><?php echo _DELETE_CONFIRM?></h2>
3110 <p><?php echo _CONFIRMTXT_MEMBER?><b><?php echo htmlspecialchars($mem->getDisplayName()) ?></b>
3114 Please note that media files will <b>NOT</b> be deleted. (At least not in this Nucleus version)
3117 <form method="post" action="index.php"><div>
3118 <input type="hidden" name="action" value="memberdeleteconfirm" />
3119 <?php $manager->addTicketHidden() ?>
3120 <input type="hidden" name="memberid" value="<?php echo $memberid; ?>" />
3121 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
3128 * @todo document this
3130 function action_memberdeleteconfirm() {
3133 $memberid = intRequestVar('memberid');
3135 ($member->getID() == $memberid) or $member->isAdmin() or $this->disallow();
3137 $error = $this->deleteOneMember($memberid);
3139 $this->error($error);
3141 if ($member->isAdmin())
3142 $this->action_usermanagement();
3144 $this->action_overview(_DELETED_MEMBER);
3149 * @todo document this
3151 function deleteOneMember($memberid) {
3154 $memberid = intval($memberid);
3155 $mem = MEMBER::createFromID($memberid);
3157 if (!$mem->canBeDeleted())
3158 return _ERROR_DELETEMEMBER;
3160 $manager->notify('PreDeleteMember', array('member' => &$mem));
3162 /* unlink comments from memberid */
3163 $query = 'UPDATE ' . sql_table('comment') . ' SET cmember="0", cuser="'. addslashes($mem->getDisplayName())
3164 .'" WHERE cmember='.$memberid;
3167 $query = 'DELETE FROM '.sql_table('member').' WHERE mnumber='.$memberid;
3170 $query = 'DELETE FROM '.sql_table('team').' WHERE tmember='.$memberid;
3173 $query = 'DELETE FROM '.sql_table('activation').' WHERE vmember='.$memberid;
3176 // delete all associated plugin options
3177 NucleusPlugin::_deleteOptionValues('member', $memberid);
3179 $manager->notify('PostDeleteMember', array('member' => &$mem));
3185 * @todo document this
3187 function action_createnewlog() {
3188 global $member, $CONF, $manager;
3190 // Only Super-Admins can do this
3191 $member->isAdmin() or $this->disallow();
3195 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3197 <h2><?php echo _EBLOG_CREATE_TITLE?></h2>
3201 <p>作成にあたって、下記の<strong>注意事項</strong> をまずお読み下さい</p>
3203 <p>新しいweblogを作成した後に、このblogにアクセスするための方法を紹介しておきます。方法は2つあります:</p>
3206 <li><strong>簡単な方法:</strong> <code>index.php</code>の複製を作り、新しいblogを表示するように変更を加えます。 この変更の詳細は、作成後に表示されます。</li>
3207 <li><strong>高度な方法:</strong> 現在のblogで使用しているスキンに<code>otherblog</code>というコードを使った記述を加えます。この方法では、同じページ内で複数のblogを展開することが可能となります。</li>
3213 <?php echo _EBLOG_CREATE_TEXT?>
3216 <form method="post" action="index.php"><div>
3218 <input type="hidden" name="action" value="addnewlog" />
3219 <?php $manager->addTicketHidden() ?>
3223 <td><?php echo _EBLOG_NAME?></td>
3224 <td><input name="name" tabindex="10" size="40" maxlength="60" /></td>
3226 <td><?php echo _EBLOG_SHORTNAME?>
3227 <?php help('shortblogname'); ?>
3229 <td><input name="shortname" tabindex="20" maxlength="15" size="15" /></td>
3231 <td><?php echo _EBLOG_DESC?></td>
3232 <td><input name="desc" tabindex="30" maxlength="200" size="40" /></td>
3234 <td><?php echo _EBLOG_DEFSKIN?>
3235 <?php help('blogdefaultskin'); ?>
3239 $query = 'SELECT sdname as text, sdnumber as value'
3240 . ' FROM '.sql_table('skin_desc');
3241 $template['name'] = 'defskin';
3242 $template['tabindex'] = 50;
3243 $template['selected'] = $CONF['BaseSkin']; // set default selected skin to be globally defined base skin
3244 showlist($query,'select',$template);
3248 <td><?php echo _EBLOG_OFFSET?>
3249 <?php help('blogtimeoffset'); ?>
3250 <br /><?php echo _EBLOG_STIME?> <b><?php echo strftime("%H:%M",time()); ?></b>
3252 <td><input name="timeoffset" tabindex="110" size="3" value="0" /></td>
3254 <td><?php echo _EBLOG_ADMIN?>
3255 <?php help('teamadmin'); ?>
3257 <td><?php echo _EBLOG_ADMIN_MSG?></td>
3259 <td><?php echo _EBLOG_CREATE?></td>
3260 <td><input type="submit" tabindex="120" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3269 * @todo document this
3271 function action_addnewlog() {
3272 global $member, $manager, $CONF;
3274 // Only Super-Admins can do this
3275 $member->isAdmin() or $this->disallow();
3277 $bname = trim(postVar('name'));
3278 $bshortname = trim(postVar('shortname'));
3279 $btimeoffset = postVar('timeoffset');
3280 $bdesc = trim(postVar('desc'));
3281 $bdefskin = postVar('defskin');
3283 if (!isValidShortName($bshortname))
3284 $this->error(_ERROR_BADSHORTBLOGNAME);
3286 if ($manager->existsBlog($bshortname))
3287 $this->error(_ERROR_DUPSHORTBLOGNAME);
3293 'shortname' => &$bshortname,
3294 'timeoffset' => &$btimeoffset,
3295 'description' => &$bdesc,
3296 'defaultskin' => &$bdefskin
3301 // add slashes for sql queries
3302 $bname = addslashes($bname);
3303 $bshortname = addslashes($bshortname);
3304 $btimeoffset = addslashes($btimeoffset);
3305 $bdesc = addslashes($bdesc);
3306 $bdefskin = addslashes($bdefskin);
3309 $query = 'INSERT INTO '.sql_table('blog')." (bname, bshortname, bdesc, btimeoffset, bdefskin) VALUES ('$bname', '$bshortname', '$bdesc', '$btimeoffset', '$bdefskin')";
3311 $blogid = mysql_insert_id();
3312 $blog =& $manager->getBlog($blogid);
3314 // create new category
3315 sql_query('INSERT INTO '.sql_table('category')." (cblog, cname, cdesc) VALUES ($blogid, 'General','Items that do not fit in other categories')");
3316 $catid = mysql_insert_id();
3318 // set as default category
3319 $blog->setDefaultCategory($catid);
3320 $blog->writeSettings();
3322 // create team member
3323 $memberid = $member->getID();
3324 $query = 'INSERT INTO '.sql_table('team')." (tmember, tblog, tadmin) VALUES ($memberid, $blogid, 1)";
3328 $blog->additem($blog->getDefaultCategory(),'First Item','これはあなたのweblogにおける最初のアイテムです。自由に削除していただいてかまいません。','',$blogid, $memberid,$blog->getCorrectTime(),0,0,0);
3341 'name' => 'General',
3342 'description' => 'Items that do not fit in other categories',
3349 <h2>新しいweblogが作成されました</h2>
3351 <p>新しいweblog 「<?php echo htmlspecialchars($bname)?>」が作成されました。続けて、これにアクセスするために以下のどちらかの手順に進んでください。</p>
3354 <li><a href="#index_php">簡単な方法: 下のコードを貼付けた <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成する</a></li>
3355 <li><a href="#skins">高度な方法: 現在使用しているスキンに新しいweblogを展開させるための記述を加える</a></li>
3358 <h3><a id="index_php">方法 1: <code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成</a></h3>
3360 <p><code><?php echo htmlspecialchars($bshortname)?>.php</code> というファイルを作成して、中身に以下のコードを貼り付ける:</p>
3363 $CONF['Self'] = '<b><?php echo htmlspecialchars($bshortname)?>.php</b>';
3365 include('<i>./config.php</i>');
3367 selectBlog('<b><?php echo htmlspecialchars($bshortname)?></b>');
3372 <p>すでにある<code>index.php</code>と同じディレクトリにアップロードします。</p>
3374 <p>新しいweblogの作成を完了するためには、下にこのファイルのURLを入力してください。 (すでに用意した値で合っているとは思いますが保証はしません):</p>
3376 <form action="index.php" method="post"><div>
3377 <input type="hidden" name="action" value="addnewlog2" />
3378 <?php $manager->addTicketHidden() ?>
3379 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3381 <td><?php echo _EBLOG_URL?></td>
3382 <td><input name="url" maxlength="100" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL'].$bshortname.'.php')?>" /></td>
3384 <td><?php echo _EBLOG_CREATE?></td>
3385 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3389 <h3><a id="skins">方法 2: 現在使用しているスキンに新しいweblogを展開する記述を加える</a></h3>
3391 <p>新しいweblogの作成を完了するためには、下にURLを入力してください。 (大抵は既存blogと同じURL)</p>
3393 <form action="index.php" method="post"><div>
3394 <input type="hidden" name="action" value="addnewlog2" />
3395 <?php $manager->addTicketHidden() ?>
3396 <input type="hidden" name="blogid" value="<?php echo intval($blogid)?>" />
3398 <td><?php echo _EBLOG_URL?></td>
3399 <td><input name="url" maxlength="100" size="40" /></td>
3401 <td><?php echo _EBLOG_CREATE?></td>
3402 <td><input type="submit" value="<?php echo _EBLOG_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3406 <?php $this->pagefoot();
3411 * @todo document this
3413 function action_addnewlog2() {
3414 global $member, $manager;
3416 $member->blogAdminRights($blogid) or $this->disallow();
3418 $burl = requestVar('url');
3419 $blogid = intRequestVar('blogid');
3421 $blog =& $manager->getBlog($blogid);
3422 $blog->setURL(trim($burl));
3423 $blog->writeSettings();
3425 $this->action_overview(_MSG_NEWBLOG);
3429 * @todo document this
3431 function action_skinieoverview() {
3432 global $member, $DIR_LIBS, $manager;
3434 $member->isAdmin() or $this->disallow();
3436 // load skinie class
3437 include_once($DIR_LIBS . 'skinie.php');
3441 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3444 <h2><?php echo _SKINIE_TITLE_IMPORT?></h2>
3446 <p><label for="skinie_import_local"><?php echo _SKINIE_LOCAL?></label>
3447 <?php global $DIR_SKINS;
3449 $candidates = SKINIMPORT::searchForCandidates($DIR_SKINS);
3451 if (sizeof($candidates) > 0) {
3453 <form method="post" action="index.php"><div>
3454 <input type="hidden" name="action" value="skinieimport" />
3455 <?php $manager->addTicketHidden() ?>
3456 <input type="hidden" name="mode" value="file" />
3457 <select name="skinfile" id="skinie_import_local">
3458 <?php foreach ($candidates as $skinname => $skinfile) {
3459 $html = htmlspecialchars($skinfile);
3460 echo '<option value="',$html,'">',$skinname,'</option>';
3464 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3467 echo _SKINIE_NOCANDIDATES;
3472 <p><em><?php echo _OR?></em></p>
3474 <form method="post" action="index.php"><p>
3475 <?php $manager->addTicketHidden() ?>
3476 <input type="hidden" name="action" value="skinieimport" />
3477 <input type="hidden" name="mode" value="url" />
3478 <label for="skinie_import_url"><?php echo _SKINIE_FROMURL?></label>
3479 <input type="text" name="skinfile" id="skinie_import_url" size="60" value="http://" />
3480 <input type="submit" value="<?php echo _SKINIE_BTN_IMPORT?>" />
3484 <h2><?php echo _SKINIE_TITLE_EXPORT?></h2>
3485 <form method="post" action="index.php"><div>
3486 <input type="hidden" name="action" value="skinieexport" />
3487 <?php $manager->addTicketHidden() ?>
3489 <p><?php echo _SKINIE_EXPORT_INTRO?></p>
3492 <th colspan="2"><?php echo _SKINIE_EXPORT_SKINS?></th>
3494 <?php // show list of skins
3495 $res = sql_query('SELECT * FROM '.sql_table('skin_desc'));
3496 while ($skinObj = mysql_fetch_object($res)) {
3497 $id = 'skinexp' . $skinObj->sdnumber;
3498 echo '<td><input type="checkbox" name="skin[',$skinObj->sdnumber,']" id="',$id,'" />';
3499 echo '<label for="',$id,'">',htmlspecialchars($skinObj->sdname),'</label></td>';
3500 echo '<td>',htmlspecialchars($skinObj->sddesc),'</td>';
3504 echo '<th colspan="2">',_SKINIE_EXPORT_TEMPLATES,'</th></tr><tr>';
3506 // show list of templates
3507 $res = sql_query('SELECT * FROM '.sql_table('template_desc'));
3508 while ($templateObj = mysql_fetch_object($res)) {
3509 $id = 'templateexp' . $templateObj->tdnumber;
3510 echo '<td><input type="checkbox" name="template[',$templateObj->tdnumber,']" id="',$id,'" />';
3511 echo '<label for="',$id,'">',htmlspecialchars($templateObj->tdname),'</label></td>';
3512 echo '<td>',htmlspecialchars($templateObj->tddesc),'</td>';
3517 <th colspan="2"><?php echo _SKINIE_EXPORT_EXTRA?></th>
3519 <td colspan="2"><textarea cols="40" rows="5" name="info"></textarea></td>
3521 <th colspan="2"><?php echo _SKINIE_TITLE_EXPORT?></th>
3523 <td colspan="2"><input type="submit" value="<?php echo _SKINIE_BTN_EXPORT?>" /></td>
3533 * @todo document this
3535 function action_skinieimport() {
3536 global $member, $DIR_LIBS, $DIR_SKINS, $manager;
3538 $member->isAdmin() or $this->disallow();
3540 // load skinie class
3541 include_once($DIR_LIBS . 'skinie.php');
3543 $skinFileRaw= postVar('skinfile');
3544 $mode = postVar('mode');
3546 $importer =& new SKINIMPORT();
3548 // get full filename
3549 if ($mode == 'file')
3551 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3553 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3554 if (!file_exists($skinFile))
3555 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3557 $skinFile = $skinFileRaw;
3560 // read only metadata
3561 $error = $importer->readFile($skinFile, 1);
3564 $skinNameClashes = $importer->checkSkinNameClashes();
3565 $templateNameClashes = $importer->checkTemplateNameClashes();
3566 $hasNameClashes = (count($skinNameClashes) > 0) || (count($templateNameClashes) > 0);
3568 if ($error) $this->error($error);
3572 echo '<p><a href="index.php?action=skinieoverview">(',_BACK,')</a></p>';
3574 <h2><?php echo _SKINIE_CONFIRM_TITLE?></h2>
3577 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3578 <li><p><strong><?php echo _SKINIE_INFO_SKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3579 <li><p><strong><?php echo _SKINIE_INFO_TEMPLATES?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3581 if ($hasNameClashes)
3584 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_SKINCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$skinNameClashes)?></p></li>
3585 <li><p><strong style="color: red;"><?php echo _SKINIE_INFO_TEMPLCLASH?></strong> <?php echo implode(' <em>'._AND.'</em> ',$templateNameClashes)?></p></li>
3587 } // if (hasNameClashes)
3591 <form method="post" action="index.php"><div>
3592 <input type="hidden" name="action" value="skiniedoimport" />
3593 <?php $manager->addTicketHidden() ?>
3594 <input type="hidden" name="skinfile" value="<?php echo htmlspecialchars(postVar('skinfile'))?>" />
3595 <input type="hidden" name="mode" value="<?php echo htmlspecialchars($mode)?>" />
3596 <input type="submit" value="<?php echo _SKINIE_CONFIRM_IMPORT?>" />
3598 if ($hasNameClashes)
3602 <input type="checkbox" name="overwrite" value="1" id="cb_overwrite" /><label for="cb_overwrite"><?php echo _SKINIE_CONFIRM_OVERWRITE?></label>
3604 } // if (hasNameClashes)
3614 * @todo document this
3616 function action_skiniedoimport() {
3617 global $member, $DIR_LIBS, $DIR_SKINS;
3619 $member->isAdmin() or $this->disallow();
3621 // load skinie class
3622 include_once($DIR_LIBS . 'skinie.php');
3624 $skinFileRaw= postVar('skinfile');
3625 $mode = postVar('mode');
3627 $allowOverwrite = intPostVar('overwrite');
3629 // get full filename
3630 if ($mode == 'file')
3632 $skinFile = $DIR_SKINS . $skinFileRaw . '/skinbackup.xml';
3634 // backwards compatibilty (in v2.0, exports were saved as skindata.xml)
3635 if (!file_exists($skinFile))
3636 $skinFile = $DIR_SKINS . $skinFileRaw . '/skindata.xml';
3639 $skinFile = $skinFileRaw;
3642 $importer =& new SKINIMPORT();
3644 $error = $importer->readFile($skinFile);
3647 $this->error($error);
3649 $error = $importer->writeToDatabase($allowOverwrite);
3652 $this->error($error);
3656 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3658 <h2><?php echo _SKINIE_DONE?></h2>
3661 <li><p><strong><?php echo _SKINIE_INFO_GENERAL?></strong> <?php echo htmlspecialchars($importer->getInfo())?></p></li>
3662 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDSKINS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getSkinNames())?></p></li>
3663 <li><p><strong><?php echo _SKINIE_INFO_IMPORTEDTEMPLS?></strong> <?php echo implode(' <em>'._AND.'</em> ',$importer->getTemplateNames())?></p></li>
3666 <?php $this->pagefoot();
3671 * @todo document this
3673 function action_skinieexport() {
3674 global $member, $DIR_LIBS;
3676 $member->isAdmin() or $this->disallow();
3678 // load skinie class
3679 include_once($DIR_LIBS . 'skinie.php');
3681 $aSkins = requestIntArray('skin');
3682 $aTemplates = requestIntArray('template');
3684 if (!is_array($aTemplates)) $aTemplates = array();
3685 if (!is_array($aSkins)) $aSkins = array();
3687 $skinList = array_keys($aSkins);
3688 $templateList = array_keys($aTemplates);
3690 $info = postVar('info');
3692 $exporter =& new SKINEXPORT();
3693 foreach ($skinList as $skinId) {
3694 $exporter->addSkin($skinId);
3696 foreach ($templateList as $templateId) {
3697 $exporter->addTemplate($templateId);
3699 $exporter->setInfo($info);
3701 $exporter->export();
3705 * @todo document this
3707 function action_templateoverview() {
3708 global $member, $manager;
3710 $member->isAdmin() or $this->disallow();
3714 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
3716 echo '<h2>' . _TEMPLATE_TITLE . '</h2>';
3717 echo '<h3>' . _TEMPLATE_AVAILABLE_TITLE . '</h3>';
3719 $query = 'SELECT * FROM '.sql_table('template_desc').' ORDER BY tdname';
3720 $template['content'] = 'templatelist';
3721 $template['tabindex'] = 10;
3722 showlist($query,'table',$template);
3724 echo '<h3>' . _TEMPLATE_NEW_TITLE . '</h3>';
3727 <form method="post" action="index.php"><div>
3729 <input name="action" value="templatenew" type="hidden" />
3730 <?php $manager->addTicketHidden() ?>
3732 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3733 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
3735 <td><?php echo _TEMPLATE_DESC?></td>
3736 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
3738 <td><?php echo _TEMPLATE_CREATE?></td>
3739 <td><input type="submit" tabindex="10030" value="<?php echo _TEMPLATE_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
3749 * @todo document this
3751 function action_templateedit($msg = '') {
3752 global $member, $manager;
3754 $templateid = intRequestVar('templateid');
3756 $member->isAdmin() or $this->disallow();
3758 $extrahead = '<script type="text/javascript" src="javascript/templateEdit.js"></script>';
3759 $extrahead .= '<script type="text/javascript">setTemplateEditText("'.addslashes(_EDITTEMPLATE_EMPTY).'");</script>';
3761 $this->pagehead($extrahead);
3763 $templatename = TEMPLATE::getNameFromId($templateid);
3764 $templatedescription = TEMPLATE::getDesc($templateid);
3765 $template =& $manager->getTemplate($templatename);
3769 <a href="index.php?action=templateoverview">(<?php echo _TEMPLATE_BACK?>)</a>
3772 <h2><?php echo _TEMPLATE_EDIT_TITLE?> '<?php echo htmlspecialchars($templatename); ?>'</h2>
3774 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
3777 <p><?php echo _TEMPLATE_EDIT_MSG?></p>
3779 <form method="post" action="index.php">
3782 <input type="hidden" name="action" value="templateupdate" />
3783 <?php $manager->addTicketHidden() ?>
3784 <input type="hidden" name="templateid" value="<?php echo $templateid; ?>" />
3787 <th colspan="2"><?php echo _TEMPLATE_SETTINGS?></th>
3789 <td><?php echo _TEMPLATE_NAME?> <?php help('shortnames');?></td>
3790 <td><input name="tname" tabindex="4" size="20" maxlength="20" value="<?php echo htmlspecialchars($templatename) ?>" /></td>
3792 <td><?php echo _TEMPLATE_DESC?></td>
3793 <td><input name="tdesc" tabindex="5" size="50" maxlength="200" value="<?php echo htmlspecialchars($templatedescription) ?>" /></td>
3795 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3797 <td><?php echo _TEMPLATE_UPDATE?></td>
3799 <input type="submit" tabindex="6" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3800 <input type="reset" tabindex="7" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3803 <th colspan="2"><?php echo _TEMPLATE_ITEMS?> <?php help('templateitems'); ?></th>
3804 <?php $this->_templateEditRow($template, _TEMPLATE_ITEMHEADER, 'ITEM_HEADER', '', 8);
3805 $this->_templateEditRow($template, _TEMPLATE_ITEMBODY, 'ITEM', '', 9, 1);
3806 $this->_templateEditRow($template, _TEMPLATE_ITEMFOOTER, 'ITEM_FOOTER', '', 10);
3807 $this->_templateEditRow($template, _TEMPLATE_MORELINK, 'MORELINK', 'morelink', 20);
3808 $this->_templateEditRow($template, _TEMPLATE_EDITLINK, 'EDITLINK', 'editlink', 25);
3809 $this->_templateEditRow($template, _TEMPLATE_NEW, 'NEW', 'new', 30);
3812 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_ANY?> <?php help('templatecomments'); ?></th>
3813 <?php $this->_templateEditRow($template, _TEMPLATE_CHEADER, 'COMMENTS_HEADER', 'commentheaders', 40);
3814 $this->_templateEditRow($template, _TEMPLATE_CBODY, 'COMMENTS_BODY', 'commentbody', 50, 1);
3815 $this->_templateEditRow($template, _TEMPLATE_CFOOTER, 'COMMENTS_FOOTER', 'commentheaders', 60);
3816 $this->_templateEditRow($template, _TEMPLATE_CONE, 'COMMENTS_ONE', 'commentwords', 70);
3817 $this->_templateEditRow($template, _TEMPLATE_CMANY, 'COMMENTS_MANY', 'commentwords', 80);
3818 $this->_templateEditRow($template, _TEMPLATE_CMORE, 'COMMENTS_CONTINUED', 'commentcontinued', 90);
3819 $this->_templateEditRow($template, _TEMPLATE_CMEXTRA, 'COMMENTS_AUTH', 'memberextra', 100);
3822 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_NONE?> <?php help('templatecomments'); ?></th>
3824 $this->_templateEditRow($template, _TEMPLATE_CNONE, 'COMMENTS_NONE', '', 110);
3827 <th colspan="2"><?php echo _TEMPLATE_COMMENTS_TOOMUCH?> <?php help('templatecomments'); ?></th>
3828 <?php $this->_templateEditRow($template, _TEMPLATE_CTOOMUCH, 'COMMENTS_TOOMUCH', '', 120);
3831 <th colspan="2"><?php echo _TEMPLATE_ARCHIVELIST?> <?php help('templatearchivelists'); ?></th>
3832 <?php $this->_templateEditRow($template, _TEMPLATE_AHEADER, 'ARCHIVELIST_HEADER', '', 130);
3833 $this->_templateEditRow($template, _TEMPLATE_AITEM, 'ARCHIVELIST_LISTITEM', '', 140);
3834 $this->_templateEditRow($template, _TEMPLATE_AFOOTER, 'ARCHIVELIST_FOOTER', '', 150);
3837 <th colspan="2"><?php echo _TEMPLATE_BLOGLIST?> <?php help('templatebloglists'); ?></th>
3838 <?php $this->_templateEditRow($template, _TEMPLATE_BLOGHEADER, 'BLOGLIST_HEADER', '', 160);
3839 $this->_templateEditRow($template, _TEMPLATE_BLOGITEM, 'BLOGLIST_LISTITEM', '', 170);
3840 $this->_templateEditRow($template, _TEMPLATE_BLOGFOOTER, 'BLOGLIST_FOOTER', '', 180);
3843 <th colspan="2"><?php echo _TEMPLATE_CATEGORYLIST?> <?php help('templatecategorylists'); ?></th>
3844 <?php $this->_templateEditRow($template, _TEMPLATE_CATHEADER, 'CATLIST_HEADER', '', 160);
3845 $this->_templateEditRow($template, _TEMPLATE_CATITEM, 'CATLIST_LISTITEM', '', 170);
3846 $this->_templateEditRow($template, _TEMPLATE_CATFOOTER, 'CATLIST_FOOTER', '', 180);
3849 <th colspan="2"><?php echo _TEMPLATE_DATETIME?></th>
3850 <?php $this->_templateEditRow($template, _TEMPLATE_DHEADER, 'DATE_HEADER', 'dateheads', 190);
3851 $this->_templateEditRow($template, _TEMPLATE_DFOOTER, 'DATE_FOOTER', 'dateheads', 200);
3852 $this->_templateEditRow($template, _TEMPLATE_DFORMAT, 'FORMAT_DATE', 'datetime', 210);
3853 $this->_templateEditRow($template, _TEMPLATE_TFORMAT, 'FORMAT_TIME', 'datetime', 220);
3854 $this->_templateEditRow($template, _TEMPLATE_LOCALE, 'LOCALE', 'locale', 230);
3857 <th colspan="2"><?php echo _TEMPLATE_IMAGE?> <?php help('templatepopups'); ?></th>
3858 <?php $this->_templateEditRow($template, _TEMPLATE_PCODE, 'POPUP_CODE', '', 240);
3859 $this->_templateEditRow($template, _TEMPLATE_ICODE, 'IMAGE_CODE', '', 250);
3860 $this->_templateEditRow($template, _TEMPLATE_MCODE, 'MEDIA_CODE', '', 260);
3863 <th colspan="2"><?php echo _TEMPLATE_SEARCH?></th>
3864 <?php $this->_templateEditRow($template, _TEMPLATE_SHIGHLIGHT, 'SEARCH_HIGHLIGHT', 'highlight',270);
3865 $this->_templateEditRow($template, _TEMPLATE_SNOTFOUND, 'SEARCH_NOTHINGFOUND', 'nothingfound',280);
3868 <th colspan="2"><?php echo _TEMPLATE_UPDATE?></th>
3870 <td><?php echo _TEMPLATE_UPDATE?></td>
3872 <input type="submit" tabindex="290" value="<?php echo _TEMPLATE_UPDATE_BTN?>" onclick="return checkSubmit();" />
3873 <input type="reset" tabindex="300" value="<?php echo _TEMPLATE_RESET_BTN?>" />
3884 * @todo document this
3886 function _templateEditRow(&$template, $description, $name, $help = '', $tabindex = 0, $big = 0) {
3890 <td><?php echo $description?> <?php if ($help) help('template'.$help); ?></td>
3891 <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 htmlspecialchars($template[$name]); ?></textarea></td>
3896 * @todo document this
3898 function action_templateupdate() {
3901 $templateid = intRequestVar('templateid');
3903 $member->isAdmin() or $this->disallow();
3905 $name = postVar('tname');
3906 $desc = postVar('tdesc');
3908 if (!isValidTemplateName($name))
3909 $this->error(_ERROR_BADTEMPLATENAME);
3911 if ((TEMPLATE::getNameFromId($templateid) != $name) && TEMPLATE::exists($name))
3912 $this->error(_ERROR_DUPTEMPLATENAME);
3915 $name = addslashes($name);
3916 $desc = addslashes($desc);
3918 // 1. Remove all template parts
3919 $query = 'DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid;
3922 // 2. Update description
3923 $query = 'UPDATE '.sql_table('template_desc').' SET'
3924 . " tdname='" . $name . "',"
3925 . " tddesc='" . $desc . "'"
3926 . " WHERE tdnumber=" . $templateid;
3929 // 3. Add non-empty template parts
3930 $this->addToTemplate($templateid, 'ITEM_HEADER', postVar('ITEM_HEADER'));
3931 $this->addToTemplate($templateid, 'ITEM', postVar('ITEM'));
3932 $this->addToTemplate($templateid, 'ITEM_FOOTER', postVar('ITEM_FOOTER'));
3933 $this->addToTemplate($templateid, 'MORELINK', postVar('MORELINK'));
3934 $this->addToTemplate($templateid, 'EDITLINK', postVar('EDITLINK'));
3935 $this->addToTemplate($templateid, 'NEW', postVar('NEW'));
3936 $this->addToTemplate($templateid, 'COMMENTS_HEADER', postVar('COMMENTS_HEADER'));
3937 $this->addToTemplate($templateid, 'COMMENTS_BODY', postVar('COMMENTS_BODY'));
3938 $this->addToTemplate($templateid, 'COMMENTS_FOOTER', postVar('COMMENTS_FOOTER'));
3939 $this->addToTemplate($templateid, 'COMMENTS_CONTINUED', postVar('COMMENTS_CONTINUED'));
3940 $this->addToTemplate($templateid, 'COMMENTS_TOOMUCH', postVar('COMMENTS_TOOMUCH'));
3941 $this->addToTemplate($templateid, 'COMMENTS_AUTH', postVar('COMMENTS_AUTH'));
3942 $this->addToTemplate($templateid, 'COMMENTS_ONE', postVar('COMMENTS_ONE'));
3943 $this->addToTemplate($templateid, 'COMMENTS_MANY', postVar('COMMENTS_MANY'));
3944 $this->addToTemplate($templateid, 'COMMENTS_NONE', postVar('COMMENTS_NONE'));
3945 $this->addToTemplate($templateid, 'ARCHIVELIST_HEADER', postVar('ARCHIVELIST_HEADER'));
3946 $this->addToTemplate($templateid, 'ARCHIVELIST_LISTITEM', postVar('ARCHIVELIST_LISTITEM'));
3947 $this->addToTemplate($templateid, 'ARCHIVELIST_FOOTER', postVar('ARCHIVELIST_FOOTER'));
3948 $this->addToTemplate($templateid, 'BLOGLIST_HEADER', postVar('BLOGLIST_HEADER'));
3949 $this->addToTemplate($templateid, 'BLOGLIST_LISTITEM', postVar('BLOGLIST_LISTITEM'));
3950 $this->addToTemplate($templateid, 'BLOGLIST_FOOTER', postVar('BLOGLIST_FOOTER'));
3951 $this->addToTemplate($templateid, 'CATLIST_HEADER', postVar('CATLIST_HEADER'));
3952 $this->addToTemplate($templateid, 'CATLIST_LISTITEM', postVar('CATLIST_LISTITEM'));
3953 $this->addToTemplate($templateid, 'CATLIST_FOOTER', postVar('CATLIST_FOOTER'));
3954 $this->addToTemplate($templateid, 'DATE_HEADER', postVar('DATE_HEADER'));
3955 $this->addToTemplate($templateid, 'DATE_FOOTER', postVar('DATE_FOOTER'));
3956 $this->addToTemplate($templateid, 'FORMAT_DATE', postVar('FORMAT_DATE'));
3957 $this->addToTemplate($templateid, 'FORMAT_TIME', postVar('FORMAT_TIME'));
3958 $this->addToTemplate($templateid, 'LOCALE', postVar('LOCALE'));
3959 $this->addToTemplate($templateid, 'SEARCH_HIGHLIGHT', postVar('SEARCH_HIGHLIGHT'));
3960 $this->addToTemplate($templateid, 'SEARCH_NOTHINGFOUND', postVar('SEARCH_NOTHINGFOUND'));
3961 $this->addToTemplate($templateid, 'POPUP_CODE', postVar('POPUP_CODE'));
3962 $this->addToTemplate($templateid, 'MEDIA_CODE', postVar('MEDIA_CODE'));
3963 $this->addToTemplate($templateid, 'IMAGE_CODE', postVar('IMAGE_CODE'));
3966 // jump back to template edit
3967 $this->action_templateedit(_TEMPLATE_UPDATED);
3972 * @todo document this
3974 function addToTemplate($id, $partname, $content) {
3975 $partname = addslashes($partname);
3976 $content = addslashes($content);
3980 // don't add empty parts:
3981 if (!trim($content)) return -1;
3983 $query = 'INSERT INTO '.sql_table('template')." (tdesc, tpartname, tcontent) "
3984 . "VALUES ($id, '$partname', '$content')";
3985 sql_query($query) or die("Query error: " . mysql_error());
3986 return mysql_insert_id();
3990 * @todo document this
3992 function action_templatedelete() {
3993 global $member, $manager;
3995 $member->isAdmin() or $this->disallow();
3997 $templateid = intRequestVar('templateid');
3998 // TODO: check if template can be deleted
4002 $name = TEMPLATE::getNameFromId($templateid);
4003 $desc = TEMPLATE::getDesc($templateid);
4006 <h2><?php echo _DELETE_CONFIRM?></h2>
4009 <?php echo _CONFIRMTXT_TEMPLATE?><b><?php echo htmlspecialchars($name)?></b> (<?php echo htmlspecialchars($desc) ?>)
4012 <form method="post" action="index.php"><div>
4013 <input type="hidden" name="action" value="templatedeleteconfirm" />
4014 <?php $manager->addTicketHidden() ?>
4015 <input type="hidden" name="templateid" value="<?php echo $templateid ?>" />
4016 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4023 * @todo document this
4025 function action_templatedeleteconfirm() {
4026 global $member, $manager;
4028 $templateid = intRequestVar('templateid');
4030 $member->isAdmin() or $this->disallow();
4032 $manager->notify('PreDeleteTemplate', array('templateid' => $templateid));
4034 // 1. delete description
4035 sql_query('DELETE FROM '.sql_table('template_desc').' WHERE tdnumber=' . $templateid);
4038 sql_query('DELETE FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4040 $manager->notify('PostDeleteTemplate', array('templateid' => $templateid));
4042 $this->action_templateoverview();
4046 * @todo document this
4048 function action_templatenew() {
4051 $member->isAdmin() or $this->disallow();
4053 $name = postVar('name');
4054 $desc = postVar('desc');
4056 if (!isValidTemplateName($name))
4057 $this->error(_ERROR_BADTEMPLATENAME);
4059 if (TEMPLATE::exists($name))
4060 $this->error(_ERROR_DUPTEMPLATENAME);
4062 $newTemplateId = TEMPLATE::createNew($name, $desc);
4064 $this->action_templateoverview();
4068 * @todo document this
4070 function action_templateclone() {
4073 $templateid = intRequestVar('templateid');
4075 $member->isAdmin() or $this->disallow();
4077 // 1. read old template
4078 $name = TEMPLATE::getNameFromId($templateid);
4079 $desc = TEMPLATE::getDesc($templateid);
4081 // 2. create desc thing
4082 $name = "cloned" . $name;
4084 // if a template with that name already exists:
4085 if (TEMPLATE::exists($name)) {
4087 while (TEMPLATE::exists($name . $i))
4092 $newid = TEMPLATE::createNew($name, $desc);
4095 // go through parts of old template and add them to the new one
4096 $res = sql_query('SELECT tpartname, tcontent FROM '.sql_table('template').' WHERE tdesc=' . $templateid);
4097 while ($o = mysql_fetch_object($res)) {
4098 $this->addToTemplate($newid, $o->tpartname, $o->tcontent);
4101 $this->action_templateoverview();
4105 * @todo document this
4107 function action_skinoverview() {
4108 global $member, $manager;
4110 $member->isAdmin() or $this->disallow();
4114 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4116 echo '<h2>' . _SKIN_EDIT_TITLE . '</h2>';
4118 echo '<h3>' . _SKIN_AVAILABLE_TITLE . '</h3>';
4120 $query = 'SELECT * FROM '.sql_table('skin_desc').' ORDER BY sdname';
4121 $template['content'] = 'skinlist';
4122 $template['tabindex'] = 10;
4123 showlist($query,'table',$template);
4125 echo '<h3>' . _SKIN_NEW_TITLE . '</h3>';
4128 <form method="post" action="index.php">
4131 <input name="action" value="skinnew" type="hidden" />
4132 <?php $manager->addTicketHidden() ?>
4134 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4135 <td><input name="name" tabindex="10010" maxlength="20" size="20" /></td>
4137 <td><?php echo _SKIN_DESC?></td>
4138 <td><input name="desc" tabindex="10020" maxlength="200" size="50" /></td>
4140 <td><?php echo _SKIN_CREATE?></td>
4141 <td><input type="submit" tabindex="10030" value="<?php echo _SKIN_CREATE_BTN?>" onclick="return checkSubmit();" /></td>
4152 * @todo document this
4154 function action_skinnew() {
4157 $member->isAdmin() or $this->disallow();
4159 $name = trim(postVar('name'));
4160 $desc = trim(postVar('desc'));
4162 if (!isValidSkinName($name))
4163 $this->error(_ERROR_BADSKINNAME);
4165 if (SKIN::exists($name))
4166 $this->error(_ERROR_DUPSKINNAME);
4168 $newId = SKIN::createNew($name, $desc);
4170 $this->action_skinoverview();
4174 * @todo document this
4176 function action_skinedit() {
4177 global $member, $manager;
4179 $skinid = intRequestVar('skinid');
4181 $member->isAdmin() or $this->disallow();
4183 $skin =& new SKIN($skinid);
4188 <a href="index.php?action=skinoverview">(<?php echo _SKIN_BACK?>)</a>
4190 <h2><?php echo _SKIN_EDITONE_TITLE?> '<?php echo $skin->getName() ?>'</h2>
4192 <h3><?php echo _SKIN_PARTS_TITLE?></h3>
4193 <?php echo _SKIN_PARTS_MSG?>
4195 <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>
4196 <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>
4197 <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>
4198 <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>
4199 <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>
4200 <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>
4201 <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>
4202 <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>
4207 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE stype NOT IN ('index', 'item', 'error', 'search', 'archive', 'archivelist', 'imagepopup', 'member') and sdesc = " . $skinid;
4208 $res = sql_query($query);
4210 echo '<h3>' . _SKIN_PARTS_SPECIAL . '</h3>';
4211 echo '<form method="get" action="index.php">' . "\r\n";
4212 echo '<input type="hidden" name="action" value="skinedittype" />' . "\r\n";
4213 echo '<input type="hidden" name="skinid" value="' . $skinid . '" />' . "\r\n";
4214 echo '<input name="type" tabindex="89" size="20" maxlength="20" />' . "\r\n";
4215 echo '<input type="submit" tabindex="140" value="' . _SKIN_CREATE . '" onclick="return checkSubmit();" />' . "\r\n";
4216 echo '</form>' . "\r\n";
4218 if ($res && mysql_num_rows($res) > 0) {
4222 while ($row = mysql_fetch_assoc($res)) {
4223 echo '<li><a tabindex="' . ($tabstart++) . '" href="index.php?action=skinedittype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">' . htmlspecialchars(ucfirst($row['stype'])) . '</a> (<a tabindex="' . ($tabstart++) . '" href="index.php?action=skinremovetype&skinid=' . $skinid . '&type=' . htmlspecialchars(strtolower($row['stype'])) . '">remove</a>)</li>';
4231 <h3><?php echo _SKIN_GENSETTINGS_TITLE; ?></h3>
4232 <form method="post" action="index.php">
4235 <input type="hidden" name="action" value="skineditgeneral" />
4236 <?php $manager->addTicketHidden() ?>
4237 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4239 <td><?php echo _SKIN_NAME?> <?php help('shortnames');?></td>
4240 <td><input name="name" tabindex="90" value="<?php echo htmlspecialchars($skin->getName()) ?>" maxlength="20" size="20" /></td>
4242 <td><?php echo _SKIN_DESC?></td>
4243 <td><input name="desc" tabindex="100" value="<?php echo htmlspecialchars($skin->getDescription()) ?>" maxlength="200" size="50" /></td>
4245 <td><?php echo _SKIN_TYPE?></td>
4246 <td><input name="type" tabindex="110" value="<?php echo htmlspecialchars($skin->getContentType()) ?>" maxlength="40" size="20" /></td>
4248 <td><?php echo _SKIN_INCLUDE_MODE?> <?php help('includemode')?></td>
4249 <td><?php $this->input_yesno('inc_mode',$skin->getIncludeMode(),120,'skindir','normal',_PARSER_INCMODE_SKINDIR,_PARSER_INCMODE_NORMAL);?></td>
4251 <td><?php echo _SKIN_INCLUDE_PREFIX?> <?php help('includeprefix')?></td>
4252 <td><input name="inc_prefix" tabindex="130" value="<?php echo htmlspecialchars($skin->getIncludePrefix()) ?>" maxlength="40" size="20" /></td>
4254 <td><?php echo _SKIN_CHANGE?></td>
4255 <td><input type="submit" tabindex="140" value="<?php echo _SKIN_CHANGE_BTN?>" onclick="return checkSubmit();" /></td>
4262 <?php $this->pagefoot();
4266 * @todo document this
4268 function action_skineditgeneral() {
4271 $skinid = intRequestVar('skinid');
4273 $member->isAdmin() or $this->disallow();
4275 $name = postVar('name');
4276 $desc = postVar('desc');
4277 $type = postVar('type');
4278 $inc_mode = postVar('inc_mode');
4279 $inc_prefix = postVar('inc_prefix');
4281 $skin =& new SKIN($skinid);
4284 if (!isValidSkinName($name))
4285 $this->error(_ERROR_BADSKINNAME);
4287 if (($skin->getName() != $name) && SKIN::exists($name))
4288 $this->error(_ERROR_DUPSKINNAME);
4290 if (!$type) $type = 'text/html';
4291 if (!$inc_mode) $inc_mode = 'normal';
4293 // 2. Update description
4294 $skin->updateGeneralInfo($name, $desc, $type, $inc_mode, $inc_prefix);
4296 $this->action_skinedit();
4301 * @todo document this
4303 function action_skinedittype($msg = '') {
4304 global $member, $manager;
4306 $skinid = intRequestVar('skinid');
4307 $type = requestVar('type');
4309 $member->isAdmin() or $this->disallow();
4311 $type = trim($type);
4312 $type = strtolower($type);
4314 if (!isValidShortName($type)) {
4315 $this->error(_ERROR_SKIN_PARTS_SPECIAL_FORMAT);
4318 $skin =& new SKIN($skinid);
4320 $friendlyNames = SKIN::getFriendlyNames();
4324 <p>(<a href="index.php?action=skinoverview"><?php echo _SKIN_GOBACK?></a>)</p>
4326 <h2><?php echo _SKIN_EDITPART_TITLE?> '<?php echo htmlspecialchars($skin->getName()) ?>': <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?></h2>
4328 <?php if ($msg) echo "<p>"._MESSAGE.": $msg</p>";
4332 <form method="post" action="index.php">
4335 <input type="hidden" name="action" value="skinupdate" />
4336 <?php $manager->addTicketHidden() ?>
4337 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4338 <input type="hidden" name="type" value="<?php echo $type ?>" />
4340 <input type="submit" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4341 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4342 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4343 <?php if (in_array($type, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4344 help('skinpart' . $type);
4346 help('skinpartspecial');
4350 <textarea class="skinedit" tabindex="10" rows="20" cols="80" name="content"><?php echo htmlspecialchars($skin->getContent($type)) ?></textarea>
4353 <input type="submit" tabindex="20" value="<?php echo _SKIN_UPDATE_BTN?>" onclick="return checkSubmit();" />
4354 <input type="reset" value="<?php echo _SKIN_RESET_BTN?>" />
4355 (skin type: <?php echo htmlspecialchars(isset($friendlyNames[$type]) ? $friendlyNames[$type] : ucfirst($type)); ?>)
4358 <?php echo _SKIN_ALLOWEDVARS?>
4359 <?php $actions = SKIN::getAllowedActionsForType($type);
4363 while ($current = array_shift($actions)) {
4364 // skip deprecated vars
4365 if ($current == 'ifcat') continue;
4366 if ($current == 'imagetext') continue;
4367 if ($current == 'vars') continue;
4369 echo helplink('skinvar-' . $current) . "$current</a>";
4370 if (count($actions) != 0) echo ", ";
4375 <?php $query = 'SELECT bshortname, bname FROM '.sql_table('blog');
4376 showlist($query,'table',array('content'=>'shortblognames'));
4381 <?php $query = 'SELECT tdname as name, tddesc as description FROM '.sql_table('template_desc');
4382 showlist($query,'table',array('content'=>'shortnames'));
4390 <?php $this->pagefoot();
4394 * @todo document this
4396 function action_skinupdate() {
4399 $skinid = intRequestVar('skinid');
4400 $content = trim(postVar('content'));
4401 $type = postVar('type');
4403 $member->isAdmin() or $this->disallow();
4405 $skin =& new SKIN($skinid);
4406 $skin->update($type, $content);
4408 $this->action_skinedittype(_SKIN_UPDATED);
4412 * @todo document this
4414 function action_skindelete() {
4415 global $member, $manager, $CONF;
4417 $skinid = intRequestVar('skinid');
4419 $member->isAdmin() or $this->disallow();
4421 // don't allow default skin to be deleted
4422 if ($skinid == $CONF['BaseSkin'])
4423 $this->error(_ERROR_DEFAULTSKIN);
4425 // don't allow deletion of default skins for blogs
4426 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4427 $r = sql_query($query);
4428 if ($o = mysql_fetch_object($r))
4429 $this->error(_ERROR_SKINDEFDELETE . htmlspecialchars($o->bname));
4433 $skin =& new SKIN($skinid);
4434 $name = $skin->getName();
4435 $desc = $skin->getDescription();
4438 <h2><?php echo _DELETE_CONFIRM?></h2>
4441 <?php echo _CONFIRMTXT_SKIN?><b><?php echo htmlspecialchars($name) ?></b> (<?php echo htmlspecialchars($desc)?>)
4444 <form method="post" action="index.php"><div>
4445 <input type="hidden" name="action" value="skindeleteconfirm" />
4446 <?php $manager->addTicketHidden() ?>
4447 <input type="hidden" name="skinid" value="<?php echo $skinid ?>" />
4448 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4455 * @todo document this
4457 function action_skindeleteconfirm() {
4458 global $member, $CONF, $manager;
4460 $skinid = intRequestVar('skinid');
4462 $member->isAdmin() or $this->disallow();
4464 // don't allow default skin to be deleted
4465 if ($skinid == $CONF['BaseSkin'])
4466 $this->error(_ERROR_DEFAULTSKIN);
4468 // don't allow deletion of default skins for blogs
4469 $query = 'SELECT bname FROM '.sql_table('blog').' WHERE bdefskin=' . $skinid;
4470 $r = sql_query($query);
4471 if ($o = mysql_fetch_object($r))
4472 $this->error(_ERROR_SKINDEFDELETE .$o->bname);
4474 $manager->notify('PreDeleteSkin', array('skinid' => $skinid));
4476 // 1. delete description
4477 sql_query('DELETE FROM '.sql_table('skin_desc').' WHERE sdnumber=' . $skinid);
4480 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid);
4482 $manager->notify('PostDeleteSkin', array('skinid' => $skinid));
4484 $this->action_skinoverview();
4488 * @todo document this
4490 function action_skinremovetype() {
4491 global $member, $manager, $CONF;
4493 $skinid = intRequestVar('skinid');
4494 $skintype = requestVar('type');
4496 if (!isValidShortName($skintype)) {
4497 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4500 $member->isAdmin() or $this->disallow();
4502 // don't allow default skinparts to be deleted
4503 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4504 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4509 $skin =& new SKIN($skinid);
4510 $name = $skin->getName();
4511 $desc = $skin->getDescription();
4514 <h2><?php echo _DELETE_CONFIRM?></h2>
4517 <?php echo _CONFIRMTXT_SKIN_PARTS_SPECIAL; ?> <b><?php echo htmlspecialchars($skintype); ?> (<?php echo htmlspecialchars($name); ?>)</b> (<?php echo htmlspecialchars($desc)?>)
4520 <form method="post" action="index.php"><div>
4521 <input type="hidden" name="action" value="skinremovetypeconfirm" />
4522 <?php $manager->addTicketHidden() ?>
4523 <input type="hidden" name="skinid" value="<?php echo $skinid; ?>" />
4524 <input type="hidden" name="type" value="<?php echo htmlspecialchars($skintype); ?>" />
4525 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
4532 * @todo document this
4534 function action_skinremovetypeconfirm() {
4535 global $member, $CONF, $manager;
4537 $skinid = intRequestVar('skinid');
4538 $skintype = requestVar('type');
4540 if (!isValidShortName($skintype)) {
4541 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4544 $member->isAdmin() or $this->disallow();
4546 // don't allow default skinparts to be deleted
4547 if (in_array($skintype, array('index', 'item', 'archivelist', 'archive', 'search', 'error', 'member', 'imagepopup'))) {
4548 $this->error(_ERROR_SKIN_PARTS_SPECIAL_DELETE);
4551 $manager->notify('PreDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4554 sql_query('DELETE FROM '.sql_table('skin').' WHERE sdesc=' . $skinid . ' AND stype=\'' . $skintype . '\'');
4556 $manager->notify('PostDeleteSkinPart', array('skinid' => $skinid, 'skintype' => $skintype));
4558 $this->action_skinedit();
4562 * @todo document this
4564 function action_skinclone() {
4567 $skinid = intRequestVar('skinid');
4569 $member->isAdmin() or $this->disallow();
4571 // 1. read skin to clone
4572 $skin =& new SKIN($skinid);
4574 $name = "clone_" . $skin->getName();
4576 // if a skin with that name already exists:
4577 if (SKIN::exists($name)) {
4579 while (SKIN::exists($name . $i))
4584 // 2. create skin desc
4585 $newid = SKIN::createNew(
4587 $skin->getDescription(),
4588 $skin->getContentType(),
4589 $skin->getIncludeMode(),
4590 $skin->getIncludePrefix()
4596 $this->skinclonetype($skin, $newid, 'index');
4597 $this->skinclonetype($skin, $newid, 'item');
4598 $this->skinclonetype($skin, $newid, 'archivelist');
4599 $this->skinclonetype($skin, $newid, 'archive');
4600 $this->skinclonetype($skin, $newid, 'search');
4601 $this->skinclonetype($skin, $newid, 'error');
4602 $this->skinclonetype($skin, $newid, 'member');
4603 $this->skinclonetype($skin, $newid, 'imagepopup');
4606 $query = "SELECT stype FROM " . sql_table('skin') . " WHERE sdesc = " . $skinid;
4607 $res = sql_query($query);
4608 while ($row = mysql_fetch_assoc($res)) {
4609 $this->skinclonetype($skin, $newid, $row['stype']);
4612 $this->action_skinoverview();
4617 * @todo document this
4619 function skinclonetype($skin, $newid, $type) {
4620 $newid = intval($newid);
4621 $content = $skin->getContent($type);
4623 $query = 'INSERT INTO '.sql_table('skin')." (sdesc, scontent, stype) VALUES ($newid,'". addslashes($content)."', '". addslashes($type)."')";
4629 * @todo document this
4631 function action_settingsedit() {
4632 global $member, $manager, $CONF, $DIR_NUCLEUS, $DIR_MEDIA;
4634 $member->isAdmin() or $this->disallow();
4638 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
4641 <h2><?php echo _SETTINGS_TITLE?></h2>
4643 <form action="index.php" method="post">
4646 <input type="hidden" name="action" value="settingsupdate" />
4647 <?php $manager->addTicketHidden() ?>
4650 <th colspan="2"><?php echo _SETTINGS_SUB_GENERAL?></th>
4652 <td><?php echo _SETTINGS_DEFBLOG?> <?php help('defaultblog'); ?></td>
4655 $query = 'SELECT bname as text, bnumber as value'
4656 . ' FROM '.sql_table('blog');
4657 $template['name'] = 'DefaultBlog';
4658 $template['selected'] = $CONF['DefaultBlog'];
4659 $template['tabindex'] = 10;
4660 showlist($query,'select',$template);
4664 <td><?php echo _SETTINGS_BASESKIN?> <?php help('baseskin'); ?></td>
4667 $query = 'SELECT sdname as text, sdnumber as value'
4668 . ' FROM '.sql_table('skin_desc');
4669 $template['name'] = 'BaseSkin';
4670 $template['selected'] = $CONF['BaseSkin'];
4671 $template['tabindex'] = 1;
4672 showlist($query,'select',$template);
4676 <td><?php echo _SETTINGS_ADMINMAIL?></td>
4677 <td><input name="AdminEmail" tabindex="10010" size="40" value="<?php echo htmlspecialchars($CONF['AdminEmail']) ?>" /></td>
4679 <td><?php echo _SETTINGS_SITENAME?></td>
4680 <td><input name="SiteName" tabindex="10020" size="40" value="<?php echo htmlspecialchars($CONF['SiteName']) ?>" /></td>
4682 <td><?php echo _SETTINGS_SITEURL?></td>
4683 <td><input name="IndexURL" tabindex="10030" size="40" value="<?php echo htmlspecialchars($CONF['IndexURL']) ?>" /></td>
4685 <td><?php echo _SETTINGS_ADMINURL?></td>
4686 <td><input name="AdminURL" tabindex="10040" size="40" value="<?php echo htmlspecialchars($CONF['AdminURL']) ?>" /></td>
4688 <td><?php echo _SETTINGS_PLUGINURL?> <?php help('pluginurl');?></td>
4689 <td><input name="PluginURL" tabindex="10045" size="40" value="<?php echo htmlspecialchars($CONF['PluginURL']) ?>" /></td>
4691 <td><?php echo _SETTINGS_SKINSURL?> <?php help('skinsurl');?></td>
4692 <td><input name="SkinsURL" tabindex="10046" size="40" value="<?php echo htmlspecialchars($CONF['SkinsURL']) ?>" /></td>
4694 <td><?php echo _SETTINGS_ACTIONSURL?> <?php help('actionurl');?></td>
4695 <td><input name="ActionURL" tabindex="10047" size="40" value="<?php echo htmlspecialchars($CONF['ActionURL']) ?>" /></td>
4697 <td><?php echo _SETTINGS_LANGUAGE?> <?php help('language'); ?>
4701 <select name="Language" tabindex="10050">
4702 <?php // show a dropdown list of all available languages
4704 $dirhandle = opendir($DIR_LANG);
4705 while ($filename = readdir($dirhandle)) {
4706 if (ereg("^(.*)\.php$",$filename,$matches)) {
4707 $name = $matches[1];
4708 echo "<option value='$name'";
4709 if ($name == $CONF['Language'])
4710 echo " selected='selected'";
4711 echo ">$name</option>";
4714 closedir($dirhandle);
4721 <td><?php echo _SETTINGS_DISABLESITE?> <?php help('disablesite'); ?>
4723 <td><?php $this->input_yesno('DisableSite',$CONF['DisableSite'],10060); ?>
4725 URL: <input name="DisableSiteURL" tabindex="10070" size="40" value="<?php echo htmlspecialchars($CONF['DisableSiteURL'])?>" />
4728 <td><?php echo _SETTINGS_DIRS?></td>
4729 <td><?php echo htmlspecialchars($DIR_NUCLEUS) ?>
4730 <i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4732 <td><?php echo _SETTINGS_DBLOGIN?></td>
4733 <td><i><?php echo _SETTINGS_SEECONFIGPHP?></i></td>
4737 echo _SETTINGS_JSTOOLBAR
4738 /* =_SETTINGS_DISABLEJS
4740 I temporary changed the meaning of DisableJsTools, until I can find a good
4741 way to select the javascript version to use
4745 1 : all javascript disabled
4746 2 : 'simpler' javascript (for mozilla/opera/mac)
4750 <td><?php /* $this->input_yesno('DisableJsTools',$CONF['DisableJsTools'],10075); */?>
4751 <select name="DisableJsTools" tabindex="10075">
4752 <?php $extra = ($CONF['DisableJsTools'] == 1) ? 'selected="selected"' : '';
4753 echo "<option $extra value='1'>",_SETTINGS_JSTOOLBAR_NONE,"</option>";
4754 $extra = ($CONF['DisableJsTools'] == 2) ? 'selected="selected"' : '';
4755 echo "<option $extra value='2'>",_SETTINGS_JSTOOLBAR_SIMPLE,"</option>";
4756 $extra = ($CONF['DisableJsTools'] == 0) ? 'selected="selected"' : '';
4757 echo "<option $extra value='0'>",_SETTINGS_JSTOOLBAR_FULL,"</option>";
4762 <td><?php echo _SETTINGS_URLMODE?> <?php help('urlmode');?></td>
4765 $this->input_yesno('URLMode',$CONF['URLMode'],10077,
4766 'normal','pathinfo',_SETTINGS_URLMODE_NORMAL,_SETTINGS_URLMODE_PATHINFO);
4768 echo ' ', _SETTINGS_URLMODE_HELP;
4774 <th colspan="2"><?php echo _SETTINGS_MEDIA?> <?php help('media'); ?></th>
4776 <td><?php echo _SETTINGS_MEDIADIR?></td>
4777 <td><?php echo htmlspecialchars($DIR_MEDIA) ?>
4778 <i><?php echo _SETTINGS_SEECONFIGPHP?></i>
4779 <?php if (!is_dir($DIR_MEDIA))
4780 echo "<br /><b>" . _WARNING_NOTADIR . "</b>";
4781 if (!is_readable($DIR_MEDIA))
4782 echo "<br /><b>" . _WARNING_NOTREADABLE . "</b>";
4783 if (!is_writeable($DIR_MEDIA))
4784 echo "<br /><b>" . _WARNING_NOTWRITABLE . "</b>";
4788 <td><?php echo _SETTINGS_MEDIAURL?></td>
4790 <input name="MediaURL" tabindex="10080" size="40" value="<?php echo htmlspecialchars($CONF['MediaURL']) ?>" />
4793 <td><?php echo _SETTINGS_ALLOWUPLOAD?></td>
4794 <td><?php $this->input_yesno('AllowUpload',$CONF['AllowUpload'],10090); ?></td>
4796 <td><?php echo _SETTINGS_ALLOWUPLOADTYPES?></td>
4798 <input name="AllowedTypes" tabindex="10100" size="40" value="<?php echo htmlspecialchars($CONF['AllowedTypes']) ?>" />
4801 <td><?php echo _SETTINGS_MAXUPLOADSIZE?></td>
4803 <input name="MaxUploadSize" tabindex="10105" size="40" value="<?php echo htmlspecialchars($CONF['MaxUploadSize']) ?>" />
4806 <td><?php echo _SETTINGS_MEDIAPREFIX?></td>
4807 <td><?php $this->input_yesno('MediaPrefix',$CONF['MediaPrefix'],10110); ?></td>
4810 <th colspan="2"><?php echo _SETTINGS_MEMBERS?></th>
4812 <td><?php echo _SETTINGS_CHANGELOGIN?></td>
4813 <td><?php $this->input_yesno('AllowLoginEdit',$CONF['AllowLoginEdit'],10120); ?></td>
4815 <td><?php echo _SETTINGS_ALLOWCREATE?>
4816 <?php help('allowaccountcreation'); ?>
4818 <td><?php $this->input_yesno('AllowMemberCreate',$CONF['AllowMemberCreate'],10130); ?>
4821 <td><?php echo _SETTINGS_NEWLOGIN?> <?php help('allownewmemberlogin'); ?>
4822 <br /><?php echo _SETTINGS_NEWLOGIN2?>
4824 <td><?php $this->input_yesno('NewMemberCanLogon',$CONF['NewMemberCanLogon'],10140); ?>
4827 <td><?php echo _SETTINGS_MEMBERMSGS?>
4828 <?php help('messageservice'); ?>
4830 <td><?php $this->input_yesno('AllowMemberMail',$CONF['AllowMemberMail'],10150); ?>
4833 <td><?php echo _SETTINGS_NONMEMBERMSGS?>
4834 <?php help('messageservice'); ?>
4836 <td><?php $this->input_yesno('NonmemberMail',$CONF['NonmemberMail'],10155); ?>
4839 <td><?php echo _SETTINGS_PROTECTMEMNAMES?>
4840 <?php help('protectmemnames'); ?>
4842 <td><?php $this->input_yesno('ProtectMemNames',$CONF['ProtectMemNames'],10156); ?>
4848 <th colspan="2"><?php echo _SETTINGS_COOKIES_TITLE?> <?php help('cookies'); ?></th>
4850 <td><?php echo _SETTINGS_COOKIEPREFIX?></td>
4851 <td><input name="CookiePrefix" tabindex="10159" size="40" value="<?php echo htmlspecialchars($CONF['CookiePrefix'])?>" /></td>
4853 <td><?php echo _SETTINGS_COOKIEDOMAIN?></td>
4854 <td><input name="CookieDomain" tabindex="10160" size="40" value="<?php echo htmlspecialchars($CONF['CookieDomain'])?>" /></td>
4856 <td><?php echo _SETTINGS_COOKIEPATH?></td>
4857 <td><input name="CookiePath" tabindex="10170" size="40" value="<?php echo htmlspecialchars($CONF['CookiePath'])?>" /></td>
4859 <td><?php echo _SETTINGS_COOKIESECURE?></td>
4860 <td><?php $this->input_yesno('CookieSecure',$CONF['CookieSecure'],10180); ?></td>
4862 <td><?php echo _SETTINGS_COOKIELIFE?></td>
4863 <td><?php $this->input_yesno('SessionCookie',$CONF['SessionCookie'],10190,
4864 1,0,_SETTINGS_COOKIESESSION,_SETTINGS_COOKIEMONTH); ?>
4867 <td><?php echo _SETTINGS_LASTVISIT?></td>
4868 <td><?php $this->input_yesno('LastVisit',$CONF['LastVisit'],10200); ?></td>
4873 <th colspan="2"><?php echo _SETTINGS_UPDATE?></th>
4875 <td><?php echo _SETTINGS_UPDATE?></td>
4876 <td><input type="submit" tabindex="10210" value="<?php echo _SETTINGS_UPDATE_BTN?>" onclick="return checkSubmit();" /></td>
4883 echo '<h2>',_PLUGINS_EXTRA,'</h2>';
4886 'GeneralSettingsFormExtras',
4894 * @todo document this
4896 function action_settingsupdate() {
4897 global $member, $CONF;
4899 $member->isAdmin() or $this->disallow();
4901 // check if email address for admin is valid
4902 if (!isValidMailAddress(postVar('AdminEmail')))
4903 $this->error(_ERROR_BADMAILADDRESS);
4907 $this->updateConfig('DefaultBlog', postVar('DefaultBlog'));
4908 $this->updateConfig('BaseSkin', postVar('BaseSkin'));
4909 $this->updateConfig('IndexURL', postVar('IndexURL'));
4910 $this->updateConfig('AdminURL', postVar('AdminURL'));
4911 $this->updateConfig('PluginURL', postVar('PluginURL'));
4912 $this->updateConfig('SkinsURL', postVar('SkinsURL'));
4913 $this->updateConfig('ActionURL', postVar('ActionURL'));
4914 $this->updateConfig('Language', postVar('Language'));
4915 $this->updateConfig('AdminEmail', postVar('AdminEmail'));
4916 $this->updateConfig('SessionCookie', postVar('SessionCookie'));
4917 $this->updateConfig('AllowMemberCreate',postVar('AllowMemberCreate'));
4918 $this->updateConfig('AllowMemberMail', postVar('AllowMemberMail'));
4919 $this->updateConfig('NonmemberMail', postVar('NonmemberMail'));
4920 $this->updateConfig('ProtectMemNames', postVar('ProtectMemNames'));
4921 $this->updateConfig('SiteName', postVar('SiteName'));
4922 $this->updateConfig('NewMemberCanLogon',postVar('NewMemberCanLogon'));
4923 $this->updateConfig('DisableSite', postVar('DisableSite'));
4924 $this->updateConfig('DisableSiteURL', postVar('DisableSiteURL'));
4925 $this->updateConfig('LastVisit', postVar('LastVisit'));
4926 $this->updateConfig('MediaURL', postVar('MediaURL'));
4927 $this->updateConfig('AllowedTypes', postVar('AllowedTypes'));
4928 $this->updateConfig('AllowUpload', postVar('AllowUpload'));
4929 $this->updateConfig('MaxUploadSize', postVar('MaxUploadSize'));
4930 $this->updateConfig('MediaPrefix', postVar('MediaPrefix'));
4931 $this->updateConfig('AllowLoginEdit', postVar('AllowLoginEdit'));
4932 $this->updateConfig('DisableJsTools', postVar('DisableJsTools'));
4933 $this->updateConfig('CookieDomain', postVar('CookieDomain'));
4934 $this->updateConfig('CookiePath', postVar('CookiePath'));
4935 $this->updateConfig('CookieSecure', postVar('CookieSecure'));
4936 $this->updateConfig('URLMode', postVar('URLMode'));
4937 $this->updateConfig('CookiePrefix', postVar('CookiePrefix'));
4939 // load new config and redirect (this way, the new language will be used is necessary)
4940 // note that when changing cookie settings, this redirect might cause the user
4941 // to have to log in again.
4943 redirect($CONF['AdminURL'] . '?action=manage');
4949 * @todo document this
4951 function updateConfig($name, $val) {
4952 $name = addslashes($name);
4953 $val = trim(addslashes($val));
4955 $query = 'UPDATE '.sql_table('config')
4956 . " SET value='$val'"
4957 . " WHERE name='$name'";
4959 sql_query($query) or die("Query error: " . mysql_error());
4960 return mysql_insert_id();
4965 * @param string $msg message that will be shown
4967 function error($msg) {
4973 echo "<a href='index.php' onclick='history.back()'>"._BACK."</a>";
4979 * @todo document this
4981 function disallow() {
4982 ACTIONLOG::add(WARNING, _ACTIONLOG_DISALLOWED . serverVar('REQUEST_URI'));
4984 $this->error(_ERROR_DISALLOWED);
4988 * @todo document this
4990 function pagehead($extrahead = '') {
4991 global $member, $nucleus, $CONF, $manager;
4996 'extrahead' => &$extrahead,
4997 'action' => $this->action
5001 $baseUrl = htmlspecialchars($CONF['AdminURL']);
5004 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5005 <html xmlns="http://www.w3.org/1999/xhtml">
5007 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo _CHARSET ?>" />
5008 <title><?php echo htmlspecialchars($CONF['SiteName'])?> - Admin</title>
5009 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css" href="<?php echo $baseUrl?>styles/admin.css" />
5010 <link rel="stylesheet" title="Nucleus Admin Default" type="text/css"
5011 href="<?php echo $baseUrl?>styles/addedit.css" />
5013 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/edit.js"></script>
5014 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/admin.js"></script>
5015 <script type="text/javascript" src="<?php echo $baseUrl?>javascript/compatibility.js"></script>
5017 <meta http-equiv='Pragma' content='no-cache' />
5018 <meta http-equiv='Cache-Control' content='no-cache, must-revalidate' />
5019 <meta http-equiv='Expires' content='-1' />
5021 <?php echo $extrahead?>
5024 <div class="header">
5025 <h1><?php echo htmlspecialchars($CONF['SiteName'])?></h1>
5027 <div id="container">
5029 <div class="loginname">
5030 <?php if ($member->isLoggedIn())
5031 echo _LOGGEDINAS . ' ' . $member->getDisplayName()
5032 ." - <a href='index.php?action=logout'>" . _LOGOUT. "</a>"
5033 . "<br /><a href='index.php?action=overview'>" . _ADMINHOME . "</a> - ";
5035 echo '<a href="index.php?action=showlogin" title="Log in">' , _NOTLOGGEDIN , '</a> <br />';
5037 echo "<a href='".$CONF['IndexURL']."'>"._YOURSITE."</a>";
5041 // Note(JP): disabled code name description
5043 if ($member->isLoggedIn() && $member->isAdmin())
5044 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"</a>';
5046 echo 'Nucleus CMS ', $nucleus['version'], ' "', $nucleus['codename'], '"';
5048 if ($member->isLoggedIn() && $member->isAdmin())
5049 echo '<a href="http://nucleuscms.org/version.php?v=',getNucleusVersion(),'&pl=',getNucleusPatchLevel(),'" title="Check for upgrade">Nucleus CMS ', $nucleus['version'], ' </a>';
5051 echo 'Nucleus CMS ', $nucleus['version'];
5057 * @todo document this
5059 function pagefoot() {
5060 global $action, $member, $manager;
5065 'action' => $this->action
5069 if ($member->isLoggedIn() && ($action != 'showlogin')) {
5071 <h2><?php echo _LOGOUT ?></h2>
5073 <li><a href="index.php?action=overview"><?php echo _BACKHOME?></a></li>
5074 <li><a href='index.php?action=logout'><?php echo _LOGOUT?></a></li>
5079 <a href="http://nucleuscms.org/">Nucleus CMS</a> © 2002-<?php echo date('Y'); ?> The Nucleus Group
5081 <a href="http://nucleuscms.org/donate.php">Donate!</a>
5084 </div><!-- content -->
5086 <div id="quickmenu">
5088 <?php // ---- user settings ----
5089 if (($action != 'showlogin') && ($member->isLoggedIn())) {
5091 echo '<li><a href="index.php?action=overview">',_QMENU_HOME,'</a></li>';
5094 echo '<h2>',_QMENU_ADD,'</h2>';
5095 echo '<form method="get" action="index.php"><div>';
5096 echo '<input type="hidden" name="action" value="createitem" />';
5098 $showAll = requestVar('showall');
5099 if (($member->isAdmin()) && ($showAll == 'yes')) {
5100 // Super-Admins have access to all blogs! (no add item support though)
5101 $query = 'SELECT bnumber as value, bname as text'
5102 . ' FROM ' . sql_table('blog')
5103 . ' ORDER BY bname';
5105 $query = 'SELECT bnumber as value, bname as text'
5106 . ' FROM ' . sql_table('blog') . ', ' . sql_table('team')
5107 . ' WHERE tblog=bnumber and tmember=' . $member->getID()
5108 . ' ORDER BY bname';
5110 $template['name'] = 'blogid';
5111 $template['tabindex'] = 15000;
5112 $template['extra'] = _QMENU_ADD_SELECT;
5113 $template['selected'] = -1;
5114 $template['shorten'] = 10;
5115 $template['shortenel'] = '';
5116 $template['javascript'] = 'onchange="return form.submit()"';
5117 showlist($query,'select',$template);
5119 echo '</div></form>';
5121 echo '<h2>' . $member->getDisplayName(). '</h2>';
5123 echo '<li><a href="index.php?action=editmembersettings">',_QMENU_USER_SETTINGS,'</a></li>';
5124 echo '<li><a href="index.php?action=browseownitems">',_QMENU_USER_ITEMS,'</a></li>';
5125 echo '<li><a href="index.php?action=browseowncomments">',_QMENU_USER_COMMENTS,'</a></li>';
5131 // ---- general settings ----
5132 if ($member->isAdmin()) {
5134 echo '<h2>',_QMENU_MANAGE,'</h2>';
5137 echo '<li><a href="index.php?action=actionlog">',_QMENU_MANAGE_LOG,'</a></li>';
5138 echo '<li><a href="index.php?action=settingsedit">',_QMENU_MANAGE_SETTINGS,'</a></li>';
5139 echo '<li><a href="index.php?action=usermanagement">',_QMENU_MANAGE_MEMBERS,'</a></li>';
5140 echo '<li><a href="index.php?action=createnewlog">',_QMENU_MANAGE_NEWBLOG,'</a></li>';
5141 echo '<li><a href="index.php?action=backupoverview">',_QMENU_MANAGE_BACKUPS,'</a></li>';
5142 echo '<li><a href="index.php?action=pluginlist">',_QMENU_MANAGE_PLUGINS,'</a></li>';
5145 echo '<h2>',_QMENU_LAYOUT,'</h2>';
5147 echo '<li><a href="index.php?action=skinoverview">',_QMENU_LAYOUT_SKINS,'</a></li>';
5148 echo '<li><a href="index.php?action=templateoverview">',_QMENU_LAYOUT_TEMPL,'</a></li>';
5149 echo '<li><a href="index.php?action=skinieoverview">',_QMENU_LAYOUT_IEXPORT,'</a></li>';
5154 $aPluginExtras = array();
5158 'options' => &$aPluginExtras
5161 if (count($aPluginExtras) > 0)
5163 echo '<h2>', _QMENU_PLUGINS, '</h2>';
5165 foreach ($aPluginExtras as $aInfo)
5167 echo '<li><a href="'.htmlspecialchars($aInfo['url']).'" title="'.htmlspecialchars($aInfo['tooltip']).'">'.htmlspecialchars($aInfo['title']).'</a></li>';
5172 } else if (($action == 'activate') || ($action == 'activatesetpwd')) {
5174 echo '<h2>', _QMENU_ACTIVATE, '</h2>', _QMENU_ACTIVATE_TEXT;
5176 // introduction text on login screen
5177 echo '<h2>', _QMENU_INTRO, '</h2>', _QMENU_INTRO_TEXT;
5182 <!-- content / quickmenu container -->
5191 * @todo document this
5193 function action_regfile() {
5194 global $member, $CONF;
5196 $blogid = intRequestVar('blogid');
5198 $member->teamRights($blogid) or $this->disallow();
5200 // header-code stolen from phpMyAdmin
5201 // REGEDIT and bookmarklet code stolen from GreyMatter
5203 $sjisBlogName = getBlogNameFromID($blogid);
5204 $sjisBlogName = mb_convert_encoding($sjisBlogName, "SJIS", "auto");
5206 header('Content-Type: application/octetstream');
5207 header('Content-Disposition: filename="nucleus.reg"');
5208 header('Pragma: no-cache');
5209 header('Expires: 0');
5212 echo "[HKEY_CURRENT_USER\\Software\\Microsoft\\Internet Explorer\\MenuExt\\Post To &Nucleus (".$sjisBlogName.")]\n";
5213 echo '@="' . $CONF['AdminURL'] . "bookmarklet.php?action=contextmenucode&blogid=".intval($blogid)."\"\n";
5214 echo '"contexts"=hex:31';
5218 * @todo document this
5220 function action_bookmarklet() {
5221 global $member, $manager;
5223 $blogid = intRequestVar('blogid');
5225 $member->teamRights($blogid) or $this->disallow();
5227 $blog =& $manager->getBlog($blogid);
5228 $bm = getBookmarklet($blogid);
5232 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5236 <h2>Bookmarklet<!-- and Right Click Menu --></h2>
5239 Bookmarklet とは、クリック1回で記事の投稿ができるシステムです。 この Bookmarklet をインストールすると、ブラウザのツールバーの'add to weblog'ボタンが利用可能となり、Nucleusの新規アイテムの追加ウィンドウがポップアップします。任意のWebページを開いた状態でこのボタンを押せば、そのWebページのタイトルと、そのページへのリンクタグがすでに埋め込まれた状態でアイテム追加ウィンドウが開き、さらに、そのページ内に引用したい文を選択した状態であればその引用文も自動的に引用します。
5242 <h3>Bookmarklet</h3>
5244 下のリンク部分を「お気に入り」もしくはツールバーにドラッグできます。<small>(その前にテストしてみたい場合は単純に下のリンクをクリックしてみてください)</small>
5247 <a href="<?php echo htmlspecialchars($bm)?>">Add to <?php echo $blog->getShortName()?></a> (ほとんどのブラウザで動作します)
5250 <h3>右クリックメニューにインストール (WindowsでIE使用時)</h3>
5253 $url = 'index.php?action=regfile&blogid=' . intval($blogid);
5254 $url = $manager->addTicketToUrl($url);
5256 あるいは<a href="<?php echo htmlspecialchars($url) ?>">右クリックメニュー</a>にインストールすることもできます (「開く」を選択すれば直接レジストリに登録します)
5260 このインストールした右クリックメニューを表示するためにはIEの再起動が必要です。
5265 「お気に入り」もしくはツールバーから消すには、単に削除するだけです。
5269 右クリックメニューから消したい時は、以下の手順を踏んでください:
5273 <li>スタートメニューから「ファイルを指定して実行...」を選択</li>
5274 <li>"regedit" と入力</li>
5275 <li>"OK" ボタンを押す</li>
5276 <li>"\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt" をツリーの中から検索</li>
5277 <li>"add to weblog" エントリを削除</li>
5286 * @todo document this
5288 function action_actionlog() {
5289 global $member, $manager;
5291 $member->isAdmin() or $this->disallow();
5295 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5297 $url = $manager->addTicketToUrl('index.php?action=clearactionlog');
5300 <h2><?php echo _ACTIONLOG_CLEAR_TITLE?></h2>
5301 <p><a href="<?php echo htmlspecialchars($url)?>"><?php echo _ACTIONLOG_CLEAR_TEXT?></a></p>
5303 echo '<h2>' . _ACTIONLOG_TITLE . '</h2>';
5305 $query = 'SELECT * FROM '.sql_table('actionlog').' ORDER BY timestamp DESC';
5306 $template['content'] = 'actionlist';
5307 $amount = showlist($query,'table',$template);
5314 * @todo document this
5316 function action_banlist() {
5317 global $member, $manager;
5319 $blogid = intRequestVar('blogid');
5321 $member->blogAdminRights($blogid) or $this->disallow();
5323 $blog =& $manager->getBlog($blogid);
5327 echo '<p><a href="index.php?action=overview">(',_BACKHOME,')</a></p>';
5329 echo '<h2>' . _BAN_TITLE . " '". $this->bloglink($blog) ."'</h2>";
5331 $query = 'SELECT * FROM '.sql_table('ban').' WHERE blogid='.$blogid.' ORDER BY iprange';
5332 $template['content'] = 'banlist';
5333 $amount = showlist($query,'table',$template);
5338 echo '<h2>'._BAN_NEW_TITLE.'</h2>';
5339 echo "<p><a href='index.php?action=banlistnew&blogid=$blogid'>"._BAN_NEW_TEXT."</a></p>";
5347 * @todo document this
5349 function action_banlistdelete() {
5350 global $member, $manager;
5352 $blogid = intRequestVar('blogid');
5353 $iprange = requestVar('iprange');
5355 $member->blogAdminRights($blogid) or $this->disallow();
5357 $blog =& $manager->getBlog($blogid);
5361 <h2><?php echo _BAN_REMOVE_TITLE?></h2>
5363 <form method="post" action="index.php">
5365 <h3><?php echo _BAN_IPRANGE?></h3>
5368 <?php echo _CONFIRMTXT_BAN?> <?php echo htmlspecialchars($iprange) ?>
5369 <input name="iprange" type="hidden" value="<?php echo htmlspecialchars($iprange)?>" />
5372 <h3><?php echo _BAN_BLOGS?></h3>
5375 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5376 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">Only blog '<?php echo htmlspecialchars($blog->getName())?>'</label>
5378 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5381 <h3><?php echo _BAN_DELETE_TITLE?></h3>
5384 <?php $manager->addTicketHidden() ?>
5385 <input type="hidden" name="action" value="banlistdeleteconfirm" />
5386 <input type="submit" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5395 * @todo document this
5397 function action_banlistdeleteconfirm() {
5398 global $member, $manager;
5400 $blogid = intPostVar('blogid');
5401 $allblogs = postVar('allblogs');
5402 $iprange = postVar('iprange');
5404 $member->blogAdminRights($blogid) or $this->disallow();
5409 if (BAN::removeBan($blogid, $iprange))
5410 array_push($deleted, $blogid);
5412 // get blogs fot which member has admin rights
5413 $adminblogs = $member->getAdminBlogs();
5414 foreach ($adminblogs as $blogje) {
5415 if (BAN::removeBan($blogje, $iprange))
5416 array_push($deleted, $blogje);
5420 if (sizeof($deleted) == 0)
5421 $this->error(_ERROR_DELETEBAN);
5425 echo '<a href="index.php?action=banlist&blogid=',$blogid,'">(',_BACK,')</a>';
5426 echo '<h2>'._BAN_REMOVED_TITLE.'</h2>';
5427 echo "<p>"._BAN_REMOVED_TEXT."</p>";
5430 foreach ($deleted as $delblog) {
5431 $b =& $manager->getBlog($delblog);
5432 echo "<li>" . htmlspecialchars($b->getName()). "</li>";
5441 * @todo document this
5443 function action_banlistnewfromitem() {
5444 $this->action_banlistnew(getBlogIDFromItemID(intRequestVar('itemid')));
5448 * @todo document this
5450 function action_banlistnew($blogid = '') {
5451 global $member, $manager;
5454 $blogid = intRequestVar('blogid');
5456 $ip = requestVar('ip');
5458 $member->blogAdminRights($blogid) or $this->disallow();
5460 $blog =& $manager->getBlog($blogid);
5464 <h2><?php echo _BAN_ADD_TITLE?></h2>
5467 <form method="post" action="index.php">
5469 <h3><?php echo _BAN_IPRANGE?></h3>
5471 <p><?php echo _BAN_IPRANGE_TEXT?></p>
5474 <b>An example</b>: "134.58.253.193" will only block one computer, while "134.58.253" will block 256 IP addresses, including the one from the first example.
5480 <input name="iprange" type="radio" value="<?php echo htmlspecialchars($ip)?>" checked="checked" id="ip_fixed" /><label for="ip_fixed"><?php echo htmlspecialchars($ip)?></label>
5482 <input name="iprange" type="radio" value="custom" id="ip_custom" /><label for="ip_custom">Custom: </label><input name='customiprange' value='<?php echo htmlspecialchars($ip)?>' maxlength='15' size='15' />
5484 echo "<input name='iprange' value='custom' type='hidden' />";
5485 echo "<input name='customiprange' value='' maxlength='15' size='15' />";
5490 <h3><?php echo _BAN_BLOGS?></h3>
5492 <p><?php echo _BAN_BLOGS_TEXT?></p>
5495 <input type="hidden" name="blogid" value="<?php echo $blogid?>" />
5496 <input name="allblogs" type="radio" value="0" id="allblogs_one" /><label for="allblogs_one">'<?php echo htmlspecialchars($blog->getName())?>'</label>
5498 <input name="allblogs" type="radio" value="1" checked="checked" id="allblogs_all" /><label for="allblogs_all"><?php echo _BAN_ALLBLOGS?></label>
5501 <h3><?php echo _BAN_REASON_TITLE?></h3>
5503 <p><?php echo _BAN_REASON_TEXT?></p>
5505 <div><textarea name="reason" cols="40" rows="5"></textarea></div>
5507 <h3><?php echo _BAN_ADD_TITLE?></h3>
5510 <input name="action" type="hidden" value="banlistadd" />
5511 <?php $manager->addTicketHidden() ?>
5512 <input type="submit" value="<?php echo _BAN_ADD_BTN?>" />
5517 <?php $this->pagefoot();
5521 * @todo document this
5523 function action_banlistadd() {
5526 $blogid = intPostVar('blogid');
5527 $allblogs = postVar('allblogs');
5528 $iprange = postVar('iprange');
5529 if ($iprange == "custom")
5530 $iprange = postVar('customiprange');
5531 $reason = postVar('reason');
5533 $member->blogAdminRights($blogid) or $this->disallow();
5535 // TODO: check IP range validity
5538 if (!BAN::addBan($blogid, $iprange, $reason))
5539 $this->error(_ERROR_ADDBAN);
5541 // get blogs fot which member has admin rights
5542 $adminblogs = $member->getAdminBlogs();
5544 foreach ($adminblogs as $blogje) {
5545 if (!BAN::addBan($blogje, $iprange, $reason))
5549 $this->error(_ERROR_ADDBAN);
5552 $this->action_banlist();
5557 * @todo document this
5559 function action_clearactionlog() {
5562 $member->isAdmin() or $this->disallow();
5566 $this->action_manage(_MSG_ACTIONLOGCLEARED);
5570 * @todo document this
5572 function action_backupoverview() {
5573 global $member, $manager;
5575 $member->isAdmin() or $this->disallow();
5579 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5581 <h2><?php echo _BACKUPS_TITLE?></h2>
5583 <h3><?php echo _BACKUP_TITLE?></h3>
5585 <p><?php echo _BACKUP_INTRO?></p>
5587 <form method="post" action="index.php"><p>
5588 <input type="hidden" name="action" value="backupcreate" />
5589 <?php $manager->addTicketHidden() ?>
5591 <input type="radio" name="gzip" value="1" checked="checked" id="gzip_yes" tabindex="10" /><label for="gzip_yes"><?php echo _BACKUP_ZIP_YES?></label>
5593 <input type="radio" name="gzip" value="0" id="gzip_no" tabindex="10" /><label for="gzip_no" ><?php echo _BACKUP_ZIP_NO?></label>
5595 <input type="submit" value="<?php echo _BACKUP_BTN?>" tabindex="20" />
5599 <div class="note"><?php echo _BACKUP_NOTE?></div>
5602 <h3><?php echo _RESTORE_TITLE?></h3>
5604 <div class="note"><?php echo _RESTORE_NOTE?></div>
5606 <p><?php echo _RESTORE_INTRO?></p>
5608 <form method="post" action="index.php" enctype="multipart/form-data"><p>
5609 <input type="hidden" name="action" value="backuprestore" />
5610 <?php $manager->addTicketHidden() ?>
5611 <input name="backup_file" type="file" tabindex="30" />
5613 <input type="submit" value="<?php echo _RESTORE_BTN?>" tabindex="40" />
5614 <br /><input type="checkbox" name="letsgo" value="1" id="letsgo" tabindex="50" /><label for="letsgo"><?php echo _RESTORE_IMSURE?></label>
5615 <br /><?php echo _RESTORE_WARNING?>
5618 <?php $this->pagefoot();
5622 * @todo document this
5624 function action_backupcreate() {
5625 global $member, $DIR_LIBS;
5627 $member->isAdmin() or $this->disallow();
5629 // use compression ?
5630 $useGzip = intval(postVar('gzip'));
5632 include($DIR_LIBS . 'backup.php');
5634 // try to extend time limit
5635 // (creating/restoring dumps might take a while)
5636 @set_time_limit(1200);
5638 do_backup($useGzip);
5643 * @todo document this
5645 function action_backuprestore() {
5646 global $member, $DIR_LIBS;
5648 $member->isAdmin() or $this->disallow();
5650 if (intPostVar('letsgo') != 1)
5651 $this->error(_ERROR_BACKUP_NOTSURE);
5653 include($DIR_LIBS . 'backup.php');
5655 // try to extend time limit
5656 // (creating/restoring dumps might take a while)
5657 @set_time_limit(1200);
5659 $message = do_restore();
5661 $this->error($message);
5665 <h2><?php echo _RESTORE_COMPLETE?></h2>
5666 <?php $this->pagefoot();
5671 * @todo document this
5673 function action_pluginlist() {
5674 global $member, $manager;
5677 $member->isAdmin() or $this->disallow();
5681 echo '<p><a href="index.php?action=manage">(',_BACKTOMANAGE,')</a></p>';
5683 echo '<h2>' , _PLUGS_TITLE_MANAGE , ' ', help('plugins'), '</h2>';
5685 echo '<h3>' , _PLUGS_TITLE_INSTALLED , '</h3>';
5688 $query = 'SELECT * FROM '.sql_table('plugin').' ORDER BY porder ASC';
5690 $template['content'] = 'pluginlist';
5691 $template['tabindex'] = 10;
5692 showlist($query, 'table', $template);
5695 <h3><?php echo _PLUGS_TITLE_UPDATE?></h3>
5697 <p><?php echo _PLUGS_TEXT_UPDATE?></p>
5699 <form method="post" action="index.php"><div>
5700 <input type="hidden" name="action" value="pluginupdate" />
5701 <?php $manager->addTicketHidden() ?>
5702 <input type="submit" value="<?php echo _PLUGS_BTN_UPDATE ?>" tabindex="20" />
5705 <h3><?php echo _PLUGS_TITLE_NEW?></h3>
5707 <?php // find a list of possibly non-installed plugins
5708 $candidates = array();
5709 global $DIR_PLUGINS;
5710 $dirhandle = opendir($DIR_PLUGINS);
5711 while ($filename = readdir($dirhandle)) {
5712 if (ereg('^NP_(.*)\.php$',$filename,$matches)) {
5713 $name = $matches[1];
5714 // only show in list when not yet installed
5715 $res = sql_query('SELECT * FROM '.sql_table('plugin').' WHERE pfile="NP_'.addslashes($name).'"');
5716 if (mysql_num_rows($res) == 0)
5717 array_push($candidates,$name);
5720 closedir($dirhandle);
5722 if (sizeof($candidates) > 0) {
5725 <p><?php echo _PLUGS_ADD_TEXT?></p>
5728 <form method='post' action='index.php'><div>
5729 <input type='hidden' name='action' value='pluginadd' />
5730 <?php $manager->addTicketHidden() ?>
5731 <select name="filename" tabindex="30">
5732 <?php foreach($candidates as $name)
5733 echo '<option value="NP_',$name,'">',htmlspecialchars($name),'</option>';
5736 <input type='submit' tabindex="40" value='<?php echo _PLUGS_BTN_INSTALL?>' />
5739 <?php } else { // sizeof(candidates) == 0
5740 echo '<p>',_PLUGS_NOCANDIDATES,'</p>';
5747 * @todo document this
5749 function action_pluginhelp() {
5750 global $member, $manager, $DIR_PLUGINS, $CONF;
5753 $member->isAdmin() or $this->disallow();
5755 $plugid = intGetVar('plugid');
5757 if (!$manager->pidInstalled($plugid))
5758 $this->error(_ERROR_NOSUCHPLUGIN);
5760 $plugName = getPluginNameFromPid($plugid);
5764 echo '<p><a href="index.php?action=pluginlist">(',_PLUGS_BACK,')</a></p>';
5766 echo '<h2>',_PLUGS_HELP_TITLE,': ',htmlspecialchars($plugName),'</h2>';
5768 $plug =& $manager->getPlugin($plugName);
5769 $helpFile = $DIR_PLUGINS.$plug->getShortName().'/help.html';
5771 if (($plug->supportsFeature('HelpPage') > 0) && (@file_exists($helpFile))) {
5772 @readfile($helpFile);
5774 echo '<p>Error: ', _ERROR_PLUGNOHELPFILE,'</p>';
5775 echo '<p><a href="index.php?action=pluginlist">(',_BACK,')</a></p>';
5783 * @todo document this
5785 function action_pluginadd() {
5786 global $member, $manager, $DIR_PLUGINS;
5789 $member->isAdmin() or $this->disallow();
5791 $name = postVar('filename');
5793 if ($manager->pluginInstalled($name))
5794 $this->error(_ERROR_DUPPLUGIN);
5795 if (!checkPlugin($name))
5796 $this->error(_ERROR_PLUGFILEERROR . ' (' . htmlspecialchars($name) . ')');
5798 // get number of currently installed plugins
5799 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
5800 $numCurrent = mysql_num_rows($res);
5802 // plugin will be added as last one in the list
5803 $newOrder = $numCurrent + 1;
5812 // do this before calling getPlugin (in case the plugin id is used there)
5813 $query = 'INSERT INTO '.sql_table('plugin').' (porder, pfile) VALUES ('.$newOrder.',"'.addslashes($name).'")';
5815 $iPid = mysql_insert_id();
5817 $manager->clearCachedInfo('installedPlugins');
5819 // Load the plugin for condition checking and instalation
5820 $plugin =& $manager->getPlugin($name);
5822 // check if it got loaded (could have failed)
5825 sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE pid='. intval($iPid));
5826 $manager->clearCachedInfo('installedPlugins');
5827 $this->error(_ERROR_PLUGIN_LOAD);
5830 // check if plugin needs a newer Nucleus version
5831 if (getNucleusVersion() < $plugin->getMinNucleusVersion())
5833 // uninstall plugin again...
5834 $this->deleteOnePlugin($plugin->getID());
5836 // ...and show error
5837 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars($plugin->getMinNucleusVersion()));
5840 // check if plugin needs a newer Nucleus version
5841 if ((getNucleusVersion() == $plugin->getMinNucleusVersion()) && (getNucleusPatchLevel() < $plugin->getMinNucleusPatchLevel()))
5843 // uninstall plugin again...
5844 $this->deleteOnePlugin($plugin->getID());
5846 // ...and show error
5847 $this->error(_ERROR_NUCLEUSVERSIONREQ . htmlspecialchars( $plugin->getMinNucleusVersion() . ' patch ' . $plugin->getMinNucleusPatchLevel() ) );
5850 $pluginList = $plugin->getPluginDep();
5851 foreach ($pluginList as $pluginName)
5854 $res = sql_query('SELECT * FROM '.sql_table('plugin') . ' WHERE pfile="' . $pluginName . '"');
5855 if (mysql_num_rows($res) == 0)
5857 // uninstall plugin again...
5858 $this->deleteOnePlugin($plugin->getID());
5860 $this->error(_ERROR_INSREQPLUGIN . htmlspecialchars($pluginName));
5864 // call the install method of the plugin
5870 'plugin' => &$plugin
5874 // update all events
5875 $this->action_pluginupdate();
5879 * @todo document this
5881 function action_pluginupdate() {
5882 global $member, $manager;
5885 $member->isAdmin() or $this->disallow();
5887 // delete everything from plugin_events
5888 sql_query('DELETE FROM '.sql_table('plugin_event'));
5890 // loop over all installed plugins
5891 $res = sql_query('SELECT pid, pfile FROM '.sql_table('plugin'));
5892 while($o = mysql_fetch_object($res)) {
5894 $plug =& $manager->getPlugin($o->pfile);
5897 $eventList = $plug->getEventList();
5898 foreach ($eventList as $eventName)
5899 sql_query('INSERT INTO '.sql_table('plugin_event').' (pid, event) VALUES ('.$pid.', \''.addslashes($eventName).'\')');
5903 $this->action_pluginlist();
5907 * @todo document this
5909 function action_plugindelete() {
5910 global $member, $manager;
5913 $member->isAdmin() or $this->disallow();
5915 $pid = intGetVar('plugid');
5917 if (!$manager->pidInstalled($pid))
5918 $this->error(_ERROR_NOSUCHPLUGIN);
5922 <h2><?php echo _DELETE_CONFIRM?></h2>
5924 <p><?php echo _CONFIRMTXT_PLUGIN?> <strong><?php echo getPluginNameFromPid($pid)?></strong>?</p>
5926 <form method="post" action="index.php"><div>
5927 <?php $manager->addTicketHidden() ?>
5928 <input type="hidden" name="action" value="plugindeleteconfirm" />
5929 <input type="hidden" name="plugid" value="<?php echo $pid; ?>" />
5930 <input type="submit" tabindex="10" value="<?php echo _DELETE_CONFIRM_BTN?>" />
5932 <?php $this->pagefoot();
5936 * @todo document this
5938 function action_plugindeleteconfirm() {
5939 global $member, $manager;
5942 $member->isAdmin() or $this->disallow();
5944 $pid = intPostVar('plugid');
5946 $error = $this->deleteOnePlugin($pid, 1);
5948 $this->error($error);
5951 $this->action_pluginlist();
5955 * @todo document this
5957 function deleteOnePlugin($pid, $callUninstall = 0) {
5960 $pid = intval($pid);
5962 if (!$manager->pidInstalled($pid))
5963 return _ERROR_NOSUCHPLUGIN;
5965 $name = quickQuery('SELECT pfile as result FROM '.sql_table('plugin').' WHERE pid='.$pid);
5967 // call the unInstall method of the plugin
5968 if ($callUninstall) {
5969 $plugin =& $manager->getPlugin($name);
5970 if ($plugin) $plugin->unInstall();
5973 // check dependency before delete
5974 $res = sql_query('SELECT pfile FROM '.sql_table('plugin'));
5975 while($o = mysql_fetch_object($res)) {
5976 $plug =& $manager->getPlugin($o->pfile);
5979 $depList = $plug->getPluginDep();
5980 foreach ($depList as $depName)
5982 if ($name == $depName)
5984 return _ERROR_DELREQPLUGIN . $o->pfile;
5990 $manager->notify('PreDeletePlugin', array('plugid' => $pid));
5992 // delete all subscriptions
5993 sql_query('DELETE FROM '.sql_table('plugin_event').' WHERE pid=' . $pid);
5995 // delete all options
5996 // get OIDs from plugin_option_desc
5997 $res = sql_query('SELECT oid FROM ' . sql_table('plugin_option_desc') . ' WHERE opid=' . $pid);
5999 while ($o = mysql_fetch_object($res)) {
6000 array_push($aOIDs, $o->oid);
6003 // delete from plugin_option and plugin_option_desc
6004 sql_query('DELETE FROM '.sql_table('plugin_option_desc').' WHERE opid=' . $pid);
6005 if (count($aOIDs) > 0)
6006 sql_query('DELETE FROM '.sql_table('plugin_option').' WHERE oid in ('.implode(',',$aOIDs).')');
6008 // update order numbers
6009 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid=' . $pid);
6010 $o = mysql_fetch_object($res);
6011 sql_query('UPDATE '.sql_table('plugin').' SET porder=(porder - 1) WHERE porder>'.$o->porder);
6014 sql_query('DELETE FROM '.sql_table('plugin').' WHERE pid='.$pid);
6016 $manager->clearCachedInfo('installedPlugins');
6017 $manager->notify('PostDeletePlugin', array('plugid' => $pid));
6023 * @todo document this
6025 function action_pluginup() {
6026 global $member, $manager;
6029 $member->isAdmin() or $this->disallow();
6031 $plugid = intGetVar('plugid');
6033 if (!$manager->pidInstalled($plugid))
6034 $this->error(_ERROR_NOSUCHPLUGIN);
6036 // 1. get old order number
6037 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6038 $o = mysql_fetch_object($res);
6039 $oldOrder = $o->porder;
6041 // 2. calculate new order number
6042 $newOrder = ($oldOrder > 1) ? ($oldOrder - 1) : 1;
6044 // 3. update plug numbers
6045 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6046 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6048 //$this->action_pluginlist();
6049 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6050 redirect('?action=pluginlist');
6054 * @todo document this
6056 function action_plugindown() {
6057 global $member, $manager;
6060 $member->isAdmin() or $this->disallow();
6062 $plugid = intGetVar('plugid');
6063 if (!$manager->pidInstalled($plugid))
6064 $this->error(_ERROR_NOSUCHPLUGIN);
6066 // 1. get old order number
6067 $res = sql_query('SELECT porder FROM '.sql_table('plugin').' WHERE pid='.$plugid);
6068 $o = mysql_fetch_object($res);
6069 $oldOrder = $o->porder;
6071 $res = sql_query('SELECT * FROM '.sql_table('plugin'));
6072 $maxOrder = mysql_num_rows($res);
6074 // 2. calculate new order number
6075 $newOrder = ($oldOrder < $maxOrder) ? ($oldOrder + 1) : $maxOrder;
6077 // 3. update plug numbers
6078 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$oldOrder.' WHERE porder='.$newOrder);
6079 sql_query('UPDATE '.sql_table('plugin').' SET porder='.$newOrder.' WHERE pid='.$plugid);
6081 //$this->action_pluginlist();
6082 // To avoid showing ticket in the URL, redirect to pluginlist, instead.
6083 redirect('?action=pluginlist');
6087 * @todo document this
6089 function action_pluginoptions($message = '') {
6090 global $member, $manager;
6093 $member->isAdmin() or $this->disallow();
6095 $pid = intRequestVar('plugid');
6096 if (!$manager->pidInstalled($pid))
6097 $this->error(_ERROR_NOSUCHPLUGIN);
6099 $extrahead = '<script type="text/javascript" src="javascript/numbercheck.js"></script>';
6100 $this->pagehead($extrahead);
6103 <p><a href="index.php?action=pluginlist">(<?php echo _PLUGS_BACK?>)</a></p>
6105 <h2>Options for <?php echo htmlspecialchars(getPluginNameFromPid($pid))?></h2>
6107 <?php if ($message) echo $message?>
6109 <form action="index.php" method="post">
6111 <input type="hidden" name="action" value="pluginoptionsupdate" />
6112 <input type="hidden" name="plugid" value="<?php echo $pid?>" />
6116 $manager->addTicketHidden();
6118 $aOptions = array();
6120 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ' WHERE ocontext=\'global\' and opid=' . $pid . ' ORDER BY oid ASC';
6121 $r = sql_query($query);
6122 while ($o = mysql_fetch_object($r)) {
6123 array_push($aOIDs, $o->oid);
6124 $aOptions[$o->oid] = array(
6126 'value' => $o->odef,
6127 'name' => $o->oname,
6128 'description' => $o->odesc,
6129 'type' => $o->otype,
6130 'typeinfo' => $o->oextra,
6134 // fill out actual values
6135 if (count($aOIDs) > 0) {
6136 $r = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE oid in ('.implode(',',$aOIDs).')');
6137 while ($o = mysql_fetch_object($r))
6138 $aOptions[$o->oid]['value'] = $o->ovalue;
6142 $manager->notify('PrePluginOptionsEdit',array('context' => 'global', 'plugid' => $pid, 'options'=>&$aOptions));
6144 $template['content'] = 'plugoptionlist';
6145 $amount = showlist($aOptions,'table',$template);
6147 echo '<p>',_ERROR_NOPLUGOPTIONS,'</p>';
6152 <?php $this->pagefoot();
6159 * @todo document this
6161 function action_pluginoptionsupdate() {
6162 global $member, $manager;
6165 $member->isAdmin() or $this->disallow();
6167 $pid = intRequestVar('plugid');
6168 if (!$manager->pidInstalled($pid))
6169 $this->error(_ERROR_NOSUCHPLUGIN);
6171 $aOptions = requestArray('plugoption');
6172 NucleusPlugin::_applyPluginOptions($aOptions);
6174 $manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
6176 $this->action_pluginoptions(_PLUGS_OPTIONS_UPDATED);
6181 * @todo document this
6183 function _insertPluginOptions($context, $contextid = 0) {
6184 // get all current values for this contextid
6185 // (note: this might contain doubles for overlapping contextids)
6186 $aIdToValue = array();
6187 $res = sql_query('SELECT oid, ovalue FROM ' . sql_table('plugin_option') . ' WHERE ocontextid=' . intval($contextid));
6188 while ($o = mysql_fetch_object($res)) {
6189 $aIdToValue[$o->oid] = $o->ovalue;
6192 // get list of oids per pid
6193 $query = 'SELECT * FROM ' . sql_table('plugin_option_desc') . ',' . sql_table('plugin')
6194 . ' WHERE opid=pid and ocontext=\''.addslashes($context).'\' ORDER BY porder, oid ASC';
6195 $res = sql_query($query);
6196 $aOptions = array();
6197 while ($o = mysql_fetch_object($res)) {
6198 if (in_array($o->oid, array_keys($aIdToValue)))
6199 $value = $aIdToValue[$o->oid];
6203 array_push($aOptions, array(
6205 'pfile' => $o->pfile,
6208 'name' => $o->oname,
6209 'description' => $o->odesc,
6210 'type' => $o->otype,
6211 'typeinfo' => $o->oextra,
6212 'contextid' => $contextid,
6218 $manager->notify('PrePluginOptionsEdit',array('context' => $context, 'contextid' => $contextid, 'options'=>&$aOptions));
6222 foreach ($aOptions as $aOption) {
6225 if ($iPrevPid != $aOption['pid']) {
6226 $iPrevPid = $aOption['pid'];
6228 echo '<tr><th colspan="2">Options for ', htmlspecialchars($aOption['pfile']),'</th></tr>';
6232 listplug_plugOptionRow($aOption);
6241 * Helper functions to create option forms etc.
6242 * @todo document parameters
6244 function input_yesno($name, $checkedval,$tabindex = 0, $value1 = 1, $value2 = 0, $yesval = _YES, $noval = _NO, $isAdmin = 0) {
6245 $id = htmlspecialchars($name);
6246 $id = str_replace('[','-',$id);
6247 $id = str_replace(']','-',$id);
6248 $id1 = $id . htmlspecialchars($value1);
6249 $id2 = $id . htmlspecialchars($value2);
6251 if ($name=="admin") {
6252 echo '<input onclick="selectCanLogin(true);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6254 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value1),'" ';
6257 if ($checkedval == $value1)
6258 echo "tabindex='$tabindex' checked='checked'";
6259 echo ' id="'.$id1.'" /><label for="'.$id1.'">' . $yesval . '</label>';
6261 if ($name=="admin") {
6262 echo '<input onclick="selectCanLogin(false);" type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6264 echo '<input type="radio" name="', htmlspecialchars($name),'" value="', htmlspecialchars($value2),'" ';
6266 if ($checkedval != $value1)
6267 echo "tabindex='$tabindex' checked='checked'";
6268 if ($isAdmin && $name=="canlogin")
6269 echo " disabled='true'";
6270 echo ' id="'.$id2.'" /><label for="'.$id2.'">' . $noval . '</label>';